OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (C) 2008 Holger Hans Peter Freyther | 6 * Copyright (C) 2008 Holger Hans Peter Freyther |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #ifndef Font_h | 25 #ifndef Font_h |
26 #define Font_h | 26 #define Font_h |
27 | 27 |
28 #include "platform/LayoutUnit.h" | 28 #include "platform/LayoutUnit.h" |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/fonts/FontDescription.h" | 30 #include "platform/fonts/FontDescription.h" |
31 #include "platform/fonts/FontFallbackList.h" | 31 #include "platform/fonts/FontFallbackList.h" |
32 #include "platform/fonts/FontFallbackPriority.h" | 32 #include "platform/fonts/FontFallbackPriority.h" |
33 #include "platform/fonts/SimpleFontData.h" | 33 #include "platform/fonts/SimpleFontData.h" |
| 34 #include "platform/graphics/paint/PaintCanvas.h" |
| 35 #include "platform/graphics/paint/PaintFlags.h" |
34 #include "platform/text/TabSize.h" | 36 #include "platform/text/TabSize.h" |
35 #include "platform/text/TextDirection.h" | 37 #include "platform/text/TextDirection.h" |
36 #include "wtf/Allocator.h" | 38 #include "wtf/Allocator.h" |
37 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
38 #include "wtf/HashSet.h" | 40 #include "wtf/HashSet.h" |
39 #include "wtf/MathExtras.h" | 41 #include "wtf/MathExtras.h" |
40 #include "wtf/text/CharacterNames.h" | 42 #include "wtf/text/CharacterNames.h" |
41 | 43 |
42 class SkCanvas; | |
43 class SkPaint; | |
44 | |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 struct CharacterRange; | 46 struct CharacterRange; |
48 class FloatPoint; | 47 class FloatPoint; |
49 class FloatRect; | 48 class FloatRect; |
50 class FontFallbackIterator; | 49 class FontFallbackIterator; |
51 class FontData; | 50 class FontData; |
52 class FontSelector; | 51 class FontSelector; |
53 class GlyphBuffer; | 52 class GlyphBuffer; |
54 class ShapeCache; | 53 class ShapeCache; |
(...skipping 17 matching lines...) Expand all Loading... |
72 const FontDescription& getFontDescription() const { | 71 const FontDescription& getFontDescription() const { |
73 return m_fontDescription; | 72 return m_fontDescription; |
74 } | 73 } |
75 | 74 |
76 void update(FontSelector*) const; | 75 void update(FontSelector*) const; |
77 | 76 |
78 enum CustomFontNotReadyAction { | 77 enum CustomFontNotReadyAction { |
79 DoNotPaintIfFontNotReady, | 78 DoNotPaintIfFontNotReady, |
80 UseFallbackIfFontNotReady | 79 UseFallbackIfFontNotReady |
81 }; | 80 }; |
82 bool drawText(SkCanvas*, | 81 bool drawText(PaintCanvas*, |
83 const TextRunPaintInfo&, | 82 const TextRunPaintInfo&, |
84 const FloatPoint&, | 83 const FloatPoint&, |
85 float deviceScaleFactor, | 84 float deviceScaleFactor, |
86 const SkPaint&) const; | 85 const PaintFlags&) const; |
87 bool drawBidiText(SkCanvas*, | 86 bool drawBidiText(PaintCanvas*, |
88 const TextRunPaintInfo&, | 87 const TextRunPaintInfo&, |
89 const FloatPoint&, | 88 const FloatPoint&, |
90 CustomFontNotReadyAction, | 89 CustomFontNotReadyAction, |
91 float deviceScaleFactor, | 90 float deviceScaleFactor, |
92 const SkPaint&) const; | 91 const PaintFlags&) const; |
93 void drawEmphasisMarks(SkCanvas*, | 92 void drawEmphasisMarks(PaintCanvas*, |
94 const TextRunPaintInfo&, | 93 const TextRunPaintInfo&, |
95 const AtomicString& mark, | 94 const AtomicString& mark, |
96 const FloatPoint&, | 95 const FloatPoint&, |
97 float deviceScaleFactor, | 96 float deviceScaleFactor, |
98 const SkPaint&) const; | 97 const PaintFlags&) const; |
99 | 98 |
100 struct TextIntercept { | 99 struct TextIntercept { |
101 float m_begin, m_end; | 100 float m_begin, m_end; |
102 }; | 101 }; |
103 | 102 |
104 // Compute the text intercepts along the axis of the advance and write them | 103 // Compute the text intercepts along the axis of the advance and write them |
105 // into the specified Vector of TextIntercepts. The number of those is zero or | 104 // into the specified Vector of TextIntercepts. The number of those is zero or |
106 // a multiple of two, and is at most the number of glyphs * 2 in the TextRun | 105 // a multiple of two, and is at most the number of glyphs * 2 in the TextRun |
107 // part of TextRunPaintInfo. Specify bounds for the upper and lower extend of | 106 // part of TextRunPaintInfo. Specify bounds for the upper and lower extend of |
108 // a line crossing through the text, parallel to the baseline. | 107 // a line crossing through the text, parallel to the baseline. |
109 // TODO(drott): crbug.com/655154 Fix this for | 108 // TODO(drott): crbug.com/655154 Fix this for |
110 // upright in vertical. | 109 // upright in vertical. |
111 void getTextIntercepts(const TextRunPaintInfo&, | 110 void getTextIntercepts(const TextRunPaintInfo&, |
112 float deviceScaleFactor, | 111 float deviceScaleFactor, |
113 const SkPaint&, | 112 const PaintFlags&, |
114 const std::tuple<float, float>& bounds, | 113 const std::tuple<float, float>& bounds, |
115 Vector<TextIntercept>&) const; | 114 Vector<TextIntercept>&) const; |
116 | 115 |
117 // Glyph bounds will be the minimum rect containing all glyph strokes, in | 116 // Glyph bounds will be the minimum rect containing all glyph strokes, in |
118 // coordinates using (<text run x position>, <baseline position>) as the | 117 // coordinates using (<text run x position>, <baseline position>) as the |
119 // origin. | 118 // origin. |
120 float width(const TextRun&, | 119 float width(const TextRun&, |
121 HashSet<const SimpleFontData*>* fallbackFonts = nullptr, | 120 HashSet<const SimpleFontData*>* fallbackFonts = nullptr, |
122 FloatRect* glyphBounds = nullptr) const; | 121 FloatRect* glyphBounds = nullptr) const; |
123 | 122 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 m_shapeWordByWordComputed = true; | 169 m_shapeWordByWordComputed = true; |
171 } | 170 } |
172 | 171 |
173 private: | 172 private: |
174 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; | 173 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; |
175 | 174 |
176 // Returns the total advance. | 175 // Returns the total advance. |
177 float buildGlyphBuffer(const TextRunPaintInfo&, | 176 float buildGlyphBuffer(const TextRunPaintInfo&, |
178 GlyphBuffer&, | 177 GlyphBuffer&, |
179 const GlyphData* emphasisData = nullptr) const; | 178 const GlyphData* emphasisData = nullptr) const; |
180 void drawGlyphBuffer(SkCanvas*, | 179 void drawGlyphBuffer(PaintCanvas*, |
181 const SkPaint&, | 180 const PaintFlags&, |
182 const TextRunPaintInfo&, | 181 const TextRunPaintInfo&, |
183 const GlyphBuffer&, | 182 const GlyphBuffer&, |
184 const FloatPoint&, | 183 const FloatPoint&, |
185 float deviceScaleFactor) const; | 184 float deviceScaleFactor) const; |
186 | 185 |
187 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; | 186 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; |
188 | 187 |
189 bool computeCanShapeWordByWord() const; | 188 bool computeCanShapeWordByWord() const; |
190 | 189 |
191 friend struct SimpleShaper; | 190 friend struct SimpleShaper; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // advance an additional tab stop. | 245 // advance an additional tab stop. |
247 if (distanceToTabStop < fontData->spaceWidth() / 2) | 246 if (distanceToTabStop < fontData->spaceWidth() / 2) |
248 distanceToTabStop += baseTabWidth; | 247 distanceToTabStop += baseTabWidth; |
249 | 248 |
250 return distanceToTabStop; | 249 return distanceToTabStop; |
251 } | 250 } |
252 | 251 |
253 } // namespace blink | 252 } // namespace blink |
254 | 253 |
255 #endif | 254 #endif |
OLD | NEW |