mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 11:45:37 +00:00
Bug 1422466. Drop a copy from TextDrawTarget::FillGlyphs. r=Gankro
We try hard to ensure that the glyph buffers are of the same type. --HG-- extra : rebase_source : b785541c15ee2d715b549e0c306e5e0669d4ad71
This commit is contained in:
parent
da8d5c072e
commit
a49417c5ed
@ -288,7 +288,7 @@ WriteFontDescriptor(const uint8_t* aData, uint32_t aLength, uint32_t aIndex,
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray<wr::GlyphInstance>& aGlyphs,
|
||||
WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, Range<const wr::GlyphInstance> aGlyphs,
|
||||
gfx::ScaledFont* aFont, const wr::ColorF& aColor, const StackingContextHelper& aSc,
|
||||
const wr::LayerRect& aBounds, const wr::LayerRect& aClip, bool aBackfaceVisible,
|
||||
const wr::GlyphOptions* aGlyphOptions)
|
||||
@ -304,7 +304,7 @@ WebRenderBridgeChild::PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArra
|
||||
aBackfaceVisible,
|
||||
aColor,
|
||||
key,
|
||||
Range<const wr::GlyphInstance>(aGlyphs.Elements(), aGlyphs.Length()),
|
||||
aGlyphs,
|
||||
aGlyphOptions);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
return wr::WrImageKey{ GetNamespace(), GetNextResourceId() };
|
||||
}
|
||||
|
||||
void PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray<wr::GlyphInstance>& aGlyphs,
|
||||
void PushGlyphs(wr::DisplayListBuilder& aBuilder, Range<const wr::GlyphInstance> aGlyphs,
|
||||
gfx::ScaledFont* aFont, const wr::ColorF& aColor,
|
||||
const StackingContextHelper& aSc,
|
||||
const wr::LayerRect& aBounds, const wr::LayerRect& aClip,
|
||||
|
@ -105,8 +105,6 @@ public:
|
||||
MOZ_RELEASE_ASSERT(aOptions.mCompositionOp == CompositionOp::OP_OVER);
|
||||
MOZ_RELEASE_ASSERT(aOptions.mAlpha == 1.0f);
|
||||
MOZ_RELEASE_ASSERT(aPattern.GetType() == PatternType::COLOR);
|
||||
auto* colorPat = static_cast<const ColorPattern*>(&aPattern);
|
||||
auto color = wr::ToColorF(colorPat->mColor);
|
||||
|
||||
// Make sure the font exists, and can be serialized
|
||||
MOZ_RELEASE_ASSERT(aFont);
|
||||
@ -115,17 +113,23 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// 170 is the maximum size gfxFont is expected to hand us
|
||||
AutoTArray<wr::GlyphInstance, 170> glyphs;
|
||||
glyphs.SetLength(aBuffer.mNumGlyphs);
|
||||
auto* colorPat = static_cast<const ColorPattern*>(&aPattern);
|
||||
auto color = wr::ToColorF(colorPat->mColor);
|
||||
auto glyphs = Range<const wr::GlyphInstance>(reinterpret_cast<const wr::GlyphInstance*>(aBuffer.mGlyphs), aBuffer.mNumGlyphs);
|
||||
|
||||
for (size_t i = 0; i < aBuffer.mNumGlyphs; i++) {
|
||||
wr::GlyphInstance& targetGlyph = glyphs[i];
|
||||
const gfx::Glyph& sourceGlyph = aBuffer.mGlyphs[i];
|
||||
targetGlyph.index = sourceGlyph.mIndex;
|
||||
targetGlyph.point = mSc.ToRelativeLayoutPoint(
|
||||
LayoutDevicePoint::FromUnknownPoint(sourceGlyph.mPosition));
|
||||
}
|
||||
// Compare gfx::Glyph and wr::GlyphInstance to make sure that they are
|
||||
// structurally equivalent to ensure that our cast above was ok
|
||||
static_assert(std::is_same<decltype(aBuffer.mGlyphs[0].mIndex), decltype(glyphs[0].index)>()
|
||||
&& std::is_same<decltype(aBuffer.mGlyphs[0].mPosition.x), decltype(glyphs[0].point.x)>()
|
||||
&& std::is_same<decltype(aBuffer.mGlyphs[0].mPosition.y), decltype(glyphs[0].point.y)>()
|
||||
&& offsetof(std::remove_reference<decltype(aBuffer.mGlyphs[0])>::type, mIndex) == offsetof(wr::GlyphInstance, index)
|
||||
&& offsetof(std::remove_reference<decltype(aBuffer.mGlyphs[0])>::type, mPosition) == offsetof(wr::GlyphInstance, point)
|
||||
&& offsetof(decltype(aBuffer.mGlyphs[0].mPosition), x) == offsetof(decltype(glyphs[0].point), x)
|
||||
&& offsetof(decltype(aBuffer.mGlyphs[0].mPosition), y) == offsetof(decltype(glyphs[0].point), y)
|
||||
&& std::is_standard_layout<decltype(aBuffer.mGlyphs[0])>::value == std::is_standard_layout<decltype(glyphs[0])>::value
|
||||
&& sizeof(aBuffer.mGlyphs[0]) == sizeof(glyphs[0])
|
||||
&& sizeof(aBuffer.mGlyphs[0].mPosition) == sizeof(glyphs[0].point)
|
||||
, "glyph buf types don't match");
|
||||
|
||||
wr::GlyphOptions glyphOptions;
|
||||
glyphOptions.render_mode = wr::ToFontRenderMode(aOptions.mAntialiasMode, GetPermitSubpixelAA());
|
||||
|
Loading…
Reference in New Issue
Block a user