2011-04-11 Justin Novosad <junov@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 00:31:31 +0000 (00:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2011 00:31:31 +0000 (00:31 +0000)
        Reviewed by Kenneth Russell.

        [Chromium] Text anti-aliasing fails when rendering text with shadow
        https://bugs.webkit.org/show_bug.cgi?id=57584

        * platform/chromium/test_expectations.txt:
        Tempoaray test failures that will need to be rebaselined
2011-04-11  Justin Novosad  <junov@chromium.org>

        Reviewed by Kenneth Russell.

        [Chromium] Text anti-aliasing fails when rendering text with shadow
        https://bugs.webkit.org/show_bug.cgi?id=57584

        * platform/graphics/chromium/FontChromiumWin.cpp:
        (WebCore::drawGlyphsWin): new static function, code factored-out
        from WebCore::Font::drawGlyphs
        (WebCore::Font::drawGlyphs): may separate font rendering into two
        passes to allow foreground glyphs to be rendered with GDI when Skia
        is required for rendering shadows
        * platform/graphics/skia/SkiaFontWin.cpp:
        (WebCore::windowsCanHandleDrawTextShadow):
        Modified method so that it does not assume a shadow is present, and
        returns true if there is no shadow (GDI can draw 'no shadow')
        (WebCore::windowsCanHandleTextDrawing):
        Factored out into sub methods so that the the shadow and foregound
        glyph properties can be tested separately independently.
        (WebCore::windowsCanHandleTextDrawingWithoutShadow):
        New method returns true if the foreground glyph only has effect
        that can be draw with GDI
        (WebCore::paintSkiaText):
        * platform/graphics/skia/SkiaFontWin.h:

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp
Source/WebCore/platform/graphics/skia/SkiaFontWin.h

index 1b05f86..d29ec05 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-11  Justin Novosad  <junov@chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        [Chromium] Text anti-aliasing fails when rendering text with shadow
+        https://bugs.webkit.org/show_bug.cgi?id=57584
+
+        * platform/chromium/test_expectations.txt:
+        Tempoaray test failures that will need to be rebaselined
+
 2011-04-11  Jian Li  <jianli@chromium.org>
 
         Unreviewed, update chromium test expectations.
index b612329..8942710 100644 (file)
@@ -690,6 +690,16 @@ BUGCR3273 MAC : platform/mac/editing/input/caret-primary-bidi.html = FAIL PASS
 BUGCR3273 MAC : platform/mac/editing/input/firstrectforcharacterrange-plain.html = FAIL PASS
 BUGCR3273 MAC : platform/mac/editing/input/range-for-empty-document.html = FAIL PASS
 
+// Need rebaseline
+BUGWK57584 WIN : fast/multicol/shadow-breaking.html = IMAGE
+BUGWK57584 WIN : fast/text/shadow-translucent-fill.html = IMAGE
+BUGWK57584 WIN : fast/transforms/shadows.html = IMAGE
+BUGWK57584 WIN : svg/css/shadow-changes.svg = IMAGE
+BUGWK57584 WIN : transitions/svg-text-shadow-transition.html = IMAGE
+BUGWK57584 WIN : svg/css/composite-shadow-text.svg = IMAGE
+BUGWK57584 WIN : svg/css/group-with-shadow.svg = IMAGE
+BUGWK57584 WIN : svg/css/text-shadow-multiple.xhtml = IMAGE
+
 // These tests also use firstRectForCharacterRange, but they generate slightly
 // different values.
 BUGCR3273 : editing/selection/5825350-1.html = TEXT
index 3e299da..577d634 100644 (file)
@@ -1,3 +1,29 @@
+2011-04-11  Justin Novosad  <junov@chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        [Chromium] Text anti-aliasing fails when rendering text with shadow
+        https://bugs.webkit.org/show_bug.cgi?id=57584
+
+        * platform/graphics/chromium/FontChromiumWin.cpp:
+        (WebCore::drawGlyphsWin): new static function, code factored-out
+        from WebCore::Font::drawGlyphs
+        (WebCore::Font::drawGlyphs): may separate font rendering into two
+        passes to allow foreground glyphs to be rendered with GDI when Skia 
+        is required for rendering shadows
+        * platform/graphics/skia/SkiaFontWin.cpp:
+        (WebCore::windowsCanHandleDrawTextShadow):
+        Modified method so that it does not assume a shadow is present, and
+        returns true if there is no shadow (GDI can draw 'no shadow')
+        (WebCore::windowsCanHandleTextDrawing):
+        Factored out into sub methods so that the the shadow and foregound
+        glyph properties can be tested separately independently.
+        (WebCore::windowsCanHandleTextDrawingWithoutShadow):
+        New method returns true if the foreground glyph only has effect
+        that can be draw with GDI
+        (WebCore::paintSkiaText):
+        * platform/graphics/skia/SkiaFontWin.h:
+
 2011-04-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Unreviewed, rolling out r83515.
index 4f0ba57..b1803ea 100644 (file)
@@ -374,21 +374,14 @@ bool Font::canExpandAroundIdeographsInComplexText()
     return false;
 }
 
