Changeset 49909 in webkit


Ignore:
Timestamp:
Oct 21, 2009 11:23:12 AM (15 years ago)
Author:
agl@chromium.org
Message:

2009-10-21 Adam Langley <agl@google.com>

Reviewed by Eric Seidel.

Chromium Linux: disable subpixel text on layers.

https://bugs.webkit.org/show_bug.cgi?id=30635
http://code.google.com/p/chromium/issues/detail?id=25365

With the addition of layers for drawing rounded corners in r49641,
subpixel text on rounded rectangles broke. This is because the layer
only contains a single alpha channel and this is insufficient to
compose subpixel text correctly.

On Windows, a large body of code in TransparencyWin.cpp exists to try
to deal with this. Even then, in some cases, it downgrades to
anti-aliased text. We need a fix for the grevious effects quickly thus
this patch disables subpixel text when rendering into a layer.

This would be covered by existing tests except that subpixel text is
disabled for pixel tests on Chromium Linux.

  • platform/graphics/chromium/FontLinux.cpp: (WebCore::isCanvasMultiLayered): (WebCore::adjustTextRenderMode): (WebCore::Font::drawGlyphs): (WebCore::Font::drawComplexText):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49907 r49909  
     12009-10-21  Adam Langley  <agl@google.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Chromium Linux: disable subpixel text on layers.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=30635
     8        http://code.google.com/p/chromium/issues/detail?id=25365
     9
     10        With the addition of layers for drawing rounded corners in r49641,
     11        subpixel text on rounded rectangles broke. This is because the layer
     12        only contains a single alpha channel and this is insufficient to
     13        compose subpixel text correctly.
     14
     15        On Windows, a large body of code in TransparencyWin.cpp exists to try
     16        to deal with this. Even then, in some cases, it downgrades to
     17        anti-aliased text. We need a fix for the grevious effects quickly thus
     18        this patch disables subpixel text when rendering into a layer.
     19
     20        This would be covered by existing tests except that subpixel text is
     21        disabled for pixel tests on Chromium Linux.
     22
     23        * platform/graphics/chromium/FontLinux.cpp:
     24        (WebCore::isCanvasMultiLayered):
     25        (WebCore::adjustTextRenderMode):
     26        (WebCore::Font::drawGlyphs):
     27        (WebCore::Font::drawComplexText):
     28
    1292009-10-21  Kevin Ollivier  <kevino@theolliviers.com>
    230
  • trunk/WebCore/platform/graphics/chromium/FontLinux.cpp

    r47998 r49909  
    5858}
    5959
     60static bool isCanvasMultiLayered(SkCanvas* canvas)
     61{
     62    SkCanvas::LayerIter layerIterator(canvas, false);
     63    layerIterator.next();
     64    return !layerIterator.done();
     65}
     66
     67static bool adjustTextRenderMode(SkPaint* paint, bool isCanvasMultiLayered)
     68{
     69    // Our layers only have a single alpha channel. This means that subpixel
     70    // rendered text cannot be compositied correctly when the layer is
     71    // collapsed. Therefore, subpixel text is disabled when we are drawing
     72    // onto a layer.
     73    if (isCanvasMultiLayered)
     74        paint->setLCDRenderText(false);
     75}
     76
    6077void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
    6178                      const GlyphBuffer& glyphBuffer,  int from, int numGlyphs,
     
    85102    SkCanvas* canvas = gc->platformContext()->canvas();
    86103    int textMode = gc->platformContext()->getTextDrawingMode();
     104    bool haveMultipleLayers = isCanvasMultiLayered(canvas);
    87105
    88106    // We draw text up to two times (once for fill, once for stroke).
     
    91109        gc->platformContext()->setupPaintForFilling(&paint);
    92110        font->platformData().setupPaint(&paint);
     111        adjustTextRenderMode(&paint, haveMultipleLayers);
    93112        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
    94113        paint.setColor(gc->fillColor().rgb());
     
    103122        gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
    104123        font->platformData().setupPaint(&paint);
     124        adjustTextRenderMode(&paint, haveMultipleLayers);
    105125        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
    106126        paint.setColor(gc->strokeColor().rgb());
     
    473493
    474494    TextRunWalker walker(run, point.x(), this);
     495    bool haveMultipleLayers = isCanvasMultiLayered(canvas);
    475496
    476497    while (walker.nextScriptRun()) {
    477498        if (fill) {
    478499            walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
     500            adjustTextRenderMode(&fillPaint, haveMultipleLayers);
    479501            canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), fillPaint);
    480502        }
     
    482504        if (stroke) {
    483505            walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
     506            adjustTextRenderMode(&strokePaint, haveMultipleLayers);
    484507            canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), strokePaint);
    485508        }
Note: See TracChangeset for help on using the changeset viewer.