Bug 632781 - Scroll non-accelerated canvases correctly with the content; r=matt,joe,roc a=blocking-betaN
☠☠ backed out by 9ed6bef2a9ac ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 14 Feb 2011 18:23:50 -0500
changeset 62559 f3d13890fbe34902c093950ca80a20e61e2a5f7c
parent 62558 2e288f06c6482a49933d6c33ad200d60407d93b8
child 62560 acb1475311a2edc5f71b24ddc7aba82af8270bf5
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersmatt, joe, roc, blocking-betaN
bugs632781
milestone2.0b12pre
Bug 632781 - Scroll non-accelerated canvases correctly with the content; r=matt,joe,roc a=blocking-betaN
gfx/layers/opengl/CanvasLayerOGL.cpp
layout/reftests/bugs/632781-normalsize.html
layout/reftests/bugs/632781-ref.html
layout/reftests/bugs/632781-verybig.html
layout/reftests/bugs/reftest.list
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -221,19 +221,20 @@ CanvasLayerOGL::RenderLayer(int aPreviou
     program = mOGLManager->GetBasicLayerProgram(CanUseOpaqueSurface(), PR_TRUE);
   } else if (mDelayedUpdates) {
     NS_ABORT_IF_FALSE(mCanvasSurface, "WebGL canvases should always be using full texture upload");
     
     drawRect.IntersectRect(drawRect, GetEffectiveVisibleRegion().GetBounds());
 
     mLayerProgram =
       gl()->UploadSurfaceToTexture(mCanvasSurface,
-                                   drawRect,
+                                   nsIntRect(0, 0, drawRect.width, drawRect.height),
                                    mTexture,
-                                   true);
+                                   true,
+                                   drawRect.TopLeft());
   }
   if (!program) { 
     program = mOGLManager->GetColorTextureLayerProgram(mLayerProgram);
   }
 
   ApplyFilter(mFilter);
 
   program->Activate();
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/632781-normalsize.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <!--
+      This test makes sure that scrolling a normal sized canvas would correctly
+      scroll its contents.  Normal sized canvases are accelerated, so this test
+      makes sure that the accelerated code path for this operaton works correctly.
+
+      The padding in this test is added mostly to make sure that scrollLeft/Top
+      correctly skip the padding.
+    -->
+    <div id="container" style="width: 100px; height: 100px; padding: 10px; overflow: hidden">
+      <canvas width="300" height="300" id="c"></canvas>
+    </div>
+    <script>
+      var ctx = document.getElementById("c").getContext("2d");
+      ctx.fillStyle = "red";
+      ctx.fillRect(0, 0, 300, 100);
+      ctx.fillStyle = "green";
+      ctx.fillRect(0, 100, 300, 200);
+      var container = document.getElementById("container");
+      container.scrollLeft = 10;
+      container.scrollTop = 110;
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/632781-ref.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <div style="width: 120px; height: 120px; overflow: hidden">
+      <canvas width="120" height="120" id="c"></canvas>
+    </div>
+    <script>
+      var ctx = document.getElementById("c").getContext("2d");
+      ctx.fillStyle = "green";
+      ctx.fillRect(0, 0, 120, 120);
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/632781-verybig.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <!--
+      This test makes sure that scrolling a huge canvas would correctly scroll
+      its contents.  We don't accelerate extremely large canvases because of
+      GPU maximum texture size limits, so this test makes sure that the
+      non-accelerated code path for this operation works correctly.
+
+      The padding in this test is added mostly to make sure that scrollLeft/Top
+      correctly skip the padding.
+    -->
+    <div id="container" style="width: 100px; height: 100px; padding: 10px; overflow: hidden">
+      <canvas width="10000" height="10000" id="c"></canvas>
+    </div>
+    <script>
+      var ctx = document.getElementById("c").getContext("2d");
+      ctx.fillStyle = "red";
+      ctx.fillRect(0, 0, 10000, 5000);
+      ctx.fillStyle = "green";
+      ctx.fillRect(0, 5000, 10000, 5000);
+      var container = document.getElementById("container");
+      container.scrollLeft = 10;
+      container.scrollTop = 5010;
+    </script>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1606,8 +1606,10 @@ HTTP(..) == 621253-1-externalFilter.html
 HTTP(..) == 621253-2-externalFilter.html 621253-2-ref.html
 == 621253-2-internalFilter.html 621253-2-ref.html
 HTTP(..) == 619511-1.html 619511-1-ref.html
 random-if(winWidget) == 621918-1.svg 621918-1-ref.svg # 1-pixel diacritic positioning discrepancy in rotated text (may depend on platform fonts)
 random-if(winWidget) HTTP(..) == 621918-2.svg 621918-2-ref.svg # same 1px issue as above, and HTTP(..) for filters.svg, used to mask antialiasing issues where glyphs touch
 == 625409-1.html 625409-1-ref.html
 == 627393-1.html about:blank
 == 631352-1.html 631352-1-ref.html
+== 632781-verybig.html 632781-ref.html
+== 632781-normalsize.html 632781-ref.html