From 2a54bb27d404f950644276b55ef58b7c2c2db033 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 29 Apr 2014 00:26:54 +0100 Subject: [PATCH] Bug 1001683 - Convert a bunch of ReadPixelsIntoImageSurface callers to ReadPixelsIntoDataSurface callers (Moz2D migration). r=mattwoodrow --- gfx/gl/GLReadTexImageHelper.cpp | 4 +-- gfx/gl/GLReadTexImageHelper.h | 2 ++ gfx/gl/GLScreenBuffer.cpp | 51 ++++++++++------------------- gfx/gl/GLScreenBuffer.h | 1 - gfx/gl/SharedSurfaceGL.cpp | 12 +------ gfx/layers/opengl/CompositorOGL.cpp | 11 +------ 6 files changed, 24 insertions(+), 57 deletions(-) diff --git a/gfx/gl/GLReadTexImageHelper.cpp b/gfx/gl/GLReadTexImageHelper.cpp index d6efc0231eba..3b5873e0456b 100644 --- a/gfx/gl/GLReadTexImageHelper.cpp +++ b/gfx/gl/GLReadTexImageHelper.cpp @@ -507,7 +507,7 @@ ReadPixelsIntoImageSurface(GLContext* gl, gfxImageSurface* dest) { } void -ReadPixelsIntoDataSourceSurface(GLContext* gl, DataSourceSurface* dest) { +ReadPixelsIntoDataSurface(GLContext* gl, DataSourceSurface* dest) { gl->MakeCurrent(); MOZ_ASSERT(dest->GetSize().width != 0); MOZ_ASSERT(dest->GetSize().height != 0); @@ -838,7 +838,7 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId, mGL->fDisableVertexAttribArray(0); /* Read-back draw results */ - ReadPixelsIntoDataSourceSurface(mGL, isurf); + ReadPixelsIntoDataSurface(mGL, isurf); CLEANUP_IF_GLERROR_OCCURRED("when reading pixels into surface"); } while (false); diff --git a/gfx/gl/GLReadTexImageHelper.h b/gfx/gl/GLReadTexImageHelper.h index d1b209ab1066..29d0017a9c13 100644 --- a/gfx/gl/GLReadTexImageHelper.h +++ b/gfx/gl/GLReadTexImageHelper.h @@ -24,6 +24,8 @@ class DataSourceSurface; namespace gl { +void ReadPixelsIntoDataSurface(GLContext* aGL, + gfx::DataSourceSurface* aSurface); void ReadPixelsIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface); void ReadScreenIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface); diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index 432bdbccc908..7704e9212a9b 100755 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -482,45 +482,30 @@ void GLScreenBuffer::Readback(SharedSurface_GL* src, DataSourceSurface* dest) { MOZ_ASSERT(src && dest); - DataSourceSurface::MappedSurface ms; - dest->Map(DataSourceSurface::MapType::READ, &ms); - nsRefPtr wrappedDest = - new gfxImageSurface(ms.mData, - ThebesIntSize(dest->GetSize()), - ms.mStride, - SurfaceFormatToImageFormat(dest->GetFormat())); - DeprecatedReadback(src, wrappedDest); - dest->Unmap(); -} + MOZ_ASSERT(dest->GetSize() == src->Size()); + MOZ_ASSERT(dest->GetFormat() == (src->HasAlpha() ? SurfaceFormat::B8G8R8A8 + : SurfaceFormat::B8G8R8X8)); -void -GLScreenBuffer::DeprecatedReadback(SharedSurface_GL* src, gfxImageSurface* dest) -{ - MOZ_ASSERT(src && dest); - MOZ_ASSERT(ToIntSize(dest->GetSize()) == src->Size()); - MOZ_ASSERT(dest->Format() == (src->HasAlpha() ? gfxImageFormat::ARGB32 - : gfxImageFormat::RGB24)); + mGL->MakeCurrent(); - mGL->MakeCurrent(); + bool needsSwap = src != SharedSurf(); + if (needsSwap) { + SharedSurf()->UnlockProd(); + src->LockProd(); + } - bool needsSwap = src != SharedSurf(); - if (needsSwap) { - SharedSurf()->UnlockProd(); - src->LockProd(); - } + ReadBuffer* buffer = CreateRead(src); + MOZ_ASSERT(buffer); - ReadBuffer* buffer = CreateRead(src); - MOZ_ASSERT(buffer); + ScopedBindFramebuffer autoFB(mGL, buffer->FB()); + ReadPixelsIntoDataSurface(mGL, dest); - ScopedBindFramebuffer autoFB(mGL, buffer->FB()); - ReadPixelsIntoImageSurface(mGL, dest); + delete buffer; - delete buffer; - - if (needsSwap) { - src->UnlockProd(); - SharedSurf()->LockProd(); - } + if (needsSwap) { + src->UnlockProd(); + SharedSurf()->LockProd(); + } } DrawBuffer* diff --git a/gfx/gl/GLScreenBuffer.h b/gfx/gl/GLScreenBuffer.h index d899eba5f18d..6324000c1aa7 100644 --- a/gfx/gl/GLScreenBuffer.h +++ b/gfx/gl/GLScreenBuffer.h @@ -280,7 +280,6 @@ public: bool Resize(const gfx::IntSize& size); void Readback(SharedSurface_GL* src, gfx::DataSourceSurface* dest); - void DeprecatedReadback(SharedSurface_GL* src, gfxImageSurface* dest); protected: void Attach(SharedSurface* surface, const gfx::IntSize& size); diff --git a/gfx/gl/SharedSurfaceGL.cpp b/gfx/gl/SharedSurfaceGL.cpp index 1aab56f26a2c..b701b1275e0a 100644 --- a/gfx/gl/SharedSurfaceGL.cpp +++ b/gfx/gl/SharedSurfaceGL.cpp @@ -322,18 +322,8 @@ void SharedSurface_Basic::Fence() { mGL->MakeCurrent(); - ScopedBindFramebuffer autoFB(mGL, mFB); - - DataSourceSurface::MappedSurface map; - mData->Map(DataSourceSurface::MapType::WRITE, &map); - nsRefPtr wrappedData = - new gfxImageSurface(map.mData, - ThebesIntSize(mData->GetSize()), - map.mStride, - SurfaceFormatToImageFormat(mData->GetFormat())); - ReadPixelsIntoImageSurface(mGL, wrappedData); - mData->Unmap(); + ReadPixelsIntoDataSurface(mGL, mData); } diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index e7fec971212f..c3f157a6f7e0 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -1328,16 +1328,7 @@ CompositorOGL::CopyToTarget(DrawTarget *aTarget, const gfx::Matrix& aTransform) RefPtr source = Factory::CreateDataSourceSurface(rect.Size(), gfx::SurfaceFormat::B8G8R8A8); - DataSourceSurface::MappedSurface map; - source->Map(DataSourceSurface::MapType::WRITE, &map); - // XXX we should do this properly one day without using the gfxImageSurface - nsRefPtr surf = - new gfxImageSurface(map.mData, - gfxIntSize(width, height), - map.mStride, - gfxImageFormat::ARGB32); - ReadPixelsIntoImageSurface(mGLContext, surf); - source->Unmap(); + ReadPixelsIntoDataSurface(mGLContext, source); // Map from GL space to Cairo space and reverse the world transform. Matrix glToCairoTransform = aTransform;