зеркало из https://github.com/mozilla/gecko-dev.git
Bug 575521 - Use gfxASurface::GetAsImageSurface in TextureImageCGL to make it faster. r=jrmuizel
This commit is contained in:
Родитель
f266d548cc
Коммит
ac3ba026a4
|
@ -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();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче