Bug 1456555 - Fix bugs in DrawTargetOffset. r=mstange

MozReview-Commit-ID: I4XFoTp1szZ

Depends on D10033

Differential Revision: https://phabricator.services.mozilla.com/D10036

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2018-11-06 00:39:59 +00:00
Родитель 22bf715e5e
Коммит df71bb3105
2 изменённых файлов: 20 добавлений и 10 удалений

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

@ -83,7 +83,9 @@ DrawTargetOffset::DrawFilter(FilterNode* aNode, const Rect& aSourceRect, const P
{
auto clone = mTransform;
bool invertible = clone.Invert();
auto src = aSourceRect;
// aSourceRect is in filter space. The filter outputs from aSourceRect need
// to be drawn at aDestPoint in user space.
Rect userSpaceSource = Rect(aDestPoint, aSourceRect.Size());
if (invertible) {
// Try to reduce the source rect so that it's not much bigger
// than the draw target. The result is not minimal. Examples
@ -92,11 +94,16 @@ DrawTargetOffset::DrawFilter(FilterNode* aNode, const Rect& aSourceRect, const P
mOrigin.y,
mDrawTarget->GetSize().width,
mDrawTarget->GetSize().height);
auto dtBounds = clone.TransformBounds(destRect);
src = aSourceRect.Intersect(dtBounds);
Rect userSpaceBounds = clone.TransformBounds(destRect);
userSpaceSource = userSpaceSource.Intersect(userSpaceBounds);
}
auto shift = src.TopLeft() - aSourceRect.TopLeft();
mDrawTarget->DrawFilter(aNode, src, aDestPoint + shift, aOptions);
// Compute how much we moved the top-left of the source rect by, and use that
// to compute the new dest point, and move our intersected source rect back
// into the (new) filter space.
Point shift = userSpaceSource.TopLeft() - aDestPoint;
Rect filterSpaceSource = Rect(aSourceRect.TopLeft() + shift, userSpaceSource.Size());
mDrawTarget->DrawFilter(aNode, filterSpaceSource, aDestPoint + shift, aOptions);
}
void
@ -184,9 +191,10 @@ DrawTargetOffset::PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
const Matrix& aMaskTransform, const IntRect& aBounds,
bool aCopyBackground)
{
IntRect bounds = aBounds;
bounds.MoveBy(mOrigin);
IntRect bounds = aBounds - mOrigin;
mDrawTarget->PushLayer(aOpaque, aOpacity, aMask, aMaskTransform, bounds, aCopyBackground);
SetPermitSubpixelAA(mDrawTarget->GetPermitSubpixelAA());
}
void
@ -197,15 +205,17 @@ DrawTargetOffset::PushLayerWithBlend(bool aOpaque, Float aOpacity,
bool aCopyBackground,
CompositionOp aOp)
{
IntRect bounds = aBounds;
bounds.MoveBy(mOrigin);
IntRect bounds = aBounds - mOrigin;
mDrawTarget->PushLayerWithBlend(aOpaque, aOpacity, aMask, aMaskTransform, bounds, aCopyBackground, aOp);
SetPermitSubpixelAA(mDrawTarget->GetPermitSubpixelAA());
}
void
DrawTargetOffset::PopLayer()
{
mDrawTarget->PopLayer();
SetPermitSubpixelAA(mDrawTarget->GetPermitSubpixelAA());
}
} // namespace gfx

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

@ -38,7 +38,7 @@ public:
return mDrawTarget->GetSize();
}
virtual IntRect GetRect() const override {
return mDrawTarget->GetRect();
return IntRect(mOrigin, GetSize());
}
virtual void Flush() override;