Title: [106729] trunk/Source/WebCore
Revision
106729
Author
[email protected]
Date
2012-02-03 22:43:50 -0800 (Fri, 03 Feb 2012)

Log Message

Canvas-into-canvas drawing should respect backing store scale ratio
https://bugs.webkit.org/show_bug.cgi?id=77784
<rdar://problem/10549729>

Reviewed by Dan Bernstein.

Respect the backing store scale ratio when drawing a canvas into another
canvas via ctx.drawImage(canvas, x, y). Previous behavior caused canvas
drawing to differ based on the size of the backing store, which is ideally
an implementation detail to authors.

Also, rename the source canvas arguments to CanvasRenderingContext2D::drawImage
to be more clear.

No new tests.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::drawImage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106728 => 106729)


--- trunk/Source/WebCore/ChangeLog	2012-02-04 04:45:42 UTC (rev 106728)
+++ trunk/Source/WebCore/ChangeLog	2012-02-04 06:43:50 UTC (rev 106729)
@@ -1,3 +1,24 @@
+2012-02-03  Tim Horton  <[email protected]>
+
+        Canvas-into-canvas drawing should respect backing store scale ratio
+        https://bugs.webkit.org/show_bug.cgi?id=77784
+        <rdar://problem/10549729>
+
+        Reviewed by Dan Bernstein.
+
+        Respect the backing store scale ratio when drawing a canvas into another
+        canvas via ctx.drawImage(canvas, x, y). Previous behavior caused canvas
+        drawing to differ based on the size of the backing store, which is ideally
+        an implementation detail to authors.
+
+        Also, rename the source canvas arguments to CanvasRenderingContext2D::drawImage
+        to be more clear.
+
+        No new tests.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::drawImage):
+
 2012-02-03  Beth Dakin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=77782

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (106728 => 106729)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-02-04 04:45:42 UTC (rev 106728)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-02-04 06:43:50 UTC (rev 106729)
@@ -1364,38 +1364,31 @@
     }
 }
 
-void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas, float x, float y, ExceptionCode& ec)
+void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, float x, float y, ExceptionCode& ec)
 {
-    if (!canvas) {
+    if (!sourceCanvas) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
 
-    // In order to emulate drawing the result of toDataURL() into the canvas, we
-    // need to deflate the size of the source rectangle by the source canvas's
-    // backing store scale factor.
-    // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=15041 for motivation.
-
-    FloatSize logicalSize = canvas->convertDeviceToLogical(canvas->size());
-
-    drawImage(canvas, 0, 0, logicalSize.width(), logicalSize.height(), x, y, canvas->width(), canvas->height(), ec);
+    drawImage(sourceCanvas, 0, 0, sourceCanvas->width(), sourceCanvas->height(), x, y, sourceCanvas->width(), sourceCanvas->height(), ec);
 }
 
-void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas,
+void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas,
     float x, float y, float width, float height, ExceptionCode& ec)
 {
-    if (!canvas) {
+    if (!sourceCanvas) {
         ec = TYPE_MISMATCH_ERR;
         return;
     }
-    drawImage(canvas, FloatRect(0, 0, canvas->width(), canvas->height()), FloatRect(x, y, width, height), ec);
+    drawImage(sourceCanvas, FloatRect(0, 0, sourceCanvas->width(), sourceCanvas->height()), FloatRect(x, y, width, height), ec);
 }
 
-void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* canvas,
+void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas,
     float sx, float sy, float sw, float sh,
     float dx, float dy, float dw, float dh, ExceptionCode& ec)
 {
-    drawImage(canvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
+    drawImage(sourceCanvas, FloatRect(sx, sy, sw, sh), FloatRect(dx, dy, dw, dh), ec);
 }
 
 void CanvasRenderingContext2D::drawImage(HTMLCanvasElement* sourceCanvas, const FloatRect& srcRect,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to