[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

mihaip at chromium.org mihaip at chromium.org
Fri Jan 21 14:36:36 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit 7dc9e842e551880f1049c35bda75f04cc435baf4
Author: mihaip at chromium.org <mihaip at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 23 03:25:35 2010 +0000

    2010-12-22  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Simon Fraser.
    
            the shadow direction is negated in canvas context shadowOffsetY.
            https://bugs.webkit.org/show_bug.cgi?id=25619
    
            Add test to verify that shadowOffsetY is handled correctly.
    
            * fast/canvas/fillText-shadow-expected.txt: Added.
            * fast/canvas/fillText-shadow.html: Added.
    2010-12-22  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Simon Fraser.
    
            the shadow direction is negated in canvas context shadowOffsetY.
            https://bugs.webkit.org/show_bug.cgi?id=25619
    
            Invert shadow offset Y direction in 0-blur path in FontMac::drawGlyps
            if we're not transforming shadows (i.e. are rendering in a canvas). Also
            use CG shadows if there's a non-translate/flip transform applied
            (shadow offsets are supposed to ignore transforms, but the naive/simple
            implementation was taking them into account).
    
            Also does the equivalent changes to FontCGWin.
    
            Test: fast/canvas/fillText-shadow.html
    
            * platform/graphics/GraphicsContext.cpp:
            (WebCore::GraphicsContext::shadowsIgnoreTransforms):
            * platform/graphics/GraphicsContext.h:
            * platform/graphics/mac/FontMac.mm:
            (WebCore::Font::drawGlyphs):
            * platform/graphics/win/FontCGWin.cpp:
            (WebCore::Font::drawGlyphs):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74532 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a789037..eb1468d 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-12-22  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        the shadow direction is negated in canvas context shadowOffsetY.
+        https://bugs.webkit.org/show_bug.cgi?id=25619
+        
+        Add test to verify that shadowOffsetY is handled correctly.
+
+        * fast/canvas/fillText-shadow-expected.txt: Added.
+        * fast/canvas/fillText-shadow.html: Added.
+
 2010-12-22  Ariya Hidayat  <ariya at sencha.com>
 
         Reviewed by Simon Fraser.
diff --git a/LayoutTests/fast/canvas/fillText-shadow-expected.txt b/LayoutTests/fast/canvas/fillText-shadow-expected.txt
new file mode 100644
index 0000000..8f245b9
--- /dev/null
+++ b/LayoutTests/fast/canvas/fillText-shadow-expected.txt
@@ -0,0 +1,65 @@
+Tests that (vertical) shadow offsets are applied correctly when using fillText() regardless of blur amount.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing with no transform
+Testing with blur of 0 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+Testing with blur of 1 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+Testing with blur of 5 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+Testing with scale transform
+Testing with blur of 0 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+Testing with blur of 1 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+Testing with blur of 5 pixels
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[3] is 255
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/fillText-shadow.html b/LayoutTests/fast/canvas/fillText-shadow.html
new file mode 100644
index 0000000..8bc455e
--- /dev/null
+++ b/LayoutTests/fast/canvas/fillText-shadow.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<canvas width="600" height="300" style="border: solid 1px gray"></canvas>
+<script>
+description('Tests that (vertical) shadow offsets are applied correctly when using fillText() regardless of blur amount.');
+var ctx = document.getElementsByTagName('canvas')[0].getContext('2d');
+ctx.font = 'bold 128px sans-serif';
+ctx.shadowColor = 'red'
+ctx.shadowOffsetY = 100;
+
+function testWithBlur(blur, belowOffset) {
+  ctx.clearRect(0, 0, 600, 300);
+  ctx.shadowBlur = blur;
+  
+  // Center the I around the Y axis.
+  ctx.fillText('I', -ctx.measureText('I').width/2, 128);
+  
+  debug('Testing with blur of ' + blur + ' pixels');
+
+  // Make sure that the shadow doesn't end up above the text...
+  var imageData = ctx.getImageData(0, 0, 1, 1);
+  imgdata = imageData.data;
+
+  shouldBe('imgdata[0]', '0');
+  shouldBe('imgdata[1]', '0');
+  shouldBe('imgdata[2]', '0');
+  shouldBe('imgdata[3]', '0');
+  
+  // ...but below.
+  var imageData = ctx.getImageData(0, belowOffset, 1, 1);
+  imgdata = imageData.data;  
+  shouldBe('imgdata[0]', '255');
+  shouldBe('imgdata[1]', '0');
+  shouldBe('imgdata[2]', '0');
+  shouldBe('imgdata[3]', '255');
+}
+
+debug('Testing with no transform');
+testWithBlur(0, 150);
+testWithBlur(1, 150);
+testWithBlur(5, 150);
+
+debug('Testing with scale transform');
+ctx.scale(1, 2);
+testWithBlur(0, 299);
+testWithBlur(1, 299);
+testWithBlur(5, 299);
+
+var successfullyParsed = true;
+
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b80080e..6d3e08f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-12-22  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        the shadow direction is negated in canvas context shadowOffsetY.
+        https://bugs.webkit.org/show_bug.cgi?id=25619
+        
+        Invert shadow offset Y direction in 0-blur path in FontMac::drawGlyps
+        if we're not transforming shadows (i.e. are rendering in a canvas). Also
+        use CG shadows if there's a non-translate/flip transform applied
+        (shadow offsets are supposed to ignore transforms, but the naive/simple
+        implementation was taking them into account).
+        
+        Also does the equivalent changes to FontCGWin.
+
+        Test: fast/canvas/fillText-shadow.html
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::shadowsIgnoreTransforms):
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::drawGlyphs):
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::Font::drawGlyphs):
+
 2010-12-22  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r74503.
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index f323969..907cdd2 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -307,6 +307,11 @@ void GraphicsContext::setShadowsIgnoreTransforms(bool ignoreTransforms)
     m_state.shadowsIgnoreTransforms = ignoreTransforms;
 }
 