-void Font::drawGlyphs(GraphicsContext* graphicsContext,
-                      const SimpleFontData* font,
-                      const GlyphBuffer& glyphBuffer,
-                      int from,
-                      int numGlyphs,
-                      const FloatPoint& point) const
-{
+static void drawGlyphsWin(GraphicsContext* graphicsContext,
+                          const SimpleFontData* font,
+                          const GlyphBuffer& glyphBuffer,
+                          int from,
+                          int numGlyphs,
+                          const FloatPoint& point) {
     graphicsContext->platformContext()->prepareForSoftwareDraw();
 
-    SkColor color = graphicsContext->platformContext()->effectiveFillColor();
-    unsigned char alpha = SkColorGetA(color);
-    // Skip 100% transparent text; no need to draw anything.
-    if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke)
-        return;
-
     TransparencyAwareGlyphPainter painter(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
 
     // We draw the glyphs in chunks to avoid having to do a heap allocation for
@@ -449,6 +442,39 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext,
     }
 }
 
+void Font::drawGlyphs(GraphicsContext* graphicsContext,
+                      const SimpleFontData* font,
+                      const GlyphBuffer& glyphBuffer,
+                      int from,
+                      int numGlyphs,
+                      const FloatPoint& point) const
+{
+    SkColor color = graphicsContext->platformContext()->effectiveFillColor();
+    unsigned char alpha = SkColorGetA(color);
+    // Skip 100% transparent text; no need to draw anything.
+    if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke && !graphicsContext->hasShadow())
+        return;
+    if (!alpha || windowsCanHandleDrawTextShadow(graphicsContext) || !windowsCanHandleTextDrawingWithoutShadow(graphicsContext)) {
+        drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
+        return;
+    }
+    // Draw in two passes: skia for the shadow, GDI for foreground text
+    // pass1: shadow (will use skia)
+    graphicsContext->save();
+    graphicsContext->setFillColor(Color::transparent, graphicsContext->fillColorSpace());
+    drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
+    graphicsContext->restore();
+    // pass2: foreground text (will use GDI)
+    FloatSize shadowOffset;
+    float shadowBlur;
+    Color shadowColor;
+    ColorSpace shadowColorSpace;
+    graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
+    graphicsContext->setShadow(shadowOffset, shadowBlur, Color::transparent, shadowColorSpace);
+    drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
+    graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
+}
+
 FloatRect Font::selectionRectForComplexText(const TextRun& run,
                                             const FloatPoint& point,
                                             int h,
index c40c4a9..8ab823e 100644 (file)
@@ -230,11 +230,23 @@ bool windowsCanHandleDrawTextShadow(GraphicsContext *context)
     ColorSpace shadowColorSpace;
 
     bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
-    return (hasShadow && (shadowBlur == 0) && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
+    return !hasShadow || (!shadowBlur && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
 }
 
 bool windowsCanHandleTextDrawing(GraphicsContext* context)
 {
+    if (!windowsCanHandleTextDrawingWithoutShadow(context))
+        return false;
+
+    // Check for shadow effects.
+    if (!windowsCanHandleDrawTextShadow(context))
+        return false;
+
+    return true;
+}
+
+bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext* context)
+{
     // Check for non-translation transforms. Sometimes zooms will look better in
     // Skia, and sometimes better in Windows. The main problem is that zooming
     // in using Skia will show you the hinted outlines for the smaller size,
@@ -256,10 +268,6 @@ bool windowsCanHandleTextDrawing(GraphicsContext* context)
     if (context->fillPattern() || context->strokePattern())
         return false;
 
-    // Check for shadow effects.
-    if (context->platformContext()->getDrawLooper() && (!windowsCanHandleDrawTextShadow(context)))
-        return false;
-
     if (!context->platformContext()->isNativeFontRenderingAllowed())
         return false;
 
@@ -362,7 +370,7 @@ bool paintSkiaText(GraphicsContext* context,
     }
     bool didFill = false;
 
-    if ((textMode & TextModeFill) && SkColorGetA(paint.getColor())) {
+    if ((textMode & TextModeFill) && (SkColorGetA(paint.getColor()) || paint.getLooper())) {
         if (!skiaDrawText(hfont, dc, platformContext, *origin, &paint,
                           &glyphs[0], &advances[0], &offsets[0], numGlyphs))
             return false;
index 40bee62..33b4aaf 100644 (file)
@@ -76,6 +76,10 @@ bool windowsCanHandleDrawTextShadow(GraphicsContext*);
 // Returns true if advanced font rendering is recommended.
 bool windowsCanHandleTextDrawing(GraphicsContext*);
 
+// Returns true if advanced font rendering is recommended if shadows are
+// disregarded.
+bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext*);
+
 // Note that the offsets parameter is optional.  If not NULL it represents a
 // per glyph offset (such as returned by ScriptPlace Windows API function).
 //