Skip to content

Commit

Permalink
Bug 1468911 - [Wayland] Visible artifacts during window resize, r=ashie
Browse files Browse the repository at this point in the history
When wayland surface is newly created or resized,
postpone buffer commit (drawing) until gecko updates whole screen
and don't publish partial updates.

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
stransky committed Mar 23, 2019
1 parent 0961433 commit 7065147
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions widget/gtk/WindowSurfaceWayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ WindowSurfaceWayland::WindowSurfaceWayland(nsWindow* aWindow)
mPendingCommit(false),
mWaylandBufferFullScreenDamage(false),
mIsMainThread(NS_IsMainThread()),
mNeedScaleFactorUpdate(true) {
mNeedScaleFactorUpdate(true),
mWaitToFullScreenUpdate(true) {
for (int i = 0; i < BACK_BUFFER_NUM; i++) mBackupBuffer[i] = nullptr;
}

Expand Down Expand Up @@ -431,6 +432,7 @@ WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth,
aWidth, aHeight));

mWaylandBuffer = new WindowBackBuffer(mWaylandDisplay, aWidth, aHeight);
mWaitToFullScreenUpdate = true;
return mWaylandBuffer;
}

Expand All @@ -439,7 +441,7 @@ WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth,
mWaylandBuffer->Resize(aWidth, aHeight);
// There's a chance that scale factor has been changed
// when buffer size changed
mNeedScaleFactorUpdate = true;
mWaitToFullScreenUpdate = true;
}
LOGWAYLAND(("%s [%p] Reuse buffer [%d x %d]\n", __PRETTY_FUNCTION__,
(void*)this, aWidth, aHeight));
Expand Down Expand Up @@ -492,6 +494,7 @@ WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(int aWidth,
// Former buffer has different size from the new request. Only resize
// the new buffer and leave gecko to render new whole content.
mWaylandBuffer->Resize(aWidth, aHeight);
mWaitToFullScreenUpdate = true;
}

return mWaylandBuffer;
Expand Down Expand Up @@ -566,6 +569,13 @@ already_AddRefed<gfx::DrawTarget> WindowSurfaceWayland::Lock(
LockWaylandBuffer(screenRect.width, screenRect.height,
mWindow->WaylandSurfaceNeedsClear());
if (dt) {
// When we have a request to update whole screen at once
// (surface was created, resized or changed somehow)
// we also need update scale factor of the screen.
if (mWaitToFullScreenUpdate) {
mWaitToFullScreenUpdate = false;
mNeedScaleFactorUpdate = true;
}
return dt.forget();
}

Expand Down Expand Up @@ -632,6 +642,10 @@ static void WaylandBufferDelayCommitHandler(WindowSurfaceWayland** aSurface) {
void WindowSurfaceWayland::CommitWaylandBuffer() {
MOZ_ASSERT(mPendingCommit, "Committing empty surface!");

if (mWaitToFullScreenUpdate) {
return;
}

wl_surface* waylandSurface = mWindow->GetWaylandSurface();
if (!waylandSurface) {
// Target window is not created yet - delay the commit. This can happen only
Expand Down Expand Up @@ -675,6 +689,7 @@ void WindowSurfaceWayland::CommitWaylandBuffer() {
LayoutDeviceIntRect rect = mWindow->GetBounds();
wl_surface_damage(waylandSurface, 0, 0, rect.width, rect.height);
mWaylandBufferFullScreenDamage = false;
mNeedScaleFactorUpdate = true;
} else {
gint scaleFactor = mWindow->GdkScaleFactor();
for (auto iter = mWaylandBufferDamage.RectIter(); !iter.Done();
Expand Down
1 change: 1 addition & 0 deletions widget/gtk/WindowSurfaceWayland.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class WindowSurfaceWayland : public WindowSurface {
bool mWaylandBufferFullScreenDamage;
bool mIsMainThread;
bool mNeedScaleFactorUpdate;
bool mWaitToFullScreenUpdate;
};

} // namespace widget
Expand Down

0 comments on commit 7065147

Please sign in to comment.