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 "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
11 #include "wtf/RefPtr.h" | 11 #include "wtf/RefPtr.h" |
12 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
13 #include <tuple> | |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 struct CharacterRange; | 16 struct CharacterRange; |
18 class FontDescription; | 17 class FontDescription; |
19 class GlyphBuffer; | |
20 struct GlyphData; | 18 struct GlyphData; |
| 19 class ShapeResultBloberizer; |
21 class TextRun; | 20 class TextRun; |
| 21 struct TextRunPaintInfo; |
22 | 22 |
23 class PLATFORM_EXPORT ShapeResultBuffer { | 23 class PLATFORM_EXPORT ShapeResultBuffer { |
24 WTF_MAKE_NONCOPYABLE(ShapeResultBuffer); | 24 WTF_MAKE_NONCOPYABLE(ShapeResultBuffer); |
25 STACK_ALLOCATED(); | 25 STACK_ALLOCATED(); |
26 | 26 |
27 public: | 27 public: |
28 ShapeResultBuffer() : m_hasVerticalOffsets(false) {} | 28 ShapeResultBuffer() : m_hasVerticalOffsets(false) {} |
29 | 29 |
30 void appendResult(PassRefPtr<const ShapeResult> result) { | 30 void appendResult(PassRefPtr<const ShapeResult> result) { |
31 m_hasVerticalOffsets |= result->hasVerticalOffsets(); | 31 m_hasVerticalOffsets |= result->hasVerticalOffsets(); |
32 m_results.push_back(result); | 32 m_results.push_back(result); |
33 } | 33 } |
34 | 34 |
35 bool hasVerticalOffsets() const { return m_hasVerticalOffsets; } | 35 bool hasVerticalOffsets() const { return m_hasVerticalOffsets; } |
36 | 36 |
37 float fillGlyphBuffer(GlyphBuffer*, | 37 float fillGlyphs(const TextRunPaintInfo&, ShapeResultBloberizer&) const; |
38 const TextRun&, | 38 void fillTextEmphasisGlyphs(const TextRunPaintInfo&, |
39 unsigned from, | 39 const GlyphData& emphasisData, |
40 unsigned to) const; | 40 ShapeResultBloberizer&) const; |
41 float fillGlyphBufferForTextEmphasis(GlyphBuffer*, | |
42 const TextRun&, | |
43 const GlyphData* emphasisData, | |
44 unsigned from, | |
45 unsigned to) const; | |
46 int offsetForPosition(const TextRun&, | 41 int offsetForPosition(const TextRun&, |
47 float targetX, | 42 float targetX, |
48 bool includePartialGlyphs) const; | 43 bool includePartialGlyphs) const; |
49 CharacterRange getCharacterRange(TextDirection, | 44 CharacterRange getCharacterRange(TextDirection, |
50 float totalWidth, | 45 float totalWidth, |
51 unsigned from, | 46 unsigned from, |
52 unsigned to) const; | 47 unsigned to) const; |
53 Vector<CharacterRange> individualCharacterRanges(TextDirection, | 48 Vector<CharacterRange> individualCharacterRanges(TextDirection, |
54 float totalWidth) const; | 49 float totalWidth) const; |
55 | 50 |
(...skipping 13 matching lines...) Expand all Loading... |
69 GlyphData emphasisMarkGlyphData(const FontDescription&) const; | 64 GlyphData emphasisMarkGlyphData(const FontDescription&) const; |
70 | 65 |
71 private: | 66 private: |
72 static CharacterRange getCharacterRangeInternal( | 67 static CharacterRange getCharacterRangeInternal( |
73 const Vector<RefPtr<const ShapeResult>, 64>&, | 68 const Vector<RefPtr<const ShapeResult>, 64>&, |
74 TextDirection, | 69 TextDirection, |
75 float totalWidth, | 70 float totalWidth, |
76 unsigned from, | 71 unsigned from, |
77 unsigned to); | 72 unsigned to); |
78 | 73 |
79 float fillFastHorizontalGlyphBuffer(GlyphBuffer*, const TextRun&) const; | 74 float fillFastHorizontalGlyphs(const TextRun&, ShapeResultBloberizer&) const; |
80 | 75 |
81 static float fillGlyphBufferForResult(GlyphBuffer*, | 76 static float fillGlyphsForResult(ShapeResultBloberizer&, |
82 const ShapeResult&, | 77 const ShapeResult&, |
83 const TextRun&, | 78 const TextRunPaintInfo&, |
84 float initialAdvance, | 79 float initialAdvance, |
85 unsigned from, | 80 unsigned runOffset); |
86 unsigned to, | 81 static float fillTextEmphasisGlyphsForRun(ShapeResultBloberizer&, |
87 unsigned runOffset); | 82 const ShapeResult::RunInfo*, |
88 static float fillGlyphBufferForTextEmphasisRun(GlyphBuffer*, | 83 const TextRunPaintInfo&, |
89 const ShapeResult::RunInfo*, | 84 const GlyphData&, |
90 const TextRun&, | 85 float initialAdvance, |
91 const GlyphData*, | 86 unsigned runOffset); |
92 float initialAdvance, | |
93 unsigned from, | |
94 unsigned to, | |
95 unsigned runOffset); | |
96 | 87 |
97 static void addRunInfoRanges(const ShapeResult::RunInfo&, | 88 static void addRunInfoRanges(const ShapeResult::RunInfo&, |
98 float offset, | 89 float offset, |
99 Vector<CharacterRange>&); | 90 Vector<CharacterRange>&); |
100 | 91 |
101 // Empirically, cases where we get more than 50 ShapeResults are extremely | 92 // Empirically, cases where we get more than 50 ShapeResults are extremely |
102 // rare. | 93 // rare. |
103 Vector<RefPtr<const ShapeResult>, 64> m_results; | 94 Vector<RefPtr<const ShapeResult>, 64> m_results; |
104 bool m_hasVerticalOffsets; | 95 bool m_hasVerticalOffsets; |
105 }; | 96 }; |
106 | 97 |
107 } // namespace blink | 98 } // namespace blink |
108 | 99 |
109 #endif // ShapeResultBuffer_h | 100 #endif // ShapeResultBuffer_h |
OLD | NEW |