Title: [136262] trunk
Revision
136262
Author
[email protected]
Date
2012-11-30 13:11:31 -0800 (Fri, 30 Nov 2012)

Log Message

[Chromium] Animation updates fail when using a canvas as a CSS backround-image style with -webkit-canvas
https://bugs.webkit.org/show_bug.cgi?id=103643

Reviewed by Stephen White.

.:

New test to verify that elements using a canvas as a style image
source are redrawn when the canvas is animated.  Added as a manual test
because the bug was not reproducible in DumpRenderTree.

* ManualTests/animated-canvas-as-background.html: Added.

Source/WebCore:

CanvasRenderingContext2D::didDraw was not propagating the change
notification to observers in the accelerated compositing case.
Problem fixed by adding observer notifications.

New manual test: animated-canvas-as-background.html

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::didDraw):
The observer notification was factored out into a separate method
so that it can be invoked directly for accelerated compositing.
(WebCore):
(WebCore::HTMLCanvasElement::notifyObserversCanvasChanged):
* html/HTMLCanvasElement.h:
(HTMLCanvasElement):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::didDraw):
Added observer notification call to trigger repainting of elements that
use this canvas for their style.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (136261 => 136262)


--- trunk/ChangeLog	2012-11-30 21:09:21 UTC (rev 136261)
+++ trunk/ChangeLog	2012-11-30 21:11:31 UTC (rev 136262)
@@ -1,3 +1,16 @@
+2012-11-30  Justin Novosad  <[email protected]>
+
+        [Chromium] Animation updates fail when using a canvas as a CSS backround-image style with -webkit-canvas
+        https://bugs.webkit.org/show_bug.cgi?id=103643
+
+        Reviewed by Stephen White.
+
+        New test to verify that elements using a canvas as a style image
+        source are redrawn when the canvas is animated.  Added as a manual test
+        because the bug was not reproducible in DumpRenderTree.
+
+        * ManualTests/animated-canvas-as-background.html: Added.
+
 2012-11-30  Pierre Rossi  <[email protected]>
 
         [Qt] Unreviewed build break

Added: trunk/ManualTests/animated-canvas-as-background.html (0 => 136262)


--- trunk/ManualTests/animated-canvas-as-background.html	                        (rev 0)
+++ trunk/ManualTests/animated-canvas-as-background.html	2012-11-30 21:11:31 UTC (rev 136262)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#container {
+    width: 300px;
+    height: 300px;
+    background-image: -webkit-canvas(sourceCanvas);
+    background-size: 100%;
+    display: inline-block;
+}
+</style>
+</head>
+<body>
+    <p>This test passes if two green squares are displayed below.</p>
+    <div>
+        <div style="display: inline-block">
+            <div id="container"></div>
+        </div>
+        <div id="canvas-container" style="display: inline-block"></div>
+    </div>
+    <script>
+        var ctx = document.getCSSCanvasContext('2d', 'sourceCanvas', 300, 300);
+        var canvas = ctx.canvas;
+
+        function asyncDraw2() {
+            ctx.fillStyle = "green";
+            ctx.fillRect(0, 0, 300, 300);
+        }
+
+        function asyncDraw1() {
+            ctx.fillStyle = "red";
+            ctx.fillRect(0, 0, 300, 300);
+            window.webkitRequestAnimationFrame(asyncDraw2);
+        }
+
+        window.webkitRequestAnimationFrame(asyncDraw1);
+
+        document.querySelector('#canvas-container').appendChild(canvas);
+    </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136261 => 136262)


--- trunk/Source/WebCore/ChangeLog	2012-11-30 21:09:21 UTC (rev 136261)
+++ trunk/Source/WebCore/ChangeLog	2012-11-30 21:11:31 UTC (rev 136262)
@@ -1,3 +1,29 @@
+2012-11-30  Justin Novosad  <[email protected]>
+
+        [Chromium] Animation updates fail when using a canvas as a CSS backround-image style with -webkit-canvas
+        https://bugs.webkit.org/show_bug.cgi?id=103643
+
+        Reviewed by Stephen White.
+
+        CanvasRenderingContext2D::didDraw was not propagating the change
+        notification to observers in the accelerated compositing case.
+        Problem fixed by adding observer notifications.
+
+        New manual test: animated-canvas-as-background.html
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::didDraw):
+        The observer notification was factored out into a separate method
+        so that it can be invoked directly for accelerated compositing.
+        (WebCore):
+        (WebCore::HTMLCanvasElement::notifyObserversCanvasChanged):
+        * html/HTMLCanvasElement.h:
+        (HTMLCanvasElement):
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::didDraw):
+        Added observer notification call to trigger repainting of elements that
+        use this canvas for their style.
+
 2012-11-30  James Simonsen  <[email protected]>
 
         Report CSS as initiator instead of elements, except body

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (136261 => 136262)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2012-11-30 21:09:21 UTC (rev 136261)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2012-11-30 21:11:31 UTC (rev 136262)
@@ -229,6 +229,11 @@
         ro->repaintRectangle(enclosingIntRect(m_dirtyRect));
     }
 
+    notifyObserversCanvasChanged(rect);
+}
+
+void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect& rect)
+{
     HashSet<CanvasObserver*>::iterator end = m_observers.end();
     for (HashSet<CanvasObserver*>::iterator it = m_observers.begin(); it != end; ++it)
         (*it)->canvasChanged(this, rect);

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (136261 => 136262)


--- trunk/Source/WebCore/html/HTMLCanvasElement.h	2012-11-30 21:09:21 UTC (rev 136261)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h	2012-11-30 21:11:31 UTC (rev 136262)
@@ -99,6 +99,7 @@
 
     // Used for rendering
     void didDraw(const FloatRect&);
+    void notifyObserversCanvasChanged(const FloatRect&);
 
     void paint(GraphicsContext*, const LayoutRect&, bool useLowQualityScale = false);
 

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (136261 => 136262)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-11-30 21:09:21 UTC (rev 136261)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-11-30 21:11:31 UTC (rev 136262)
@@ -1814,6 +1814,7 @@
         if (renderBox && renderBox->hasAcceleratedCompositing()) {
             renderBox->contentChanged(CanvasPixelsChanged);
             canvas()->clearCopiedImage();
+            canvas()->notifyObserversCanvasChanged(r);
             return;
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to