Bug 620799 - Fallback to normal surface allocation if creating a PBO fails. r=joe a=blocking2.0

This commit is contained in:
Matt Woodrow 2011-01-18 10:47:18 +13:00
parent f5f4d25848
commit 9301918144
2 changed files with 19 additions and 7 deletions

View File

@ -461,11 +461,11 @@ BasicBufferOGL::BeginPaint(ContentType aContentType)
// BeginUpdate is allowed to modify the given region,
// if it wants more to be repainted than we request.
result.mContext = mTexImage->BeginUpdate(result.mRegionToDraw);
result.mContext->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
if (!result.mContext) {
NS_WARNING("unable to get context for update");
return result;
}
result.mContext->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
// Move rgnToPaint back into position so that the thebes callback
// gets the right coordintes.
result.mRegionToDraw.MoveBy(-offset);

View File

@ -308,9 +308,12 @@ protected:
GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
{
mGLContext->MakeCurrent();
if (!mGLContext->IsExtensionSupported(GLContext::ARB_pixel_buffer_object)) {
if (!mGLContext->
IsExtensionSupported(GLContext::ARB_pixel_buffer_object))
{
return gfxPlatform::GetPlatform()->
CreateOffscreenSurface(aSize, gfxASurface::ContentFromFormat(aFmt));
CreateOffscreenSurface(aSize,
gfxASurface::ContentFromFormat(aFmt));
}
if (!mPixelBuffer) {
@ -325,22 +328,28 @@ protected:
mPixelBufferSize = size;
}
unsigned char* data =
(unsigned char*)mGLContext->fMapBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, LOCAL_GL_WRITE_ONLY);
(unsigned char*)mGLContext->
fMapBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER,
LOCAL_GL_WRITE_ONLY);
if (!data) {
return nsnull;
mGLContext->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
return gfxPlatform::GetPlatform()->
CreateOffscreenSurface(aSize,
gfxASurface::ContentFromFormat(aFmt));
}
nsRefPtr<gfxQuartzSurface> surf =
new gfxQuartzSurface(data, aSize,
aSize.width * 4, aFmt);
mBoundPixelBuffer = true;
return surf.forget();
}
bool FinishedSurfaceUpdate()
{
if (mPixelBuffer) {
if (mBoundPixelBuffer) {
mGLContext->MakeCurrent();
mGLContext->fUnmapBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER);
return true;
@ -350,9 +359,10 @@ protected:
void FinishedSurfaceUpload()
{
if (mPixelBuffer) {
if (mBoundPixelBuffer) {
mGLContext->MakeCurrent();
mGLContext->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
mBoundPixelBuffer = false;
}
}
@ -365,10 +375,12 @@ private:
: BasicTextureImage(aTexture, aSize, aWrapMode, aContentType, aContext)
, mPixelBuffer(0)
, mPixelBufferSize(0)
, mBoundPixelBuffer(false)
{}
GLuint mPixelBuffer;
PRInt32 mPixelBufferSize;
bool mBoundPixelBuffer;
};
already_AddRefed<TextureImage>