зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1872545 - Hoist color-font palette cache out of TextRunDrawParams to the nsPresContext or CanvasRenderingContext2D, for greater effectiveness. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D197463
This commit is contained in:
Родитель
4f6c32c210
Коммит
b3387dce2c
|
@ -4251,7 +4251,8 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor final
|
|||
: public nsBidiPresUtils::BidiProcessor {
|
||||
using Style = CanvasRenderingContext2D::Style;
|
||||
|
||||
CanvasBidiProcessor() : nsBidiPresUtils::BidiProcessor() {
|
||||
explicit CanvasBidiProcessor(mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: mPaletteCache(aPaletteCache) {
|
||||
if (StaticPrefs::gfx_missing_fonts_notify()) {
|
||||
mMissingFonts = MakeUnique<gfxMissingFontRecorder>();
|
||||
}
|
||||
|
@ -4496,7 +4497,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor final
|
|||
}
|
||||
|
||||
gfxContext thebes(target, /* aPreserveTransform */ true);
|
||||
gfxTextRun::DrawParams params(&thebes);
|
||||
gfxTextRun::DrawParams params(&thebes, mPaletteCache);
|
||||
|
||||
params.allowGDI = false;
|
||||
|
||||
|
@ -4566,6 +4567,9 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor final
|
|||
// current font
|
||||
gfxFontGroup* mFontgrp = nullptr;
|
||||
|
||||
// palette cache for COLR font rendering
|
||||
mozilla::gfx::PaletteCache& mPaletteCache;
|
||||
|
||||
// spacing adjustments to be applied
|
||||
gfx::Float mLetterSpacing = 0.0f;
|
||||
gfx::Float mWordSpacing = 0.0f;
|
||||
|
@ -4687,7 +4691,7 @@ UniquePtr<TextMetrics> CanvasRenderingContext2D::DrawOrMeasureText(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
CanvasBidiProcessor processor;
|
||||
CanvasBidiProcessor processor(mPaletteCache);
|
||||
|
||||
// If we don't have a ComputedStyle, we can't set up vertical-text flags
|
||||
// (for now, at least; perhaps we need new Canvas API to control this).
|
||||
|
|
|
@ -1119,6 +1119,8 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
|
|||
|
||||
ColorStyleCacheEntry ParseColorSlow(const nsACString&);
|
||||
|
||||
mozilla::gfx::PaletteCache mPaletteCache;
|
||||
|
||||
friend class CanvasGeneralPattern;
|
||||
friend class AdjustedTarget;
|
||||
friend class AdjustedTargetForShadow;
|
||||
|
|
|
@ -334,7 +334,8 @@ void nsFontMetrics::DrawString(const char* aString, uint32_t aLength,
|
|||
pt.x += textRun->GetAdvanceWidth(range, &provider);
|
||||
}
|
||||
}
|
||||
gfxTextRun::DrawParams params(aContext);
|
||||
mozilla::gfx::PaletteCache paletteCache;
|
||||
gfxTextRun::DrawParams params(aContext, paletteCache);
|
||||
params.provider = &provider;
|
||||
textRun->Draw(range, pt, params);
|
||||
}
|
||||
|
@ -359,7 +360,8 @@ void nsFontMetrics::DrawString(
|
|||
pt.x += textRun->GetAdvanceWidth(range, &provider);
|
||||
}
|
||||
}
|
||||
gfxTextRun::DrawParams params(aContext);
|
||||
mozilla::gfx::PaletteCache paletteCache;
|
||||
gfxTextRun::DrawParams params(aContext, paletteCache);
|
||||
params.provider = &provider;
|
||||
textRun->Draw(range, pt, params);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FontPaletteCache.h"
|
||||
#include "COLRFonts.h"
|
||||
|
||||
void mozilla::gfx::PaletteCache::SetPaletteValueSet(
|
||||
const gfx::FontPaletteValueSet* aSet) {
|
||||
mPaletteValueSet = aSet;
|
||||
Clear();
|
||||
}
|
||||
|
||||
nsTArray<gfx::sRGBColor>* mozilla::gfx::PaletteCache::GetPaletteFor(
|
||||
gfxFontEntry* aFontEntry, nsAtom* aPaletteName) {
|
||||
auto entry = Lookup(std::pair(aFontEntry, aPaletteName));
|
||||
if (!entry) {
|
||||
CacheData newData;
|
||||
newData.mKey = std::pair(aFontEntry, aPaletteName);
|
||||
|
||||
gfxFontEntry::AutoHBFace face = aFontEntry->GetHBFace();
|
||||
newData.mPalette = gfx::COLRFonts::SetupColorPalette(
|
||||
face, mPaletteValueSet, aPaletteName, aFontEntry->FamilyName());
|
||||
|
||||
entry.Set(std::move(newData));
|
||||
}
|
||||
return entry.Data().mPalette.get();
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef FONT_PALETTE_CACHE_H
|
||||
#define FONT_PALETTE_CACHE_H
|
||||
|
||||
#include "gfxFontEntry.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/MruCache.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "nsAtom.h"
|
||||
#include <utility>
|
||||
|
||||
namespace mozilla::gfx {
|
||||
|
||||
class FontPaletteValueSet;
|
||||
|
||||
// MRU cache used for resolved color-font palettes, to avoid reconstructing
|
||||
// the palette for each glyph rendered with a given font.
|
||||
using CacheKey = std::pair<RefPtr<gfxFontEntry>, RefPtr<nsAtom>>;
|
||||
struct CacheData {
|
||||
CacheKey mKey;
|
||||
mozilla::UniquePtr<nsTArray<mozilla::gfx::sRGBColor>> mPalette;
|
||||
};
|
||||
|
||||
class PaletteCache
|
||||
: public mozilla::MruCache<CacheKey, CacheData, PaletteCache> {
|
||||
public:
|
||||
explicit PaletteCache(const FontPaletteValueSet* aPaletteValueSet = nullptr)
|
||||
: mPaletteValueSet(aPaletteValueSet) {}
|
||||
|
||||
void SetPaletteValueSet(const FontPaletteValueSet* aSet);
|
||||
|
||||
nsTArray<mozilla::gfx::sRGBColor>* GetPaletteFor(gfxFontEntry* aFontEntry,
|
||||
nsAtom* aPaletteName);
|
||||
|
||||
static mozilla::HashNumber Hash(const CacheKey& aKey) {
|
||||
return mozilla::HashGeneric(aKey.first.get(), aKey.second.get());
|
||||
}
|
||||
static bool Match(const CacheKey& aKey, const CacheData& aVal) {
|
||||
return aVal.mKey == aKey;
|
||||
}
|
||||
|
||||
protected:
|
||||
const FontPaletteValueSet* mPaletteValueSet = nullptr;
|
||||
};
|
||||
|
||||
} // namespace mozilla::gfx
|
||||
|
||||
#endif
|
|
@ -1715,7 +1715,8 @@ bool gfxFont::HasFeatureSet(uint32_t aFeature, bool& aFeatureOn) {
|
|||
|
||||
already_AddRefed<mozilla::gfx::ScaledFont> gfxFont::GetScaledFont(
|
||||
mozilla::gfx::DrawTarget* aDrawTarget) {
|
||||
TextRunDrawParams params;
|
||||
mozilla::gfx::PaletteCache dummy;
|
||||
TextRunDrawParams params(dummy);
|
||||
return GetScaledFont(params);
|
||||
}
|
||||
|
||||
|
@ -2233,7 +2234,7 @@ void gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfx::Point* aPt,
|
|||
const EmphasisMarkDrawParams& aParams) {
|
||||
float& inlineCoord = aParams.isVertical ? aPt->y.value : aPt->x.value;
|
||||
gfxTextRun::Range markRange(aParams.mark);
|
||||
gfxTextRun::DrawParams params(aParams.context);
|
||||
gfxTextRun::DrawParams params(aParams.context, aParams.paletteCache);
|
||||
|
||||
float clusterStart = -std::numeric_limits<float>::infinity();
|
||||
bool shouldDrawEmphasisMark = false;
|
||||
|
@ -2265,23 +2266,6 @@ void gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfx::Point* aPt,
|
|||
}
|
||||
}
|
||||
|
||||
nsTArray<mozilla::gfx::sRGBColor>* TextRunDrawParams::GetPaletteFor(
|
||||
const gfxFont* aFont) {
|
||||
auto entry = mPaletteCache.Lookup(aFont);
|
||||
if (!entry) {
|
||||
CacheData newData;
|
||||
newData.mKey = aFont;
|
||||
|
||||
gfxFontEntry* fe = aFont->GetFontEntry();
|
||||
gfxFontEntry::AutoHBFace face = fe->GetHBFace();
|
||||
newData.mPalette = COLRFonts::SetupColorPalette(
|
||||
face, paletteValueSet, fontPalette, fe->FamilyName());
|
||||
|
||||
entry.Set(std::move(newData));
|
||||
}
|
||||
return entry.Data().mPalette.get();
|
||||
}
|
||||
|
||||
void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
gfx::Point* aPt, TextRunDrawParams& aRunParams,
|
||||
gfx::ShapedTextFlags aOrientation) {
|
||||
|
@ -2317,7 +2301,8 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
|
|||
fontParams.currentColor = aRunParams.context->GetDeviceColor(ctxColor)
|
||||
? sRGBColor::FromABGR(ctxColor.ToABGR())
|
||||
: sRGBColor::OpaqueBlack();
|
||||
fontParams.palette = aRunParams.GetPaletteFor(this);
|
||||
fontParams.palette = aRunParams.paletteCache.GetPaletteFor(
|
||||
GetFontEntry(), aRunParams.fontPalette);
|
||||
}
|
||||
|
||||
if (textDrawer) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <new>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include "FontPaletteCache.h"
|
||||
#include "PLDHashTable.h"
|
||||
#include "ThebesRLBoxTypes.h"
|
||||
#include "gfxFontVariations.h"
|
||||
|
@ -2299,6 +2300,10 @@ class gfxFont {
|
|||
// are dependent on the specific font, so they are set per GlyphRun.
|
||||
|
||||
struct MOZ_STACK_CLASS TextRunDrawParams {
|
||||
explicit TextRunDrawParams(mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: paletteCache(aPaletteCache) {}
|
||||
|
||||
mozilla::gfx::PaletteCache& paletteCache;
|
||||
RefPtr<mozilla::gfx::DrawTarget> dt;
|
||||
gfxContext* context = nullptr;
|
||||
gfxFont::Spacing* spacing = nullptr;
|
||||
|
@ -2312,7 +2317,6 @@ struct MOZ_STACK_CLASS TextRunDrawParams {
|
|||
gfxPattern* textStrokePattern = nullptr;
|
||||
const mozilla::gfx::StrokeOptions* strokeOpts = nullptr;
|
||||
const mozilla::gfx::DrawOptions* drawOpts = nullptr;
|
||||
const mozilla::gfx::FontPaletteValueSet* paletteValueSet = nullptr;
|
||||
nsAtom* fontPalette = nullptr;
|
||||
DrawMode drawMode = DrawMode::GLYPH_FILL;
|
||||
bool isVerticalRun = false;
|
||||
|
@ -2320,34 +2324,6 @@ struct MOZ_STACK_CLASS TextRunDrawParams {
|
|||
bool paintSVGGlyphs = true;
|
||||
bool allowGDI = true;
|
||||
bool hasTextShadow = false;
|
||||
|
||||
// MRU cache of color-font palettes being used by fonts in the run. We cache
|
||||
// these in the TextRunDrawParams so that we can avoid re-creating a new
|
||||
// palette (which can be quite expensive) for each individual glyph run.
|
||||
using CacheKey = const gfxFont*;
|
||||
|
||||
struct CacheData {
|
||||
CacheKey mKey;
|
||||
mozilla::UniquePtr<nsTArray<mozilla::gfx::sRGBColor>> mPalette;
|
||||
};
|
||||
|
||||
class PaletteCache
|
||||
: public mozilla::MruCache<CacheKey, CacheData, PaletteCache> {
|
||||
public:
|
||||
static mozilla::HashNumber Hash(const CacheKey& aKey) {
|
||||
return mozilla::HashGeneric(aKey);
|
||||
}
|
||||
static bool Match(const CacheKey& aKey, const CacheData& aVal) {
|
||||
return aVal.mKey == aKey;
|
||||
}
|
||||
};
|
||||
|
||||
PaletteCache mPaletteCache;
|
||||
|
||||
// Returns a pointer to a palette owned by the PaletteCache. This is only
|
||||
// valid until the next call to GetPaletteFor (which might evict it) or
|
||||
// until the TextRunDrawParams goes out of scope.
|
||||
nsTArray<mozilla::gfx::sRGBColor>* GetPaletteFor(const gfxFont* aFont);
|
||||
};
|
||||
|
||||
struct MOZ_STACK_CLASS FontDrawParams {
|
||||
|
@ -2368,7 +2344,11 @@ struct MOZ_STACK_CLASS FontDrawParams {
|
|||
};
|
||||
|
||||
struct MOZ_STACK_CLASS EmphasisMarkDrawParams {
|
||||
EmphasisMarkDrawParams(gfxContext* aContext,
|
||||
mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: context(aContext), paletteCache(aPaletteCache) {}
|
||||
gfxContext* context;
|
||||
mozilla::gfx::PaletteCache& paletteCache;
|
||||
gfxFont::Spacing* spacing;
|
||||
gfxTextRun* mark;
|
||||
gfxFloat advance;
|
||||
|
|
|
@ -611,7 +611,7 @@ void gfxTextRun::Draw(const Range aRange, const gfx::Point aPt,
|
|||
|
||||
// Set up parameters that will be constant across all glyph runs we need
|
||||
// to draw, regardless of the font used.
|
||||
TextRunDrawParams params;
|
||||
TextRunDrawParams params(aParams.paletteCache);
|
||||
params.context = aParams.context;
|
||||
params.devPerApp = 1.0 / double(GetAppUnitsPerDevUnit());
|
||||
params.isVerticalRun = IsVertical();
|
||||
|
@ -620,7 +620,6 @@ void gfxTextRun::Draw(const Range aRange, const gfx::Point aPt,
|
|||
params.strokeOpts = aParams.strokeOpts;
|
||||
params.textStrokeColor = aParams.textStrokeColor;
|
||||
params.fontPalette = aParams.fontPalette;
|
||||
params.paletteValueSet = aParams.paletteValueSet;
|
||||
params.textStrokePattern = aParams.textStrokePattern;
|
||||
params.drawOpts = aParams.drawOpts;
|
||||
params.drawMode = aParams.drawMode;
|
||||
|
@ -710,14 +709,13 @@ void gfxTextRun::Draw(const Range aRange, const gfx::Point aPt,
|
|||
}
|
||||
|
||||
// This method is mostly parallel to Draw().
|
||||
void gfxTextRun::DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, gfx::Point aPt,
|
||||
Range aRange,
|
||||
const PropertyProvider* aProvider) const {
|
||||
void gfxTextRun::DrawEmphasisMarks(
|
||||
gfxContext* aContext, gfxTextRun* aMark, gfxFloat aMarkAdvance,
|
||||
gfx::Point aPt, Range aRange, const PropertyProvider* aProvider,
|
||||
mozilla::gfx::PaletteCache& aPaletteCache) const {
|
||||
MOZ_ASSERT(aRange.end <= GetLength());
|
||||
|
||||
EmphasisMarkDrawParams params;
|
||||
params.context = aContext;
|
||||
EmphasisMarkDrawParams params(aContext, aPaletteCache);
|
||||
params.mark = aMark;
|
||||
params.advance = aMarkAdvance;
|
||||
params.direction = GetDirection();
|
||||
|
|
|
@ -251,10 +251,10 @@ class gfxTextRun : public gfxShapedText {
|
|||
|
||||
struct MOZ_STACK_CLASS DrawParams {
|
||||
gfxContext* context;
|
||||
mozilla::gfx::PaletteCache& paletteCache;
|
||||
DrawMode drawMode = DrawMode::GLYPH_FILL;
|
||||
nscolor textStrokeColor = 0;
|
||||
nsAtom* fontPalette = nullptr;
|
||||
mozilla::gfx::FontPaletteValueSet* paletteValueSet = nullptr;
|
||||
gfxPattern* textStrokePattern = nullptr;
|
||||
const mozilla::gfx::StrokeOptions* strokeOpts = nullptr;
|
||||
const mozilla::gfx::DrawOptions* drawOpts = nullptr;
|
||||
|
@ -265,7 +265,8 @@ class gfxTextRun : public gfxShapedText {
|
|||
gfxTextRunDrawCallbacks* callbacks = nullptr;
|
||||
bool allowGDI = true;
|
||||
bool hasTextShadow = false;
|
||||
explicit DrawParams(gfxContext* aContext) : context(aContext) {}
|
||||
DrawParams(gfxContext* aContext, mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: context(aContext), paletteCache(aPaletteCache) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -298,7 +299,8 @@ class gfxTextRun : public gfxShapedText {
|
|||
*/
|
||||
void DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, mozilla::gfx::Point aPt,
|
||||
Range aRange, const PropertyProvider* aProvider) const;
|
||||
Range aRange, const PropertyProvider* aProvider,
|
||||
mozilla::gfx::PaletteCache& aPaletteCache) const;
|
||||
|
||||
/**
|
||||
* Computes the ReflowMetrics for a substring.
|
||||
|
|
|
@ -19,6 +19,7 @@ XPIDL_MODULE = "gfx"
|
|||
EXPORTS += [
|
||||
"COLRFonts.h",
|
||||
"DrawMode.h",
|
||||
"FontPaletteCache.h",
|
||||
"gfx2DGlue.h",
|
||||
"gfxAlphaRecovery.h",
|
||||
"gfxASurface.h",
|
||||
|
@ -198,6 +199,7 @@ SOURCES += [
|
|||
UNIFIED_SOURCES += [
|
||||
"CJKCompatSVS.cpp",
|
||||
"COLRFonts.cpp",
|
||||
"FontPaletteCache.cpp",
|
||||
"gfxAlphaRecovery.cpp",
|
||||
"gfxBaseSharedMemorySurface.cpp",
|
||||
"gfxBlur.cpp",
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "gfxTextRun.h"
|
||||
#include "nsFontFaceUtils.h"
|
||||
#include "COLRFonts.h"
|
||||
#include "mozilla/ContentBlockingAllowList.h"
|
||||
#include "mozilla/GlobalStyleSheetCache.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
|
@ -2948,11 +2949,22 @@ void nsPresContext::FlushFontPaletteValues() {
|
|||
mFontPaletteValueSet = styleSet->BuildFontPaletteValueSet();
|
||||
mFontPaletteValuesDirty = false;
|
||||
|
||||
if (mFontPaletteCache) {
|
||||
mFontPaletteCache->SetPaletteValueSet(mFontPaletteValueSet);
|
||||
}
|
||||
|
||||
// Even if we're not reflowing anything, a change to the palette means we
|
||||
// need to repaint in order to show the new colors.
|
||||
InvalidatePaintedLayers();
|
||||
}
|
||||
|
||||
gfx::PaletteCache& nsPresContext::FontPaletteCache() {
|
||||
if (!mFontPaletteCache) {
|
||||
mFontPaletteCache = MakeUnique<gfx::PaletteCache>(mFontPaletteValueSet);
|
||||
}
|
||||
return *mFontPaletteCache.get();
|
||||
}
|
||||
|
||||
void nsPresContext::SetVisibleArea(const nsRect& r) {
|
||||
if (!r.IsEqualEdges(mVisibleArea)) {
|
||||
mVisibleArea = r;
|
||||
|
|
|
@ -97,6 +97,7 @@ enum class PrefersColorSchemeOverride : uint8_t;
|
|||
} // namespace dom
|
||||
namespace gfx {
|
||||
class FontPaletteValueSet;
|
||||
class PaletteCache;
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -932,6 +933,8 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
|
|||
void FlushFontPaletteValues();
|
||||
void MarkFontPaletteValuesDirty() { mFontPaletteValuesDirty = true; }
|
||||
|
||||
mozilla::gfx::PaletteCache& FontPaletteCache();
|
||||
|
||||
// Ensure that it is safe to hand out CSS rules outside the layout
|
||||
// engine by ensuring that all CSS style sheets have unique inners
|
||||
// and, if necessary, synchronously rebuilding all style data.
|
||||
|
@ -1200,6 +1203,8 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
|
|||
RefPtr<gfxFontFeatureValueSet> mFontFeatureValuesLookup;
|
||||
RefPtr<mozilla::gfx::FontPaletteValueSet> mFontPaletteValueSet;
|
||||
|
||||
mozilla::UniquePtr<mozilla::gfx::PaletteCache> mFontPaletteCache;
|
||||
|
||||
// TODO(emilio): Maybe lazily create and put under a UniquePtr if this grows a
|
||||
// lot?
|
||||
MediaEmulationData mMediaEmulationData;
|
||||
|
|
|
@ -244,8 +244,9 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
|
|||
NS_ASSERTION(!textRun->IsRightToLeft(),
|
||||
"Ellipsis textruns should always be LTR!");
|
||||
gfx::Point gfxPt(pt.x, pt.y);
|
||||
auto& paletteCache = mFrame->PresContext()->FontPaletteCache();
|
||||
textRun->Draw(gfxTextRun::Range(textRun), gfxPt,
|
||||
gfxTextRun::DrawParams(aCtx));
|
||||
gfxTextRun::DrawParams(aCtx, paletteCache));
|
||||
}
|
||||
} else {
|
||||
RefPtr<nsFontMetrics> fm =
|
||||
|
|
|
@ -215,6 +215,7 @@ struct nsTextFrame::PaintTextSelectionParams : nsTextFrame::PaintTextParams {
|
|||
|
||||
struct nsTextFrame::DrawTextRunParams {
|
||||
gfxContext* context;
|
||||
mozilla::gfx::PaletteCache& paletteCache;
|
||||
PropertyProvider* provider = nullptr;
|
||||
gfxFloat* advanceWidth = nullptr;
|
||||
mozilla::SVGContextPaint* contextPaint = nullptr;
|
||||
|
@ -222,11 +223,12 @@ struct nsTextFrame::DrawTextRunParams {
|
|||
nscolor textColor = NS_RGBA(0, 0, 0, 0);
|
||||
nscolor textStrokeColor = NS_RGBA(0, 0, 0, 0);
|
||||
nsAtom* fontPalette = nullptr;
|
||||
gfx::FontPaletteValueSet* paletteValueSet = nullptr;
|
||||
float textStrokeWidth = 0.0f;
|
||||
bool drawSoftHyphen = false;
|
||||
bool hasTextShadow = false;
|
||||
explicit DrawTextRunParams(gfxContext* aContext) : context(aContext) {}
|
||||
DrawTextRunParams(gfxContext* aContext,
|
||||
mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: context(aContext), paletteCache(aPaletteCache) {}
|
||||
};
|
||||
|
||||
struct nsTextFrame::ClipEdges {
|
||||
|
@ -263,7 +265,9 @@ struct nsTextFrame::DrawTextParams : nsTextFrame::DrawTextRunParams {
|
|||
const ClipEdges* clipEdges = nullptr;
|
||||
const nscolor* decorationOverrideColor = nullptr;
|
||||
Range glyphRange;
|
||||
explicit DrawTextParams(gfxContext* aContext) : DrawTextRunParams(aContext) {}
|
||||
DrawTextParams(gfxContext* aContext,
|
||||
mozilla::gfx::PaletteCache& aPaletteCache)
|
||||
: DrawTextRunParams(aContext, aPaletteCache) {}
|
||||
};
|
||||
|
||||
struct nsTextFrame::PaintShadowParams {
|
||||
|
@ -5949,7 +5953,7 @@ void nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams,
|
|||
// need to translate any coordinates to fit on the surface.
|
||||
gfxFloat advanceWidth;
|
||||
nsTextPaintStyle textPaintStyle(this);
|
||||
DrawTextParams params(shadowContext);
|
||||
DrawTextParams params(shadowContext, PresContext()->FontPaletteCache());
|
||||
params.advanceWidth = &advanceWidth;
|
||||
params.dirtyRect = aParams.dirtyRect;
|
||||
params.framePt = aParams.framePt + shadowGfxOffset;
|
||||
|
@ -5963,7 +5967,6 @@ void nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams,
|
|||
// color.
|
||||
params.decorationOverrideColor = ¶ms.textColor;
|
||||
params.fontPalette = StyleFont()->GetFontPaletteAtom();
|
||||
params.paletteValueSet = PresContext()->GetFontPaletteValueSet();
|
||||
|
||||
DrawText(aParams.range, aParams.textBaselinePt + shadowGfxOffset, params);
|
||||
|
||||
|
@ -6252,7 +6255,7 @@ bool nsTextFrame::PaintTextWithSelectionColors(
|
|||
}
|
||||
|
||||
gfxFloat advance;
|
||||
DrawTextParams params(aParams.context);
|
||||
DrawTextParams params(aParams.context, PresContext()->FontPaletteCache());
|
||||
params.dirtyRect = aParams.dirtyRect;
|
||||
params.framePt = aParams.framePt;
|
||||
params.provider = aParams.provider;
|
||||
|
@ -6262,7 +6265,6 @@ bool nsTextFrame::PaintTextWithSelectionColors(
|
|||
params.callbacks = aParams.callbacks;
|
||||
params.glyphRange = aParams.glyphRange;
|
||||
params.fontPalette = StyleFont()->GetFontPaletteAtom();
|
||||
params.paletteValueSet = PresContext()->GetFontPaletteValueSet();
|
||||
params.hasTextShadow = !StyleText()->mTextShadow.IsEmpty();
|
||||
|
||||
PaintShadowParams shadowParams(aParams);
|
||||
|
@ -6498,10 +6500,11 @@ void nsTextFrame::DrawEmphasisMarks(gfxContext* aContext, WritingMode aWM,
|
|||
}
|
||||
if (!isTextCombined) {
|
||||
mTextRun->DrawEmphasisMarks(aContext, info->textRun.get(), info->advance,
|
||||
pt, aRange, aProvider);
|
||||
pt, aRange, aProvider,
|
||||
PresContext()->FontPaletteCache());
|
||||
} else {
|
||||
pt.y += (GetSize().height - info->advance) / 2;
|
||||
gfxTextRun::DrawParams params(aContext);
|
||||
gfxTextRun::DrawParams params(aContext, PresContext()->FontPaletteCache());
|
||||
info->textRun->Draw(Range(info->textRun.get()), pt, params);
|
||||
}
|
||||
}
|
||||
|
@ -6834,7 +6837,7 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
|
|||
}
|
||||
|
||||
gfxFloat advanceWidth;
|
||||
DrawTextParams params(aParams.context);
|
||||
DrawTextParams params(aParams.context, PresContext()->FontPaletteCache());
|
||||
params.dirtyRect = aParams.dirtyRect;
|
||||
params.framePt = aParams.framePt;
|
||||
params.provider = &provider;
|
||||
|
@ -6849,7 +6852,6 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
|
|||
params.callbacks = aParams.callbacks;
|
||||
params.glyphRange = range;
|
||||
params.fontPalette = StyleFont()->GetFontPaletteAtom();
|
||||
params.paletteValueSet = PresContext()->GetFontPaletteValueSet();
|
||||
params.hasTextShadow = !StyleText()->mTextShadow.IsEmpty();
|
||||
|
||||
DrawText(range, textBaselinePt, params);
|
||||
|
@ -6860,12 +6862,11 @@ static void DrawTextRun(const gfxTextRun* aTextRun,
|
|||
gfxTextRun::Range aRange,
|
||||
const nsTextFrame::DrawTextRunParams& aParams,
|
||||
nsTextFrame* aFrame) {
|
||||
gfxTextRun::DrawParams params(aParams.context);
|
||||
gfxTextRun::DrawParams params(aParams.context, aParams.paletteCache);
|
||||
params.provider = aParams.provider;
|
||||
params.advanceWidth = aParams.advanceWidth;
|
||||
params.contextPaint = aParams.contextPaint;
|
||||
params.fontPalette = aParams.fontPalette;
|
||||
params.paletteValueSet = aParams.paletteValueSet;
|
||||
params.callbacks = aParams.callbacks;
|
||||
params.hasTextShadow = aParams.hasTextShadow;
|
||||
if (aParams.callbacks) {
|
||||
|
|
|
@ -1881,7 +1881,9 @@ void nsMathMLChar::PaintForeground(nsIFrame* aForFrame,
|
|||
if (mGlyphs[0]) {
|
||||
mGlyphs[0]->Draw(Range(mGlyphs[0].get()),
|
||||
gfx::Point(0.0, mUnscaledAscent),
|
||||
gfxTextRun::DrawParams(&aRenderingContext));
|
||||
gfxTextRun::DrawParams(
|
||||
&aRenderingContext,
|
||||
aForFrame->PresContext()->FontPaletteCache()));
|
||||
}
|
||||
break;
|
||||
case DRAW_PARTS: {
|
||||
|
@ -1995,7 +1997,8 @@ nsresult nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
|
|||
mBoundingMetrics.rightBearing - mBoundingMetrics.leftBearing;
|
||||
unionRect.Inflate(oneDevPixel);
|
||||
|
||||
gfxTextRun::DrawParams params(aThebesContext);
|
||||
gfxTextRun::DrawParams params(aThebesContext,
|
||||
aPresContext->FontPaletteCache());
|
||||
|
||||
/////////////////////////////////////
|
||||
// draw top, middle, bottom
|
||||
|
@ -2157,7 +2160,8 @@ nsresult nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
|
|||
nsRect unionRect = aRect;
|
||||
unionRect.Inflate(oneDevPixel);
|
||||
|
||||
gfxTextRun::DrawParams params(aThebesContext);
|
||||
gfxTextRun::DrawParams params(aThebesContext,
|
||||
aPresContext->FontPaletteCache());
|
||||
|
||||
///////////////////////////
|
||||
// draw left, middle, right
|
||||
|
|
Загрузка…
Ссылка в новой задаче