From 5d541fe0e5c552b923cbe0980f06cf8ba73be8bb Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 29 Sep 2010 14:36:32 -0400 Subject: [PATCH] Bug 598538 - Reset the viewport rect when we create a temporary VBO, which can be bigger than the viewport! r=vlad a=b --- gfx/layers/opengl/ContainerLayerOGL.cpp | 11 ++++++++--- gfx/layers/opengl/LayerManagerOGL.cpp | 15 +-------------- gfx/layers/opengl/LayerManagerOGL.h | 21 ++++++++++++--------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/gfx/layers/opengl/ContainerLayerOGL.cpp b/gfx/layers/opengl/ContainerLayerOGL.cpp index e9d2e3f1f18..c4e8eacfd4b 100644 --- a/gfx/layers/opengl/ContainerLayerOGL.cpp +++ b/gfx/layers/opengl/ContainerLayerOGL.cpp @@ -169,9 +169,8 @@ ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer, childOffset.x = visibleRect.x; childOffset.y = visibleRect.y; - // Note that we don't set a new viewport here, even though we're - // about to render to a new FBO -- see the comments in - // LayerManagerOGL::SetupPipeline. + gl()->PushViewportRect(); + mOGLManager->SetupPipeline(visibleRect.width, visibleRect.height); gl()->fScissor(0, 0, visibleRect.width, visibleRect.height); gl()->fClearColor(0.0, 0.0, 0.0, 0.0); @@ -214,6 +213,12 @@ ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer, if (needsFramebuffer) { // Unbind the current framebuffer and rebind the previous one. + + // Restore the viewport + gl()->PopViewportRect(); + nsIntRect viewport = gl()->ViewportRect(); + mOGLManager->SetupPipeline(viewport.width, viewport.height); + gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer); gl()->fDeleteFramebuffers(1, &frameBuffer); diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index 04bd04e0804..ee0a50a4822 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -671,20 +671,7 @@ LayerManagerOGL::Render() void LayerManagerOGL::SetupPipeline(int aWidth, int aHeight) { - // Set the viewport correctly. Note that his viewport is used - // throughout the GL layers rendering pipeline, even when we're - // rendering to a FBO with different dimensions than the window. - // This means that we can set the viewMatrix once on every program - // (below). When we render to a FBO (as in ContainerLayerOGL), we - // have to pass a correct child offset so that the coordinate system - // is translated appropriately to start at the origin of the FBO - // (or, put another way, so that the FBO looks to be at the right - // spot in the parent). - // - // Note: this effectively means that we can't really draw to a FBO - // that is bigger than the window dimensions. This is fine for now, - // but might be a problem if we ever start doing GL drawing to - // retained layer FBOs that happen to retain more than is visible. + // Set the viewport correctly. // // When we're not double buffering, we use a FBO as our backbuffer. // We use a normal view transform in that case, meaning that our FBO diff --git a/gfx/layers/opengl/LayerManagerOGL.h b/gfx/layers/opengl/LayerManagerOGL.h index 165ef94eb12..b352e573068 100644 --- a/gfx/layers/opengl/LayerManagerOGL.h +++ b/gfx/layers/opengl/LayerManagerOGL.h @@ -314,12 +314,18 @@ public: } #ifdef MOZ_LAYERS_HAVE_LOG - virtual const char* Name() const { return "OGL"; } + virtual const char* Name() const { return "OGL"; } #endif // MOZ_LAYERS_HAVE_LOG - const nsIntSize& GetWigetSize() { - return mWidgetSize; - } + const nsIntSize& GetWigetSize() { + return mWidgetSize; + } + + /** + * Setup the viewport and projection matrix for rendering + * to a window of the given dimensions. + */ + void SetupPipeline(int aWidth, int aHeight); private: /** Widget associated with this layer manager */ @@ -382,15 +388,12 @@ private: * Render the current layer tree to the active target. */ void Render(); - /** - * Setup the viewport and projection matrix for rendering - * to a window of the given dimensions. - */ - void SetupPipeline(int aWidth, int aHeight); + /** * Setup a backbuffer of the given dimensions. */ void SetupBackBuffer(int aWidth, int aHeight); + /** * Copies the content of our backbuffer to the set transaction target. */