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
Родитель 462e0daa64
Коммит c8a8b06b4c
4 изменённых файлов: 14 добавлений и 12 удалений

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

@ -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;

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

@ -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;
}

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

@ -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);

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

@ -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);
}