Bug 1006198 - Use Moz2D for WebGL snapshot readback. r=jgilbert

This commit is contained in:
Matt Woodrow 2014-05-13 14:20:26 +12:00
parent dbc26acf88
commit 3f0708c419

View File

@ -1337,10 +1337,10 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
if (!gl) if (!gl)
return nullptr; return nullptr;
nsRefPtr<gfxImageSurface> surf = new gfxImageSurface(gfxIntSize(mWidth, mHeight), RefPtr<DataSourceSurface> surf = Factory::CreateDataSourceSurfaceWithStride(IntSize(mWidth, mHeight),
gfxImageFormat::ARGB32, SurfaceFormat::B8G8R8A8,
mWidth * 4, 0, false); mWidth * 4);
if (surf->CairoStatus() != 0) { if (!surf) {
return nullptr; return nullptr;
} }
@ -1348,7 +1348,7 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
{ {
ScopedBindFramebuffer autoFB(gl, 0); ScopedBindFramebuffer autoFB(gl, 0);
ClearBackbufferIfNeeded(); ClearBackbufferIfNeeded();
ReadPixelsIntoImageSurface(gl, surf); ReadPixelsIntoDataSurface(gl, surf);
} }
if (aPremultAlpha) { if (aPremultAlpha) {
@ -1359,8 +1359,7 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
if (aPremultAlpha) { if (aPremultAlpha) {
*aPremultAlpha = false; *aPremultAlpha = false;
} else { } else {
gfxUtils::PremultiplyImageSurface(surf); gfxUtils::PremultiplyDataSurface(surf);
surf->MarkDirty();
} }
} }
@ -1373,14 +1372,12 @@ WebGLContext::GetSurfaceSnapshot(bool* aPremultAlpha)
return nullptr; return nullptr;
} }
RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, surf);
Matrix m; Matrix m;
m.Translate(0.0, mHeight); m.Translate(0.0, mHeight);
m.Scale(1.0, -1.0); m.Scale(1.0, -1.0);
dt->SetTransform(m); dt->SetTransform(m);
dt->DrawSurface(source, dt->DrawSurface(surf,
Rect(0, 0, mWidth, mHeight), Rect(0, 0, mWidth, mHeight),
Rect(0, 0, mWidth, mHeight), Rect(0, 0, mWidth, mHeight),
DrawSurfaceOptions(), DrawSurfaceOptions(),