summaryrefslogtreecommitdiff
path: root/mozilla-1627469.patch
blob: 3e53ec5778acb513c2598d1fdc922f2784c13036 (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
diff -up firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1627469 firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp
--- firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp.mozilla-1627469	2020-04-06 15:07:16.772431937 +0200
+++ firefox-74.0.1/widget/gtk/WindowSurfaceWayland.cpp	2020-04-06 15:09:57.037320477 +0200
@@ -647,13 +647,14 @@ WindowBackBuffer* WindowSurfaceWayland::
   LOGWAYLAND(
       ("WindowSurfaceWayland::NewWaylandBuffer [%p] Requested buffer [%d "
        "x %d] DMABuf %d\n",
-       (void*)this, mWidgetRect.width, mWidgetRect.height, aUseDMABufBackend));
+       (void*)this, mWLBufferRect.width, mWLBufferRect.height,
+       aUseDMABufBackend));
 
   mWaylandBuffer = WaylandBufferFindAvailable(
-      mWidgetRect.width, mWidgetRect.height, aUseDMABufBackend);
+      mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend);
   if (!mWaylandBuffer) {
-    mWaylandBuffer = CreateWaylandBuffer(mWidgetRect.width, mWidgetRect.height,
-                                         aUseDMABufBackend);
+    mWaylandBuffer = CreateWaylandBuffer(
+        mWLBufferRect.width, mWLBufferRect.height, aUseDMABufBackend);
   }
 
   return mWaylandBuffer;
@@ -663,7 +664,7 @@ WindowBackBuffer* WindowSurfaceWayland::
   LOGWAYLAND(
       ("WindowSurfaceWayland::GetWaylandBufferRecent [%p] Requested buffer [%d "
        "x %d]\n",
-       (void*)this, mWidgetRect.width, mWidgetRect.height));
+       (void*)this, mWLBufferRect.width, mWLBufferRect.height));
 
   // There's no buffer created yet, create a new one for partial screen updates.
   if (!mWaylandBuffer) {
@@ -675,9 +676,10 @@ WindowBackBuffer* WindowSurfaceWayland::
     return nullptr;
   }
 
-  if (mWaylandBuffer->IsMatchingSize(mWidgetRect.width, mWidgetRect.height)) {
-    LOGWAYLAND(("    Size is ok, use the buffer [%d x %d]\n", mWidgetRect.width,
-                mWidgetRect.height));
+  if (mWaylandBuffer->IsMatchingSize(mWLBufferRect.width,
+                                     mWLBufferRect.height)) {
+    LOGWAYLAND(("    Size is ok, use the buffer [%d x %d]\n",
+                mWLBufferRect.width, mWLBufferRect.height));
     return mWaylandBuffer;
   }
 
@@ -692,7 +694,7 @@ WindowBackBuffer* WindowSurfaceWayland::
   LOGWAYLAND(
       ("WindowSurfaceWayland::GetWaylandBufferWithSwitch [%p] Requested buffer "
        "[%d x %d]\n",
-       (void*)this, mWidgetRect.width, mWidgetRect.height));
+       (void*)this, mWLBufferRect.width, mWLBufferRect.height));
 
   // There's no buffer created yet or actual buffer is attached, get a new one.
   // Use DMABuf for fullscreen updates only.
@@ -701,20 +703,21 @@ WindowBackBuffer* WindowSurfaceWayland::
   }
 
   // Reuse existing buffer
-  LOGWAYLAND(("    Reuse buffer with resize [%d x %d]\n", mWidgetRect.width,
-              mWidgetRect.height));
+  LOGWAYLAND(("    Reuse buffer with resize [%d x %d]\n", mWLBufferRect.width,
+              mWLBufferRect.height));
 
   // OOM here, just return null to skip this frame.
-  if (!mWaylandBuffer->Resize(mWidgetRect.width, mWidgetRect.height)) {
+  if (!mWaylandBuffer->Resize(mWLBufferRect.width, mWLBufferRect.height)) {
     return nullptr;
   }
   return mWaylandBuffer;
 }
 
 already_AddRefed<gfx::DrawTarget> WindowSurfaceWayland::LockWaylandBuffer() {
-  // Allocated wayland buffer must match widget size, otherwise wayland
-  // compositor is confused and may produce various rendering artifacts.
-  mWidgetRect = mWindow->GetMozContainerSize();
+  // Allocated wayland buffer can't be bigger than mozilla widget size.
+  LayoutDeviceIntRegion region;
+  region.And(mLockedScreenRect, mWindow->GetMozContainerSize());
+  mWLBufferRect = LayoutDeviceIntRect(region.GetBounds());
 
   // mCanSwitchWaylandBuffer set means we're getting buffer for fullscreen
   // update. We can use DMABuf and we can get a new buffer for drawing.
@@ -882,8 +885,8 @@ already_AddRefed<gfx::DrawTarget> Window
   LayoutDeviceIntRect size = mWindow->GetMozContainerSize();
 
   // We can draw directly only when widget has the same size as wl_buffer
-  mDrawToWaylandBufferDirectly = (size.width == mLockedScreenRect.width &&
-                                  size.height == mLockedScreenRect.height);
+  mDrawToWaylandBufferDirectly = (size.width >= mLockedScreenRect.width &&
+                                  size.height >= mLockedScreenRect.height);
 
   // We can draw directly only when we redraw significant part of the window
   // to avoid flickering.
diff -up firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h.mozilla-1627469 firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h
--- firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h.mozilla-1627469	2020-04-06 15:07:16.773431931 +0200
+++ firefox-74.0.1/widget/gtk/WindowSurfaceWayland.h	2020-04-06 15:07:16.775431919 +0200
@@ -264,11 +264,11 @@ class WindowSurfaceWayland : public Wind
   // mLockedScreenRect is window size when our wayland buffer was allocated.
   LayoutDeviceIntRect mLockedScreenRect;
 
-  // WidgetRect is an actual size of mozcontainer widget. It can be
-  // different than mLockedScreenRect during resize when mBounds are updated
-  // immediately but actual GtkWidget size is updated asynchronously
-  // (see Bug 1489463).
-  LayoutDeviceIntRect mWidgetRect;
+  // mWLBufferRect is an intersection of mozcontainer widgetsize and
+  // mLockedScreenRect size. It can be different than mLockedScreenRect
+  // during resize when mBounds are updated immediately but actual
+  // GtkWidget size is updated asynchronously (see Bug 1489463).
+  LayoutDeviceIntRect mWLBufferRect;
   nsWaylandDisplay* mWaylandDisplay;
 
   // Actual buffer (backed by wl_buffer) where all drawings go into.
bgstack15