Bug 877115 - [Moz2Dify] Part 6. Moz2Dify SharedSurface_EGLImage::GetPixels. r=nical

This commit is contained in:
Andreas Pehrson 2013-12-16 15:50:53 -05:00
Родитель 96f82c49cb
Коммит 2d0ad0d42d
3 изменённых файлов: 17 добавлений и 43 удалений

Просмотреть файл

@ -170,14 +170,18 @@ SharedSurface_EGLImage::Fence()
} }
if (!mPixels) { if (!mPixels) {
gfxImageFormat format = SurfaceFormat format =
HasAlpha() ? gfxImageFormatARGB32 HasAlpha() ? FORMAT_B8G8R8A8
: gfxImageFormatRGB24; : FORMAT_B8G8R8X8;
mPixels = new gfxImageSurface(ThebesIntSize(Size()), format); mPixels = Factory::CreateDataSourceSurface(Size(), format);
} }
mPixels->Flush(); nsRefPtr<gfxImageSurface> wrappedData =
mGL->ReadScreenIntoImageSurface(mPixels); new gfxImageSurface(mPixels->GetData(),
ThebesIntSize(mPixels->GetSize()),
mPixels->Stride(),
SurfaceFormatToImageFormat(mPixels->GetFormat()));
mGL->ReadScreenIntoImageSurface(wrappedData);
mPixels->MarkDirty(); mPixels->MarkDirty();
return; return;
} }
@ -270,7 +274,7 @@ SharedSurface_EGLImage::AcquireConsumerTexture(GLContext* consGL)
return 0; return 0;
} }
gfxImageSurface* DataSourceSurface*
SharedSurface_EGLImage::GetPixels() const SharedSurface_EGLImage::GetPixels() const
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);

Просмотреть файл

@ -40,7 +40,7 @@ protected:
GLLibraryEGL* const mEGL; GLLibraryEGL* const mEGL;
const GLFormats mFormats; const GLFormats mFormats;
GLuint mProdTex; GLuint mProdTex;
nsRefPtr<gfxImageSurface> mPixels; RefPtr<gfx::DataSourceSurface> mPixels;
GLuint mProdTexForPipe; // Moves to mProdTex when mPipeActive becomes true. GLuint mProdTexForPipe; // Moves to mProdTex when mPipeActive becomes true.
EGLImage mImage; EGLImage mImage;
GLContext* mCurConsGL; GLContext* mCurConsGL;
@ -82,7 +82,7 @@ public:
GLuint AcquireConsumerTexture(GLContext* consGL); GLuint AcquireConsumerTexture(GLContext* consGL);
// Will be void if AcquireConsumerTexture returns non-zero. // Will be void if AcquireConsumerTexture returns non-zero.
gfxImageSurface* GetPixels() const; gfx::DataSourceSurface* GetPixels() const;
}; };

Просмотреть файл

@ -483,7 +483,6 @@ StreamTextureSourceOGL::RetrieveTextureFromStream()
mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height); mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
gfxImageSurface* deprecatedToUpload = nullptr;
gfx::DataSourceSurface* toUpload = nullptr; gfx::DataSourceSurface* toUpload = nullptr;
switch (sharedSurf->Type()) { switch (sharedSurf->Type()) {
case SharedSurfaceType::GLTextureShare: { case SharedSurfaceType::GLTextureShare: {
@ -503,8 +502,8 @@ StreamTextureSourceOGL::RetrieveTextureFromStream()
mTextureHandle = eglImageSurf->AcquireConsumerTexture(gl()); mTextureHandle = eglImageSurf->AcquireConsumerTexture(gl());
mTextureTarget = eglImageSurf->TextureTarget(); mTextureTarget = eglImageSurf->TextureTarget();
if (!mTextureHandle) { if (!mTextureHandle) {
deprecatedToUpload = eglImageSurf->GetPixels(); toUpload = eglImageSurf->GetPixels();
MOZ_ASSERT(deprecatedToUpload); MOZ_ASSERT(toUpload);
} else { } else {
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8 mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8; : FORMAT_R8G8B8X8;
@ -531,20 +530,6 @@ StreamTextureSourceOGL::RetrieveTextureFromStream()
MOZ_CRASH("Invalid SharedSurface type."); 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) { if (toUpload) {
// mBounds seems to end up as (0,0,0,0) a lot, so don't use it? // mBounds seems to end up as (0,0,0,0) a lot, so don't use it?
nsIntSize size(ThebesIntSize(toUpload->GetSize())); nsIntSize size(ThebesIntSize(toUpload->GetSize()));
@ -964,7 +949,6 @@ SurfaceStreamHostOGL::Lock()
mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height); mSize = IntSize(sharedSurf->Size().width, sharedSurf->Size().height);
gfxImageSurface* deprecatedToUpload = nullptr;
DataSourceSurface* toUpload = nullptr; DataSourceSurface* toUpload = nullptr;
switch (sharedSurf->Type()) { switch (sharedSurf->Type()) {
case SharedSurfaceType::GLTextureShare: { case SharedSurfaceType::GLTextureShare: {
@ -984,8 +968,8 @@ SurfaceStreamHostOGL::Lock()
mTextureHandle = eglImageSurf->AcquireConsumerTexture(mGL); mTextureHandle = eglImageSurf->AcquireConsumerTexture(mGL);
mTextureTarget = eglImageSurf->TextureTarget(); mTextureTarget = eglImageSurf->TextureTarget();
if (!mTextureHandle) { if (!mTextureHandle) {
deprecatedToUpload = eglImageSurf->GetPixels(); toUpload = eglImageSurf->GetPixels();
MOZ_ASSERT(deprecatedToUpload); MOZ_ASSERT(toUpload);
} else { } else {
mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8 mFormat = sharedSurf->HasAlpha() ? FORMAT_R8G8B8A8
: FORMAT_R8G8B8X8; : FORMAT_R8G8B8X8;
@ -1012,20 +996,6 @@ SurfaceStreamHostOGL::Lock()
MOZ_CRASH("Invalid SharedSurface type."); 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) { if (toUpload) {
// mBounds seems to end up as (0,0,0,0) a lot, so don't use it? // mBounds seems to end up as (0,0,0,0) a lot, so don't use it?
nsIntSize size(ThebesIntSize(toUpload->GetSize())); nsIntSize size(ThebesIntSize(toUpload->GetSize()));