Bug 709490 - Part 9: Readback without blocking main thread. r=jgilbert
This commit is contained in:
@@ -214,7 +214,7 @@ GetActualReadFormats(GLContext* gl,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
SwapRAndBComponents(DataSourceSurface* surf)
|
||||
{
|
||||
DataSourceSurface::MappedSurface map;
|
||||
@@ -614,8 +614,7 @@ ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, SurfaceFormat aFo
|
||||
|
||||
#define CLEANUP_IF_GLERROR_OCCURRED(x) \
|
||||
if (DidGLErrorOccur(x)) { \
|
||||
isurf = nullptr; \
|
||||
break; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
already_AddRefed<DataSourceSurface>
|
||||
@@ -624,6 +623,31 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
const gfx::IntSize& aSize,
|
||||
/* ShaderConfigOGL.mFeature */ int aConfig,
|
||||
bool aYInvert)
|
||||
{
|
||||
/* Allocate resulting image surface */
|
||||
int32_t stride = aSize.width * BytesPerPixel(SurfaceFormat::R8G8B8A8);
|
||||
RefPtr<DataSourceSurface> isurf =
|
||||
Factory::CreateDataSourceSurfaceWithStride(aSize,
|
||||
SurfaceFormat::R8G8B8A8,
|
||||
stride);
|
||||
if (NS_WARN_IF(!isurf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ReadTexImage(isurf, aTextureId, aTextureTarget, aSize, aConfig, aYInvert)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return isurf.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
GLReadTexImageHelper::ReadTexImage(DataSourceSurface* aDest,
|
||||
GLuint aTextureId,
|
||||
GLenum aTextureTarget,
|
||||
const gfx::IntSize& aSize,
|
||||
/* ShaderConfigOGL.mFeature */ int aConfig,
|
||||
bool aYInvert)
|
||||
{
|
||||
MOZ_ASSERT(aTextureTarget == LOCAL_GL_TEXTURE_2D ||
|
||||
aTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL ||
|
||||
@@ -631,16 +655,6 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
|
||||
mGL->MakeCurrent();
|
||||
|
||||
/* Allocate resulting image surface */
|
||||
int32_t stride = aSize.width * BytesPerPixel(SurfaceFormat::R8G8B8A8);
|
||||
RefPtr<DataSourceSurface> isurf =
|
||||
Factory::CreateDataSourceSurfaceWithStride(aSize,
|
||||
SurfaceFormat::R8G8B8A8,
|
||||
stride);
|
||||
if (NS_WARN_IF(!isurf)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GLint oldrb, oldfb, oldprog, oldTexUnit, oldTex;
|
||||
GLuint rb, fb;
|
||||
|
||||
@@ -737,7 +751,7 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
CLEANUP_IF_GLERROR_OCCURRED("when drawing texture");
|
||||
|
||||
/* Read-back draw results */
|
||||
ReadPixelsIntoDataSurface(mGL, isurf);
|
||||
ReadPixelsIntoDataSurface(mGL, aDest);
|
||||
CLEANUP_IF_GLERROR_OCCURRED("when reading pixels into surface");
|
||||
} while (false);
|
||||
|
||||
@@ -756,7 +770,7 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
|
||||
if (oldTexUnit != LOCAL_GL_TEXTURE0)
|
||||
mGL->fActiveTexture(oldTexUnit);
|
||||
|
||||
return isurf.forget();
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef CLEANUP_IF_GLERROR_OCCURRED
|
||||
|
||||
Reference in New Issue
Block a user