From 36345da5139b4ffba1e6529abf1240fc80b42c1d Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Wed, 11 Sep 2019 08:35:24 +0200 Subject: Added fix for mozbz#1579794 - Flickering on video playback on 4k/HiDPI displays --- mozilla-1579794-1.patch | 134 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 mozilla-1579794-1.patch (limited to 'mozilla-1579794-1.patch') diff --git a/mozilla-1579794-1.patch b/mozilla-1579794-1.patch new file mode 100644 index 0000000..60c8cab --- /dev/null +++ b/mozilla-1579794-1.patch @@ -0,0 +1,134 @@ +diff --git a/widget/gtk/WindowSurfaceWayland.h b/widget/gtk/WindowSurfaceWayland.h +--- a/widget/gtk/WindowSurfaceWayland.h ++++ b/widget/gtk/WindowSurfaceWayland.h +@@ -154,11 +154,12 @@ + void Draw(gfx::DrawTarget* aDest, + LayoutDeviceIntRegion& aWaylandBufferDamage); + +- WindowImageSurface(gfx::SourceSurface* aSurface, ++ WindowImageSurface(gfxImageSurface* aImageSurface, + const LayoutDeviceIntRegion& aUpdateRegion); + + private: + RefPtr mSurface; ++ RefPtr mImageSurface; + const LayoutDeviceIntRegion mUpdateRegion; + }; + +diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp +--- a/widget/gtk/WindowSurfaceWayland.cpp ++++ b/widget/gtk/WindowSurfaceWayland.cpp +@@ -890,8 +890,12 @@ + } + + WindowImageSurface::WindowImageSurface( +- gfx::SourceSurface* aSurface, const LayoutDeviceIntRegion& aUpdateRegion) +- : mSurface(aSurface), mUpdateRegion(aUpdateRegion){}; ++ gfxImageSurface* aImageSurface, const LayoutDeviceIntRegion& aUpdateRegion) ++ : mImageSurface(aImageSurface), mUpdateRegion(aUpdateRegion) { ++ mSurface = gfx::Factory::CreateSourceSurfaceForCairoSurface( ++ mImageSurface->CairoSurface(), mImageSurface->GetSize(), ++ mImageSurface->Format()); ++} + + void WindowSurfaceWayland::DrawDelayedImageCommits( + gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aWaylandBufferDamage) { +@@ -915,36 +919,24 @@ + LOGWAYLAND(("%s [%p] screenSize [%d x %d]\n", __PRETTY_FUNCTION__, + (void*)this, mBufferScreenRect.width, mBufferScreenRect.height)); + +- RefPtr surf = +- gfx::Factory::CreateSourceSurfaceForCairoSurface( +- mImageSurface->CairoSurface(), mImageSurface->GetSize(), +- mImageSurface->Format()); +- if (!surf) { +- NS_WARNING("Failed to create source cairo surface!"); +- return false; +- } ++ mDelayedImageCommits.AppendElement( ++ WindowImageSurface(mImageSurface, aRegion)); ++ // mImageSurface is owned by mDelayedImageCommits ++ mImageSurface = nullptr; + + RefPtr dt = LockWaylandBuffer( + /* aCanSwitchBuffer */ mWholeWindowBufferDamage); +- if (dt) { +- LOGWAYLAND( +- (" Flushing %ld cached WindowImageSurfaces to Wayland buffer\n", +- long(mDelayedImageCommits.Length() + 1))); +- +- // Draw any delayed image commits first +- DrawDelayedImageCommits(dt, aWaylandBufferDamage); +- // Draw image from recent WindowSurfaceWayland::Lock(). +- WindowImageSurface::Draw(surf, dt, aRegion); +- // Submit all drawing to final Wayland buffer upload +- aWaylandBufferDamage.OrWith(aRegion); +- UnlockWaylandBuffer(); +- } else { +- mDelayedImageCommits.AppendElement(WindowImageSurface(surf, aRegion)); +- LOGWAYLAND((" Added WindowImageSurfaces, cached surfaces %ld\n", +- long(mDelayedImageCommits.Length()))); ++ if (!dt) { + return false; + } + ++ LOGWAYLAND((" Flushing %ld cached WindowImageSurfaces to Wayland buffer\n", ++ long(mDelayedImageCommits.Length() + 1))); ++ ++ // Draw any delayed image commits first ++ DrawDelayedImageCommits(dt, aWaylandBufferDamage); ++ UnlockWaylandBuffer(); ++ + return true; + } + +@@ -980,23 +972,6 @@ + LOGWAYLAND((" mFrameCallback = %p\n", mFrameCallback)); + LOGWAYLAND((" mLastCommittedSurface = %p\n", mLastCommittedSurface)); + +- if (!mDrawToWaylandBufferDirectly) { +- MOZ_ASSERT(mDelayedImageCommits.Length(), +- "Indirect drawing without any image?"); +- +- // There's some cached drawings - try to flush them now. +- RefPtr dt = LockWaylandBuffer( +- /* aCanSwitchBuffer */ mWholeWindowBufferDamage); +- +- if (dt) { +- LOGWAYLAND(("%s [%p] flushed indirect drawing\n", __PRETTY_FUNCTION__, +- (void*)this)); +- DrawDelayedImageCommits(dt, mWaylandBufferDamage); +- UnlockWaylandBuffer(); +- mDrawToWaylandBufferDirectly = true; +- } +- } +- + wl_surface* waylandSurface = mWindow->GetWaylandSurface(); + if (!waylandSurface) { + LOGWAYLAND(("%s [%p] mWindow->GetWaylandSurface() failed, delay commit.\n", +@@ -1105,6 +1080,7 @@ + mWaylandBufferDamage.OrWith(aInvalidRegion); + } + UnlockWaylandBuffer(); ++ mPendingCommit = true; + } else { + MOZ_ASSERT(!mWaylandBuffer->IsLocked(), + "Drawing to already locked buffer?"); +@@ -1112,12 +1088,13 @@ + mWaylandBufferDamage)) { + // Our cached drawing is flushed, we can draw fullscreen again. + mDrawToWaylandBufferDirectly = true; ++ mPendingCommit = true; + } + } + +- // We're ready to commit. +- mPendingCommit = true; +- CommitWaylandBuffer(); ++ if (mPendingCommit) { ++ CommitWaylandBuffer(); ++ } + } + + void WindowSurfaceWayland::FrameCallbackHandler() { + -- cgit