Bug 572283. Fix CanvasLayerOGL to work with retained layers (and on Mac). r=vlad

This commit is contained in:
Robert O'Callahan 2010-06-18 21:21:42 +12:00
Родитель 8555d326d4
Коммит 2280cd5e00
2 изменённых файлов: 34 добавлений и 23 удалений

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

@ -57,8 +57,9 @@ CanvasLayerOGL::~CanvasLayerOGL()
{
mOGLManager->MakeCurrent();
if (mTexture)
if (mTexture) {
gl()->fDeleteTextures(1, &mTexture);
}
}
void
@ -101,7 +102,8 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
mUpdatedRect.UnionRect(mUpdatedRect, aRect);
if (mCanvasSurface) {
if (mTexture == 0) {
PRBool newTexture = mTexture == 0;
if (newTexture) {
gl()->fGenTextures(1, &mTexture);
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
@ -114,6 +116,7 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
mUpdatedRect = mBounds;
} else {
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
}
@ -154,7 +157,7 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
ctx->Paint();
}
if (mUpdatedRect == mBounds) {
if (newTexture) {
gl()->fTexImage2D(LOCAL_GL_TEXTURE_2D,
0,
LOCAL_GL_RGBA,
@ -189,10 +192,31 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
mUpdatedRect = mBounds;
}
#if defined(XP_MACOSX)
// We only need to do this for the first time we set up the texture
if (newTexture) {
CGLError err;
err = CGLTexImagePBuffer((CGLContextObj) gl()->GetNativeData(GLContext::NativeCGLContext),
(CGLPBufferObj) mCanvasGLContext->GetNativeData(GLContext::NativePBuffer),
LOCAL_GL_BACK);
if (err) {
NS_WARNING("CanvasLayerOGL::Updated CGLTexImagePBuffer failed");
}
}
#elif defined(XP_WIN)
// We need to do this every time before we paint
if (!sWGLLibrary.fBindTexImage((HANDLE) mCanvasGLContext->GetNativeData(GLContext::NativePBuffer),
LOCAL_WGL_FRONT_LEFT_ARB)) {
NS_WARNING("CanvasLayerOGL::Updated wglBindTexImageARB failed");
}
#else
NS_WARNING("CanvasLayerOGL::Updated with GL context, but I don't know how to render on this platform!");
#endif
}
// sanity
NS_ASSERTION(mUpdatedRect.IsEmpty() || mBounds.Contains(mUpdatedRect),
NS_ASSERTION(mBounds.Contains(mUpdatedRect),
"CanvasLayer: Updated rect bigger than bounds!");
}
@ -212,22 +236,6 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
if (mCanvasGLContext) {
#if defined(XP_MACOSX)
CGLError err;
err = CGLTexImagePBuffer((CGLContextObj) mCanvasGLContext->GetNativeData(GLContext::NativeCGLContext),
(CGLPBufferObj) mCanvasGLContext->GetNativeData(GLContext::NativePBuffer),
LOCAL_GL_BACK);
#elif defined(XP_WIN)
if (!sWGLLibrary.fBindTexImage((HANDLE) mCanvasGLContext->GetNativeData(GLContext::NativePBuffer),
LOCAL_WGL_FRONT_LEFT_ARB))
{
NS_WARNING("CanvasLayerOGL::RenderLayer wglBindTexImageARB failed");
return;
}
#else
NS_WARNING("CanvasLayerOGL::RenderLayer with GL context, but I don't know how to render on this platform!");
#endif
program = mOGLManager->GetRGBALayerProgram();
} else {
program = mOGLManager->GetBGRALayerProgram();
@ -242,10 +250,14 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false);
if (mCanvasGLContext) {
#if defined(XP_WIN)
// We need to do this ever time after we paint, before anyone
// draws into the pbuffer again
if (mCanvasGLContext) {
sWGLLibrary.fReleaseTexImage((HANDLE) mCanvasGLContext->GetNativeData(GLContext::NativePBuffer),
LOCAL_WGL_FRONT_LEFT_ARB);
#endif
}
#endif
mUpdatedRect.Empty();
}

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

@ -297,7 +297,6 @@ LayerManagerOGL::SetClippingRegion(const nsIntRegion& aClippingRegion)
void
LayerManagerOGL::BeginTransaction()
{
NS_ASSERTION(mRootLayer, "Root not set");
}
void