| 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 #ifndef ShapeResultBuffer_h | 5 #ifndef ShapeResultBuffer_h |
| 6 #define ShapeResultBuffer_h | 6 #define ShapeResultBuffer_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/fonts/shaping/ShapeResult.h" | 9 #include "platform/fonts/shaping/ShapeResult.h" |
| 10 #include "platform/wtf/Allocator.h" | 10 #include "platform/wtf/Allocator.h" |
| 11 #include "platform/wtf/RefPtr.h" | 11 #include "platform/wtf/RefPtr.h" |
| 12 #include "platform/wtf/Vector.h" | 12 #include "platform/wtf/Vector.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 struct CharacterRange; | 16 struct CharacterRange; |
| 17 class FontDescription; | 17 class FontDescription; |
| 18 struct GlyphData; | 18 struct GlyphData; |
| 19 class ShapeResultBloberizer; | 19 class ShapeResultBloberizer; |
| 20 class TextRun; | 20 class TextRun; |
| 21 struct TextRunPaintInfo; | |
| 22 | 21 |
| 23 class PLATFORM_EXPORT ShapeResultBuffer { | 22 class PLATFORM_EXPORT ShapeResultBuffer { |
| 24 WTF_MAKE_NONCOPYABLE(ShapeResultBuffer); | 23 WTF_MAKE_NONCOPYABLE(ShapeResultBuffer); |
| 25 STACK_ALLOCATED(); | 24 STACK_ALLOCATED(); |
| 26 | 25 |
| 27 public: | 26 public: |
| 28 ShapeResultBuffer() : has_vertical_offsets_(false) {} | 27 ShapeResultBuffer() : has_vertical_offsets_(false) {} |
| 29 | 28 |
| 30 void AppendResult(PassRefPtr<const ShapeResult> result) { | 29 void AppendResult(PassRefPtr<const ShapeResult> result) { |
| 31 has_vertical_offsets_ |= result->HasVerticalOffsets(); | 30 has_vertical_offsets_ |= result->HasVerticalOffsets(); |
| 32 results_.push_back(std::move(result)); | 31 results_.push_back(std::move(result)); |
| 33 } | 32 } |
| 34 | 33 |
| 35 bool HasVerticalOffsets() const { return has_vertical_offsets_; } | 34 bool HasVerticalOffsets() const { return has_vertical_offsets_; } |
| 36 | 35 |
| 37 float FillGlyphs(const TextRunPaintInfo&, ShapeResultBloberizer&) const; | |
| 38 void FillTextEmphasisGlyphs(const TextRunPaintInfo&, | |
| 39 const GlyphData& emphasis_data, | |
| 40 ShapeResultBloberizer&) const; | |
| 41 int OffsetForPosition(const TextRun&, | 36 int OffsetForPosition(const TextRun&, |
| 42 float target_x, | 37 float target_x, |
| 43 bool include_partial_glyphs) const; | 38 bool include_partial_glyphs) const; |
| 44 CharacterRange GetCharacterRange(TextDirection, | 39 CharacterRange GetCharacterRange(TextDirection, |
| 45 float total_width, | 40 float total_width, |
| 46 unsigned from, | 41 unsigned from, |
| 47 unsigned to) const; | 42 unsigned to) const; |
| 48 Vector<CharacterRange> IndividualCharacterRanges(TextDirection, | 43 Vector<CharacterRange> IndividualCharacterRanges(TextDirection, |
| 49 float total_width) const; | 44 float total_width) const; |
| 50 | 45 |
| 51 static CharacterRange GetCharacterRange(RefPtr<const ShapeResult>, | 46 static CharacterRange GetCharacterRange(RefPtr<const ShapeResult>, |
| 52 TextDirection, | 47 TextDirection, |
| 53 float total_width, | 48 float total_width, |
| 54 unsigned from, | 49 unsigned from, |
| 55 unsigned to); | 50 unsigned to); |
| 56 | 51 |
| 57 struct RunFontData { | 52 struct RunFontData { |
| 58 SimpleFontData* font_data_; | 53 SimpleFontData* font_data_; |
| 59 size_t glyph_count_; | 54 size_t glyph_count_; |
| 60 }; | 55 }; |
| 61 | 56 |
| 62 Vector<RunFontData> GetRunFontData() const; | 57 Vector<RunFontData> GetRunFontData() const; |
| 63 | 58 |
| 64 GlyphData EmphasisMarkGlyphData(const FontDescription&) const; | 59 GlyphData EmphasisMarkGlyphData(const FontDescription&) const; |
| 65 | 60 |
| 66 private: | 61 private: |
| 62 friend class ShapeResultBloberizer; |
| 67 static CharacterRange GetCharacterRangeInternal( | 63 static CharacterRange GetCharacterRangeInternal( |
| 68 const Vector<RefPtr<const ShapeResult>, 64>&, | 64 const Vector<RefPtr<const ShapeResult>, 64>&, |
| 69 TextDirection, | 65 TextDirection, |
| 70 float total_width, | 66 float total_width, |
| 71 unsigned from, | 67 unsigned from, |
| 72 unsigned to); | 68 unsigned to); |
| 73 | 69 |
| 74 float FillFastHorizontalGlyphs(const TextRun&, ShapeResultBloberizer&) const; | |
| 75 | |
| 76 static float FillGlyphsForResult(ShapeResultBloberizer&, | |
| 77 const ShapeResult&, | |
| 78 const TextRunPaintInfo&, | |
| 79 float initial_advance, | |
| 80 unsigned run_offset); | |
| 81 static float FillTextEmphasisGlyphsForRun(ShapeResultBloberizer&, | |
| 82 const ShapeResult::RunInfo*, | |
| 83 const TextRunPaintInfo&, | |
| 84 const GlyphData&, | |
| 85 float initial_advance, | |
| 86 unsigned run_offset); | |
| 87 | |
| 88 static void AddRunInfoRanges(const ShapeResult::RunInfo&, | 70 static void AddRunInfoRanges(const ShapeResult::RunInfo&, |
| 89 float offset, | 71 float offset, |
| 90 Vector<CharacterRange>&); | 72 Vector<CharacterRange>&); |
| 91 | 73 |
| 92 // Empirically, cases where we get more than 50 ShapeResults are extremely | 74 // Empirically, cases where we get more than 50 ShapeResults are extremely |
| 93 // rare. | 75 // rare. |
| 94 Vector<RefPtr<const ShapeResult>, 64> results_; | 76 Vector<RefPtr<const ShapeResult>, 64> results_; |
| 95 bool has_vertical_offsets_; | 77 bool has_vertical_offsets_; |
| 96 }; | 78 }; |
| 97 | 79 |
| 98 } // namespace blink | 80 } // namespace blink |
| 99 | 81 |
| 100 #endif // ShapeResultBuffer_h | 82 #endif // ShapeResultBuffer_h |
| OLD | NEW |