Bug 1403261 - enable native webrender handling of partial ligatures. r=jrmuizel,mstange

The clipping code uses gfxContext::GetClipExtents which calls gfxContext::GetDeviceOffset
and DrawTarget::GetSize. The former was previously not being intialized, while the latter
was explicitly unimplemented. This patch fixes both of those facts.

Otherwise, enabling this functionality has been made trivial by several upstream patches
in webrender (the most recent being glenn's work on unifying shadows which eliminated
the buggy text-shadow shader code that was blocking this).

MozReview-Commit-ID: B1AlG3o4XQS

--HG--
extra : rebase_source : 2043c9c781f507c5d02041420145b1a5c59c0bb2
This commit is contained in:
Alexis Beingessner 2018-04-16 23:05:48 -04:00
Родитель d361ce7995
Коммит 4303ce985c
3 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -472,11 +472,6 @@ gfxTextRun::DrawPartialLigature(gfxFont* aFont, Range aRange,
return;
}
if (auto* textDrawer = aParams.context->GetTextDrawer()) {
textDrawer->FoundUnsupportedFeature();
return;
}
// Draw partial ligature. We hack this by clipping the ligature.
LigatureData data = ComputeLigatureData(aRange, aProvider);
gfxRect clipExtents = aParams.context->GetClipExtents();

Просмотреть файл

@ -68,6 +68,7 @@ public:
// Add 1 pixel of dirty area around clip rect to allow us to paint
// antialiased pixels beyond the measured text extents.
layoutClipRect.Inflate(1);
mSize = IntSize::Ceil(layoutClipRect.Width(), layoutClipRect.Height());
mClipStack.AppendElement(layoutClipRect);
mBackfaceVisible = !aItem->BackfaceIsHidden();
@ -188,6 +189,10 @@ public:
mClipStack.RemoveLastElement();
}
IntSize GetSize() const override {
return mSize;
}
void
AppendShadow(const wr::Shadow& aShadow)
{
@ -322,6 +327,7 @@ private:
layers::WebRenderLayerManager* mManager;
// Computed facts
IntSize mSize;
wr::LayerRect mBoundsRect;
nsTArray<LayoutDeviceRect> mClipStack;
bool mBackfaceVisible;
@ -352,11 +358,6 @@ public:
return nullptr;
}
IntSize GetSize() const override {
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
return IntSize(1, 1);
}
void Flush() override {
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}

Просмотреть файл

@ -5101,8 +5101,13 @@ nsDisplayText::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder
return true;
}
auto appUnitsPerDevPixel = Frame()->PresContext()->AppUnitsPerDevPixel();
gfx::Point deviceOffset = LayoutDevicePoint::FromAppUnits(
mBounds.TopLeft(), appUnitsPerDevPixel).ToUnknownPoint();
RefPtr<TextDrawTarget> textDrawer = new TextDrawTarget(aBuilder, aSc, aManager, this, mBounds);
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer, deviceOffset);
RenderToContext(captureCtx, aDisplayListBuilder, true);