| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef HarfBuzzShaper_h | 31 #ifndef HarfBuzzShaper_h |
| 32 #define HarfBuzzShaper_h | 32 #define HarfBuzzShaper_h |
| 33 | 33 |
| 34 #include "platform/fonts/FontDescription.h" | |
| 35 #include "platform/fonts/shaping/ShapeResult.h" | 34 #include "platform/fonts/shaping/ShapeResult.h" |
| 36 #include "platform/geometry/FloatPoint.h" | |
| 37 #include "platform/geometry/FloatRect.h" | |
| 38 #include "platform/text/TextRun.h" | 35 #include "platform/text/TextRun.h" |
| 39 #include "wtf/Allocator.h" | 36 #include "wtf/Allocator.h" |
| 40 #include "wtf/Deque.h" | 37 #include "wtf/Deque.h" |
| 41 #include "wtf/HashSet.h" | |
| 42 #include "wtf/Vector.h" | 38 #include "wtf/Vector.h" |
| 43 #include "wtf/text/CharacterNames.h" | |
| 44 #include <hb.h> | 39 #include <hb.h> |
| 45 #include <memory> | 40 #include <memory> |
| 46 #include <unicode/uscript.h> | 41 #include <unicode/uscript.h> |
| 47 | 42 |
| 48 namespace blink { | 43 namespace blink { |
| 49 | 44 |
| 50 class Font; | 45 class Font; |
| 51 class SimpleFontData; | 46 class SimpleFontData; |
| 52 class HarfBuzzShaper; | 47 class HarfBuzzShaper; |
| 53 class UnicodeRangeSet; | 48 class UnicodeRangeSet; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Now this sub run is successfully processed and can be appended to | 125 // Now this sub run is successfully processed and can be appended to |
| 131 // ShapeResult. A new ShapeResult::RunInfo is created. The logic in | 126 // ShapeResult. A new ShapeResult::RunInfo is created. The logic in |
| 132 // insertRunIntoShapeResult then takes care of merging the shape result into | 127 // insertRunIntoShapeResult then takes care of merging the shape result into |
| 133 // the right position the vector of RunInfos in ShapeResult. | 128 // the right position the vector of RunInfos in ShapeResult. |
| 134 // | 129 // |
| 135 // Shaping then continues analogously for the remaining Hiragana Japanese | 130 // Shaping then continues analogously for the remaining Hiragana Japanese |
| 136 // sub-run, and the result is inserted into ShapeResult as well. | 131 // sub-run, and the result is inserted into ShapeResult as well. |
| 137 class PLATFORM_EXPORT HarfBuzzShaper final { | 132 class PLATFORM_EXPORT HarfBuzzShaper final { |
| 138 public: | 133 public: |
| 139 HarfBuzzShaper(const TextRun&); | 134 HarfBuzzShaper(const TextRun&); |
| 140 PassRefPtr<ShapeResult> shapeResult(const Font*); | 135 PassRefPtr<ShapeResult> shapeResult(const Font*) const; |
| 141 ~HarfBuzzShaper() {} | 136 ~HarfBuzzShaper() {} |
| 142 | 137 |
| 143 enum HolesQueueItemAction { HolesQueueNextFont, HolesQueueRange }; | 138 enum HolesQueueItemAction { HolesQueueNextFont, HolesQueueRange }; |
| 144 | 139 |
| 145 struct HolesQueueItem { | 140 struct HolesQueueItem { |
| 146 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 141 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 147 HolesQueueItemAction m_action; | 142 HolesQueueItemAction m_action; |
| 148 unsigned m_startIndex; | 143 unsigned m_startIndex; |
| 149 unsigned m_numCharacters; | 144 unsigned m_numCharacters; |
| 150 HolesQueueItem(HolesQueueItemAction action, unsigned start, unsigned num) | 145 HolesQueueItem(HolesQueueItemAction action, unsigned start, unsigned num) |
| 151 : m_action(action), m_startIndex(start), m_numCharacters(num){}; | 146 : m_action(action), m_startIndex(start), m_numCharacters(num){}; |
| 152 }; | 147 }; |
| 153 | 148 |
| 154 using FeaturesVector = Vector<hb_feature_t, 6>; | |
| 155 | |
| 156 private: | 149 private: |
| 157 inline bool shapeRange(hb_buffer_t*, | |
| 158 const Font*, | |
| 159 const FeaturesVector&, | |
| 160 const SimpleFontData*, | |
| 161 PassRefPtr<UnicodeRangeSet>, | |
| 162 UScriptCode, | |
| 163 hb_language_t); | |
| 164 bool extractShapeResults(hb_buffer_t*, | 150 bool extractShapeResults(hb_buffer_t*, |
| 165 ShapeResult*, | 151 ShapeResult*, |
| 166 bool& fontCycleQueued, | 152 bool& fontCycleQueued, |
| 167 Deque<HolesQueueItem>*, | 153 Deque<HolesQueueItem>*, |
| 168 const HolesQueueItem&, | 154 const HolesQueueItem&, |
| 169 const Font*, | 155 const Font*, |
| 170 const SimpleFontData*, | 156 const SimpleFontData*, |
| 171 UScriptCode, | 157 UScriptCode, |
| 172 bool isLastResort); | 158 bool isLastResort) const; |
| 173 bool collectFallbackHintChars(const Deque<HolesQueueItem>&, | 159 bool collectFallbackHintChars(const Deque<HolesQueueItem>&, |
| 174 Vector<UChar32>& hint); | 160 Vector<UChar32>& hint) const; |
| 175 | 161 |
| 176 void insertRunIntoShapeResult( | 162 void insertRunIntoShapeResult( |
| 177 ShapeResult*, | 163 ShapeResult*, |
| 178 std::unique_ptr<ShapeResult::RunInfo> runToInsert, | 164 std::unique_ptr<ShapeResult::RunInfo> runToInsert, |
| 179 unsigned startGlyph, | 165 unsigned startGlyph, |
| 180 unsigned numGlyphs, | 166 unsigned numGlyphs, |
| 181 hb_buffer_t*); | 167 hb_buffer_t*); |
| 182 | 168 |
| 183 const TextRun& m_textRun; | 169 const TextRun& m_textRun; |
| 184 std::unique_ptr<UChar[]> m_normalizedBuffer; | 170 std::unique_ptr<UChar[]> m_normalizedBuffer; |
| 185 unsigned m_normalizedBufferLength; | 171 unsigned m_normalizedBufferLength; |
| 186 }; | 172 }; |
| 187 | 173 |
| 188 } // namespace blink | 174 } // namespace blink |
| 189 | 175 |
| 190 #endif // HarfBuzzShaper_h | 176 #endif // HarfBuzzShaper_h |
| OLD | NEW |