OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 TextPainter_h | 5 #ifndef TextPainter_h |
6 #define TextPainter_h | 6 #define TextPainter_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
10 #include "platform/fonts/TextBlob.h" | 10 #include "platform/fonts/TextBlob.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 struct Style; | 36 struct Style; |
37 | 37 |
38 TextPainter(GraphicsContext&, const Font&, const TextRun&, const LayoutPoint
& textOrigin, const LayoutRect& textBounds, bool horizontal); | 38 TextPainter(GraphicsContext&, const Font&, const TextRun&, const LayoutPoint
& textOrigin, const LayoutRect& textBounds, bool horizontal); |
39 ~TextPainter(); | 39 ~TextPainter(); |
40 | 40 |
41 void setEmphasisMark(const AtomicString&, TextEmphasisPosition); | 41 void setEmphasisMark(const AtomicString&, TextEmphasisPosition); |
42 void setCombinedText(LayoutTextCombine* combinedText) { m_combinedText = com
binedText; } | 42 void setCombinedText(LayoutTextCombine* combinedText) { m_combinedText = com
binedText; } |
43 | 43 |
44 static void updateGraphicsContext(GraphicsContext&, const Style&, bool horiz
ontal, GraphicsContextStateSaver&); | 44 static void updateGraphicsContext(GraphicsContext&, const Style&, bool horiz
ontal, GraphicsContextStateSaver&); |
45 | 45 |
46 void paint(int startOffset, int endOffset, int length, const Style&, TextBlo
bPtr* cachedTextBlob = 0); | 46 void paint(unsigned startOffset, unsigned endOffset, unsigned length, const
Style&, TextBlobPtr* cachedTextBlob = 0); |
47 | 47 |
48 struct Style { | 48 struct Style { |
49 STACK_ALLOCATED(); | 49 STACK_ALLOCATED(); |
50 Color currentColor; | 50 Color currentColor; |
51 Color fillColor; | 51 Color fillColor; |
52 Color strokeColor; | 52 Color strokeColor; |
53 Color emphasisMarkColor; | 53 Color emphasisMarkColor; |
54 float strokeWidth; | 54 float strokeWidth; |
55 const ShadowList* shadow; | 55 const ShadowList* shadow; |
56 | 56 |
(...skipping 16 matching lines...) Expand all Loading... |
73 | 73 |
74 private: | 74 private: |
75 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) | 75 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) |
76 { | 76 { |
77 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); | 77 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); |
78 } | 78 } |
79 | 79 |
80 enum PaintInternalStep { PaintText, PaintEmphasisMark }; | 80 enum PaintInternalStep { PaintText, PaintEmphasisMark }; |
81 | 81 |
82 template <PaintInternalStep step> | 82 template <PaintInternalStep step> |
83 void paintInternalRun(TextRunPaintInfo&, int from, int to); | 83 void paintInternalRun(TextRunPaintInfo&, unsigned from, unsigned to); |
84 | 84 |
85 template <PaintInternalStep step> | 85 template <PaintInternalStep step> |
86 void paintInternal(int startOffset, int endOffset, int truncationPoint, Text
BlobPtr* cachedTextBlob = 0); | 86 void paintInternal(unsigned startOffset, unsigned endOffset, unsigned trunca
tionPoint, TextBlobPtr* cachedTextBlob = 0); |
87 | 87 |
88 void paintEmphasisMarkForCombinedText(); | 88 void paintEmphasisMarkForCombinedText(); |
89 | 89 |
90 GraphicsContext& m_graphicsContext; | 90 GraphicsContext& m_graphicsContext; |
91 const Font& m_font; | 91 const Font& m_font; |
92 const TextRun& m_run; | 92 const TextRun& m_run; |
93 LayoutPoint m_textOrigin; | 93 LayoutPoint m_textOrigin; |
94 LayoutRect m_textBounds; | 94 LayoutRect m_textBounds; |
95 bool m_horizontal; | 95 bool m_horizontal; |
96 AtomicString m_emphasisMark; | 96 AtomicString m_emphasisMark; |
(...skipping 14 matching lines...) Expand all Loading... |
111 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) | 111 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) |
112 | 112 |
113 // A similar argument derives the counter-clockwise case. | 113 // A similar argument derives the counter-clockwise case. |
114 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) | 114 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) |
115 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); | 115 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); |
116 } | 116 } |
117 | 117 |
118 } // namespace blink | 118 } // namespace blink |
119 | 119 |
120 #endif // TextPainter_h | 120 #endif // TextPainter_h |
OLD | NEW |