зеркало из https://github.com/mozilla/pjs.git
Bug 604101 - Part 3 - Use UploadSurfaceToTexture in CanvasLayerOGL. r=joe a=blocking2.0
This commit is contained in:
Родитель
f60965ddb0
Коммит
95faf2267a
|
@ -157,84 +157,30 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
|
|||
MakeTexture();
|
||||
}
|
||||
} else {
|
||||
PRBool newTexture = mTexture == 0;
|
||||
if (newTexture) {
|
||||
MakeTexture();
|
||||
if (!mTexture) {
|
||||
mUpdatedRect = mBounds;
|
||||
} else {
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
||||
}
|
||||
|
||||
nsRefPtr<gfxImageSurface> updatedAreaImageSurface;
|
||||
nsRefPtr<gfxASurface> updatedAreaSurface;
|
||||
if (mCanvasSurface) {
|
||||
nsRefPtr<gfxASurface> sourceSurface = mCanvasSurface;
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (sourceSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
|
||||
sourceSurface = sourceSurface->GetAsImageSurface();
|
||||
if (!sourceSurface)
|
||||
sourceSurface = mCanvasSurface;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// XXX don't copy, blah.
|
||||
// but need to deal with stride on the gl side; do this later.
|
||||
if (mCanvasSurface->GetType() == gfxASurface::SurfaceTypeImage) {
|
||||
gfxImageSurface *s = static_cast<gfxImageSurface*>(mCanvasSurface.get());
|
||||
if (s->Format() == gfxASurface::ImageFormatARGB32 ||
|
||||
s->Format() == gfxASurface::ImageFormatRGB24)
|
||||
{
|
||||
updatedAreaImageSurface = ...;
|
||||
} else {
|
||||
NS_WARNING("surface with format that we can't handle");
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
updatedAreaImageSurface =
|
||||
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(updatedAreaImageSurface);
|
||||
ctx->Translate(gfxPoint(-mUpdatedRect.x, -mUpdatedRect.y));
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx->SetSource(sourceSurface);
|
||||
ctx->Paint();
|
||||
}
|
||||
updatedAreaSurface = mCanvasSurface;
|
||||
} else if (mCanvasGLContext) {
|
||||
updatedAreaImageSurface =
|
||||
nsRefPtr<gfxImageSurface> updatedAreaImageSurface =
|
||||
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
mCanvasGLContext->ReadPixelsIntoImageSurface(mUpdatedRect.x, mUpdatedRect.y,
|
||||
mUpdatedRect.width,
|
||||
mUpdatedRect.height,
|
||||
updatedAreaImageSurface);
|
||||
updatedAreaSurface = updatedAreaImageSurface;
|
||||
}
|
||||
|
||||
if (newTexture) {
|
||||
|
||||
gl()->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
LOCAL_GL_RGBA,
|
||||
mUpdatedRect.width,
|
||||
mUpdatedRect.height,
|
||||
0,
|
||||
LOCAL_GL_RGBA,
|
||||
LOCAL_GL_UNSIGNED_BYTE,
|
||||
updatedAreaImageSurface->Data());
|
||||
} else {
|
||||
gl()->fTexSubImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
mUpdatedRect.x,
|
||||
mUpdatedRect.y,
|
||||
mUpdatedRect.width,
|
||||
mUpdatedRect.height,
|
||||
LOCAL_GL_RGBA,
|
||||
LOCAL_GL_UNSIGNED_BYTE,
|
||||
updatedAreaImageSurface->Data());
|
||||
}
|
||||
mLayerProgram =
|
||||
gl()->UploadSurfaceToTexture(updatedAreaSurface,
|
||||
mUpdatedRect,
|
||||
mTexture,
|
||||
false,
|
||||
mUpdatedRect.TopLeft());
|
||||
}
|
||||
|
||||
// sanity
|
||||
|
@ -252,14 +198,14 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
|
|||
// mGLBufferIsPremultiplied is TRUE or not. The RGBLayerProgram
|
||||
// assumes that it's true.
|
||||
|
||||
ColorTextureLayerProgram *program = nsnull;
|
||||
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
|
||||
if (mTexture) {
|
||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
||||
}
|
||||
|
||||
ColorTextureLayerProgram *program = nsnull;
|
||||
|
||||
bool useGLContext = mCanvasGLContext &&
|
||||
mCanvasGLContext->GetContextType() == gl()->GetContextType();
|
||||
|
||||
|
@ -272,33 +218,21 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
|
|||
gl()->MakeCurrent();
|
||||
gl()->BindTex2DOffscreen(mCanvasGLContext);
|
||||
DEBUG_GL_ERROR_CHECK(gl());
|
||||
program = mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(), PR_TRUE);
|
||||
} else if (mDelayedUpdates) {
|
||||
NS_ABORT_IF_FALSE(mCanvasSurface, "WebGL canvases should always be using full texture upload");
|
||||
|
||||
drawRect.IntersectRect(drawRect, GetEffectiveVisibleRegion().GetBounds());
|
||||
|
||||
nsRefPtr<gfxImageSurface> imageSurface =
|
||||
new gfxImageSurface(gfxIntSize(drawRect.width, drawRect.height),
|
||||
gfxASurface::ImageFormatARGB32);
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(imageSurface);
|
||||
ctx->Translate(gfxPoint(-drawRect.x, -drawRect.y));
|
||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
ctx->SetSource(mCanvasSurface);
|
||||
ctx->Paint();
|
||||
|
||||
gl()->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
LOCAL_GL_RGBA,
|
||||
drawRect.width,
|
||||
drawRect.height,
|
||||
0,
|
||||
LOCAL_GL_RGBA,
|
||||
LOCAL_GL_UNSIGNED_BYTE,
|
||||
imageSurface->Data());
|
||||
mLayerProgram =
|
||||
gl()->UploadSurfaceToTexture(mCanvasSurface,
|
||||
drawRect,
|
||||
mTexture,
|
||||
true);
|
||||
}
|
||||
if (!program) {
|
||||
program = mOGLManager->GetColorTextureLayerProgram(mLayerProgram);
|
||||
}
|
||||
program =
|
||||
mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(),
|
||||
useGLContext != 0);
|
||||
|
||||
ApplyFilter(mFilter);
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
protected:
|
||||
nsRefPtr<gfxASurface> mCanvasSurface;
|
||||
nsRefPtr<GLContext> mCanvasGLContext;
|
||||
gl::ShaderProgramType mLayerProgram;
|
||||
|
||||
void MakeTexture();
|
||||
GLuint mTexture;
|
||||
|
|
Загрузка…
Ссылка в новой задаче