Title: [101592] trunk
Revision
101592
Author
[email protected]
Date
2011-11-30 19:25:46 -0800 (Wed, 30 Nov 2011)

Log Message

Alter an early return that was preventing HTMLCanvasElement::didDraw notifications
from being triggered when accelerated compositing was enabled. The notification is
necessary to make sure that any cached state is cleared in the HTMLCanvasElement object.
To prevent performance regressions, the cached state is explicitly cleared, as the didDraw
machinery is not necessary for accelerated canvases.
https://bugs.webkit.org/show_bug.cgi?id=73257

Patch by Jeff Timanus <[email protected]> on 2011-11-30
Reviewed by Stephen White.

Source/WebCore:

Test: fast/canvas/webgl/canvas-2d-webgl-texture.html

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::didDraw):
(WebCore::HTMLCanvasElement::setSurfaceSize):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::didDraw):

LayoutTests:

* fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt: Added.
* fast/canvas/webgl/canvas-2d-webgl-texture.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101591 => 101592)


--- trunk/LayoutTests/ChangeLog	2011-12-01 03:23:05 UTC (rev 101591)
+++ trunk/LayoutTests/ChangeLog	2011-12-01 03:25:46 UTC (rev 101592)
@@ -1,3 +1,17 @@
+2011-11-30  Jeff Timanus  <[email protected]>
+
+        Alter an early return that was preventing HTMLCanvasElement::didDraw notifications
+        from being triggered when accelerated compositing was enabled. The notification is
+        necessary to make sure that any cached state is cleared in the HTMLCanvasElement object.
+        To prevent performance regressions, the cached state is explicitly cleared, as the didDraw
+        machinery is not necessary for accelerated canvases.
+        https://bugs.webkit.org/show_bug.cgi?id=73257
+
+        Reviewed by Stephen White.
+
+        * fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt: Added.
+        * fast/canvas/webgl/canvas-2d-webgl-texture.html: Added.
+
 2011-11-30  Kentaro Hara  <[email protected]>
 
         Implement the StorageEvent constructor

Added: trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt (0 => 101592)


--- trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture-expected.txt	2011-12-01 03:25:46 UTC (rev 101592)
@@ -0,0 +1,11 @@
+Checks that copying canvas results to a WebGL texture functions without error.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS Should have rendered red.
+PASS Should have rendered blue.
+ 

Added: trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture.html (0 => 101592)


--- trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture.html	2011-12-01 03:25:46 UTC (rev 101592)
@@ -0,0 +1,77 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src="" </script>
+</head>
+<script>
+description("Checks that copying canvas results to a WebGL texture functions without error.");
+
+var wtu = WebGLTestUtils;
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var canvas;
+var gl;
+var ctx;
+
+function draw()
+{
+  ctx.fillStyle = "rgb(200, 0, 0)";
+  ctx.fillRect(0, 0, 256, 256);
+  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+
+  wtu.drawQuad(gl);
+  wtu.checkCanvasRect(gl, 0, 0, 1, 1, [200, 0, 0, 255], "Should have rendered red.", 1);
+
+  ctx.fillStyle = "rgb(0, 0, 200)";
+  ctx.fillRect(0, 0, 256, 256);
+  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
+
+  wtu.drawQuad(gl);
+  wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 0, 200, 255], "Should have rendered blue.", 1);
+
+  if (window.layoutTestController)
+      layoutTestController.notifyDone();
+}
+
+window._onload_ = function()
+{
+  if (window.initNonKhronosFramework)
+    window.initNonKhronosFramework(false);
+
+  canvas = document.getElementById("webgl-canvas");
+  gl = create3DContext(canvas);
+
+  canvas2d = document.getElementById("canvas-2d");
+
+  // Set a size that ensures a hardware-accelerated canvas.
+  canvas2d.width = 256;
+  canvas2d.height = 256;
+  ctx = canvas2d.getContext("2d");
+
+  var program = wtu.setupTexturedQuad(gl);
+  var bufferObjects = wtu.setupUnitQuad(gl);
+
+  var texture = gl.createTexture();
+  gl.bindTexture(gl.TEXTURE_2D, texture);
+  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+
+  gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
+  gl.viewport(0, 0, canvas.width, canvas.height);
+
+  // Ensure that the compositor has become active.
+  setTimeout(draw, 0);
+}
+</script>
+<script src=""
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="webgl-canvas" width="32px" height="32px"></canvas>
+<canvas id="canvas-2d" style="-webkit-transform: translateZ(0);"></canvas>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/canvas-2d-webgl-texture.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (101591 => 101592)


--- trunk/Source/WebCore/ChangeLog	2011-12-01 03:23:05 UTC (rev 101591)
+++ trunk/Source/WebCore/ChangeLog	2011-12-01 03:25:46 UTC (rev 101592)
@@ -1,3 +1,22 @@
+2011-11-30  Jeff Timanus  <[email protected]>
+
+        Alter an early return that was preventing HTMLCanvasElement::didDraw notifications
+        from being triggered when accelerated compositing was enabled. The notification is
+        necessary to make sure that any cached state is cleared in the HTMLCanvasElement object.
+        To prevent performance regressions, the cached state is explicitly cleared, as the didDraw
+        machinery is not necessary for accelerated canvases.
+        https://bugs.webkit.org/show_bug.cgi?id=73257
+
+        Reviewed by Stephen White.
+
+        Test: fast/canvas/webgl/canvas-2d-webgl-texture.html
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::didDraw):
+        (WebCore::HTMLCanvasElement::setSurfaceSize):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::didDraw):
+
 2011-11-30  Kentaro Hara  <[email protected]>
 
         Implement the StorageEvent constructor

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (101591 => 101592)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2011-12-01 03:23:05 UTC (rev 101591)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2011-12-01 03:25:46 UTC (rev 101592)
@@ -205,7 +205,7 @@
 
 void HTMLCanvasElement::didDraw(const FloatRect& rect)
 {
-    m_copiedImage.clear(); // Clear our image snapshot if we have one.
+    clearCopiedImage();
 
     if (RenderBox* ro = renderBox()) {
         FloatRect destRect = ro->contentBoxRect();
@@ -325,7 +325,7 @@
     m_size = size;
     m_hasCreatedImageBuffer = false;
     m_imageBuffer.clear();
-    m_copiedImage.clear();
+    clearCopiedImage();
 }
 
 String HTMLCanvasElement::toEncodingMimeType(const String& mimeType)

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (101591 => 101592)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-12-01 03:23:05 UTC (rev 101591)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-12-01 03:25:46 UTC (rev 101592)
@@ -1782,6 +1782,7 @@
         RenderBox* renderBox = canvas()->renderBox();
         if (renderBox && renderBox->hasLayer() && renderBox->layer()->hasAcceleratedCompositing()) {
             renderBox->layer()->contentChanged(RenderLayer::CanvasChanged);
+            canvas()->clearCopiedImage();
             return;
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to