| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // current versions of all compilers we care about and avoids making | 771 // current versions of all compilers we care about and avoids making |
| 772 // a copy of the string. | 772 // a copy of the string. |
| 773 COMPILE_ASSERT(sizeof(UChar) == sizeof(uint16_t), UChar_is_the_same_size_as_
uint16_t); | 773 COMPILE_ASSERT(sizeof(UChar) == sizeof(uint16_t), UChar_is_the_same_size_as_
uint16_t); |
| 774 return reinterpret_cast<const uint16_t*>(src); | 774 return reinterpret_cast<const uint16_t*>(src); |
| 775 } | 775 } |
| 776 | 776 |
| 777 bool HarfBuzzShaper::shapeHarfBuzzRuns() | 777 bool HarfBuzzShaper::shapeHarfBuzzRuns() |
| 778 { | 778 { |
| 779 HarfBuzzScopedPtr<hb_buffer_t> harfBuzzBuffer(hb_buffer_create(), hb_buffer_
destroy); | 779 HarfBuzzScopedPtr<hb_buffer_t> harfBuzzBuffer(hb_buffer_create(), hb_buffer_
destroy); |
| 780 | 780 |
| 781 hb_buffer_set_unicode_funcs(harfBuzzBuffer.get(), hb_icu_get_unicode_funcs()
); | |
| 782 HarfBuzzRunCache& runCache = harfBuzzRunCache(); | 781 HarfBuzzRunCache& runCache = harfBuzzRunCache(); |
| 783 | 782 |
| 784 for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) { | 783 for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) { |
| 785 unsigned runIndex = m_run.rtl() ? m_harfBuzzRuns.size() - i - 1 : i; | 784 unsigned runIndex = m_run.rtl() ? m_harfBuzzRuns.size() - i - 1 : i; |
| 786 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); | 785 HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get(); |
| 787 const SimpleFontData* currentFontData = currentRun->fontData(); | 786 const SimpleFontData* currentFontData = currentRun->fontData(); |
| 788 if (currentFontData->isSVGFont()) | 787 if (currentFontData->isSVGFont()) |
| 789 return false; | 788 return false; |
| 790 | 789 |
| 791 FontPlatformData* platformData = const_cast<FontPlatformData*>(¤tF
ontData->platformData()); | 790 FontPlatformData* platformData = const_cast<FontPlatformData*>(¤tF
ontData->platformData()); |
| 792 HarfBuzzFace* face = platformData->harfBuzzFace(); | 791 HarfBuzzFace* face = platformData->harfBuzzFace(); |
| 793 if (!face) | 792 if (!face) |
| 794 return false; | 793 return false; |
| 795 | 794 |
| 796 hb_buffer_set_script(harfBuzzBuffer.get(), currentRun->script()); | 795 hb_buffer_set_script(harfBuzzBuffer.get(), currentRun->script()); |
| 797 hb_buffer_set_direction(harfBuzzBuffer.get(), currentRun->rtl() ? HB_DIR
ECTION_RTL : HB_DIRECTION_LTR); | 796 hb_buffer_set_direction(harfBuzzBuffer.get(), currentRun->rtl() ? HB_DIR
ECTION_RTL : HB_DIRECTION_LTR); |
| 798 | 797 |
| 799 hb_segment_properties_t props; | 798 hb_segment_properties_t props; |
| 800 hb_buffer_get_segment_properties(harfBuzzBuffer.get(), &props); | 799 hb_buffer_get_segment_properties(harfBuzzBuffer.get(), &props); |
| 801 | 800 |
| 802 const UChar* src = m_normalizedBuffer.get() + currentRun->startIndex(); | 801 const UChar* src = m_normalizedBuffer.get() + currentRun->startIndex(); |
| 803 std::wstring key(src, src + currentRun->numCharacters()); | 802 std::wstring key(src, src + currentRun->numCharacters()); |
| 804 | 803 |
| 805 CachedShapingResults* cachedResults = runCache.find(key); | 804 CachedShapingResults* cachedResults = runCache.find(key); |
| 806 if (cachedResults) { | 805 if (cachedResults) { |
| 807 if (cachedResults->dir == props.direction && cachedResults->font ==
*m_font) { | 806 if (cachedResults->dir == props.direction && cachedResults->font ==
*m_font) { |
| 808 currentRun->applyShapeResult(cachedResults->buffer); | 807 currentRun->applyShapeResult(cachedResults->buffer); |
| 809 setGlyphPositionsForHarfBuzzRun(currentRun, cachedResults->buffe
r); | 808 setGlyphPositionsForHarfBuzzRun(currentRun, cachedResults->buffe
r); |
| 810 | 809 |
| 811 hb_buffer_reset(harfBuzzBuffer.get()); | 810 hb_buffer_clear_contents(harfBuzzBuffer.get()); |
| 812 | 811 |
| 813 runCache.moveToBack(cachedResults); | 812 runCache.moveToBack(cachedResults); |
| 814 | 813 |
| 815 continue; | 814 continue; |
| 816 } | 815 } |
| 817 | 816 |
| 818 runCache.remove(cachedResults); | 817 runCache.remove(cachedResults); |
| 819 } | 818 } |
| 820 | 819 |
| 821 // Add a space as pre-context to the buffer. This prevents showing dotte
d-circle | 820 // Add a space as pre-context to the buffer. This prevents showing dotte
d-circle |
| (...skipping 15 matching lines...) Expand all Loading... |
| 837 | 836 |
| 838 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de
stroy); | 837 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de
stroy); |
| 839 | 838 |
| 840 hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty()
? 0 : m_features.data(), m_features.size()); | 839 hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty()
? 0 : m_features.data(), m_features.size()); |
| 841 currentRun->applyShapeResult(harfBuzzBuffer.get()); | 840 currentRun->applyShapeResult(harfBuzzBuffer.get()); |
| 842 setGlyphPositionsForHarfBuzzRun(currentRun, harfBuzzBuffer.get()); | 841 setGlyphPositionsForHarfBuzzRun(currentRun, harfBuzzBuffer.get()); |
| 843 | 842 |
| 844 runCache.insert(key, new CachedShapingResults(harfBuzzBuffer.get(), m_fo
nt, props.direction)); | 843 runCache.insert(key, new CachedShapingResults(harfBuzzBuffer.get(), m_fo
nt, props.direction)); |
| 845 | 844 |
| 846 harfBuzzBuffer.set(hb_buffer_create()); | 845 harfBuzzBuffer.set(hb_buffer_create()); |
| 847 hb_buffer_set_unicode_funcs(harfBuzzBuffer.get(), hb_icu_get_unicode_fun
cs()); | |
| 848 } | 846 } |
| 849 | 847 |
| 850 return true; | 848 return true; |
| 851 } | 849 } |
| 852 | 850 |
| 853 void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb
_buffer_t* harfBuzzBuffer) | 851 void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb
_buffer_t* harfBuzzBuffer) |
| 854 { | 852 { |
| 855 const SimpleFontData* currentFontData = currentRun->fontData(); | 853 const SimpleFontData* currentFontData = currentRun->fontData(); |
| 856 hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfBuzzBuffer, 0); | 854 hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfBuzzBuffer, 0); |
| 857 hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfBuzz
Buffer, 0); | 855 hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfBuzz
Buffer, 0); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 if (!foundToX) | 1085 if (!foundToX) |
| 1088 toX = m_run.rtl() ? 0 : m_totalWidth; | 1086 toX = m_run.rtl() ? 0 : m_totalWidth; |
| 1089 | 1087 |
| 1090 // Using floorf() and roundf() as the same as mac port. | 1088 // Using floorf() and roundf() as the same as mac port. |
| 1091 if (fromX < toX) | 1089 if (fromX < toX) |
| 1092 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); | 1090 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); |
| 1093 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); | 1091 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); |
| 1094 } | 1092 } |
| 1095 | 1093 |
| 1096 } // namespace WebCore | 1094 } // namespace WebCore |
| OLD | NEW |