Bug 593342 - Use double buffering on Mac instead of flushing, for greater performance. r=vlad,roc,joe a=b

This commit is contained in:
Markus Stange ext:(%2C%20Joe%20Drew%20%3Cjoe%40drew.ca%3E%2C%20Matt%20Woodrow%20%3Cmwoodrow%40mozilla.com%3E) 2010-09-21 14:39:38 -04:00
Родитель 3f0755e7bd
Коммит 5030fab5c1
4 изменённых файлов: 48 добавлений и 20 удалений

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

@ -174,13 +174,20 @@ ContainerRender(Container* aContainer,
if (needsFramebuffer) {
scissorRect.MoveBy(- visibleRect.TopLeft());
}
} else {
if (!aPreviousFrameBuffer) {
/**
* glScissor coordinates are oriented with 0,0 being at the bottom left,
* the opposite to layout (0,0 at the top left).
* All rendering to an FBO is upside-down, making the coordinate systems
* match.
* When rendering directly to a window (No current or previous FBO),
* we need to flip the scissor rect.
*/
aContainer->gl()->FixWindowCoordinateRect(scissorRect,
aManager->GetWigetSize().height);
}
if (!needsFramebuffer && aPreviousFrameBuffer) {
scissorRect.IntersectRect(scissorRect, cachedScissor);
} else if (!needsFramebuffer) {
aContainer->gl()->FixWindowCoordinateRect(scissorRect,
aManager->GetWigetSize().height);
scissorRect.IntersectRect(scissorRect, cachedScissor);
}
@ -242,7 +249,7 @@ ContainerRender(Container* aContainer,
DEBUG_GL_ERROR_CHECK(aContainer->gl());
aManager->BindAndDrawQuad(rgb);
aManager->BindAndDrawQuad(rgb, aPreviousFrameBuffer == 0);
DEBUG_GL_ERROR_CHECK(aContainer->gl());

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

@ -579,7 +579,7 @@ LayerManagerOGL::Render()
if (clipRect) {
nsIntRect r = *clipRect;
if (!mGLContext->IsDoubleBuffered())
if (!mGLContext->IsDoubleBuffered() && !mTarget)
mGLContext->FixWindowCoordinateRect(r, mWidgetSize.height);
mGLContext->fScissor(r.x, r.y, r.width, r.height);
} else {
@ -594,7 +594,7 @@ LayerManagerOGL::Render()
mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT);
// Render our layers.
RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO,
RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() && !mTarget ? 0 : mBackBufferFBO,
nsIntPoint(0, 0));
DEBUG_GL_ERROR_CHECK(mGLContext);
@ -718,7 +718,7 @@ LayerManagerOGL::SetupPipeline(int aWidth, int aHeight)
// XXX we keep track of whether the window size changed, so we can
// skip this update if it hadn't since the last call.
gfx3DMatrix viewMatrix;
if (mGLContext->IsDoubleBuffered()) {
if (mGLContext->IsDoubleBuffered() && !mTarget) {
/* If it's double buffered, we don't have a frontbuffer FBO,
* so put in a Y-flip in this transform.
*/
@ -739,7 +739,7 @@ LayerManagerOGL::SetupPipeline(int aWidth, int aHeight)
void
LayerManagerOGL::SetupBackBuffer(int aWidth, int aHeight)
{
if (mGLContext->IsDoubleBuffered()) {
if (mGLContext->IsDoubleBuffered() && !mTarget) {
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
return;
}
@ -796,13 +796,12 @@ LayerManagerOGL::CopyToTarget()
new gfxImageSurface(gfxIntSize(width, height),
gfxASurface::ImageFormatARGB32);
#ifdef USE_GLES2
// GLES2 promises that binding to any custom FBO will attach
// to GL_COLOR_ATTACHMENT0 attachment point.
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO);
#else
mGLContext->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
mBackBufferFBO);
#ifndef USE_GLES2
// GLES2 promises that binding to any custom FBO will attach
// to GL_COLOR_ATTACHMENT0 attachment point.
mGLContext->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
#endif
GLenum format = LOCAL_GL_RGBA;
@ -818,6 +817,8 @@ LayerManagerOGL::CopyToTarget()
mGLContext->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, 4);
}
mGLContext->fFinish();
mGLContext->fReadPixels(0, 0,
width, height,
format,

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

@ -44,10 +44,13 @@
#include "gfxImageSurface.h"
#include "gfxQuartzSurface.h"
#include "gfxPlatform.h"
#include "prenv.h"
namespace mozilla {
namespace gl {
static PRBool gUseDoubleBufferedWindows = PR_TRUE;
class CGLLibrary
{
public:
@ -69,7 +72,10 @@ public:
return PR_FALSE;
}
}
const char* db = PR_GetEnv("MOZ_CGL_DB");
gUseDoubleBufferedWindows = (!db || *db != '0');
mInitialized = PR_TRUE;
return PR_TRUE;
}
@ -79,9 +85,14 @@ public:
if (mPixelFormat == nsnull) {
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
(NSOpenGLPixelFormatAttribute)nil
};
if (!gUseDoubleBufferedWindows) {
attribs[1] = (NSOpenGLPixelFormatAttribute)nil;
}
mPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
}
@ -165,6 +176,17 @@ public:
return PR_FALSE;
}
PRBool IsDoubleBuffered()
{
return gUseDoubleBufferedWindows;
}
PRBool SwapBuffers()
{
[mContext flushBuffer];
return PR_TRUE;
}
PRBool BindTex2DOffscreen(GLContext *aOffscreen);
void UnbindTex2DOffscreen(GLContext *aOffscreen);
PRBool ResizeOffscreen(const gfxIntSize& aNewSize);

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

@ -2727,9 +2727,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
mGLContext = (NSOpenGLContext *)manager->gl()->GetNativeData(mozilla::gl::GLContext::NativeGLContext);
[mGLContext retain];
}
[mGLContext makeCurrentContext];
mGeckoChild->DispatchWindowEvent(paintEvent);
[mGLContext flushBuffer];
return;
}