Commit 29c4406c authored by caryclark@google.com's avatar caryclark@google.com

[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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@100283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 513d4873
2011-11-15 Cary Clark <caryclark@google.com>
[chromium-mac] Enable vertical text using Skia
https://bugs.webkit.org/show_bug.cgi?id=72137
Ignore vertical text tests on Skia on Mac for now.
Reviewed by Stephen White.
* platform/chromium/test_expectations.txt:
2011-11-15 Eric Carlson <eric.carlson@apple.com>
media-blocked-by-willsendrequest.html is flaky
......@@ -3886,6 +3886,37 @@ BUGWK72133 SKIP MAC : http/tests/inspector-enabled/dedicated-workers-list.html =
BUGWK59552 MAC DEBUG : http/tests/security/cross-frame-access-custom.html = PASS CRASH
// use Skia to draw vertical text directly instead of text-on-path
BUG_CARYCLARK MAC CPU : editing/selection/vertical-lr-ltr-extend-line-backward-br.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-lr-ltr-extend-line-forward-br.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-br.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-p.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-backward-wrap.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-br.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-p.html = IMAGE
BUG_CARYCLARK MAC CPU : editing/selection/vertical-rl-ltr-extend-line-forward-wrap.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/dynamic/text-combine.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-clear.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-repaint-in-regions.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/repaint/japanese-rl-selection-repaint.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/repaint/repaint-across-writing-mode-boundary.html = IMAGE
BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/text/international/vertical-text-glyph-test.html = IMAGE
BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/text/justify-ideograph-vertical.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/Kusa-Makura-background-canvas.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/border-vertical-lr.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/broken-ideographic-font.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/fallback-orientation.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-lr-text.html = IMAGE
BUG_CARYCLARK LION CPU : fast/writing-mode/japanese-rl-text-with-broken-font.html = IMAGE
BUG_CARYCLARK SNOWLEOPARD CPU RELEASE : fast/writing-mode/japanese-rl-text-with-broken-font.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-rl-text.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-ruby-vertical-lr.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/japanese-ruby-vertical-rl.html = IMAGE
BUG_CARYCLARK SNOWLEOPARD LION CPU : fast/writing-mode/text-orientation-basic.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-align-table-baseline.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-baseline-alignment.html = IMAGE
BUG_CARYCLARK MAC CPU : fast/writing-mode/vertical-font-fallback.html = IMAGE
BUGWK72271 MAC DEBUG : fast/loader/javascript-url-in-embed.html = PASS CRASH
BUGWK72272 WIN : security/crypto-random-values-types.html = TEXT PASS
......
2011-11-15 Cary Clark <caryclark@google.com>
[chromium-mac] Enable vertical text using Skia
https://bugs.webkit.org/show_bug.cgi?id=72137
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):
2011-11-15 Philip Rogers <pdr@google.com>
Fix SVG hit testing when padding is present
......
......@@ -79,6 +79,7 @@ static void setupPaint(SkPaint* paint, const SimpleFontData* fontData, const Fon
paint->setAntiAlias(shouldAntialias);
paint->setEmbeddedBitmapText(false);
paint->setTextSize(SkFloatToScalar(textSize));
paint->setVerticalText(platformData.orientation() == Vertical);
SkTypeface* typeface = SkCreateTypefaceFromCTFont(platformData.ctFont());
SkAutoUnref autoUnref(typeface);
paint->setTypeface(typeface);
......@@ -122,6 +123,8 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
SkScalar x = SkFloatToScalar(point.x());
SkScalar y = SkFloatToScalar(point.y());
if (font->platformData().orientation() == Vertical)
y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
// FIXME: text rendering speed:
// Android has code in their WebCore fork to special case when the
// GlyphBuffer has no advances other than the defaults. In that case the
......@@ -129,24 +132,24 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
// patches may be upstreamed to WebKit so we always use the slower path
// here.
const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs);
SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
SkPoint* pos = storage.get();
SkPoint* vPosBegin = storage2.get();
SkPoint* vPosEnd = storage3.get();
bool isVertical = font->platformData().orientation() == Vertical;
for (int i = 0; i < numGlyphs; i++) {
SkScalar myWidth = SkFloatToScalar(adv[i].width);
pos[i].set(x, y);
if (isVertical) {
vPosBegin[i].set(x + myWidth, y);
vPosEnd[i].set(x + myWidth, y - myWidth);
}
x += myWidth;
x += SkFloatToScalar(adv[i].width);
y += SkFloatToScalar(adv[i].height);
}
SkCanvas* canvas = gc->platformContext()->canvas();
if (font->platformData().orientation() == Vertical) {
canvas->save();
canvas->rotate(-90);
SkMatrix rotator;
rotator.reset();
rotator.setRotate(90);
rotator.mapPoints(pos, numGlyphs);
}
TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
// We draw text up to two times (once for fill, once for stroke).
......@@ -158,16 +161,7 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setColor(gc->fillColor().rgb());
if (isVertical) {
SkPath path;
for (int i = 0; i < numGlyphs; ++i) {
path.reset();
path.moveTo(vPosBegin[i]);
path.lineTo(vPosEnd[i]);
canvas->drawTextOnPath(glyphs + i, sizeof(uint16_t), path, 0, paint);
}
} else
canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
}
if ((textMode & TextModeStroke)
......@@ -187,17 +181,10 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
paint.setLooper(0);
}
if (isVertical) {
SkPath path;
for (int i = 0; i < numGlyphs; ++i) {
path.reset();
path.moveTo(vPosBegin[i]);
path.lineTo(vPosEnd[i]);
canvas->drawTextOnPath(glyphs + i, sizeof(uint16_t), path, 0, paint);
}
} else
canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
}
if (font->platformData().orientation() == Vertical)
canvas->restore();
}
} // namespace WebCore
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment