Bug 1573343 - Add mDrawTargetBounds to clarify the position of mDrawTarget in window space. r=mattwoodrow

There was an interesting "ExpandToEnclose(IntPoint(0, 0))" call in
CreateRenderTargetForWindow that snuck in some surprising behavior that this
change makes a bit more visible.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-08-19 22:39:45 +00:00
Родитель 8b68a014ae
Коммит 4491f22f3b
2 изменённых файлов: 18 добавлений и 7 удалений

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

@ -315,12 +315,7 @@ BasicCompositor::CreateRenderTargetForWindow(
MOZ_ASSERT(target != mDrawTarget);
rt = new BasicCompositingRenderTarget(target, rect);
} else {
IntRect windowRect = rect;
// Adjust bounds rect to account for new origin at (0, 0).
if (windowRect.Size() != mDrawTarget->GetSize()) {
windowRect.ExpandToEnclose(IntPoint(0, 0));
}
rt = new BasicCompositingRenderTarget(mDrawTarget, windowRect);
rt = new BasicCompositingRenderTarget(mDrawTarget, mDrawTargetBounds);
}
rt->mDrawTarget->SetTransform(Matrix::Translation(-rt->GetOrigin()));
@ -933,6 +928,7 @@ void BasicCompositor::BeginFrame(
// draw target that we composite into, then copy the results the
// destination.
mDrawTarget = mTarget;
mDrawTargetBounds = mTargetBounds;
bufferMode = BufferMode::BUFFER_NONE;
} else {
// StartRemoteDrawingInRegion can mutate mInvalidRegion.
@ -946,6 +942,18 @@ void BasicCompositor::BeginFrame(
mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
return;
}
// The DrawTarget returned by StartRemoteDrawingInRegion can cover different
// rectangles in window space. It can either cover the entire window, or it
// can cover just the invalid region. We discern between the two cases by
// comparing the DrawTarget's size with the invalild region's size.
IntSize dtSize = mDrawTarget->GetSize();
if (bufferMode == BufferMode::BUFFER_NONE &&
dtSize == mInvalidRect.Size().ToUnknownSize()) {
mDrawTargetBounds = mInvalidRect.ToUnknownRect();
} else {
mDrawTargetBounds = IntRect(IntPoint(0, 0), dtSize);
}
}
if (!mDrawTarget || mInvalidRect.IsEmpty()) {
@ -1061,7 +1069,7 @@ void BasicCompositor::TryToEndRemoteDrawing(bool aForceToEnd) {
// drawing.
RefPtr<SourceSurface> source = mWidget->EndBackBufferDrawing();
IntPoint srcOffset = mRenderTarget->GetOrigin();
IntPoint dstOffset = mTarget ? mTargetBounds.TopLeft() : IntPoint();
IntPoint dstOffset = mDrawTargetBounds.TopLeft();
// The source DrawTarget is clipped to the invalidation region, so we have
// to copy the individual rectangles in the region or else we'll draw

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

@ -183,6 +183,9 @@ class BasicCompositor : public Compositor {
// The final destination surface
RefPtr<gfx::DrawTarget> mDrawTarget;
// The bounds that mDrawTarget occupies in window space.
gfx::IntRect mDrawTargetBounds;
// The current render target for drawing
RefPtr<BasicCompositingRenderTarget> mRenderTarget;