зеркало из 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;
|
return PR_FALSE;
|
||||||
|
|
||||||
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
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)
|
if (!mTextureInited)
|
||||||
{
|
{
|
||||||
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||||
|
@ -588,6 +595,10 @@ BasicTextureImage::EndUpdate()
|
||||||
uploadImage->Data());
|
uploadImage->Data());
|
||||||
}
|
}
|
||||||
mUpdateContext = NULL;
|
mUpdateContext = NULL;
|
||||||
|
|
||||||
|
// Reset row length to use the default.
|
||||||
|
mGLContext->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
|
||||||
return PR_TRUE; // mTexture is bound
|
return PR_TRUE; // mTexture is bound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <AppKit/NSOpenGL.h>
|
#include <AppKit/NSOpenGL.h>
|
||||||
#include "gfxASurface.h"
|
#include "gfxASurface.h"
|
||||||
#include "gfxImageSurface.h"
|
#include "gfxImageSurface.h"
|
||||||
|
#include "gfxQuartzSurface.h"
|
||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
@ -281,16 +282,24 @@ protected:
|
||||||
virtual already_AddRefed<gfxImageSurface>
|
virtual already_AddRefed<gfxImageSurface>
|
||||||
GetImageForUpload(gfxASurface* aUpdateSurface)
|
GetImageForUpload(gfxASurface* aUpdateSurface)
|
||||||
{
|
{
|
||||||
// FIXME/bug 575521: make me fast!
|
nsRefPtr<gfxImageSurface> image = aUpdateSurface->GetAsImageSurface();
|
||||||
nsRefPtr<gfxImageSurface> image =
|
|
||||||
new gfxImageSurface(gfxIntSize(mUpdateRect.width,
|
|
||||||
mUpdateRect.height),
|
|
||||||
mUpdateFormat);
|
|
||||||
nsRefPtr<gfxContext> tmpContext = new gfxContext(image);
|
|
||||||
|
|
||||||
tmpContext->SetSource(aUpdateSurface);
|
if (image && image->Format() != mUpdateFormat) {
|
||||||
tmpContext->SetOperator(gfxContext::OPERATOR_SOURCE);
|
image = nsnull;
|
||||||
tmpContext->Paint();
|
}
|
||||||
|
|
||||||
|
// 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();
|
return image.forget();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче