Bug 713774 - Fix crasher when changing orientation on Android r=blassey

This commit is contained in:
James Willcox 2012-01-04 21:53:09 -05:00
parent 462e0daa64
commit c8a8b06b4c
4 changed files with 14 additions and 12 deletions

View File

@ -126,6 +126,9 @@ AndroidDirectTexture::Reallocate(PRUint32 aWidth, PRUint32 aHeight, gfxASurface:
bool result = mBackBuffer->Reallocate(aWidth, aHeight, aFormat);
if (result) {
mPendingReallocBuffer = mFrontBuffer;
mWidth = aWidth;
mHeight = aHeight;
}
return result;

View File

@ -303,11 +303,11 @@ AndroidGraphicBuffer::DestroyBuffer()
}
bool
AndroidGraphicBuffer::EnsureBufferCreated(PRUint32 aWidth, PRUint32 aHeight, PRUint32 aUsage, gfxImageFormat aFormat)
AndroidGraphicBuffer::EnsureBufferCreated()
{
if (!mHandle) {
mHandle = malloc(GRAPHIC_BUFFER_SIZE);
sGLFunctions.fGraphicBufferCtor(mHandle, mWidth, mHeight, GetAndroidFormat(aFormat), GetAndroidUsage(aUsage));
sGLFunctions.fGraphicBufferCtor(mHandle, mWidth, mHeight, GetAndroidFormat(mFormat), GetAndroidUsage(mUsage));
}
return true;
@ -320,7 +320,7 @@ AndroidGraphicBuffer::EnsureInitialized()
return false;
}
EnsureBufferCreated(mWidth, mHeight, mUsage, mFormat);
EnsureBufferCreated();
return true;
}
@ -363,19 +363,19 @@ AndroidGraphicBuffer::Reallocate(PRUint32 aWidth, PRUint32 aHeight, gfxImageForm
if (!EnsureInitialized())
return false;
mWidth = aWidth;
mHeight = aHeight;
mFormat = aFormat;
// Sometimes GraphicBuffer::reallocate just doesn't work. In those cases we'll just allocate a brand
// new buffer. If reallocate fails once, never try it again.
if (!gTryRealloc || sGLFunctions.fGraphicBufferReallocate(mHandle, aWidth, aHeight, GetAndroidFormat(aFormat)) != 0) {
DestroyBuffer();
EnsureBufferCreated(aWidth, aHeight, mUsage, aFormat);
EnsureBufferCreated();
gTryRealloc = false;
}
mWidth = aWidth;
mHeight = aHeight;
mFormat = aFormat;
return true;
}

View File

@ -86,7 +86,7 @@ private:
bool EnsureEGLImage();
void DestroyBuffer();
bool EnsureBufferCreated(PRUint32 aWidth, PRUint32 aHeight, PRUint32 aUsage, gfxASurface::gfxImageFormat aFormat);
bool EnsureBufferCreated();
PRUint32 GetAndroidUsage(PRUint32 aUsage);
PRUint32 GetAndroidFormat(gfxASurface::gfxImageFormat aFormat);

View File

@ -1191,9 +1191,8 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
nsAutoString metadata;
unsigned char *bits = NULL;
if (sHasDirectTexture) {
if ((sDirectTexture->Width() != gAndroidBounds.width ||
sDirectTexture->Height() != gAndroidBounds.height) &&
gAndroidBounds.width != 0 && gAndroidBounds.height != 0) {
if (sDirectTexture->Width() != gAndroidBounds.width ||
sDirectTexture->Height() != gAndroidBounds.height) {
sDirectTexture->Reallocate(gAndroidBounds.width, gAndroidBounds.height);
}