Bug 598538 - Reset the viewport rect when we create a temporary VBO, which can be bigger than the viewport! r=vlad a=b

This commit is contained in:
Matt Woodrow 2010-09-29 14:36:32 -04:00
parent 80e6919bfc
commit 934603a171
3 changed files with 21 additions and 26 deletions

View File

@ -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);

View File

@ -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

View File

@ -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.
*/