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 28 matching lines...) Expand all Loading... |
116 | 117 |
117 void setTextBaseline(TextBaseline baseline) { m_textBaseline = baseline; } | 118 void setTextBaseline(TextBaseline baseline) { m_textBaseline = baseline; } |
118 TextBaseline getTextBaseline() const { return m_textBaseline; } | 119 TextBaseline getTextBaseline() const { return m_textBaseline; } |
119 | 120 |
120 void setLineWidth(double lineWidth) { | 121 void setLineWidth(double lineWidth) { |
121 m_strokePaint.setStrokeWidth(lineWidth); | 122 m_strokePaint.setStrokeWidth(lineWidth); |
122 } | 123 } |
123 double lineWidth() const { return m_strokePaint.getStrokeWidth(); } | 124 double lineWidth() const { return m_strokePaint.getStrokeWidth(); } |
124 | 125 |
125 void setLineCap(LineCap lineCap) { | 126 void setLineCap(LineCap lineCap) { |
126 m_strokePaint.setStrokeCap(static_cast<SkPaint::Cap>(lineCap)); | 127 m_strokePaint.setStrokeCap(static_cast<PaintFlags::Cap>(lineCap)); |
127 } | 128 } |
128 LineCap getLineCap() const { | 129 LineCap getLineCap() const { |
129 return static_cast<LineCap>(m_strokePaint.getStrokeCap()); | 130 return static_cast<LineCap>(m_strokePaint.getStrokeCap()); |
130 } | 131 } |
131 | 132 |
132 void setLineJoin(LineJoin lineJoin) { | 133 void setLineJoin(LineJoin lineJoin) { |
133 m_strokePaint.setStrokeJoin(static_cast<SkPaint::Join>(lineJoin)); | 134 m_strokePaint.setStrokeJoin(static_cast<PaintFlags::Join>(lineJoin)); |
134 } | 135 } |
135 LineJoin getLineJoin() const { | 136 LineJoin getLineJoin() const { |
136 return static_cast<LineJoin>(m_strokePaint.getStrokeJoin()); | 137 return static_cast<LineJoin>(m_strokePaint.getStrokeJoin()); |
137 } | 138 } |
138 | 139 |
139 void setMiterLimit(double miterLimit) { | 140 void setMiterLimit(double miterLimit) { |
140 m_strokePaint.setStrokeMiter(miterLimit); | 141 m_strokePaint.setStrokeMiter(miterLimit); |
141 } | 142 } |
142 double miterLimit() const { return m_strokePaint.getStrokeMiter(); } | 143 double miterLimit() const { return m_strokePaint.getStrokeMiter(); } |
143 | 144 |
(...skipping 27 matching lines...) Expand all Loading... |
171 m_unparsedFillColor = color; | 172 m_unparsedFillColor = color; |
172 } | 173 } |
173 const String& unparsedFillColor() const { return m_unparsedFillColor; } | 174 const String& unparsedFillColor() const { return m_unparsedFillColor; } |
174 | 175 |
175 bool shouldDrawShadows() const; | 176 bool shouldDrawShadows() const; |
176 | 177 |
177 enum ImageType { NoImage, OpaqueImage, NonOpaqueImage }; | 178 enum ImageType { NoImage, OpaqueImage, NonOpaqueImage }; |
178 | 179 |
179 // If paint will not be used for painting a bitmap, set bitmapOpacity to | 180 // If paint will not be used for painting a bitmap, set bitmapOpacity to |
180 // Opaque. | 181 // Opaque. |
181 const SkPaint* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; | 182 const PaintFlags* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; |
182 | 183 |
183 private: | 184 private: |
184 CanvasRenderingContext2DState(); | 185 CanvasRenderingContext2DState(); |
185 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, | 186 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, |
186 ClipListCopyMode); | 187 ClipListCopyMode); |
187 | 188 |
188 void updateLineDash() const; | 189 void updateLineDash() const; |
189 void updateStrokeStyle() const; | 190 void updateStrokeStyle() const; |
190 void updateFillStyle() const; | 191 void updateFillStyle() const; |
191 void updateFilterQuality() const; | 192 void updateFilterQuality() const; |
192 void updateFilterQualityWithSkFilterQuality(const SkFilterQuality&) const; | 193 void updateFilterQualityWithSkFilterQuality(const SkFilterQuality&) const; |
193 void shadowParameterChanged(); | 194 void shadowParameterChanged(); |
194 SkDrawLooper* emptyDrawLooper() const; | 195 SkDrawLooper* emptyDrawLooper() const; |
195 SkDrawLooper* shadowOnlyDrawLooper() const; | 196 SkDrawLooper* shadowOnlyDrawLooper() const; |
196 SkDrawLooper* shadowAndForegroundDrawLooper() const; | 197 SkDrawLooper* shadowAndForegroundDrawLooper() const; |
197 sk_sp<SkImageFilter> shadowOnlyImageFilter() const; | 198 sk_sp<SkImageFilter> shadowOnlyImageFilter() const; |
198 sk_sp<SkImageFilter> shadowAndForegroundImageFilter() const; | 199 sk_sp<SkImageFilter> shadowAndForegroundImageFilter() const; |
199 | 200 |
200 unsigned m_unrealizedSaveCount; | 201 unsigned m_unrealizedSaveCount; |
201 | 202 |
202 String m_unparsedStrokeColor; | 203 String m_unparsedStrokeColor; |
203 String m_unparsedFillColor; | 204 String m_unparsedFillColor; |
204 Member<CanvasStyle> m_strokeStyle; | 205 Member<CanvasStyle> m_strokeStyle; |
205 Member<CanvasStyle> m_fillStyle; | 206 Member<CanvasStyle> m_fillStyle; |
206 | 207 |
207 mutable SkPaint m_strokePaint; | 208 mutable PaintFlags m_strokePaint; |
208 mutable SkPaint m_fillPaint; | 209 mutable PaintFlags m_fillPaint; |
209 mutable SkPaint m_imagePaint; | 210 mutable PaintFlags m_imagePaint; |
210 | 211 |
211 FloatSize m_shadowOffset; | 212 FloatSize m_shadowOffset; |
212 double m_shadowBlur; | 213 double m_shadowBlur; |
213 SkColor m_shadowColor; | 214 SkColor m_shadowColor; |
214 mutable sk_sp<SkDrawLooper> m_emptyDrawLooper; | 215 mutable sk_sp<SkDrawLooper> m_emptyDrawLooper; |
215 mutable sk_sp<SkDrawLooper> m_shadowOnlyDrawLooper; | 216 mutable sk_sp<SkDrawLooper> m_shadowOnlyDrawLooper; |
216 mutable sk_sp<SkDrawLooper> m_shadowAndForegroundDrawLooper; | 217 mutable sk_sp<SkDrawLooper> m_shadowAndForegroundDrawLooper; |
217 mutable sk_sp<SkImageFilter> m_shadowOnlyImageFilter; | 218 mutable sk_sp<SkImageFilter> m_shadowOnlyImageFilter; |
218 mutable sk_sp<SkImageFilter> m_shadowAndForegroundImageFilter; | 219 mutable sk_sp<SkImageFilter> m_shadowAndForegroundImageFilter; |
219 | 220 |
(...skipping 25 matching lines...) Expand all Loading... |
245 | 246 |
246 bool m_imageSmoothingEnabled; | 247 bool m_imageSmoothingEnabled; |
247 SkFilterQuality m_imageSmoothingQuality; | 248 SkFilterQuality m_imageSmoothingQuality; |
248 | 249 |
249 ClipList m_clipList; | 250 ClipList m_clipList; |
250 }; | 251 }; |
251 | 252 |
252 } // namespace blink | 253 } // namespace blink |
253 | 254 |
254 #endif | 255 #endif |
OLD | NEW |