Bug 1167786. Restrict bounds of drawn region to the nsShmImage bounds to avoid X errors. r=karlt
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 14 Jul 2015 00:03:44 +1200
changeset 252566 fe452120866e9a66ea70ba1089ac6b3d2164d676
parent 252565 694c698ed1c8d5f89448c87c948dd3879447495c
child 252567 b390f54186e6a0a50c935733fefb9fff12a89071
push id62180
push userrocallahan@mozilla.com
push dateMon, 13 Jul 2015 12:23:08 +0000
treeherdermozilla-inbound@fe452120866e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1167786
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1167786. Restrict bounds of drawn region to the nsShmImage bounds to avoid X errors. r=karlt
widget/nsShmImage.cpp
--- a/widget/nsShmImage.cpp
+++ b/widget/nsShmImage.cpp
@@ -126,17 +126,19 @@ nsShmImage::Put(GdkWindow* aWindow, cons
     GdkDrawable* gd;
     gint dx, dy;
     gdk_window_get_internal_paint_info(aWindow, &gd, &dx, &dy);
 
     Display* dpy = gdk_x11_get_default_xdisplay();
     Drawable d = GDK_DRAWABLE_XID(gd);
 
     GC gc = XCreateGC(dpy, d, 0, nullptr);
-    nsIntRegionRectIterator iter(aRegion);
+    nsIntRegion bounded;
+    bounded.And(aRegion, nsIntRect(0, 0, mImage->width, mImage->height));
+    nsIntRegionRectIterator iter(bounded);
     for (const nsIntRect *r = iter.Next(); r; r = iter.Next()) {
         XShmPutImage(dpy, d, gc, mImage,
                      r->x, r->y,
                      r->x - dx, r->y - dy,
                      r->width, r->height,
                      False);
     }
     XFreeGC(dpy, gc);
@@ -154,17 +156,19 @@ nsShmImage::Put(GdkWindow* aWindow, cons
 void
 nsShmImage::Put(GdkWindow* aWindow, const nsIntRegion& aRegion)
 {
     Display* dpy = gdk_x11_get_default_xdisplay();
     Drawable d = GDK_WINDOW_XID(aWindow);
     int dx = 0, dy = 0;
 
     GC gc = XCreateGC(dpy, d, 0, nullptr);
-    nsIntRegionRectIterator iter(aRegion);
+    nsIntRegion bounded;
+    bounded.And(aRegion, nsIntRect(0, 0, mImage->width, mImage->height));
+    nsIntRegionRectIterator iter(bounded);
     for (const nsIntRect *r = iter.Next(); r; r = iter.Next()) {
         XShmPutImage(dpy, d, gc, mImage,
                      r->x, r->y,
                      r->x - dx, r->y - dy,
                      r->width, r->height,
                      False);
     }