Bug 1258086 - Clear unbuffered SHM images with a 32-bit visual before drawing with the basic layer manager. r?lsalzman draft
authorAndrew Comminos <acomminos@mozilla.com>
Wed, 27 Apr 2016 13:46:07 -0700
changeset 356971 869ca91267d59b4a2c5540ebd30bca0bed76295d
parent 356700 52072b6bec1416578615ec73027eb80a65d3fcd4
child 519548 3316339720822af9aff7b7fdd310ae43c4ad9b3b
push id16673
push userbmo:andrew@comminos.com
push dateWed, 27 Apr 2016 20:46:49 +0000
reviewerslsalzman
bugs1258086
milestone49.0a1
Bug 1258086 - Clear unbuffered SHM images with a 32-bit visual before drawing with the basic layer manager. r?lsalzman MozReview-Commit-ID: 8XgVwvBDZ3X
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2277,16 +2277,27 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 #endif
 #endif
 
 #endif // MOZ_X11
 
     bool painted = false;
     {
       if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
+        GdkScreen *screen = gdk_window_get_screen(mGdkWindow);
+        if (GetTransparencyMode() == eTransparencyTransparent &&
+            layerBuffering == BufferMode::BUFFER_NONE &&
+            gdk_screen_is_composited(screen) &&
+            gdk_window_get_visual(mGdkWindow) ==
+            gdk_screen_get_rgba_visual(screen)) {
+          // If our draw target is unbuffered and we use an alpha channel,
+          // clear the image beforehand to ensure we don't get artifacts from a
+          // reused SHM image. See bug 1258086.
+          dt->ClearRect(Rect(boundsRect));
+        }
         AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering);
         painted = listener->PaintWindow(this, region);
       }
     }
 
 #ifdef MOZ_X11
     // PaintWindow can Destroy us (bug 378273), avoid doing any paint
     // operations below if that happened - it will lead to XError and exit().