Changeset 83541 in webkit


Ignore:
Timestamp:
Apr 11, 2011 5:31:31 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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 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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r83536 r83541  
     12011-04-11  Justin Novosad  <junov@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [Chromium] Text anti-aliasing fails when rendering text with shadow
     6        https://bugs.webkit.org/show_bug.cgi?id=57584
     7
     8        * platform/chromium/test_expectations.txt:
     9        Tempoaray test failures that will need to be rebaselined
     10
    1112011-04-11  Jian Li  <jianli@chromium.org>
    212
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r83536 r83541  
    690690BUGCR3273 MAC : platform/mac/editing/input/firstrectforcharacterrange-plain.html = FAIL PASS
    691691BUGCR3273 MAC : platform/mac/editing/input/range-for-empty-document.html = FAIL PASS
     692
     693// Need rebaseline
     694BUGWK57584 WIN : fast/multicol/shadow-breaking.html = IMAGE
     695BUGWK57584 WIN : fast/text/shadow-translucent-fill.html = IMAGE
     696BUGWK57584 WIN : fast/transforms/shadows.html = IMAGE
     697BUGWK57584 WIN : svg/css/shadow-changes.svg = IMAGE
     698BUGWK57584 WIN : transitions/svg-text-shadow-transition.html = IMAGE
     699BUGWK57584 WIN : svg/css/composite-shadow-text.svg = IMAGE
     700BUGWK57584 WIN : svg/css/group-with-shadow.svg = IMAGE
     701BUGWK57584 WIN : svg/css/text-shadow-multiple.xhtml = IMAGE
    692702
    693703// These tests also use firstRectForCharacterRange, but they generate slightly
  • trunk/Source/WebCore/ChangeLog

    r83540 r83541  
     12011-04-11  Justin Novosad  <junov@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [Chromium] Text anti-aliasing fails when rendering text with shadow
     6        https://bugs.webkit.org/show_bug.cgi?id=57584
     7
     8        * platform/graphics/chromium/FontChromiumWin.cpp:
     9        (WebCore::drawGlyphsWin): new static function, code factored-out
     10        from WebCore::Font::drawGlyphs
     11        (WebCore::Font::drawGlyphs): may separate font rendering into two
     12        passes to allow foreground glyphs to be rendered with GDI when Skia
     13        is required for rendering shadows
     14        * platform/graphics/skia/SkiaFontWin.cpp:
     15        (WebCore::windowsCanHandleDrawTextShadow):
     16        Modified method so that it does not assume a shadow is present, and
     17        returns true if there is no shadow (GDI can draw 'no shadow')
     18        (WebCore::windowsCanHandleTextDrawing):
     19        Factored out into sub methods so that the the shadow and foregound
     20        glyph properties can be tested separately independently.
     21        (WebCore::windowsCanHandleTextDrawingWithoutShadow):
     22        New method returns true if the foreground glyph only has effect
     23        that can be draw with GDI
     24        (WebCore::paintSkiaText):
     25        * platform/graphics/skia/SkiaFontWin.h:
     26
    1272011-04-11  Ryosuke Niwa  <rniwa@webkit.org>
    228
  • trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp

    r83013 r83541  
    375375}
    376376
    377 void Font::drawGlyphs(GraphicsContext* graphicsContext,
    378                       const SimpleFontData* font,
    379                       const GlyphBuffer& glyphBuffer,
    380                       int from,
    381                       int numGlyphs,
    382                       const FloatPoint& point) const
    383 {
     377static void drawGlyphsWin(GraphicsContext* graphicsContext,
     378                          const SimpleFontData* font,
     379                          const GlyphBuffer& glyphBuffer,
     380                          int from,
     381                          int numGlyphs,
     382                          const FloatPoint& point) {
    384383    graphicsContext->platformContext()->prepareForSoftwareDraw();
    385 
    386     SkColor color = graphicsContext->platformContext()->effectiveFillColor();
    387     unsigned char alpha = SkColorGetA(color);
    388     // Skip 100% transparent text; no need to draw anything.
    389     if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke)
    390         return;
    391384
    392385    TransparencyAwareGlyphPainter painter(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
     
    450443}
    451444
     445void Font::drawGlyphs(GraphicsContext* graphicsContext,
     446                      const SimpleFontData* font,
     447                      const GlyphBuffer& glyphBuffer,
     448                      int from,
     449                      int numGlyphs,
     450                      const FloatPoint& point) const
     451{
     452    SkColor color = graphicsContext->platformContext()->effectiveFillColor();
     453    unsigned char alpha = SkColorGetA(color);
     454    // Skip 100% transparent text; no need to draw anything.
     455    if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke && !graphicsContext->hasShadow())
     456        return;
     457    if (!alpha || windowsCanHandleDrawTextShadow(graphicsContext) || !windowsCanHandleTextDrawingWithoutShadow(graphicsContext)) {
     458        drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
     459        return;
     460    }
     461    // Draw in two passes: skia for the shadow, GDI for foreground text
     462    // pass1: shadow (will use skia)
     463    graphicsContext->save();
     464    graphicsContext->setFillColor(Color::transparent, graphicsContext->fillColorSpace());
     465    drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
     466    graphicsContext->restore();
     467    // pass2: foreground text (will use GDI)
     468    FloatSize shadowOffset;
     469    float shadowBlur;
     470    Color shadowColor;
     471    ColorSpace shadowColorSpace;
     472    graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
     473    graphicsContext->setShadow(shadowOffset, shadowBlur, Color::transparent, shadowColorSpace);
     474    drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
     475    graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
     476}
     477
    452478FloatRect Font::selectionRectForComplexText(const TextRun& run,
    453479                                            const FloatPoint& point,
  • trunk/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp

    r83329 r83541  
    231231
    232232    bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
    233     return (hasShadow && (shadowBlur == 0) && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
     233    return !hasShadow || (!shadowBlur && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
    234234}
    235235
    236236bool windowsCanHandleTextDrawing(GraphicsContext* context)
     237{
     238    if (!windowsCanHandleTextDrawingWithoutShadow(context))
     239        return false;
     240
     241    // Check for shadow effects.
     242    if (!windowsCanHandleDrawTextShadow(context))
     243        return false;
     244
     245    return true;
     246}
     247
     248bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext* context)
    237249{
    238250    // Check for non-translation transforms. Sometimes zooms will look better in
     
    255267    // Check for patterns.
    256268    if (context->fillPattern() || context->strokePattern())
    257         return false;
    258 
    259     // Check for shadow effects.
    260     if (context->platformContext()->getDrawLooper() && (!windowsCanHandleDrawTextShadow(context)))
    261269        return false;
    262270
     
    363371    bool didFill = false;
    364372
    365     if ((textMode & TextModeFill) && SkColorGetA(paint.getColor())) {
     373    if ((textMode & TextModeFill) && (SkColorGetA(paint.getColor()) || paint.getLooper())) {
    366374        if (!skiaDrawText(hfont, dc, platformContext, *origin, &paint,
    367375                          &glyphs[0], &advances[0], &offsets[0], numGlyphs))
  • trunk/Source/WebCore/platform/graphics/skia/SkiaFontWin.h

    r64584 r83541  
    7777bool windowsCanHandleTextDrawing(GraphicsContext*);
    7878
     79// Returns true if advanced font rendering is recommended if shadows are
     80// disregarded.
     81bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext*);
     82
    7983// Note that the offsets parameter is optional.  If not NULL it represents a
    8084// per glyph offset (such as returned by ScriptPlace Windows API function).
Note: See TracChangeset for help on using the changeset viewer.