Bug 864287 - Add back code to readback IOSurface plugins when using BasicLayers. r=BenWa

This commit is contained in:
Matt Woodrow 2013-05-01 17:03:27 +12:00
parent c727739057
commit f7d12ccdaa
7 changed files with 60 additions and 1 deletions

View File

@ -464,6 +464,31 @@ GLContextProviderCGL::CreateSharedHandle(GLContext::SharedTextureShareType share
return (SharedTextureHandle)surf;
}
already_AddRefed<gfxASurface>
GLContextProviderCGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
MacIOSurface* surf = reinterpret_cast<MacIOSurface*>(sharedHandle);
surf->Lock();
size_t bytesPerRow = surf->GetBytesPerRow();
size_t ioWidth = surf->GetWidth();
size_t ioHeight = surf->GetHeight();
unsigned char* ioData = (unsigned char*)surf->GetBaseAddress();
nsRefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxASurface::ImageFormatARGB32);
for (size_t i = 0; i < ioHeight; i++) {
memcpy(imgSurface->Data() + i * imgSurface->Stride(),
ioData + i * bytesPerRow, ioWidth * 4);
}
surf->Unlock();
return imgSurface.forget();
}
void
GLContextProviderCGL::Shutdown()
{

View File

@ -2019,6 +2019,13 @@ GLContextProviderEGL::CreateSharedHandle(GLContext::SharedTextureShareType share
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderEGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;
}
// Don't want a global context on Android as 1) share groups across 2 threads fail on many Tegra drivers (bug 759225)
// and 2) some mobile devices have a very strict limit on global number of GL contexts (bug 754257)
// and 3) each EGL context eats 750k on B2G (bug 813783)

View File

@ -1424,6 +1424,13 @@ GLContextProviderGLX::CreateSharedHandle(GLContext::SharedTextureShareType share
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderGLX::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;
}
static nsRefPtr<GLContext> gGlobalContext[GLXLibrary::LIBS_MAX];
// TODO move that out of static initializaion
static bool gUseContextSharing = getenv("MOZ_DISABLE_CONTEXT_SHARING_GLX") == 0;

View File

@ -79,6 +79,9 @@ public:
void* buffer,
GLContext::SharedTextureBufferType bufferType);
static already_AddRefed<gfxASurface> GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle);
/**
* Free any resources held by this Context Provider.
*/

View File

@ -30,6 +30,13 @@ GLContextProviderNull::CreateSharedHandle(GLContext::SharedTextureShareType shar
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderNull::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;
}
GLContext*
GLContextProviderNull::GetGlobalContext(ContextFlags)
{

View File

@ -695,6 +695,13 @@ GLContextProviderWGL::CreateSharedHandle(GLContext::SharedTextureShareType share
return 0;
}
already_AddRefed<gfxASurface>
GLContextProviderWGL::GetSharedHandleAsSurface(GLContext::SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
return nullptr;
}
static nsRefPtr<GLContextWGL> gGlobalContext[WGLLibrary::LIBS_MAX];
GLContext *

View File

@ -8,6 +8,7 @@
#include "ImageContainer.h"
#include "GLContext.h"
#include "GLContextProvider.h"
// Split into a separate header from ImageLayers.h due to GLContext.h dependence
// Implementation remains in ImageLayers.cpp
@ -30,7 +31,9 @@ public:
gfxIntSize GetSize() { return mData.mSize; }
virtual already_AddRefed<gfxASurface> GetAsSurface() { return NULL; }
virtual already_AddRefed<gfxASurface> GetAsSurface() {
return gl::GLContextProvider::GetSharedHandleAsSurface(mData.mShareType, mData.mHandle);
}
SharedTextureImage() : Image(NULL, SHARED_TEXTURE) {}