Changeset 126907 in webkit
- Timestamp:
- Aug 28, 2012 11:52:17 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126902 r126907 1 2012-08-28 Koji Ishii <kojiishi@gmail.com> 2 3 OPENTYPE_VERTICAL support for Chromium Win 4 https://bugs.webkit.org/show_bug.cgi?id=94822 5 6 Reviewed by Tony Chang. 7 8 To fix bug 51450 - Glyphs in vertical text tests are rotated 90 degrees clockwise on Chromium Windows, 9 this patch adds support of OPENTYPE_VERTICAL feature for Chromium Windows. 10 Since enabling OPENTYPE_VERTICAL feature would require rather a big number of tests to rebaseline, 11 the actual fix is separated into this patch, and the feature will be enabled in bug 51450, 12 so that it is easier to revert on any perf regressions, as suggested by Tony in comment #50 of bug 51450. 13 14 All changes in this patch are behind #if ENABLE(OPENTYPE_VERTICAL) and therefore no tests are included in this patch. 15 All tests in fast/writing-modes currently skipped will be enabled in bug 51450. 16 17 * WebCore.gyp/WebCore.gyp: Added platform/graphics/opentype/OpenType*. 18 * WebCore.gypi: Ditto. 19 * platform/graphics/FontCache.h: SKia uses uint32_t as FontFileKey. 20 * platform/graphics/GlyphPageTreeNode.cpp: 21 (WebCore::fill): Replace vertical alternate glyphs if vertical flow. 22 * platform/graphics/SimpleFontData.cpp: Added m_verticalData. 23 (WebCore::SimpleFontData::SimpleFontData): 24 * platform/graphics/SimpleFontData.h: 25 (WebCore::SimpleFontData::verticalData): 26 (SimpleFontData): 27 (WebCore::SimpleFontData::widthForGlyph): 28 * platform/graphics/chromium/FontChromiumWin.cpp: 29 (WebCore::Font::drawGlyphs): Draw glyphs verticaly if font->verticalData(). 30 * platform/graphics/chromium/FontPlatformDataChromiumWin.cpp: 31 (WebCore::FontPlatformData::verticalData): Added. 32 (WebCore): 33 (WebCore::FontPlatformData::openTypeTable): Added. 34 * platform/graphics/chromium/FontPlatformDataChromiumWin.h: 35 (WebCore): 36 (FontPlatformData): Added verticalData() and openTypeTable(). 37 1 38 2012-08-28 Andy Estes <aestes@apple.com> 2 39 -
trunk/Source/WebCore/WebCore.gyp/WebCore.gyp
r126857 r126907 1845 1845 ['exclude', 'Posix\\.cpp$'], 1846 1846 1847 ['include', 'platform/graphics/opentype/OpenTypeTypes\\.h$'], 1848 ['include', 'platform/graphics/opentype/OpenTypeVerticalData\\.cpp$'], 1849 ['include', 'platform/graphics/opentype/OpenTypeVerticalData\\.h$'], 1850 1847 1851 # The Chromium Win currently uses GlyphPageTreeNodeChromiumWin.cpp from 1848 1852 # platform/graphics/chromium, included by regex above, instead. -
trunk/Source/WebCore/WebCore.gypi
r126890 r126907 3874 3874 'platform/graphics/opentype/OpenTypeSanitizer.cpp', 3875 3875 'platform/graphics/opentype/OpenTypeSanitizer.h', 3876 'platform/graphics/opentype/OpenTypeTypes.h', 3876 3877 'platform/graphics/opentype/OpenTypeUtilities.cpp', 3877 3878 'platform/graphics/opentype/OpenTypeUtilities.h', 3879 'platform/graphics/opentype/OpenTypeVerticalData.cpp', 3880 'platform/graphics/opentype/OpenTypeVerticalData.h', 3878 3881 'platform/graphics/openvg/EGLDisplayOpenVG.cpp', 3879 3882 'platform/graphics/openvg/EGLDisplayOpenVG.h', -
trunk/Source/WebCore/platform/graphics/FontCache.h
r124397 r126907 107 107 108 108 #if ENABLE(OPENTYPE_VERTICAL) 109 #if USE(SKIA) 110 typedef uint32_t FontFileKey; 111 #else 109 112 typedef AtomicString FontFileKey; 113 #endif 110 114 OpenTypeVerticalData* getVerticalData(const FontFileKey&, const FontPlatformData&); 111 115 #endif -
trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
r126837 r126907 30 30 #include "GlyphPageTreeNode.h" 31 31 32 #include "OpenTypeVerticalData.h" 32 33 #include "PlatformString.h" 33 34 #include "SegmentedFontData.h" … … 131 132 return additionalFontData->fillSVGGlyphPage(pageToFill, offset, length, buffer, bufferLength, fontData); 132 133 #endif 133 return pageToFill->fill(offset, length, buffer, bufferLength, fontData); 134 bool hasGlyphs = pageToFill->fill(offset, length, buffer, bufferLength, fontData); 135 #if ENABLE(OPENTYPE_VERTICAL) 136 if (hasGlyphs && fontData->verticalData()) 137 fontData->verticalData()->substituteWithVerticalGlyphs(fontData, pageToFill, offset, length); 138 #endif 139 return hasGlyphs; 134 140 } 135 141 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r125766 r126907 33 33 #include "Font.h" 34 34 #include "FontCache.h" 35 #include "OpenTypeVerticalData.h" 35 36 36 37 #include <wtf/MathExtras.h> … … 50 51 , m_isTextOrientationFallback(isTextOrientationFallback) 51 52 , m_isBrokenIdeographFallback(false) 53 #if ENABLE(OPENTYPE_VERTICAL) 54 , m_verticalData(0) 55 #endif 52 56 , m_hasVerticalGlyphs(false) 53 57 { … … 55 59 platformGlyphInit(); 56 60 platformCharWidthInit(); 61 #if ENABLE(OPENTYPE_VERTICAL) 62 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { 63 m_verticalData = platformData.verticalData(); 64 m_hasVerticalGlyphs = m_verticalData && m_verticalData->hasVerticalMetrics(); 65 } 66 #endif 57 67 } 58 68 … … 65 75 , m_isTextOrientationFallback(false) 66 76 , m_isBrokenIdeographFallback(false) 77 #if ENABLE(OPENTYPE_VERTICAL) 78 , m_verticalData(0) 79 #endif 67 80 , m_hasVerticalGlyphs(false) 68 81 { -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r126456 r126907 89 89 const FontPlatformData& platformData() const { return m_platformData; } 90 90 #if ENABLE(OPENTYPE_VERTICAL) 91 const OpenTypeVerticalData* verticalData() const { return 0; } // FIXME: implement91 const OpenTypeVerticalData* verticalData() const { return m_verticalData; } 92 92 #endif 93 93 … … 230 230 mutable OwnPtr<GlyphMetricsMap<FloatRect> > m_glyphToBoundsMap; 231 231 mutable GlyphMetricsMap<float> m_glyphToWidthMap; 232 #if ENABLE(OPENTYPE_VERTICAL) 233 const OpenTypeVerticalData* m_verticalData; 234 #endif 232 235 233 236 bool m_treatAsFixedPitch; … … 318 321 if (m_fontData) 319 322 width = m_fontData->widthForSVGGlyph(glyph, m_platformData.size()); 323 #if ENABLE(OPENTYPE_VERTICAL) 324 else if (m_verticalData) 325 #if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROMIUM) 326 width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset; 327 #else 328 width = m_verticalData->advanceHeight(this, glyph); 329 #endif 330 #endif 320 331 else 321 332 width = platformWidthForGlyph(glyph); -
trunk/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
r113345 r126907 391 391 // the arrays of characters and advances. 392 392 const int kMaxBufferLength = 256; 393 Vector<WORD, kMaxBufferLength> glyphs;394 393 Vector<int, kMaxBufferLength> advances; 395 394 int glyphIndex = 0; // The starting glyph of the current chunk. 396 395 396 float horizontalOffset = point.x(); // The floating point offset of the left side of the current glyph. 397 #if ENABLE(OPENTYPE_VERTICAL) 398 const OpenTypeVerticalData* verticalData = font->verticalData(); 399 if (verticalData) { 400 Vector<FloatPoint, kMaxBufferLength> translations; 401 Vector<GOFFSET, kMaxBufferLength> offsets; 402 403 // Skia doesn't have matrix for glyph coordinate space, so we rotate back the CTM. 404 AffineTransform savedMatrix = graphicsContext->getCTM(); 405 graphicsContext->concatCTM(AffineTransform(0, -1, 1, 0, point.x(), point.y())); 406 graphicsContext->concatCTM(AffineTransform(1, 0, 0, 1, -point.x(), -point.y())); 407 408 const FontMetrics& metrics = font->fontMetrics(); 409 SkScalar verticalOriginX = SkFloatToScalar(point.x() + metrics.floatAscent() - metrics.floatAscent(IdeographicBaseline)); 410 while (glyphIndex < numGlyphs) { 411 // How many chars will be in this chunk? 412 int curLen = std::min(kMaxBufferLength, numGlyphs - glyphIndex); 413 414 const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex); 415 translations.resize(curLen); 416 verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], curLen, reinterpret_cast<float*>(&translations[0])); 417 // To position glyphs vertically, we use offsets instead of advances. 418 advances.resize(curLen); 419 advances.fill(0); 420 offsets.resize(curLen); 421 float currentWidth = 0; 422 for (int i = 0; i < curLen; ++i, ++glyphIndex) { 423 offsets[i].du = lroundf(translations[i].x()); 424 offsets[i].dv = -lroundf(currentWidth - translations[i].y()); 425 currentWidth += glyphBuffer.advanceAt(from + glyphIndex); 426 } 427 SkPoint origin; 428 origin.set(verticalOriginX, SkFloatToScalar(point.y() + horizontalOffset - point.x())); 429 horizontalOffset += currentWidth; 430 paintSkiaText(graphicsContext, font->platformData(), curLen, &glyphs[0], &advances[0], &offsets[0], &origin); 431 } 432 433 graphicsContext->setCTM(savedMatrix); 434 return; 435 } 436 #endif 437 397 438 // In order to round all offsets to the correct pixel boundary, this code keeps track of the absolute position 398 439 // of each glyph in floating point units and rounds to integer advances at the last possible moment. 399 440 400 float horizontalOffset = point.x(); // The floating point offset of the left side of the current glyph.401 441 int lastHorizontalOffsetRounded = lroundf(horizontalOffset); // The rounded offset of the left side of the last glyph rendered. 442 Vector<WORD, kMaxBufferLength> glyphs; 402 443 while (glyphIndex < numGlyphs) { 403 444 // How many chars will be in this chunk? -
trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
r126312 r126907 192 192 } 193 193 194 #if ENABLE(OPENTYPE_VERTICAL) 195 const OpenTypeVerticalData* FontPlatformData::verticalData() const 196 { 197 SkFontID id = typeface()->uniqueID(); 198 return fontCache()->getVerticalData(id, *this); 199 } 200 201 PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const 202 { 203 HWndDC hdc(0); 204 HGDIOBJ oldFont = SelectObject(hdc, hfont()); 205 206 DWORD size = GetFontData(hdc, table, 0, 0, 0); 207 RefPtr<SharedBuffer> buffer; 208 if (size != GDI_ERROR) { 209 buffer = SharedBuffer::create(size); 210 DWORD result = GetFontData(hdc, table, 0, (PVOID)buffer->data(), size); 211 ASSERT(result == size); 212 } 213 214 SelectObject(hdc, oldFont); 215 return buffer.release(); 216 } 217 #endif 218 194 219 #ifndef NDEBUG 195 220 String FontPlatformData::description() const -
trunk/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
r126312 r126907 36 36 37 37 #include "FontOrientation.h" 38 #include "SharedBuffer.h" 38 39 #include "SkTypeface.h" 39 40 #include <wtf/Forward.h> … … 54 55 55 56 class FontDescription; 57 #if ENABLE(OPENTYPE_VERTICAL) 58 class OpenTypeVerticalData; 59 #endif 56 60 57 61 class FontPlatformData { … … 92 96 return m_font == other.m_font && m_size == other.m_size && m_orientation == other.m_orientation; 93 97 } 98 99 #if ENABLE(OPENTYPE_VERTICAL) 100 const OpenTypeVerticalData* verticalData() const; 101 PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const; 102 #endif 94 103 95 104 #ifndef NDEBUG
Note: See TracChangeset
for help on using the changeset viewer.