Changeset 100283 in webkit


Ignore:
Timestamp:
Nov 15, 2011, 8:17:25 AM (14 years ago)
Author:
caryclark@google.com
Message:

[chromium-mac] Enable vertical text using Skia
https://bugs.webkit.org/show_bug.cgi?id=72137

Source/WebCore:

Use Skia to draw vertical text. This is much
faster and has higher fidelity than the old method
of drawing text on a path.

The graphics context passed to Skia has been
rotated 90 degrees but the character advances
have not, so it is necessary to unrotate the canvas,
and re-rotate the positions.

This generates correct output (or, at least,
consistent with Chromium CG on Mac) for all vertical
text tests, one of which is mentioned below.

Reviewed by Stephen White.

Test: fast/writing-mode/text-orientation-basic.html

  • platform/graphics/skia/FontSkia.cpp:

(WebCore::setupPaint):
(WebCore::Font::drawGlyphs):

LayoutTests:

Ignore vertical text tests on Skia on Mac for now.

Reviewed by Stephen White.

  • platform/chromium/test_expectations.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r100282 r100283  
     12011-11-15  Cary Clark  <caryclark@google.com>
     2
     3        [chromium-mac] Enable vertical text using Skia
     4        https://bugs.webkit.org/show_bug.cgi?id=72137
     5
     6        Ignore vertical text tests on Skia on Mac for now.
     7
     8        Reviewed by Stephen White.
     9
     10        * platform/chromium/test_expectations.txt:
     11
    1122011-11-15  Eric Carlson  <eric.carlson@apple.com>
    213
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r100282 r100283  
    38873887BUGWK59552 MAC DEBUG : http/tests/security/cross-frame-access-custom.html = PASS CRASH
    38883888
     3889// use Skia to draw vertical text directly instead of text-on-path
     3890BUG_CARYCLARK MAC CPU : editing/selection/vertical-lr-ltr-extend-line-backward-br.html = IMAGE
     3891BUG_CARYCLARK MAC CPU : editing/selection/vertical-lr-ltr-extend-line-forward-br.html = IMAGE
     3892BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-br.html = IMAGE
     3893BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-p.html = IMAGE
     3894BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-wrap.html = IMAGE
     3895BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-br.html = IMAGE
     3896BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-p.html = IMAGE
     3897BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-wrap.html = IMAGE
     3898BUG_CARYCLARK MAC CPU : fast/dynamic/text-combine.html = IMAGE
     3899BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-clear.html = IMAGE
     3900BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-repaint-in-regions.html = IMAGE
     3901BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-repaint.html = IMAGE
     3902BUG_CARYCLARK MAC CPU : fast/repaint/repaint-across-writing-mode-boundary.html = IMAGE
     3903BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/text/international/vertical-text-glyph-test.html = IMAGE
     3904BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/text/justify-ideograph-vertical.html = IMAGE
     3905BUG_CARYCLARK MAC CPU : fast/writing-mode/Kusa-Makura-background-canvas.html = IMAGE
     3906BUG_CARYCLARK MAC CPU : fast/writing-mode/border-vertical-lr.html = IMAGE
     3907BUG_CARYCLARK MAC CPU : fast/writing-mode/broken-ideographic-font.html = IMAGE
     3908BUG_CARYCLARK MAC CPU : fast/writing-mode/fallback-orientation.html = IMAGE
     3909BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-lr-text.html = IMAGE
     3910BUG_CARYCLARK LION CPU : fast/writing-mode/japanese-rl-text-with-broken-font.html = IMAGE
     3911BUG_CARYCLARK SNOWLEOPARD CPU RELEASE : fast/writing-mode/japanese-rl-text-with-broken-font.html = IMAGE
     3912BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-rl-text.html = IMAGE
     3913BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-ruby-vertical-lr.html = IMAGE
     3914BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-ruby-vertical-rl.html = IMAGE
     3915BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/writing-mode/text-orientation-basic.html = IMAGE
     3916BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-align-table-baseline.html = IMAGE
     3917BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-baseline-alignment.html = IMAGE
     3918BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-font-fallback.html = IMAGE
     3919
    38893920BUGWK72271 MAC DEBUG : fast/loader/javascript-url-in-embed.html = PASS CRASH
    38903921
  • trunk/Source/WebCore/ChangeLog

    r100280 r100283  
     12011-11-15  Cary Clark  <caryclark@google.com>
     2
     3        [chromium-mac] Enable vertical text using Skia
     4        https://bugs.webkit.org/show_bug.cgi?id=72137
     5
     6        Use Skia to draw vertical text. This is much
     7        faster and has higher fidelity than the old method
     8        of drawing text on a path.
     9
     10        The graphics context passed to Skia has been
     11        rotated 90 degrees but the character advances
     12        have not, so it is necessary to unrotate the canvas,
     13        and re-rotate the positions.
     14
     15        This generates correct output (or, at least,
     16        consistent with Chromium CG on Mac) for all vertical
     17        text tests, one of which is mentioned below.
     18       
     19        Reviewed by Stephen White.
     20
     21        Test: fast/writing-mode/text-orientation-basic.html
     22
     23        * platform/graphics/skia/FontSkia.cpp:
     24        (WebCore::setupPaint):
     25        (WebCore::Font::drawGlyphs):
     26
    1272011-11-15  Philip Rogers  <pdr@google.com>
    228
  • trunk/Source/WebCore/platform/graphics/skia/FontSkia.cpp

    r97058 r100283  
    8080    paint->setEmbeddedBitmapText(false);
    8181    paint->setTextSize(SkFloatToScalar(textSize));
     82    paint->setVerticalText(platformData.orientation() == Vertical);
    8283    SkTypeface* typeface = SkCreateTypefaceFromCTFont(platformData.ctFont());
    8384    SkAutoUnref autoUnref(typeface);
     
    123124    SkScalar y = SkFloatToScalar(point.y());
    124125
     126    if (font->platformData().orientation() == Vertical)
     127        y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
    125128    // FIXME: text rendering speed:
    126129    // Android has code in their WebCore fork to special case when the
     
    130133    // here.
    131134    const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
    132     SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs);
     135    SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
    133136    SkPoint* pos = storage.get();
    134     SkPoint* vPosBegin = storage2.get();
    135     SkPoint* vPosEnd = storage3.get();
    136137
    137     bool isVertical = font->platformData().orientation() == Vertical;
    138138    for (int i = 0; i < numGlyphs; i++) {
    139         SkScalar myWidth = SkFloatToScalar(adv[i].width);
    140139        pos[i].set(x, y);
    141         if (isVertical) {
    142             vPosBegin[i].set(x + myWidth, y);
    143             vPosEnd[i].set(x + myWidth, y - myWidth);
    144         }
    145         x += myWidth;
     140        x += SkFloatToScalar(adv[i].width);
    146141        y += SkFloatToScalar(adv[i].height);
    147142    }
    148143
    149144    SkCanvas* canvas = gc->platformContext()->canvas();
     145    if (font->platformData().orientation() == Vertical) {
     146        canvas->save();
     147        canvas->rotate(-90);
     148        SkMatrix rotator;
     149        rotator.reset();
     150        rotator.setRotate(90);
     151        rotator.mapPoints(pos, numGlyphs);
     152    }
    150153    TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
    151154
     
    159162        paint.setColor(gc->fillColor().rgb());
    160163
    161         if (isVertical) {
    162             SkPath path;
    163             for (int i = 0; i < numGlyphs; ++i) {
    164                 path.reset();
    165                 path.moveTo(vPosBegin[i]);
    166                 path.lineTo(vPosEnd[i]);
    167                 canvas->drawTextOnPath(glyphs + i, sizeof(uint16_t), path, 0, paint);
    168             }
    169         } else
    170             canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
     164        canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
    171165    }
    172166
     
    188182        }
    189183
    190         if (isVertical) {
    191             SkPath path;
    192             for (int i = 0; i < numGlyphs; ++i) {
    193                 path.reset();
    194                 path.moveTo(vPosBegin[i]);
    195                 path.lineTo(vPosEnd[i]);
    196                 canvas->drawTextOnPath(glyphs + i, sizeof(uint16_t), path, 0, paint);
    197             }
    198         } else
    199             canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
     184        canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
    200185    }
     186    if (font->platformData().orientation() == Vertical)
     187        canvas->restore();
    201188}
    202189
Note: See TracChangeset for help on using the changeset viewer.