diff --git a/gfx/gl/SharedSurfaceEGL.cpp b/gfx/gl/SharedSurfaceEGL.cpp index 8f5b15bfb7ec..4178f81bd957 100644 --- a/gfx/gl/SharedSurfaceEGL.cpp +++ b/gfx/gl/SharedSurfaceEGL.cpp @@ -170,14 +170,18 @@ SharedSurface_EGLImage::Fence() } if (!mPixels) { - gfxImageFormat format = - HasAlpha() ? gfxImageFormatARGB32 - : gfxImageFormatRGB24; - mPixels = new gfxImageSurface(ThebesIntSize(Size()), format); + SurfaceFormat format = + HasAlpha() ? FORMAT_B8G8R8A8 + : FORMAT_B8G8R8X8; + mPixels = Factory::CreateDataSourceSurface(Size(), format); } - mPixels->Flush(); - mGL->ReadScreenIntoImageSurface(mPixels); + nsRefPtr wrappedData = + new gfxImageSurface(mPixels->GetData(), + ThebesIntSize(mPixels->GetSize()), + mPixels->Stride(), + SurfaceFormatToImageFormat(mPixels->GetFormat())); + mGL->ReadScreenIntoImageSurface(wrappedData); mPixels->MarkDirty(); return; } @@ -270,7 +274,7 @@ SharedSurface_EGLImage::AcquireConsumerTexture(GLContext* consGL) return 0; } -gfxImageSurface* +DataSourceSurface* SharedSurface_EGLImage::GetPixels() const { MutexAutoLock lock(mMutex); diff --git a/gfx/gl/SharedSurfaceEGL.h b/gfx/gl/SharedSurfaceEGL.h index 242b0d7add4f..03339f44bb75 100644 --- a/gfx/gl/SharedSurfaceEGL.h +++ b/gfx/gl/SharedSurfaceEGL.h @@ -40,7 +40,7 @@ protected: GLLibraryEGL* const mEGL; const GLFormats mFormats; GLuint mProdTex; - nsRefPtr mPixels; + RefPtr mPixels; GLuint mProdTexForPipe; // Moves to mProdTex when mPipeActive becomes true. EGLImage mImage; GLContext* mCurConsGL; @@ -82,7 +82,7 @@ public: GLuint AcquireConsumerTexture(GLContext* consGL); // Will be void if AcquireConsumerTexture returns non-zero. - gfxImageSurface* GetPixels() const; + gfx::DataSourceSurface* GetPixels() const; }; diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 3801e7b7914f..58c35e52f639 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -483,7 +483,6 @@ StreamTextureSourceOGL::RetrieveTextureFromStream() mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height); - gfxImageSurface* deprecatedToUpload = nullptr; gfx::DataSourceSurface* toUpload = nullptr; switch (sharedSurf->Type()) { case SharedSurfaceType::GLTextureShare: { @@ -503,8 +502,8 @@ StreamTextureSourceOGL::RetrieveTextureFromStream() mTextureHandle = eglImageSurf->AcquireConsumerTexture(gl()); mTextureTarget = eglImageSurf->TextureTarget(); if (!mTextureHandle) { - deprecatedToUpload = eglImageSurf->GetPixels(); - MOZ_ASSERT(deprecatedToUpload); + toUpload = eglImageSurf->GetPixels(); + MOZ_ASSERT(toUpload); } else { mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8 : FORMAT_R8G8B8X8; @@ -531,20 +530,6 @@ StreamTextureSourceOGL::RetrieveTextureFromStream() MOZ_CRASH("Invalid SharedSurface type."); } - if (deprecatedToUpload) { - // FIXME Remove this whole block when deprecatedToUpload gets deleted - // mBounds seems to end up as (0,0,0,0) a lot, so don't use it? - nsIntSize size(deprecatedToUpload->GetSize()); - nsIntRect rect(nsIntPoint(0,0), size); - nsIntRegion bounds(rect); - mFormat = UploadSurfaceToTexture(gl(), - deprecatedToUpload, - bounds, - mUploadTexture, - true); - mTextureHandle = mUploadTexture; - mTextureTarget = LOCAL_GL_TEXTURE_2D; - } if (toUpload) { // mBounds seems to end up as (0,0,0,0) a lot, so don't use it? nsIntSize size(ThebesIntSize(toUpload->GetSize())); @@ -964,7 +949,6 @@ SurfaceStreamHostOGL::Lock() mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height); - gfxImageSurface* deprecatedToUpload = nullptr; DataSourceSurface* toUpload = nullptr; switch (sharedSurf->Type()) { case SharedSurfaceType::GLTextureShare: { @@ -984,8 +968,8 @@ SurfaceStreamHostOGL::Lock() mTextureHandle = eglImageSurf->AcquireConsumerTexture(mGL); mTextureTarget = eglImageSurf->TextureTarget(); if (!mTextureHandle) { - deprecatedToUpload = eglImageSurf->GetPixels(); - MOZ_ASSERT(deprecatedToUpload); + toUpload = eglImageSurf->GetPixels(); + MOZ_ASSERT(toUpload); } else { mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8 : FORMAT_R8G8B8X8; @@ -1012,20 +996,6 @@ SurfaceStreamHostOGL::Lock() MOZ_CRASH("Invalid SharedSurface type."); } - if (deprecatedToUpload) { - // FIXME Remove this whole block when deprecatedToUpload gets deleted - // mBounds seems to end up as (0,0,0,0) a lot, so don't use it? - nsIntSize size(deprecatedToUpload->GetSize()); - nsIntRect rect(nsIntPoint(0,0), size); - nsIntRegion bounds(rect); - mFormat = UploadSurfaceToTexture(mGL, - deprecatedToUpload, - bounds, - mUploadTexture, - true); - mTextureHandle = mUploadTexture; - mTextureTarget = LOCAL_GL_TEXTURE_2D; - } if (toUpload) { // mBounds seems to end up as (0,0,0,0) a lot, so don't use it? nsIntSize size(ThebesIntSize(toUpload->GetSize()));