Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2495)

Unified Diff: Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp

Issue 617103003: Replace ENABLE_OPENTYPE_VERTICAL implementation with HarfBuzz (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@removeOpenTypeVertical
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/SimpleFontData.h ('k') | Source/platform/fonts/harfbuzz/HarfBuzzFaceCoreText.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp
diff --git a/Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp b/Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp
index bd597b1a157b1f9228f2d64b2e5c28dce9e25b70..2d23b4ccfb51fc231e2f82c4f50f960ec499f169 100644
--- a/Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp
+++ b/Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp
@@ -126,48 +126,16 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
SkScalar y = SkFloatToScalar(point.y());
const OpenTypeVerticalData* verticalData = font->verticalData();
- if (font->platformData().orientation() == Vertical && verticalData) {
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
- SkPoint* pos = storage.get();
+ bool drawVertically = font->platformData().orientation() == Vertical && verticalData;
- AffineTransform savedMatrix = gc->getCTM();
+ AffineTransform savedMatrix = gc->getCTM();
+ if (drawVertically) {
eae 2014/10/01 15:39:50 Could you move this down to line 150 so that it is
gc->concatCTM(AffineTransform(0, -1, 1, 0, point.x(), point.y()));
gc->concatCTM(AffineTransform(1, 0, 0, 1, -point.x(), -point.y()));
-
- const unsigned kMaxBufferLength = 256;
- Vector<FloatPoint, kMaxBufferLength> translations;
-
- const FontMetrics& metrics = font->fontMetrics();
- SkScalar verticalOriginX = SkFloatToScalar(point.x() + metrics.floatAscent() - metrics.floatAscent(IdeographicBaseline));
- float horizontalOffset = point.x();
-
- unsigned glyphIndex = 0;
- while (glyphIndex < numGlyphs) {
- unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
-
- const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex);
- translations.resize(chunkLength);
- verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], chunkLength, reinterpret_cast<float*>(&translations[0]));
-
- x = verticalOriginX;
- y = SkFloatToScalar(point.y() + horizontalOffset - point.x());
-
- float currentWidth = 0;
- for (unsigned i = 0; i < chunkLength; ++i, ++glyphIndex) {
- pos[i].set(
- x + SkIntToScalar(lroundf(translations[i].x())),
- y + -SkIntToScalar(-lroundf(currentWidth - translations[i].y())));
- currentWidth += glyphBuffer.advanceAt(from + glyphIndex);
- }
- horizontalOffset += currentWidth;
- paintGlyphs(gc, font, glyphs, chunkLength, pos, textRect);
- }
-
- gc->setCTM(savedMatrix);
- return;
}
if (!glyphBuffer.hasOffsets()) {
+ ASSERT(!drawVertically);
SkAutoSTMalloc<64, SkScalar> storage(numGlyphs);
SkScalar* xpos = storage.get();
const float* adv = glyphBuffer.advances(from);
@@ -188,15 +156,30 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const FloatSize* offsets = glyphBufferWithOffsets.offsets(from);
const float* advances = glyphBufferWithOffsets.advances(from);
SkScalar advanceSoFar = SkFloatToScalar(0);
- for (unsigned i = 0; i < numGlyphs; i++) {
- pos[i].set(
- x + SkFloatToScalar(offsets[i].width()) + advanceSoFar,
- y + SkFloatToScalar(offsets[i].height()));
- advanceSoFar += SkFloatToScalar(advances[i]);
+ if (drawVertically) {
+ const FontMetrics& metrics = font->fontMetrics();
+ x += SkFloatToScalar(metrics.floatAscent() - metrics.floatAscent(IdeographicBaseline));
+ for (unsigned i = 0; i < numGlyphs; i++) {
+ pos[i].set(
+ x + SkFloatToScalar(offsets[i].width()),
+ y + SkFloatToScalar(offsets[i].height()) + advanceSoFar);
+ advanceSoFar += SkFloatToScalar(advances[i]);
+ }
+ } else {
+ for (unsigned i = 0; i < numGlyphs; i++) {
+ pos[i].set(
+ x + SkFloatToScalar(offsets[i].width()) + advanceSoFar,
+ y + SkFloatToScalar(offsets[i].height()));
+ advanceSoFar += SkFloatToScalar(advances[i]);
+ }
}
const Glyph* glyphs = glyphBufferWithOffsets.glyphs(from);
paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect);
+
+ if (drawVertically) {
+ gc->setCTM(savedMatrix);
+ }
}
void Font::drawTextBlob(GraphicsContext* gc, const SkTextBlob* blob, const SkPoint& origin) const
« no previous file with comments | « Source/platform/fonts/SimpleFontData.h ('k') | Source/platform/fonts/harfbuzz/HarfBuzzFaceCoreText.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698