Bug 640082 - Part 2 - Use texture_from_pixmap in CanvasLayerOGL. r=joe

This commit is contained in:
Matt Woodrow 2011-03-09 10:41:10 +13:00
Родитель ce2fc8c5d5
Коммит 30b3523f5d
2 изменённых файлов: 47 добавлений и 0 удалений

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

@ -65,6 +65,12 @@ 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;
}
@ -82,9 +88,22 @@ CanvasLayerOGL::Initialize(const Data& aData)
return;
}
mOGLManager->MakeCurrent();
if (aData.mSurface) {
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;
}
MakeTexture();
}
#endif
} else if (aData.mGLContext) {
if (!aData.mGLContext->IsOffscreen()) {
NS_WARNING("CanvasLayerOGL with a non-offscreen GL context given");
@ -143,6 +162,12 @@ CanvasLayerOGL::UpdateSurface()
return;
}
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
if (mPixmap) {
return;
}
#endif
mOGLManager->MakeCurrent();
if (mCanvasGLContext &&
@ -226,6 +251,12 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
program = mOGLManager->GetColorTextureLayerProgram(mLayerProgram);
}
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
if (mPixmap && !mDelayedUpdates) {
sGLXLibrary.BindTexImage(mPixmap);
}
#endif
ApplyFilter(mFilter);
program->Activate();
@ -237,6 +268,12 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false);
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
if (mPixmap && !mDelayedUpdates) {
sGLXLibrary.ReleaseTexImage(mPixmap);
}
#endif
if (useGLContext) {
gl()->UnbindTex2DOffscreen(mCanvasGLContext);
}

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

@ -43,6 +43,10 @@
#include "LayerManagerOGL.h"
#include "gfxASurface.h"
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
#include "GLXLibrary.h"
#include "mozilla/X11Util.h"
#endif
namespace mozilla {
namespace layers {
@ -57,6 +61,9 @@ public:
LayerOGL(aManager),
mTexture(0),
mDelayedUpdates(PR_FALSE)
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
,mPixmap(0)
#endif
{
mImplData = static_cast<LayerOGL*>(this);
}
@ -84,6 +91,9 @@ protected:
PRPackedBool mDelayedUpdates;
PRPackedBool mGLBufferIsPremultiplied;
PRPackedBool mNeedsYFlip;
#if defined(MOZ_WIDGET_GTK2) && !defined(MOZ_PLATFORM_MAEMO)
GLXPixmap mPixmap;
#endif
};
// NB: eventually we'll have separate shadow canvas2d and shadow