summaryrefslogtreecommitdiff
path: root/mozilla-1579794-1.patch
blob: 60c8caba20b5e0ff3162f2db52febbd3c719c754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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<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() {

bgstack15