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 "core/html/canvas/ClipList.h" | 9 #include "core/html/canvas/ClipList.h" |
10 #include "platform/fonts/Font.h" | 10 #include "platform/fonts/Font.h" |
11 #include "platform/transforms/AffineTransform.h" | 11 #include "platform/transforms/AffineTransform.h" |
12 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class CanvasStyle; | 16 class CanvasStyle; |
17 | 17 |
18 class CanvasRenderingContext2DState final : public CSSFontSelectorClient { | 18 class CanvasRenderingContext2DState final : public NoBaseWillBeGarbageCollectedF
inalized<CanvasRenderingContext2DState>, public CSSFontSelectorClient { |
| 19 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2DState); |
19 public: | 20 public: |
20 CanvasRenderingContext2DState(); | 21 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2DState> create() |
| 22 { |
| 23 return adoptPtrWillBeNoop(new CanvasRenderingContext2DState); |
| 24 } |
| 25 |
21 virtual ~CanvasRenderingContext2DState(); | 26 virtual ~CanvasRenderingContext2DState(); |
22 | 27 |
23 DECLARE_VIRTUAL_TRACE(); | 28 DECLARE_VIRTUAL_TRACE(); |
24 | 29 |
25 enum ClipListCopyMode { | 30 enum ClipListCopyMode { |
26 CopyClipList, | 31 CopyClipList, |
27 DontCopyClipList | 32 DontCopyClipList |
28 }; | 33 }; |
29 | 34 |
30 enum PaintType { | 35 enum PaintType { |
31 FillPaintType, | 36 FillPaintType, |
32 StrokePaintType, | 37 StrokePaintType, |
33 ImagePaintType, | 38 ImagePaintType, |
34 }; | 39 }; |
35 | 40 |
36 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, ClipList
CopyMode = CopyClipList); | 41 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2DState> create(const Ca
nvasRenderingContext2DState& other, ClipListCopyMode mode) |
| 42 { |
| 43 return adoptPtrWillBeNoop(new CanvasRenderingContext2DState(other, mode)
); |
| 44 } |
37 CanvasRenderingContext2DState& operator=(const CanvasRenderingContext2DState
&); | 45 CanvasRenderingContext2DState& operator=(const CanvasRenderingContext2DState
&); |
38 | 46 |
39 // CSSFontSelectorClient implementation | 47 // CSSFontSelectorClient implementation |
40 virtual void fontsNeedUpdate(CSSFontSelector*) override; | 48 virtual void fontsNeedUpdate(CSSFontSelector*) override; |
41 | 49 |
42 bool hasUnrealizedSaves() const { return m_unrealizedSaveCount; } | 50 bool hasUnrealizedSaves() const { return m_unrealizedSaveCount; } |
43 void save() { ++m_unrealizedSaveCount; } | 51 void save() { ++m_unrealizedSaveCount; } |
44 void restore() { --m_unrealizedSaveCount; } | 52 void restore() { --m_unrealizedSaveCount; } |
45 void resetUnrealizedSaveCount() { m_unrealizedSaveCount = 0; } | 53 void resetUnrealizedSaveCount() { m_unrealizedSaveCount = 0; } |
46 | 54 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 enum ImageType { | 143 enum ImageType { |
136 NoImage, | 144 NoImage, |
137 OpaqueImage, | 145 OpaqueImage, |
138 NonOpaqueImage | 146 NonOpaqueImage |
139 }; | 147 }; |
140 | 148 |
141 // If paint will not be used for painting a bitmap, set bitmapOpacity to Opa
que | 149 // If paint will not be used for painting a bitmap, set bitmapOpacity to Opa
que |
142 const SkPaint* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; | 150 const SkPaint* getPaint(PaintType, ShadowMode, ImageType = NoImage) const; |
143 | 151 |
144 private: | 152 private: |
| 153 CanvasRenderingContext2DState(); |
| 154 CanvasRenderingContext2DState(const CanvasRenderingContext2DState&, ClipList
CopyMode = CopyClipList); |
| 155 |
145 void updateLineDash() const; | 156 void updateLineDash() const; |
146 void updateStrokeStyle() const; | 157 void updateStrokeStyle() const; |
147 void updateFillStyle() const; | 158 void updateFillStyle() const; |
148 void shadowParameterChanged(); | 159 void shadowParameterChanged(); |
149 SkDrawLooper* emptyDrawLooper() const; | 160 SkDrawLooper* emptyDrawLooper() const; |
150 SkDrawLooper* shadowOnlyDrawLooper() const; | 161 SkDrawLooper* shadowOnlyDrawLooper() const; |
151 SkDrawLooper* shadowAndForegroundDrawLooper() const; | 162 SkDrawLooper* shadowAndForegroundDrawLooper() const; |
152 SkImageFilter* shadowOnlyImageFilter() const; | 163 SkImageFilter* shadowOnlyImageFilter() const; |
153 SkImageFilter* shadowAndForegroundImageFilter() const; | 164 SkImageFilter* shadowAndForegroundImageFilter() const; |
154 | 165 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 mutable bool m_fillStyleDirty : 1; | 203 mutable bool m_fillStyleDirty : 1; |
193 mutable bool m_strokeStyleDirty : 1; | 204 mutable bool m_strokeStyleDirty : 1; |
194 mutable bool m_lineDashDirty : 1; | 205 mutable bool m_lineDashDirty : 1; |
195 | 206 |
196 ClipList m_clipList; | 207 ClipList m_clipList; |
197 }; | 208 }; |
198 | 209 |
199 } // blink | 210 } // blink |
200 | 211 |
201 #endif | 212 #endif |
OLD | NEW |