REGRESSION: Canvas is broken in high dpi mode
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Dec 2008 14:11:04 +0000 (14:11 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Dec 2008 14:11:04 +0000 (14:11 +0000)
<rdar://problem/6432739> <https://bugs.webkit.org/show_bug.cgi?id=22823>

Reviewed by Alexey Proskuryakov.

Simply made sure that we correctly scale the graphics context to
account for the difference between logical and buffer resolution.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39240 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/html/HTMLCanvasElement.cpp

index 13e5f5e..1df18fa 100644 (file)
@@ -1,3 +1,17 @@
+2008-12-12  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        REGRESSION: Canvas is broken in high dpi mode
+        <rdar://problem/6432739> <https://bugs.webkit.org/show_bug.cgi?id=22823>
+
+        Simply made sure that we correctly scale the graphics context to
+        account for the difference between logical and buffer resolution.
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        (WebCore::HTMLCanvasElement::baseTransform):
+
 2008-12-12  Tor Arne Vestbø  <tavestbo@trolltech.com>
 
         Rubber-stamped by Oliver Hunt.
index 9f59f23..e34880e 100644 (file)
@@ -253,8 +253,9 @@ void HTMLCanvasElement::createImageBuffer() const
     IntSize size = convertLogicalToDevice(unscaledSize);
     if (!size.width() || !size.height())
         return;
-    m_imageBuffer.set(ImageBuffer::create(size, false).release());
 
+    m_imageBuffer.set(ImageBuffer::create(size, false).release());
+    m_imageBuffer->context()->scale(FloatSize(size.width() / unscaledSize.width(), size.height() / unscaledSize.height()));
     m_imageBuffer->context()->setShadowsIgnoreTransforms(true);
 }
 
@@ -273,7 +274,13 @@ ImageBuffer* HTMLCanvasElement::buffer() const
 AffineTransform HTMLCanvasElement::baseTransform() const
 {
     ASSERT(m_createdImageBuffer);
-    return m_imageBuffer->baseTransform();
+    FloatSize unscaledSize(width(), height());
+    IntSize size = convertLogicalToDevice(unscaledSize);
+    AffineTransform transform;
+    if (size.width() && size.height())
+        transform.scale(size.width() / unscaledSize.width(), size.height() / unscaledSize.height());
+    transform.multiply(m_imageBuffer->baseTransform());
+    return transform;
 }
 
 }