OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CanvasRenderingContext2DState_h | 5 #ifndef CanvasRenderingContext2DState_h |
6 #define CanvasRenderingContext2DState_h | 6 #define CanvasRenderingContext2DState_h |
7 | 7 |
8 #include "core/css/CSSFontSelectorClient.h" | 8 #include "core/css/CSSFontSelectorClient.h" |
9 #include "modules/canvas2d/ClipList.h" | 9 #include "modules/canvas2d/ClipList.h" |
10 #include "platform/fonts/Font.h" | 10 #include "platform/fonts/Font.h" |
| 11 #include "platform/graphics/paint/PaintFlags.h" |
11 #include "platform/transforms/AffineTransform.h" | 12 #include "platform/transforms/AffineTransform.h" |
12 #include "third_party/skia/include/core/SkRefCnt.h" | 13 #include "third_party/skia/include/core/SkRefCnt.h" |
13 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class CanvasRenderingContext2D; | 18 class CanvasRenderingContext2D; |
18 class CanvasStyle; | 19 class CanvasStyle; |
19 class CSSValue; | 20 class CSSValue; |
20 class Element; | 21 class Element; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 // setTransform returns true iff transform is invertible; | 69 // setTransform returns true iff transform is invertible; |
69 void setTransform(const AffineTransform&); | 70 void setTransform(const AffineTransform&); |
70 void resetTransform(); | 71 void resetTransform(); |
71 AffineTransform transform() const { return m_transform; } | 72 AffineTransform transform() const { return m_transform; } |
72 bool isTransformInvertible() const { return m_isTransformInvertible; } | 73 bool isTransformInvertible() const { return m_isTransformInvertible; } |
73 | 74 |
74 void clipPath(const SkPath&, AntiAliasingMode); | 75 void clipPath(const SkPath&, AntiAliasingMode); |
75 bool hasClip() const { return m_hasClip; } | 76 bool hasClip() const { return m_hasClip; } |
76 bool hasComplexClip() const { return m_hasComplexClip; } | 77 bool hasComplexClip() const { return m_hasComplexClip; } |
77 void playbackClips(SkCanvas* canvas) const { m_clipList.playback(canvas); } | 78 void playbackClips(PaintCanvas* canvas) const { m_clipList.playback(canvas); } |
78 const SkPath& getCurrentClipPath() const { | 79 const SkPath& getCurrentClipPath() const { |
79 return m_clipList.getCurrentClipPath(); | 80 return m_clipList.getCurrentClipPath(); |
80 } | 81 } |
81 | 82 |
82 void setFont(const Font&, CSSFontSelector*); | 83 void setFont(const Font&, CSSFontSelector*); |
83 const Font& font() const; | 84 const Font& font() const; |
84 bool hasRealizedFont() const { return m_realizedFont; } | 85 bool hasRealizedFont() const { return m_realizedFont; } |
85 void setUnparsedFont(const String& font) { m_unparsedFont = font; } | 86 void setUnparsedFont(const String& font) { m_unparsedFont = font; } |
86 const String& unparsedFont() const { return m_unparsedFont; } | 87 const String& unparsedFont() const { return m_unparsedFont; } |
87 | 88 |
(...skipping 30 matching lines...) Expand all Loading... |
118 | 119 |
119 void setTextBaseline(TextBaseline baseline) { m_textBaseline = baseline; } | 120 void setTextBaseline(TextBaseline baseline) { m_textBaseline = baseline; } |
120 TextBaseline getTextBaseline() const { return m_textBaseline; } | 121 TextBaseline getTextBaseline() const { return m_textBaseline; } |
121 | 122 |
122 void setLineWidth(double lineWidth) { | 123 void setLineWidth(double lineWidth) { |
123 m_strokePaint.setStrokeWidth(lineWidth); | 124 m_strokePaint.setStrokeWidth(lineWidth); |
124 } | 125 } |
125 double lineWidth() const { return m_strokePaint.getStrokeWidth(); } | 126 double lineWidth() const { return m_strokePaint.getStrokeWidth(); } |
126 | 127 |
127 void setLineCap(LineCap lineCap) { | 128 void setLineCap(LineCap lineCap) { |
128 m_strokePaint.setStrokeCap(static_cast<SkPaint::Cap>(lineCap)); | 129 m_strokePaint.setStrokeCap(static_cast<PaintFlags::Cap>(lineCap)); |
129 } | 130 } |
130 LineCap getLineCap() const { | 131 LineCap getLineCap() const { |
131 return static_cast<LineCap>(m_strokePaint.getStrokeCap()); | 132 return static_cast<LineCap>(m_strokePaint.getStrokeCap()); |
132 } | 133 } |
133 | 134 |
134 void setLineJoin(LineJoin lineJoin) { | 135 void setLineJoin(LineJoin lineJoin) { |
135 m_strokePaint.setStrokeJoin(static_cast<SkPaint::Join>(lineJoin)); | 136 m_strokePaint.setStrokeJoin(static_cast<PaintFlags::Join>(lineJoin)); |
136 } | 137 } |
137 LineJoin getLineJoin() const { | 138 LineJoin getLineJoin() const { |
138 return static_cast<LineJoin>(m_strokePaint.getStrokeJoin()); | 139 return static_cast<LineJoin>(m_strokePaint.getStrokeJoin()); |
139 } | 140 } |
140 | 141 |
141 void setMiterLimit(double miterLimit) { | 142 void setMiterLimit(double miterLimit) { |
142 m_strokePaint.setStrokeMiter(miterLimit); | 143 m_strokePaint.setStrokeMiter(miterLimit); |
143 } | 144 } |
144 double miterLimit() const { return m_strokePaint.getStrokeMiter(); } | 145 double miterLimit() const { return m_strokePaint.getStrokeMiter(); } |
145 | 146 |
(...skipping 27 matching lines...) Expand all Loading... |
173 m_unparsedFillColor = color; | 174 m_unparsedFillColor = color; |
174 } | 175 } |
175 const String& unparsedFillColor() const { return m_unparsedFillColor; } | 176 const String& unparsedFillColor() const { return m_unparsedFillColor; } |
176 | 177 |
177 bool shouldDrawShadows() const; | 178 bool shouldDrawShadows() const; |
178 | 179 |
179 enum ImageType { NoImage, OpaqueImage, NonOpaqueImage }; | 180 enum ImageType { NoImage, OpaqueImage, NonOpaqueImage }; |
180 | 181 |
181 // If paint will not be used for painting a bitmap, set bitmapOpacity to | 182 // If paint will not be used for painting a bitmap, set bitmapOpacity to |
182 // Opaque. | 183 // Opaque. |
183 const SkPaint* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; | 184 const PaintFlags* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; |
184 | 185 |
185 private: | 186 private: |
186 CanvasRenderingContext2DState(); | 187 CanvasRenderingContext2DState(); |
187 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, | 188 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, |
188 ClipListCopyMode); | 189 ClipListCopyMode); |
189 | 190 |
190 void updateLineDash() const; | 191 void updateLineDash() const; |
191 void updateStrokeStyle() const; | 192 void updateStrokeStyle() const; |
192 void updateFillStyle() const; | 193 void updateFillStyle() const; |
193 void updateFilterQuality() const; | 194 void updateFilterQuality() const; |
194 void updateFilterQualityWithSkFilterQuality(const SkFilterQuality&) const; | 195 void updateFilterQualityWithSkFilterQuality(const SkFilterQuality&) const; |
195 void shadowParameterChanged(); | 196 void shadowParameterChanged(); |
196 SkDrawLooper* emptyDrawLooper() const; | 197 SkDrawLooper* emptyDrawLooper() const; |
197 SkDrawLooper* shadowOnlyDrawLooper() const; | 198 SkDrawLooper* shadowOnlyDrawLooper() const; |
198 SkDrawLooper* shadowAndForegroundDrawLooper() const; | 199 SkDrawLooper* shadowAndForegroundDrawLooper() const; |
199 sk_sp<SkImageFilter> shadowOnlyImageFilter() const; | 200 sk_sp<SkImageFilter> shadowOnlyImageFilter() const; |
200 sk_sp<SkImageFilter> shadowAndForegroundImageFilter() const; | 201 sk_sp<SkImageFilter> shadowAndForegroundImageFilter() const; |
201 | 202 |
202 unsigned m_unrealizedSaveCount; | 203 unsigned m_unrealizedSaveCount; |
203 | 204 |
204 String m_unparsedStrokeColor; | 205 String m_unparsedStrokeColor; |
205 String m_unparsedFillColor; | 206 String m_unparsedFillColor; |
206 Member<CanvasStyle> m_strokeStyle; | 207 Member<CanvasStyle> m_strokeStyle; |
207 Member<CanvasStyle> m_fillStyle; | 208 Member<CanvasStyle> m_fillStyle; |
208 | 209 |
209 mutable SkPaint m_strokePaint; | 210 mutable PaintFlags m_strokePaint; |
210 mutable SkPaint m_fillPaint; | 211 mutable PaintFlags m_fillPaint; |
211 mutable SkPaint m_imagePaint; | 212 mutable PaintFlags m_imagePaint; |
212 | 213 |
213 FloatSize m_shadowOffset; | 214 FloatSize m_shadowOffset; |
214 double m_shadowBlur; | 215 double m_shadowBlur; |
215 SkColor m_shadowColor; | 216 SkColor m_shadowColor; |
216 mutable sk_sp<SkDrawLooper> m_emptyDrawLooper; | 217 mutable sk_sp<SkDrawLooper> m_emptyDrawLooper; |
217 mutable sk_sp<SkDrawLooper> m_shadowOnlyDrawLooper; | 218 mutable sk_sp<SkDrawLooper> m_shadowOnlyDrawLooper; |
218 mutable sk_sp<SkDrawLooper> m_shadowAndForegroundDrawLooper; | 219 mutable sk_sp<SkDrawLooper> m_shadowAndForegroundDrawLooper; |
219 mutable sk_sp<SkImageFilter> m_shadowOnlyImageFilter; | 220 mutable sk_sp<SkImageFilter> m_shadowOnlyImageFilter; |
220 mutable sk_sp<SkImageFilter> m_shadowAndForegroundImageFilter; | 221 mutable sk_sp<SkImageFilter> m_shadowAndForegroundImageFilter; |
221 | 222 |
(...skipping 25 matching lines...) Expand all Loading... |
247 | 248 |
248 bool m_imageSmoothingEnabled; | 249 bool m_imageSmoothingEnabled; |
249 SkFilterQuality m_imageSmoothingQuality; | 250 SkFilterQuality m_imageSmoothingQuality; |
250 | 251 |
251 ClipList m_clipList; | 252 ClipList m_clipList; |
252 }; | 253 }; |
253 | 254 |
254 } // namespace blink | 255 } // namespace blink |
255 | 256 |
256 #endif | 257 #endif |
OLD | NEW |