Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: Source/core/paint/TextPainter.h

Issue 1319893002: Make classes and structures in core/paint fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "platform/geometry/FloatPoint.h" 11 #include "platform/geometry/FloatPoint.h"
12 #include "platform/geometry/FloatRect.h" 12 #include "platform/geometry/FloatRect.h"
13 #include "platform/geometry/LayoutRect.h" 13 #include "platform/geometry/LayoutRect.h"
14 #include "platform/graphics/Color.h" 14 #include "platform/graphics/Color.h"
15 #include "platform/transforms/AffineTransform.h" 15 #include "platform/transforms/AffineTransform.h"
16 #include "wtf/Allocator.h"
16 #include "wtf/text/AtomicString.h" 17 #include "wtf/text/AtomicString.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 class ComputedStyle; 21 class ComputedStyle;
21 class Font; 22 class Font;
22 class GraphicsContext; 23 class GraphicsContext;
23 class GraphicsContextStateSaver; 24 class GraphicsContextStateSaver;
24 class LayoutTextCombine; 25 class LayoutTextCombine;
25 class LayoutObject; 26 class LayoutObject;
26 struct PaintInfo; 27 struct PaintInfo;
27 class ShadowList; 28 class ShadowList;
28 class TextRun; 29 class TextRun;
29 struct TextRunPaintInfo; 30 struct TextRunPaintInfo;
30 31
31 class CORE_EXPORT TextPainter { 32 class CORE_EXPORT TextPainter {
33 STACK_ALLOCATED();
32 public: 34 public:
33 struct Style; 35 struct Style;
34 36
35 TextPainter(GraphicsContext*, const Font&, const TextRun&, const LayoutPoint & textOrigin, const LayoutRect& textBounds, bool horizontal); 37 TextPainter(GraphicsContext*, const Font&, const TextRun&, const LayoutPoint & textOrigin, const LayoutRect& textBounds, bool horizontal);
36 ~TextPainter(); 38 ~TextPainter();
37 39
38 void setEmphasisMark(const AtomicString&, TextEmphasisPosition); 40 void setEmphasisMark(const AtomicString&, TextEmphasisPosition);
39 void setCombinedText(LayoutTextCombine* combinedText) { m_combinedText = com binedText; } 41 void setCombinedText(LayoutTextCombine* combinedText) { m_combinedText = com binedText; }
40 42
41 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horiz ontal, GraphicsContextStateSaver&); 43 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horiz ontal, GraphicsContextStateSaver&);
42 44
43 void paint(int startOffset, int endOffset, int length, const Style&, TextBlo bPtr* cachedTextBlob = 0); 45 void paint(int startOffset, int endOffset, int length, const Style&, TextBlo bPtr* cachedTextBlob = 0);
44 46
45 struct Style { 47 struct Style {
48 STACK_ALLOCATED();
46 Color currentColor; 49 Color currentColor;
47 Color fillColor; 50 Color fillColor;
48 Color strokeColor; 51 Color strokeColor;
49 Color emphasisMarkColor; 52 Color emphasisMarkColor;
50 float strokeWidth; 53 float strokeWidth;
51 const ShadowList* shadow; 54 const ShadowList* shadow;
52 55
53 bool operator==(const Style& other) 56 bool operator==(const Style& other)
54 { 57 {
55 return currentColor == other.currentColor 58 return currentColor == other.currentColor
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x( )) = (x() + maxY(), y() - x()) 110 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x( )) = (x() + maxY(), y() - x())
108 111
109 // A similar argument derives the counter-clockwise case. 112 // A similar argument derives the counter-clockwise case.
110 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.y() - boxRect.x()) 113 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.y() - boxRect.x())
111 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() + boxRect.maxY()); 114 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() + boxRect.maxY());
112 } 115 }
113 116
114 } // namespace blink 117 } // namespace blink
115 118
116 #endif // TextPainter_h 119 #endif // TextPainter_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698