135 lines
4.7 KiB
Diff
135 lines
4.7 KiB
Diff
|
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<gfx::SourceSurface> mSurface;
|
||
|
+ RefPtr<gfxImageSurface> 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<gfx::SourceSurface> 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<gfx::DrawTarget> 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<gfx::DrawTarget> 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() {
|
||
|
|