b=797568 destroy GLXPixmap on Finish r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 31 Oct 2012 15:54:20 +1300
changeset 111997 541b971b847b323dfdd8b3995c5945dd296d68be
parent 111996 2886e8e67bfdb76c617ae4ecf62c8ed7ad80fa7d
child 111998 1ba88bd2f4407ccb49f73efce360714b5e36ff64
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersroc
bugs797568
milestone19.0a1
b=797568 destroy GLXPixmap on Finish r=roc
gfx/thebes/gfxXlibSurface.cpp
gfx/thebes/gfxXlibSurface.h
--- a/gfx/thebes/gfxXlibSurface.cpp
+++ b/gfx/thebes/gfxXlibSurface.cpp
@@ -210,16 +210,28 @@ gfxXlibSurface::CreateSimilarSurface(gfx
             }
         }
     }
 
     return gfxASurface::CreateSimilarSurface(aContent, aSize);
 }
 
 void
+gfxXlibSurface::Finish()
+{
+#if !defined(MOZ_PLATFORM_MAEMO)
+    if (mGLXPixmap) {
+        gl::sDefGLXLib.DestroyPixmap(mGLXPixmap);
+        mGLXPixmap = None;
+    }
+#endif
+    gfxASurface::Finish();
+}
+
+void
 gfxXlibSurface::DoSizeQuery()
 {
     // figure out width/height/depth
     Window root_ignore;
     int x_ignore, y_ignore;
     unsigned int bwidth_ignore, width, height, depth;
 
     XGetGeometry(mDisplay,
@@ -506,16 +518,24 @@ gfxXlibSurface::XRenderFormat()
     return cairo_xlib_surface_get_xrender_format(CairoSurface());
 }
 
 #if !defined(MOZ_PLATFORM_MAEMO)
 GLXPixmap
 gfxXlibSurface::GetGLXPixmap()
 {
     if (!mGLXPixmap) {
+#ifdef DEBUG
+        // cairo_surface_has_show_text_glyphs is used solely for the
+        // side-effect of setting the error on surface if
+        // cairo_surface_finish() has been called.
+        cairo_surface_has_show_text_glyphs(CairoSurface());
+        NS_ASSERTION(CairoStatus() != CAIRO_STATUS_SURFACE_FINISHED,
+            "GetGLXPixmap called after surface finished");
+#endif
         mGLXPixmap = gl::sDefGLXLib.CreatePixmap(this);
     }
     return mGLXPixmap;
 }
 #endif
 
 gfxASurface::MemoryLocation
 gfxXlibSurface::GetMemoryLocation() const
--- a/gfx/thebes/gfxXlibSurface.h
+++ b/gfx/thebes/gfxXlibSurface.h
@@ -42,16 +42,17 @@ public:
     static already_AddRefed<gfxXlibSurface>
     Create(Screen* screen, XRenderPictFormat *format, const gfxIntSize& size,
            Drawable relatedDrawable = None);
 
     virtual ~gfxXlibSurface();
 
     virtual already_AddRefed<gfxASurface>
     CreateSimilarSurface(gfxContentType aType, const gfxIntSize& aSize);
+    virtual void Finish() MOZ_OVERRIDE;
 
     virtual const gfxIntSize GetSize() const { return mSize; }
 
     Display* XDisplay() { return mDisplay; }
     Screen* XScreen();
     Drawable XDrawable() { return mDrawable; }
     XRenderPictFormat* XRenderFormat();