Skip to content

Commit

Permalink
Bug 1573343 - Always create the back buffer sized to the widget's cli…
Browse files Browse the repository at this point in the history
…ent size. r=mattwoodrow

This should be equivalent to what we had before but clearer.
Before this patch, we would reallocate the back buffer if
 - the back buffer was larger than the client size (meaning the window had shrunk) or
 - the invalid region didn't fit in the back buffer.
Whenever the window is resized, we have a frame where the invalid region covers
the entire window, and thus size would be equal clientSize in that frame.
So effectively, the back buffer size was always kept in sync with the client size.

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
mstange committed Aug 19, 2019
1 parent c771ae8 commit f182a07
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions widget/CompositorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ already_AddRefed<gfx::DrawTarget> CompositorWidget::GetBackBufferDrawTarget(
? gfx::SurfaceFormat::B8G8R8X8
: gfx::SurfaceFormat::B8G8R8A8;
gfx::IntSize size = aRect.ToUnknownRect().Size();
gfx::IntSize clientSize(GetClientSize().ToUnknownSize());
gfx::IntSize clientSize = Max(size, GetClientSize().ToUnknownSize());

RefPtr<gfx::DrawTarget> target;
// Re-use back buffer if possible
if (mLastBackBuffer &&
mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
mLastBackBuffer->GetFormat() == format &&
size <= mLastBackBuffer->GetSize() &&
mLastBackBuffer->GetSize() <= clientSize) {
mLastBackBuffer->GetSize() == clientSize) {
target = mLastBackBuffer;
target->SetTransform(gfx::Matrix());
if (!aClearRect.IsEmpty()) {
Expand All @@ -48,7 +47,7 @@ already_AddRefed<gfx::DrawTarget> CompositorWidget::GetBackBufferDrawTarget(
clearRect.Width(), clearRect.Height()));
}
} else {
target = aScreenTarget->CreateSimilarDrawTarget(size, format);
target = aScreenTarget->CreateSimilarDrawTarget(clientSize, format);
mLastBackBuffer = target;
}
return target.forget();
Expand Down

0 comments on commit f182a07

Please sign in to comment.