Bug 1720429 - CreateClippedDrawTarget takes a rect in user space. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D120135
This commit is contained in:
Matt Woodrow 2021-07-19 22:01:31 +00:00
Родитель f36ae46161
Коммит 81dcdf515d
2 изменённых файлов: 9 добавлений и 13 удалений

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

@ -1539,6 +1539,7 @@ class DrawTarget : public external::AtomicRefCounted<DrawTarget> {
* Create a similar DrawTarget in the same space as this DrawTarget whose
* device size may be clipped based on the active clips intersected with
* aBounds (if it is not empty).
* aRect is a rectangle in user space.
*/
virtual RefPtr<DrawTarget> CreateClippedDrawTarget(const Rect& aBounds,
SurfaceFormat aFormat) = 0;

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

@ -6164,24 +6164,18 @@ void nsDisplayBlendMode::Paint(nsDisplayListBuilder* aBuilder,
// been implemented for all DrawTarget backends.
DrawTarget* dt = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
IntRect rect =
IntRect::RoundOut(NSRectToRect(GetPaintRect(), appUnitsPerDevPixel));
// Compute the device space rect that we'll draw to, and allocate
// a temporary draw target of that size.
Rect deviceRect = dt->GetTransform().TransformBounds(Rect(rect));
if (deviceRect.IsEmpty()) {
return;
}
Rect rect = NSRectToRect(GetPaintRect(), appUnitsPerDevPixel);
rect.RoundOut();
// Create a temporary DrawTarget that is clipped to the area that
// we're going to draw to. This will include the same transform as
// is currently on |dt|.
RefPtr<DrawTarget> temp =
dt->CreateClippedDrawTarget(deviceRect, SurfaceFormat::B8G8R8A8);
dt->CreateClippedDrawTarget(rect, SurfaceFormat::B8G8R8A8);
if (!temp) {
return;
}
// Copy the transform across to the temporary DT so that we
// draw in device space.
RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(temp);
GetChildren()->Paint(aBuilder, ctx,
@ -6194,7 +6188,8 @@ void nsDisplayBlendMode::Paint(nsDisplayListBuilder* aBuilder,
gfxContextMatrixAutoSaveRestore saveMatrix(aCtx);
dt->SetTransform(Matrix());
dt->DrawSurface(
surface, deviceRect, deviceRect, DrawSurfaceOptions(),
surface, Rect(surface->GetRect()), Rect(surface->GetRect()),
DrawSurfaceOptions(),
DrawOptions(1.0f, nsCSSRendering::GetGFXBlendMode(mBlendMode)));
}