Chromium Code Reviews| 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/rendering/style/RenderStyleConstants.h" | 8 #include "core/rendering/style/RenderStyleConstants.h" |
| 9 #include "platform/fonts/TextBlob.h" | |
|
f(malita)
2014/09/12 13:21:24
Could we use a forward declaration in the header?
jbroman
2014/09/13 00:06:42
Tricky because it's a typedef for a templated clas
| |
| 9 #include "platform/geometry/FloatPoint.h" | 10 #include "platform/geometry/FloatPoint.h" |
| 10 #include "platform/geometry/FloatRect.h" | 11 #include "platform/geometry/FloatRect.h" |
| 11 #include "platform/graphics/Color.h" | 12 #include "platform/graphics/Color.h" |
| 12 #include "wtf/text/AtomicString.h" | 13 #include "wtf/text/AtomicString.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class Font; | 17 class Font; |
| 17 class GraphicsContext; | 18 class GraphicsContext; |
| 18 class GraphicsContextStateSaver; | 19 class GraphicsContextStateSaver; |
| 19 class RenderCombineText; | 20 class RenderCombineText; |
| 20 class ShadowList; | 21 class ShadowList; |
| 21 class TextRun; | 22 class TextRun; |
| 22 struct TextRunPaintInfo; | 23 struct TextRunPaintInfo; |
| 23 | 24 |
| 24 class TextPainter { | 25 class TextPainter { |
| 25 public: | 26 public: |
| 26 struct Style; | 27 struct Style; |
| 27 | 28 |
| 28 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizontal); | 29 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizontal); |
| 29 ~TextPainter(); | 30 ~TextPainter(); |
| 30 | 31 |
| 31 void setEmphasisMark(const AtomicString&, TextEmphasisPosition); | 32 void setEmphasisMark(const AtomicString&, TextEmphasisPosition); |
| 32 void setCombinedText(RenderCombineText* combinedText) { m_combinedText = com binedText; } | 33 void setCombinedText(RenderCombineText* combinedText) { m_combinedText = com binedText; } |
| 33 | 34 |
| 34 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horiz ontal, GraphicsContextStateSaver&); | 35 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horiz ontal, GraphicsContextStateSaver&); |
| 35 | 36 |
| 36 void paint(int startOffset, int endOffset, int length, const Style&); | 37 void paint(int startOffset, int endOffset, int length, const Style&, TextBlo bPtr* textBlobCache = 0); |
| 37 | 38 |
| 38 struct Style { | 39 struct Style { |
| 39 Color fillColor; | 40 Color fillColor; |
| 40 Color strokeColor; | 41 Color strokeColor; |
| 41 Color emphasisMarkColor; | 42 Color emphasisMarkColor; |
| 42 float strokeWidth; | 43 float strokeWidth; |
| 43 const ShadowList* shadow; | 44 const ShadowList* shadow; |
| 44 | 45 |
| 45 bool operator==(const Style& other) | 46 bool operator==(const Style& other) |
| 46 { | 47 { |
| 47 return fillColor == other.fillColor | 48 return fillColor == other.fillColor |
| 48 && strokeColor == other.strokeColor | 49 && strokeColor == other.strokeColor |
| 49 && emphasisMarkColor == other.emphasisMarkColor | 50 && emphasisMarkColor == other.emphasisMarkColor |
| 50 && strokeWidth == other.strokeWidth | 51 && strokeWidth == other.strokeWidth |
| 51 && shadow == other.shadow; | 52 && shadow == other.shadow; |
| 52 } | 53 } |
| 53 bool operator!=(const Style& other) { return !(*this == other); } | 54 bool operator!=(const Style& other) { return !(*this == other); } |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa ver) | 58 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa ver) |
| 58 { | 59 { |
| 59 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); | 60 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); |
| 60 } | 61 } |
| 61 | 62 |
| 62 enum PaintInternalStep { PaintText, PaintEmphasisMark }; | 63 enum PaintInternalStep { PaintText, PaintEmphasisMark }; |
| 63 | 64 |
| 64 template <PaintInternalStep step> | 65 template <PaintInternalStep step> |
| 65 void paintInternalRun(TextRunPaintInfo&, int from, int to); | 66 void paintInternalRun(TextRunPaintInfo&, int from, int to, TextBlobPtr* text BlobCache = 0); |
| 66 | 67 |
| 67 template <PaintInternalStep step> | 68 template <PaintInternalStep step> |
| 68 void paintInternal(int startOffset, int endOffset, int truncationPoint); | 69 void paintInternal(int startOffset, int endOffset, int truncationPoint, Text BlobPtr* textBlobCache = 0); |
|
f(malita)
2014/09/12 13:21:24
We may avoid hauling textBlobCache all over the pl
jbroman
2014/09/13 00:06:42
I'm mostly afraid that you can pass TextRunPaintIn
| |
| 69 | 70 |
| 70 void paintEmphasisMarkForCombinedText(); | 71 void paintEmphasisMarkForCombinedText(); |
| 71 | 72 |
| 72 GraphicsContext* m_graphicsContext; | 73 GraphicsContext* m_graphicsContext; |
| 73 const Font& m_font; | 74 const Font& m_font; |
| 74 const TextRun& m_run; | 75 const TextRun& m_run; |
| 75 FloatPoint m_textOrigin; | 76 FloatPoint m_textOrigin; |
| 76 FloatRect m_textBounds; | 77 FloatRect m_textBounds; |
| 77 bool m_horizontal; | 78 bool m_horizontal; |
| 78 AtomicString m_emphasisMark; | 79 AtomicString m_emphasisMark; |
| 79 int m_emphasisMarkOffset; | 80 int m_emphasisMarkOffset; |
| 80 RenderCombineText* m_combinedText; | 81 RenderCombineText* m_combinedText; |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } // namespace blink | 84 } // namespace blink |
| 84 | 85 |
| 85 #endif // TextPainter_h | 86 #endif // TextPainter_h |
| OLD | NEW |