| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/fonts/shaping/CachingWordShapeIterator.h" | 5 #include "platform/fonts/shaping/CachingWordShapeIterator.h" |
| 6 | 6 |
| 7 #include "platform/fonts/shaping/HarfBuzzShaper.h" | 7 #include "platform/fonts/shaping/HarfBuzzShaper.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 PassRefPtr<const ShapeResult> CachingWordShapeIterator::shapeWordWithoutSpacing( | 11 PassRefPtr<const ShapeResult> CachingWordShapeIterator::shapeWordWithoutSpacing( |
| 12 const TextRun& wordRun, | 12 const TextRun& wordRun, |
| 13 const Font* font) { | 13 const Font* font) { |
| 14 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun, ShapeCacheEntry()); | 14 ShapeCacheEntry* cacheEntry = m_shapeCache->add(wordRun, ShapeCacheEntry()); |
| 15 if (cacheEntry && cacheEntry->m_shapeResult) | 15 if (cacheEntry && cacheEntry->m_shapeResult) |
| 16 return cacheEntry->m_shapeResult; | 16 return cacheEntry->m_shapeResult; |
| 17 | 17 |
| 18 unsigned wordLength = 0; | 18 unsigned wordLength = 0; |
| 19 std::unique_ptr<UChar[]> wordText = wordRun.normalizedUTF16(&wordLength); | 19 std::unique_ptr<UChar[]> wordText = wordRun.normalizedUTF16(&wordLength); |
| 20 | 20 |
| 21 HarfBuzzShaper shaper(wordText.get(), wordLength, wordRun.direction()); | 21 HarfBuzzShaper shaper(wordText.get(), wordLength); |
| 22 RefPtr<const ShapeResult> shapeResult = shaper.shapeResult(font); | 22 RefPtr<const ShapeResult> shapeResult = |
| 23 shaper.shape(font, wordRun.direction()); |
| 23 if (!shapeResult) | 24 if (!shapeResult) |
| 24 return nullptr; | 25 return nullptr; |
| 25 | 26 |
| 26 if (cacheEntry) | 27 if (cacheEntry) |
| 27 cacheEntry->m_shapeResult = shapeResult; | 28 cacheEntry->m_shapeResult = shapeResult; |
| 28 | 29 |
| 29 return shapeResult.release(); | 30 return shapeResult.release(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 } // namespace blink | 33 } // namespace blink |
| OLD | NEW |