Bug 575521 - Use gfxASurface::GetAsImageSurface in TextureImageCGL to make it faster. r=jrmuizel

This commit is contained in:
Joe Drew 2010-11-11 15:31:23 -05:00
Родитель f266d548cc
Коммит ac3ba026a4
2 изменённых файлов: 29 добавлений и 9 удалений

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

@ -564,6 +564,13 @@ BasicTextureImage::EndUpdate()
return PR_FALSE;
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
// The images that come out of the cairo quartz surface are 16-byte aligned
// for performance. We know this is an RGBA surface, so we divide the
// stride by 4 to represent the number of elements long the row is.
mGLContext->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH,
uploadImage->Stride() / 4);
if (!mTextureInited)
{
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
@ -588,6 +595,10 @@ BasicTextureImage::EndUpdate()
uploadImage->Data());
}
mUpdateContext = NULL;
// Reset row length to use the default.
mGLContext->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
return PR_TRUE; // mTexture is bound
}

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

@ -42,6 +42,7 @@
#include <AppKit/NSOpenGL.h>
#include "gfxASurface.h"
#include "gfxImageSurface.h"
#include "gfxQuartzSurface.h"
#include "gfxPlatform.h"
namespace mozilla {
@ -281,16 +282,24 @@ protected:
virtual already_AddRefed<gfxImageSurface>
GetImageForUpload(gfxASurface* aUpdateSurface)
{
// FIXME/bug 575521: make me fast!
nsRefPtr<gfxImageSurface> image =
new gfxImageSurface(gfxIntSize(mUpdateRect.width,
mUpdateRect.height),
mUpdateFormat);
nsRefPtr<gfxContext> tmpContext = new gfxContext(image);
nsRefPtr<gfxImageSurface> image = aUpdateSurface->GetAsImageSurface();
tmpContext->SetSource(aUpdateSurface);
tmpContext->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpContext->Paint();
if (image && image->Format() != mUpdateFormat) {
image = nsnull;
}
// If we don't get an image directly from the quartz surface, we have
// to take the slow boat.
if (!image) {
image = new gfxImageSurface(gfxIntSize(mUpdateRect.width,
mUpdateRect.height),
mUpdateFormat);
nsRefPtr<gfxContext> tmpContext = new gfxContext(image);
tmpContext->SetSource(aUpdateSurface);
tmpContext->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpContext->Paint();
}
return image.forget();
}