зеркало из https://github.com/mozilla/gecko-dev.git
b=574158 free Pixmaps from the destructor to handle error cairo surfaces r=jrmuizel
This commit is contained in:
Родитель
a593aed844
Коммит
cc62298b1d
|
@ -80,10 +80,13 @@ public:
|
|||
|
||||
// take ownership of a passed-in Pixmap, calling XFreePixmap on it
|
||||
// when the gfxXlibSurface is destroyed.
|
||||
void TakePixmap();
|
||||
void TakePixmap() {
|
||||
NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!");
|
||||
mPixmapTaken = PR_TRUE;
|
||||
}
|
||||
|
||||
protected:
|
||||
// if TakePixmap() was already called on this
|
||||
// if TakePixmap() has been called on this
|
||||
PRBool mPixmapTaken;
|
||||
|
||||
Display *mDisplay;
|
||||
|
|
|
@ -42,15 +42,6 @@
|
|||
#include "cairo-xlib.h"
|
||||
#include "cairo-xlib-xrender.h"
|
||||
|
||||
static cairo_user_data_key_t pixmap_free_key;
|
||||
|
||||
typedef struct {
|
||||
Display* dpy;
|
||||
Pixmap pixmap;
|
||||
} pixmap_free_struct;
|
||||
|
||||
static void pixmap_free_func (void *);
|
||||
|
||||
// Although the dimension parameters in the xCreatePixmapReq wire protocol are
|
||||
// 16-bit unsigned integers, the server's CreatePixmap returns BadAlloc if
|
||||
// either dimension cannot be represented by a 16-bit *signed* integer.
|
||||
|
@ -133,6 +124,9 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
|||
|
||||
gfxXlibSurface::~gfxXlibSurface()
|
||||
{
|
||||
if (mPixmapTaken) {
|
||||
XFreePixmap (mDisplay, mDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -197,31 +191,3 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
|
|||
|
||||
return (XRenderPictFormat*)NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gfxXlibSurface::TakePixmap()
|
||||
{
|
||||
if (mPixmapTaken)
|
||||
return;
|
||||
|
||||
pixmap_free_struct *pfs = new pixmap_free_struct;
|
||||
pfs->dpy = mDisplay;
|
||||
pfs->pixmap = mDrawable;
|
||||
|
||||
cairo_surface_set_user_data (CairoSurface(),
|
||||
&pixmap_free_key,
|
||||
pfs,
|
||||
pixmap_free_func);
|
||||
|
||||
mPixmapTaken = PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
pixmap_free_func (void *data)
|
||||
{
|
||||
pixmap_free_struct *pfs = (pixmap_free_struct*) data;
|
||||
|
||||
XFreePixmap (pfs->dpy, pfs->pixmap);
|
||||
|
||||
delete pfs;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче