зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1283932 - support COLR table layers with unset color, r=jfkthame
This commit is contained in:
Родитель
a4f9c9188e
Коммит
d8d7f64870
|
@ -1786,7 +1786,7 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID, double aAdvance, gfxPoint *aPt,
|
|||
}
|
||||
|
||||
if (fontParams.haveColorGlyphs &&
|
||||
RenderColorGlyph(runParams.dt,
|
||||
RenderColorGlyph(runParams.dt, runParams.context,
|
||||
fontParams.scaledFont, fontParams.renderingOptions,
|
||||
fontParams.drawOptions,
|
||||
fontParams.matInv * gfx::Point(devPt.x, devPt.y),
|
||||
|
@ -2170,6 +2170,7 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint,
|
|||
|
||||
bool
|
||||
gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget,
|
||||
gfxContext* aContext,
|
||||
mozilla::gfx::ScaledFont* scaledFont,
|
||||
GlyphRenderingOptions* aRenderingOptions,
|
||||
mozilla::gfx::DrawOptions aDrawOptions,
|
||||
|
@ -2179,7 +2180,12 @@ gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget,
|
|||
AutoTArray<uint16_t, 8> layerGlyphs;
|
||||
AutoTArray<mozilla::gfx::Color, 8> layerColors;
|
||||
|
||||
if (!GetFontEntry()->GetColorLayersInfo(aGlyphId, layerGlyphs, layerColors)) {
|
||||
mozilla::gfx::Color defaultColor;
|
||||
if (!aContext->GetDeviceColor(defaultColor)) {
|
||||
defaultColor = mozilla::gfx::Color(0, 0, 0);
|
||||
}
|
||||
if (!GetFontEntry()->GetColorLayersInfo(aGlyphId, defaultColor,
|
||||
layerGlyphs, layerColors)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2155,6 +2155,7 @@ protected:
|
|||
bool& aEmittedGlyphs) const;
|
||||
|
||||
bool RenderColorGlyph(DrawTarget* aDrawTarget,
|
||||
gfxContext* aContext,
|
||||
mozilla::gfx::ScaledFont* scaledFont,
|
||||
mozilla::gfx::GlyphRenderingOptions* renderingOptions,
|
||||
mozilla::gfx::DrawOptions drawOptions,
|
||||
|
|
|
@ -1062,12 +1062,14 @@ gfxFontEntry::SupportsGraphiteFeature(uint32_t aFeatureTag)
|
|||
|
||||
bool
|
||||
gfxFontEntry::GetColorLayersInfo(uint32_t aGlyphId,
|
||||
const mozilla::gfx::Color& aDefaultColor,
|
||||
nsTArray<uint16_t>& aLayerGlyphs,
|
||||
nsTArray<mozilla::gfx::Color>& aLayerColors)
|
||||
{
|
||||
return gfxFontUtils::GetColorGlyphLayers(mCOLR,
|
||||
mCPAL,
|
||||
aGlyphId,
|
||||
aDefaultColor,
|
||||
aLayerGlyphs,
|
||||
aLayerColors);
|
||||
}
|
||||
|
|
|
@ -265,6 +265,7 @@ public:
|
|||
|
||||
bool TryGetColorGlyphs();
|
||||
bool GetColorLayersInfo(uint32_t aGlyphId,
|
||||
const mozilla::gfx::Color& aDefaultColor,
|
||||
nsTArray<uint16_t>& layerGlyphs,
|
||||
nsTArray<mozilla::gfx::Color>& layerColors);
|
||||
|
||||
|
|
|
@ -1669,7 +1669,8 @@ gfxFontUtils::ValidateColorGlyphs(hb_blob_t* aCOLR, hb_blob_t* aCPAL)
|
|||
reinterpret_cast<const uint8_t*>(colr) + offsetLayerRecord);
|
||||
|
||||
for (uint16_t i = 0; i < numLayerRecords; i++, layer++) {
|
||||
if (uint16_t(layer->paletteEntryIndex) >= numPaletteEntries) {
|
||||
if (uint16_t(layer->paletteEntryIndex) >= numPaletteEntries &&
|
||||
uint16_t(layer->paletteEntryIndex) != 0xFFFF) {
|
||||
// CPAL palette entry record is overflow
|
||||
return false;
|
||||
}
|
||||
|
@ -1713,6 +1714,7 @@ bool
|
|||
gfxFontUtils::GetColorGlyphLayers(hb_blob_t* aCOLR,
|
||||
hb_blob_t* aCPAL,
|
||||
uint32_t aGlyphId,
|
||||
const mozilla::gfx::Color& aDefaultColor,
|
||||
nsTArray<uint16_t>& aGlyphs,
|
||||
nsTArray<mozilla::gfx::Color>& aColors)
|
||||
{
|
||||
|
@ -1744,15 +1746,19 @@ gfxFontUtils::GetColorGlyphLayers(hb_blob_t* aCOLR,
|
|||
|
||||
for (uint16_t layerIndex = 0; layerIndex < numLayers; layerIndex++) {
|
||||
aGlyphs.AppendElement(uint16_t(layer->glyphId));
|
||||
const CPALColorRecord* color =
|
||||
reinterpret_cast<const CPALColorRecord*>(
|
||||
reinterpret_cast<const uint8_t*>(cpal) +
|
||||
offsetFirstColorRecord +
|
||||
sizeof(CPALColorRecord) * uint16_t(layer->paletteEntryIndex));
|
||||
aColors.AppendElement(mozilla::gfx::Color(color->red / 255.0,
|
||||
color->green / 255.0,
|
||||
color->blue / 255.0,
|
||||
color->alpha / 255.0));
|
||||
if (uint16_t(layer->paletteEntryIndex) == 0xFFFF) {
|
||||
aColors.AppendElement(aDefaultColor);
|
||||
} else {
|
||||
const CPALColorRecord* color =
|
||||
reinterpret_cast<const CPALColorRecord*>(
|
||||
reinterpret_cast<const uint8_t*>(cpal) +
|
||||
offsetFirstColorRecord +
|
||||
sizeof(CPALColorRecord) * uint16_t(layer->paletteEntryIndex));
|
||||
aColors.AppendElement(mozilla::gfx::Color(color->red / 255.0,
|
||||
color->green / 255.0,
|
||||
color->blue / 255.0,
|
||||
color->alpha / 255.0));
|
||||
}
|
||||
layer++;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -979,6 +979,7 @@ public:
|
|||
static bool GetColorGlyphLayers(hb_blob_t* aCOLR,
|
||||
hb_blob_t* aCPAL,
|
||||
uint32_t aGlyphId,
|
||||
const mozilla::gfx::Color& aDefaultColor,
|
||||
nsTArray<uint16_t> &aGlyphs,
|
||||
nsTArray<mozilla::gfx::Color> &aColors);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче