[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

eric at webkit.org eric at webkit.org
Fri Feb 26 22:20:55 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit b04a33f1eae5cced0f8b8382e26256861a74dc2b
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 16 09:17:44 2010 +0000

    2010-02-16  Noam Rosenthal  <noam.rosenthal at nokia.com>
    
            Reviewed by Ariya Hidayat.
    
            [Qt] canvas clipping is buggy
            https://bugs.webkit.org/show_bug.cgi?id=32405
    
            Apparently the bug was in GraphicsContext::roundToDevicePixels, we
            didn't take unto accounts rotation, so the device pixels were rounded
            incorrectly. The new formula is a 1:1 copy from GraphicsContextCG so
            it should be rather safe
    
            Test: http://glimr.rubyforge.org/cake/canvas.html#Polaroids now looks right
    
            * platform/graphics/qt/GraphicsContextQt.cpp:
            (WebCore::GraphicsContext::roundToDevicePixels): Copy the formula from
            GraphicsContextCG
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54811 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a60f839..0aab728 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-02-16  Noam Rosenthal  <noam.rosenthal at nokia.com>
+
+        Reviewed by Ariya Hidayat.
+
+        [Qt] canvas clipping is buggy
+        https://bugs.webkit.org/show_bug.cgi?id=32405
+
+        Apparently the bug was in GraphicsContext::roundToDevicePixels, we
+        didn't take unto accounts rotation, so the device pixels were rounded
+        incorrectly. The new formula is a 1:1 copy from GraphicsContextCG so
+        it should be rather safe
+
+        Test: http://glimr.rubyforge.org/cake/canvas.html#Polaroids now looks right
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::roundToDevicePixels): Copy the formula from
+        GraphicsContextCG
+
 2010-02-16  Yury Semikhatsky  <yurys at chromium.org>
 
         Not Reviewed, build fix.
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 3331f1a..8bcda2e 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -761,11 +761,30 @@ void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint&, int, b
 
 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
 {
-    QRectF rect(frect);
-    rect = m_data->p()->deviceMatrix().mapRect(rect);
-
-    QRect result = rect.toRect(); //round it
-    return FloatRect(QRectF(result));
+    // It is not enough just to round to pixels in device space. The rotation part of the
+    // affine transform matrix to device space can mess with this conversion if we have a
+    // rotating image like the hands of the world clock widget. We just need the scale, so
+    // we get the affine transform matrix and extract the scale.
+    QPainter* painter = platformContext();
+    QTransform deviceTransform = painter->deviceTransform();
+    if (deviceTransform.isIdentity())
+        return frect;
+
+    qreal deviceScaleX = sqrtf(deviceTransform.m11() * deviceTransform.m11() + deviceTransform.m12() * deviceTransform.m12());
+    qreal deviceScaleY = sqrtf(deviceTransform.m21() * deviceTransform.m21() + deviceTransform.m22() * deviceTransform.m22());
+
+    QPoint deviceOrigin(frect.x() * deviceScaleX, frect.y() * deviceScaleY);
+    QPoint deviceLowerRight(frect.right() * deviceScaleX, frect.bottom() * deviceScaleY);
+
+    // Don't let the height or width round to 0 unless either was originally 0
+    if (deviceOrigin.y() == deviceLowerRight.y() && frect.height())
+        deviceLowerRight.setY(deviceLowerRight.y() + 1);
+    if (deviceOrigin.x() == deviceLowerRight.x() && frect.width())
+        deviceLowerRight.setX(deviceLowerRight.x() + 1);
+
+    FloatPoint roundedOrigin = FloatPoint(deviceOrigin.x() / deviceScaleX, deviceOrigin.y() / deviceScaleY);
+    FloatPoint roundedLowerRight = FloatPoint(deviceLowerRight.x() / deviceScaleX, deviceLowerRight.y() / deviceScaleY);
+    return FloatRect(roundedOrigin, roundedLowerRight - roundedOrigin);
 }
 
 void GraphicsContext::setPlatformShadow(const IntSize& size, int, const Color&, ColorSpace)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list