Bug 655017 - Let gfxXlibSurface track GLXPixmaps and use this for CanvasLayerOGL. r=karlt, roc

This commit is contained in:
Matt Woodrow 2011-08-05 13:13:25 +12:00
Родитель c635ef3627
Коммит f3b63676a0
3 изменённых файлов: 34 добавлений и 17 удалений

Просмотреть файл

@ -72,12 +72,6 @@ CanvasLayerOGL::Destroy()
cx->MakeCurrent();
cx->fDeleteTextures(1, &mTexture);
}
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
if (mPixmap) {
sGLXLibrary.DestroyPixmap(mPixmap);
mPixmap = 0;
}
#endif
mDestroyed = PR_TRUE;
}
@ -101,14 +95,17 @@ CanvasLayerOGL::Initialize(const Data& aData)
mCanvasSurface = aData.mSurface;
mNeedsYFlip = PR_FALSE;
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
mPixmap = sGLXLibrary.CreatePixmap(aData.mSurface);
if (mPixmap) {
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
mLayerProgram = gl::RGBALayerProgramType;
} else {
mLayerProgram = gl::RGBXLayerProgramType;
if (aData.mSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(aData.mSurface);
mPixmap = xsurf->GetGLXPixmap();
if (mPixmap) {
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
mLayerProgram = gl::RGBALayerProgramType;
} else {
mLayerProgram = gl::RGBXLayerProgramType;
}
MakeTexture();
}
MakeTexture();
}
#endif
} else if (aData.mGLContext) {

Просмотреть файл

@ -56,7 +56,7 @@ using namespace mozilla;
#define XLIB_IMAGE_SIDE_SIZE_LIMIT 0x7fff
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable)
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mGLXPixmap(None)
{
DoSizeQuery();
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, mSize.width, mSize.height);
@ -64,7 +64,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
}
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfxIntSize& size)
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mSize(size)
: mPixmapTaken(PR_FALSE), mDisplay(dpy), mDrawable(drawable), mSize(size), mGLXPixmap(None)
{
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad size");
@ -76,7 +76,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual,
gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFormat *format,
const gfxIntSize& size)
: mPixmapTaken(PR_FALSE), mDisplay(DisplayOfScreen(screen)),
mDrawable(drawable), mSize(size)
mDrawable(drawable), mSize(size), mGLXPixmap(None)
{
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
"Bad Size");
@ -91,7 +91,8 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
: mPixmapTaken(PR_FALSE),
mSize(cairo_xlib_surface_get_width(csurf),
cairo_xlib_surface_get_height(csurf))
cairo_xlib_surface_get_height(csurf)),
mGLXPixmap(None)
{
NS_PRECONDITION(cairo_surface_status(csurf) == 0,
"Not expecting an error surface");
@ -104,6 +105,9 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
gfxXlibSurface::~gfxXlibSurface()
{
if (mGLXPixmap) {
gl::sGLXLibrary.DestroyPixmap(mGLXPixmap);
}
// gfxASurface's destructor calls RecordMemoryFreed().
if (mPixmapTaken) {
XFreePixmap (mDisplay, mDrawable);
@ -523,6 +527,16 @@ gfxXlibSurface::XRenderFormat()
return cairo_xlib_surface_get_xrender_format(CairoSurface());
}
GLXPixmap
gfxXlibSurface::GetGLXPixmap()
{
if (!mGLXPixmap) {
mGLXPixmap = gl::sGLXLibrary.CreatePixmap(this);
}
return mGLXPixmap;
}
gfxASurface::MemoryLocation
gfxXlibSurface::GetMemoryLocation() const
{

Просмотреть файл

@ -44,6 +44,8 @@
#include <X11/extensions/Xrender.h>
#include <X11/Xlib.h>
#include "GLXLibrary.h"
class THEBES_API gfxXlibSurface : public gfxASurface {
public:
// construct a wrapper around the specified drawable with dpy/visual.
@ -104,6 +106,8 @@ public:
// server, not the main application.
virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
GLXPixmap GetGLXPixmap();
protected:
// if TakePixmap() has been called on this
PRBool mPixmapTaken;
@ -114,6 +118,8 @@ protected:
void DoSizeQuery();
gfxIntSize mSize;
GLXPixmap mGLXPixmap;
};
#endif /* GFX_XLIBSURFACE_H */