зеркало из https://github.com/mozilla/pjs.git
Bug 655017 - Let gfxXlibSurface track GLXPixmaps and use this for CanvasLayerOGL. r=karlt, roc
This commit is contained in:
Родитель
c635ef3627
Коммит
f3b63676a0
|
@ -72,12 +72,6 @@ CanvasLayerOGL::Destroy()
|
||||||
cx->MakeCurrent();
|
cx->MakeCurrent();
|
||||||
cx->fDeleteTextures(1, &mTexture);
|
cx->fDeleteTextures(1, &mTexture);
|
||||||
}
|
}
|
||||||
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
|
||||||
if (mPixmap) {
|
|
||||||
sGLXLibrary.DestroyPixmap(mPixmap);
|
|
||||||
mPixmap = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mDestroyed = PR_TRUE;
|
mDestroyed = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +95,9 @@ CanvasLayerOGL::Initialize(const Data& aData)
|
||||||
mCanvasSurface = aData.mSurface;
|
mCanvasSurface = aData.mSurface;
|
||||||
mNeedsYFlip = PR_FALSE;
|
mNeedsYFlip = PR_FALSE;
|
||||||
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
|
||||||
mPixmap = sGLXLibrary.CreatePixmap(aData.mSurface);
|
if (aData.mSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
|
||||||
|
gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(aData.mSurface);
|
||||||
|
mPixmap = xsurf->GetGLXPixmap();
|
||||||
if (mPixmap) {
|
if (mPixmap) {
|
||||||
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
|
if (aData.mSurface->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
|
||||||
mLayerProgram = gl::RGBALayerProgramType;
|
mLayerProgram = gl::RGBALayerProgramType;
|
||||||
|
@ -110,6 +106,7 @@ CanvasLayerOGL::Initialize(const Data& aData)
|
||||||
}
|
}
|
||||||
MakeTexture();
|
MakeTexture();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (aData.mGLContext) {
|
} else if (aData.mGLContext) {
|
||||||
if (!aData.mGLContext->IsOffscreen()) {
|
if (!aData.mGLContext->IsOffscreen()) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ using namespace mozilla;
|
||||||
#define XLIB_IMAGE_SIDE_SIZE_LIMIT 0x7fff
|
#define XLIB_IMAGE_SIDE_SIZE_LIMIT 0x7fff
|
||||||
|
|
||||||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
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();
|
DoSizeQuery();
|
||||||
cairo_surface_t *surf = cairo_xlib_surface_create(dpy, drawable, visual, mSize.width, mSize.height);
|
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)
|
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),
|
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||||
"Bad size");
|
"Bad size");
|
||||||
|
@ -76,7 +76,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual,
|
||||||
gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFormat *format,
|
gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFormat *format,
|
||||||
const gfxIntSize& size)
|
const gfxIntSize& size)
|
||||||
: mPixmapTaken(PR_FALSE), mDisplay(DisplayOfScreen(screen)),
|
: 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),
|
NS_ASSERTION(CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||||
"Bad Size");
|
"Bad Size");
|
||||||
|
@ -91,7 +91,8 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
|
||||||
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
||||||
: mPixmapTaken(PR_FALSE),
|
: mPixmapTaken(PR_FALSE),
|
||||||
mSize(cairo_xlib_surface_get_width(csurf),
|
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,
|
NS_PRECONDITION(cairo_surface_status(csurf) == 0,
|
||||||
"Not expecting an error surface");
|
"Not expecting an error surface");
|
||||||
|
@ -104,6 +105,9 @@ gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
||||||
|
|
||||||
gfxXlibSurface::~gfxXlibSurface()
|
gfxXlibSurface::~gfxXlibSurface()
|
||||||
{
|
{
|
||||||
|
if (mGLXPixmap) {
|
||||||
|
gl::sGLXLibrary.DestroyPixmap(mGLXPixmap);
|
||||||
|
}
|
||||||
// gfxASurface's destructor calls RecordMemoryFreed().
|
// gfxASurface's destructor calls RecordMemoryFreed().
|
||||||
if (mPixmapTaken) {
|
if (mPixmapTaken) {
|
||||||
XFreePixmap (mDisplay, mDrawable);
|
XFreePixmap (mDisplay, mDrawable);
|
||||||
|
@ -523,6 +527,16 @@ gfxXlibSurface::XRenderFormat()
|
||||||
return cairo_xlib_surface_get_xrender_format(CairoSurface());
|
return cairo_xlib_surface_get_xrender_format(CairoSurface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLXPixmap
|
||||||
|
gfxXlibSurface::GetGLXPixmap()
|
||||||
|
{
|
||||||
|
if (!mGLXPixmap) {
|
||||||
|
mGLXPixmap = gl::sGLXLibrary.CreatePixmap(this);
|
||||||
|
}
|
||||||
|
return mGLXPixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gfxASurface::MemoryLocation
|
gfxASurface::MemoryLocation
|
||||||
gfxXlibSurface::GetMemoryLocation() const
|
gfxXlibSurface::GetMemoryLocation() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
#include <X11/extensions/Xrender.h>
|
#include <X11/extensions/Xrender.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include "GLXLibrary.h"
|
||||||
|
|
||||||
class THEBES_API gfxXlibSurface : public gfxASurface {
|
class THEBES_API gfxXlibSurface : public gfxASurface {
|
||||||
public:
|
public:
|
||||||
// construct a wrapper around the specified drawable with dpy/visual.
|
// construct a wrapper around the specified drawable with dpy/visual.
|
||||||
|
@ -104,6 +106,8 @@ public:
|
||||||
// server, not the main application.
|
// server, not the main application.
|
||||||
virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
|
virtual gfxASurface::MemoryLocation GetMemoryLocation() const;
|
||||||
|
|
||||||
|
GLXPixmap GetGLXPixmap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// if TakePixmap() has been called on this
|
// if TakePixmap() has been called on this
|
||||||
PRBool mPixmapTaken;
|
PRBool mPixmapTaken;
|
||||||
|
@ -114,6 +118,8 @@ protected:
|
||||||
void DoSizeQuery();
|
void DoSizeQuery();
|
||||||
|
|
||||||
gfxIntSize mSize;
|
gfxIntSize mSize;
|
||||||
|
|
||||||
|
GLXPixmap mGLXPixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* GFX_XLIBSURFACE_H */
|
#endif /* GFX_XLIBSURFACE_H */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче