Bug 827170 - Clamp intermediate surface's framebuffer dimensions to what is supported by the GL - r=BenWa, a=bajaj
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 25 Jan 2013 13:40:38 -0500
changeset 127352 24b80b8f4da2d280294e8e9804f88b3fb798a157
parent 127351 96a7615ccad0ea3e5fca91f5c007f134a1c3ea60
child 127353 1678cbabc8db0de84234d0cfcd6315c20f76f1fc
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa, bajaj
bugs827170
milestone20.0a2
Bug 827170 - Clamp intermediate surface's framebuffer dimensions to what is supported by the GL - r=BenWa, a=bajaj Without this, we have assertion failures as we fail to create our textures and subsequently we have incomplete framebuffers. The present patch is a short-term compromise: to avoid asserting, we just clamp texture sizes. That can result in fuzzy rendering. Ideally (with some suitable tiling) we wouldn't have to do that.
gfx/layers/opengl/ContainerLayerOGL.cpp
--- a/gfx/layers/opengl/ContainerLayerOGL.cpp
+++ b/gfx/layers/opengl/ContainerLayerOGL.cpp
@@ -188,18 +188,29 @@ ContainerRender(Container* aContainer,
   nsIntRect cachedScissor = aContainer->gl()->ScissorRect();
   aContainer->gl()->PushScissorRect();
   aContainer->mSupportsComponentAlphaChildren = false;
 
   float opacity = aContainer->GetEffectiveOpacity();
   const gfx3DMatrix& transform = aContainer->GetEffectiveTransform();
   bool needsFramebuffer = aContainer->UseIntermediateSurface();
   if (needsFramebuffer) {
+    nsIntRect framebufferRect = visibleRect;
+    // we're about to create a framebuffer backed by textures to use as an intermediate
+    // surface. What to do if its size (as given by framebufferRect) would exceed the
+    // maximum texture size supported by the GL? The present code chooses the compromise
+    // of just clamping the framebuffer's size to the max supported size.
+    // This gives us a lower resolution rendering of the intermediate surface (children layers).
+    // See bug 827170 for a discussion.
+    GLint maxTexSize;
+    aContainer->gl()->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &maxTexSize);
+    framebufferRect.width = std::min(framebufferRect.width, maxTexSize);
+    framebufferRect.height = std::min(framebufferRect.height, maxTexSize);
+
     LayerManagerOGL::InitMode mode = LayerManagerOGL::InitModeClear;
-    nsIntRect framebufferRect = visibleRect;
     if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 && 
         (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE))
     {
       // don't need a background, we're going to paint all opaque stuff
       aContainer->mSupportsComponentAlphaChildren = true;
       mode = LayerManagerOGL::InitModeNone;
     } else {
       const gfx3DMatrix& transform3D = aContainer->GetEffectiveTransform();