From c07e3281ea3350495b84f36153cd8706ab9b2198 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Sun, 27 Jun 2010 20:05:00 +1200 Subject: [PATCH] b=573319 no longer use GdkPixmaps in offscreen-surfaces as they were unusable without a GdkColormap r=jrmuizel --- gfx/thebes/src/gfxPlatformGtk.cpp | 34 +++++-------------------------- gfx/thebes/src/gfxXlibSurface.cpp | 3 +++ 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/gfx/thebes/src/gfxPlatformGtk.cpp b/gfx/thebes/src/gfxPlatformGtk.cpp index 834da3232f9..ca7d28aed5d 100644 --- a/gfx/thebes/src/gfxPlatformGtk.cpp +++ b/gfx/thebes/src/gfxPlatformGtk.cpp @@ -164,12 +164,6 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size, gfxASurface::gfxImageFormat imageFormat) { nsRefPtr newSurface = nsnull; - PRBool sizeOk = PR_TRUE; - - if (size.width >= GDK_PIXMAP_SIZE_MAX || - size.height >= GDK_PIXMAP_SIZE_MAX) - sizeOk = PR_FALSE; - #ifdef MOZ_X11 // XXX we really need a different interface here, something that passes // in more context, including the display and/or target surface type that @@ -178,7 +172,6 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size, if (!display) return nsnull; - GdkPixmap* pixmap = nsnull; // try to optimize it for 16bpp default screen if (gfxASurface::ImageFormatRGB24 == imageFormat && 16 == gdk_visual_get_system()->depth) @@ -187,37 +180,20 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size, XRenderPictFormat* xrenderFormat = gfxXlibSurface::FindRenderFormat(display, imageFormat); - if (xrenderFormat && sizeOk) { - pixmap = gdk_pixmap_new(nsnull, size.width, size.height, - xrenderFormat->depth); - - if (pixmap) { - gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap), nsnull); - newSurface = new gfxXlibSurface(display, - GDK_PIXMAP_XID(GDK_DRAWABLE(pixmap)), - xrenderFormat, - size); - } - - if (newSurface && newSurface->CairoStatus() == 0) { - // set up the surface to auto-unref the gdk pixmap when - // the surface is released - SetGdkDrawable(newSurface, GDK_DRAWABLE(pixmap)); - } else { + if (xrenderFormat) { + newSurface = new gfxXlibSurface(display, xrenderFormat, size); + if (newSurface && newSurface->CairoStatus() != 0) { // something went wrong with the surface creation. // Ignore and let's fall back to image surfaces. newSurface = nsnull; } - - // always unref; SetGdkDrawable takes its own ref - if (pixmap) - g_object_unref(pixmap); } #endif #ifdef MOZ_DFB - if (sizeOk) + if (size.width < GDK_PIXMAP_SIZE_MAX && size.height < GDK_PIXMAP_SIZE_MAX) { newSurface = new gfxDirectFBSurface(size, imageFormat); + } #endif diff --git a/gfx/thebes/src/gfxXlibSurface.cpp b/gfx/thebes/src/gfxXlibSurface.cpp index c19bbc9b8db..1eaae38d1b1 100644 --- a/gfx/thebes/src/gfxXlibSurface.cpp +++ b/gfx/thebes/src/gfxXlibSurface.cpp @@ -99,6 +99,9 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, XRenderPictForma gfxXlibSurface::gfxXlibSurface(Display *dpy, XRenderPictFormat *format, const gfxIntSize& size) : mPixmapTaken(PR_FALSE), mDisplay(dpy), mSize(size) { + if (!CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT)) + return; + mDrawable = (Drawable)XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), mSize.width, mSize.height,