diff --git a/widget/gtk/WindowSurfaceWaylandMultiBuffer.cpp b/widget/gtk/WindowSurfaceWaylandMultiBuffer.cpp --- a/widget/gtk/WindowSurfaceWaylandMultiBuffer.cpp +++ b/widget/gtk/WindowSurfaceWaylandMultiBuffer.cpp @@ -19,11 +19,11 @@ #include "mozilla/gfx/Tools.h" #include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_widget.h" #include "mozilla/WidgetUtils.h" -#undef LOG +#undef LOGWAYLAND #ifdef MOZ_LOGGING # include "mozilla/Logging.h" # include "Units.h" extern mozilla::LazyLogModule gWidgetWaylandLog; # define LOGWAYLAND(...) \ @@ -283,21 +283,22 @@ return; } mFrameInProcess = false; MozContainer* container = mWindow->GetMozContainer(); - MozContainerSurfaceLock MozContainerLock(container); - struct wl_surface* waylandSurface = MozContainerLock.GetSurface(); - if (!waylandSurface) { + WaylandSurface* waylandSurface = MOZ_WL_SURFACE(container); + WaylandSurfaceLock lock(waylandSurface); + // TODO: Mapped or read to draw? + if (!waylandSurface->IsMapped()) { LOGWAYLAND( "WindowSurfaceWaylandMB::Commit [%p] frame queued: can't lock " "wl_surface\n", (void*)mWindow.get()); if (!mCallbackRequested) { RefPtr self(this); - moz_container_wayland_add_initial_draw_callback_locked( - container, [self, aInvalidRegion]() -> void { + waylandSurface->AddInitialDrawCallbackLocked( + lock, [self, aInvalidRegion]() -> void { MutexAutoLock lock(self->mSurfaceLock); if (!self->mFrameInProcess) { self->Commit(lock, aInvalidRegion); } self->mCallbackRequested = false; @@ -305,49 +306,23 @@ mCallbackRequested = true; } return; } - if (moz_container_wayland_is_commiting_to_parent(container)) { - // When committing to parent surface we must use wl_surface_damage(). - // A parent surface is created as v.3 object which does not support - // wl_surface_damage_buffer(). - wl_surface_damage(waylandSurface, 0, 0, INT32_MAX, INT32_MAX); - } else { - for (auto iter = aInvalidRegion.RectIter(); !iter.Done(); iter.Next()) { - LayoutDeviceIntRect r = iter.Get(); - wl_surface_damage_buffer(waylandSurface, r.x, r.y, r.width, r.height); - } - } - - // aProofOfLock is a kind of substitution of MozContainerSurfaceLock. - // MozContainer is locked but MozContainerSurfaceLock doen't convert to - // MutexAutoLock& so we use aProofOfLock here. - moz_container_wayland_set_scale_factor_locked( - aProofOfLock, container, mWindow->GdkCeiledScaleFactor()); - - // It's possible that scale factor changed between Lock() and Commit() - // but window size is the same. - // Don't attach such buffer as it may have incorrect size, - // we'll paint new content soon. - if (moz_container_wayland_size_matches_scale_factor_locked( - aProofOfLock, container, mWindowSize.width, mWindowSize.height)) { - mInProgressBuffer->AttachAndCommit(waylandSurface); - } + waylandSurface->InvalidateRegionLocked(lock, + aInvalidRegion.ToUnknownRegion()); + waylandSurface->AttachLocked(lock, mInProgressBuffer); + waylandSurface->CommitLocked(lock, /* force commit */ true, + /* force flush */ true); mInProgressBuffer->ResetBufferAge(); mFrontBuffer = mInProgressBuffer; mFrontBufferInvalidRegion = aInvalidRegion; mInProgressBuffer = nullptr; EnforcePoolSizeLimit(aProofOfLock); IncrementBufferAge(aProofOfLock); - - if (wl_display_flush(WaylandDisplayGet()->GetDisplay()) == -1) { - LOGWAYLAND("WindowSurfaceWaylandMB::Commit [%p] flush failed\n", - (void*)mWindow.get()); - } } RefPtr WindowSurfaceWaylandMB::ObtainBufferFromPool( const MutexAutoLock& aProofOfLock, const LayoutDeviceIntSize& aSize) { if (!mAvailableBuffers.IsEmpty()) {