b=583838; add ANGLE/D3D WebGL support - part 4 - allow CanvasLayerOGL to work with different-type GL contexts; r=bas

This commit is contained in:
Vladimir Vukicevic 2010-08-06 22:09:18 -07:00
parent 9636d54ad1
commit 51835ef8a6

View File

@ -132,13 +132,15 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
mUpdatedRect.UnionRect(mUpdatedRect, aRect);
if (mCanvasGLContext) {
if (mCanvasGLContext &&
mCanvasGLContext->GetContextType() == gl()->GetContextType())
{
if (gl()->BindOffscreenNeedsTexture(mCanvasGLContext) &&
mTexture == 0)
{
MakeTexture();
}
} else if (mCanvasSurface) {
} else {
PRBool newTexture = mTexture == 0;
if (newTexture) {
MakeTexture();
@ -149,6 +151,7 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
}
nsRefPtr<gfxImageSurface> updatedAreaImageSurface;
if (mCanvasSurface) {
nsRefPtr<gfxASurface> sourceSurface = mCanvasSurface;
#ifdef XP_WIN
@ -184,6 +187,15 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
ctx->SetSource(sourceSurface);
ctx->Paint();
}
} else if (mCanvasGLContext) {
updatedAreaImageSurface =
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
gfxASurface::ImageFormatARGB32);
mCanvasGLContext->ReadPixelsIntoImageSurface(mUpdatedRect.x, mUpdatedRect.y,
mUpdatedRect.width,
mUpdatedRect.height,
updatedAreaImageSurface);
}
if (newTexture) {
gl()->fTexImage2D(LOCAL_GL_TEXTURE_2D,
@ -231,12 +243,12 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
}
if (mCanvasGLContext) {
bool useGLContext = mCanvasGLContext &&
mCanvasGLContext->GetContextType() == gl()->GetContextType();
if (useGLContext) {
gl()->BindTex2DOffscreen(mCanvasGLContext);
DEBUG_GL_ERROR_CHECK(gl());
}
if (mCanvasGLContext) {
program = mOGLManager->GetRGBALayerProgram();
} else {
program = mOGLManager->GetBGRALayerProgram();
@ -253,7 +265,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
DEBUG_GL_ERROR_CHECK(gl());
if (mCanvasGLContext) {
if (useGLContext) {
gl()->UnbindTex2DOffscreen(mCanvasGLContext);
}