+bool GraphicsContext::shadowsIgnoreTransforms() const
+{
+    return m_state.shadowsIgnoreTransforms;
+}
+
 bool GraphicsContext::updatingControlTints() const
 {
     return m_updatingControlTints;
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index 6a5cfcc..bcf6b10 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -242,6 +242,7 @@ namespace WebCore {
         Gradient* fillGradient() const;
 
         void setShadowsIgnoreTransforms(bool);
+        bool shadowsIgnoreTransforms() const;
 
         void setShouldAntialias(bool);
         bool shouldAntialias() const;
diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm
index 2169490..8519667 100644
--- a/WebCore/platform/graphics/mac/FontMac.mm
+++ b/WebCore/platform/graphics/mac/FontMac.mm
@@ -173,17 +173,20 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
     ColorSpace fillColorSpace = context->fillColorSpace();
     context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
 
-    bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont();
+    bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || context->getCTM().isIdentityOrTranslationOrFlipped());
     if (hasSimpleShadow) {
         // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
         context->clearShadow();
         Color fillColor = context->fillColor();
         Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
         context->setFillColor(shadowFillColor, shadowColorSpace);
-        CGContextSetTextPosition(cgContext, point.x() + shadowOffset.width(), point.y() + shadowOffset.height());
+        float shadowTextX = point.x() + shadowOffset.width();
+        // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
+        float shadowTextY = point.y() + shadowOffset.height() * (context->shadowsIgnoreTransforms() ? -1 : 1);
+        CGContextSetTextPosition(cgContext, shadowTextX, shadowTextY);
         showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         if (font->syntheticBoldOffset()) {
-            CGContextSetTextPosition(cgContext, point.x() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + shadowOffset.height());
+            CGContextSetTextPosition(cgContext, shadowTextX + font->syntheticBoldOffset(), shadowTextY);
             showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         }
         context->setFillColor(fillColor, fillColorSpace);
diff --git a/WebCore/platform/graphics/win/FontCGWin.cpp b/WebCore/platform/graphics/win/FontCGWin.cpp
index 2194ef7..8012722 100644
--- a/WebCore/platform/graphics/win/FontCGWin.cpp
+++ b/WebCore/platform/graphics/win/FontCGWin.cpp
@@ -357,14 +357,17 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo
     ColorSpace shadowColorSpace;
     graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
 
-    bool hasSimpleShadow = graphicsContext->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur;
+    bool hasSimpleShadow = graphicsContext->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && (!graphicsContext->shadowsIgnoreTransforms() || graphicsContext->getCTM().isIdentityOrTranslationOrFlipped());
     if (hasSimpleShadow) {
         // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
         graphicsContext->clearShadow();
         Color fillColor = graphicsContext->fillColor();
         Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
         graphicsContext->setFillColor(shadowFillColor, ColorSpaceDeviceRGB);
-        CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width(), point.y() + translation.height() + shadowOffset.height());
+        float shadowTextX = point.x() + translation.width() + shadowOffset.width();
+        // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
+        float shadowTextY = point.y() + translation.height() + shadowOffset.height() * (graphicsContext->shadowsIgnoreTransforms() ? -1 : 1);
+        CGContextSetTextPosition(cgContext, shadowTextX, shadowTextY);
         CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         if (font->syntheticBoldOffset()) {
             CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + translation.height() + shadowOffset.height());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list