| 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/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 CanvasRenderingContext2D; | 16 class CanvasRenderingContext2D; |
| 17 class CanvasStyle; | 17 class CanvasStyle; |
| 18 class CSSValue; | 18 class CSSValue; |
| 19 class Element; | 19 class Element; |
| 20 | 20 |
| 21 class CanvasRenderingContext2DState final : public NoBaseWillBeGarbageCollectedF
inalized<CanvasRenderingContext2DState>, public CSSFontSelectorClient { | 21 class CanvasRenderingContext2DState final : public GarbageCollectedFinalized<Can
vasRenderingContext2DState>, public CSSFontSelectorClient { |
| 22 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext2DState); | 22 WTF_MAKE_NONCOPYABLE(CanvasRenderingContext2DState); |
| 23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2DState); | 23 USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2DState); |
| 24 USING_FAST_MALLOC_WILL_BE_REMOVED(CanvasRenderingContext2DState); | |
| 25 public: | 24 public: |
| 26 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2DState> create() | 25 static RawPtr<CanvasRenderingContext2DState> create() |
| 27 { | 26 { |
| 28 return adoptPtrWillBeNoop(new CanvasRenderingContext2DState); | 27 return adoptPtrWillBeNoop(new CanvasRenderingContext2DState); |
| 29 } | 28 } |
| 30 | 29 |
| 31 ~CanvasRenderingContext2DState() override; | 30 ~CanvasRenderingContext2DState() override; |
| 32 | 31 |
| 33 DECLARE_VIRTUAL_TRACE(); | 32 DECLARE_VIRTUAL_TRACE(); |
| 34 | 33 |
| 35 enum ClipListCopyMode { | 34 enum ClipListCopyMode { |
| 36 CopyClipList, | 35 CopyClipList, |
| 37 DontCopyClipList | 36 DontCopyClipList |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 enum PaintType { | 39 enum PaintType { |
| 41 FillPaintType, | 40 FillPaintType, |
| 42 StrokePaintType, | 41 StrokePaintType, |
| 43 ImagePaintType, | 42 ImagePaintType, |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2DState> create(const Ca
nvasRenderingContext2DState& other, ClipListCopyMode mode) | 45 static RawPtr<CanvasRenderingContext2DState> create(const CanvasRenderingCon
text2DState& other, ClipListCopyMode mode) |
| 47 { | 46 { |
| 48 return adoptPtrWillBeNoop(new CanvasRenderingContext2DState(other, mode)
); | 47 return new CanvasRenderingContext2DState(other, mode); |
| 49 } | 48 } |
| 50 | 49 |
| 51 // CSSFontSelectorClient implementation | 50 // CSSFontSelectorClient implementation |
| 52 void fontsNeedUpdate(CSSFontSelector*) override; | 51 void fontsNeedUpdate(CSSFontSelector*) override; |
| 53 | 52 |
| 54 bool hasUnrealizedSaves() const { return m_unrealizedSaveCount; } | 53 bool hasUnrealizedSaves() const { return m_unrealizedSaveCount; } |
| 55 void save() { ++m_unrealizedSaveCount; } | 54 void save() { ++m_unrealizedSaveCount; } |
| 56 void restore() { --m_unrealizedSaveCount; } | 55 void restore() { --m_unrealizedSaveCount; } |
| 57 void resetUnrealizedSaveCount() { m_unrealizedSaveCount = 0; } | 56 void resetUnrealizedSaveCount() { m_unrealizedSaveCount = 0; } |
| 58 | 57 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 76 bool hasComplexClip() const { return m_hasComplexClip; } | 75 bool hasComplexClip() const { return m_hasComplexClip; } |
| 77 void playbackClips(SkCanvas* canvas) const { m_clipList.playback(canvas); } | 76 void playbackClips(SkCanvas* canvas) const { m_clipList.playback(canvas); } |
| 78 const SkPath& getCurrentClipPath() const { return m_clipList.getCurrentClipP
ath(); } | 77 const SkPath& getCurrentClipPath() const { return m_clipList.getCurrentClipP
ath(); } |
| 79 | 78 |
| 80 void setFont(const Font&, CSSFontSelector*); | 79 void setFont(const Font&, CSSFontSelector*); |
| 81 const Font& font() const; | 80 const Font& font() const; |
| 82 bool hasRealizedFont() const { return m_realizedFont; } | 81 bool hasRealizedFont() const { return m_realizedFont; } |
| 83 void setUnparsedFont(const String& font) { m_unparsedFont = font; } | 82 void setUnparsedFont(const String& font) { m_unparsedFont = font; } |
| 84 const String& unparsedFont() const { return m_unparsedFont; } | 83 const String& unparsedFont() const { return m_unparsedFont; } |
| 85 | 84 |
| 86 void setFilter(PassRefPtrWillBeRawPtr<CSSValue>); | 85 void setFilter(RawPtr<CSSValue>); |
| 87 void setUnparsedFilter(const String& filterString) { m_unparsedFilter = filt
erString; } | 86 void setUnparsedFilter(const String& filterString) { m_unparsedFilter = filt
erString; } |
| 88 const String& unparsedFilter() const { return m_unparsedFilter; } | 87 const String& unparsedFilter() const { return m_unparsedFilter; } |
| 89 SkImageFilter* getFilter(Element*, const Font&, IntSize canvasSize, CanvasRe
nderingContext2D*) const; | 88 SkImageFilter* getFilter(Element*, const Font&, IntSize canvasSize, CanvasRe
nderingContext2D*) const; |
| 90 bool hasFilter(Element*, const Font&, IntSize canvasSize, CanvasRenderingCon
text2D*) const; | 89 bool hasFilter(Element*, const Font&, IntSize canvasSize, CanvasRenderingCon
text2D*) const; |
| 91 void clearResolvedFilter() const; | 90 void clearResolvedFilter() const; |
| 92 | 91 |
| 93 void setStrokeStyle(CanvasStyle*); | 92 void setStrokeStyle(CanvasStyle*); |
| 94 CanvasStyle* strokeStyle() const { return m_strokeStyle.get(); } | 93 CanvasStyle* strokeStyle() const { return m_strokeStyle.get(); } |
| 95 | 94 |
| 96 void setFillStyle(CanvasStyle*); | 95 void setFillStyle(CanvasStyle*); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 SkDrawLooper* emptyDrawLooper() const; | 175 SkDrawLooper* emptyDrawLooper() const; |
| 177 SkDrawLooper* shadowOnlyDrawLooper() const; | 176 SkDrawLooper* shadowOnlyDrawLooper() const; |
| 178 SkDrawLooper* shadowAndForegroundDrawLooper() const; | 177 SkDrawLooper* shadowAndForegroundDrawLooper() const; |
| 179 SkImageFilter* shadowOnlyImageFilter() const; | 178 SkImageFilter* shadowOnlyImageFilter() const; |
| 180 SkImageFilter* shadowAndForegroundImageFilter() const; | 179 SkImageFilter* shadowAndForegroundImageFilter() const; |
| 181 | 180 |
| 182 unsigned m_unrealizedSaveCount; | 181 unsigned m_unrealizedSaveCount; |
| 183 | 182 |
| 184 String m_unparsedStrokeColor; | 183 String m_unparsedStrokeColor; |
| 185 String m_unparsedFillColor; | 184 String m_unparsedFillColor; |
| 186 PersistentWillBeMember<CanvasStyle> m_strokeStyle; | 185 Member<CanvasStyle> m_strokeStyle; |
| 187 PersistentWillBeMember<CanvasStyle> m_fillStyle; | 186 Member<CanvasStyle> m_fillStyle; |
| 188 | 187 |
| 189 mutable SkPaint m_strokePaint; | 188 mutable SkPaint m_strokePaint; |
| 190 mutable SkPaint m_fillPaint; | 189 mutable SkPaint m_fillPaint; |
| 191 mutable SkPaint m_imagePaint; | 190 mutable SkPaint m_imagePaint; |
| 192 | 191 |
| 193 FloatSize m_shadowOffset; | 192 FloatSize m_shadowOffset; |
| 194 double m_shadowBlur; | 193 double m_shadowBlur; |
| 195 SkColor m_shadowColor; | 194 SkColor m_shadowColor; |
| 196 mutable RefPtr<SkDrawLooper> m_emptyDrawLooper; | 195 mutable RefPtr<SkDrawLooper> m_emptyDrawLooper; |
| 197 mutable RefPtr<SkDrawLooper> m_shadowOnlyDrawLooper; | 196 mutable RefPtr<SkDrawLooper> m_shadowOnlyDrawLooper; |
| 198 mutable RefPtr<SkDrawLooper> m_shadowAndForegroundDrawLooper; | 197 mutable RefPtr<SkDrawLooper> m_shadowAndForegroundDrawLooper; |
| 199 mutable RefPtr<SkImageFilter> m_shadowOnlyImageFilter; | 198 mutable RefPtr<SkImageFilter> m_shadowOnlyImageFilter; |
| 200 mutable RefPtr<SkImageFilter> m_shadowAndForegroundImageFilter; | 199 mutable RefPtr<SkImageFilter> m_shadowAndForegroundImageFilter; |
| 201 | 200 |
| 202 double m_globalAlpha; | 201 double m_globalAlpha; |
| 203 AffineTransform m_transform; | 202 AffineTransform m_transform; |
| 204 Vector<double> m_lineDash; | 203 Vector<double> m_lineDash; |
| 205 double m_lineDashOffset; | 204 double m_lineDashOffset; |
| 206 | 205 |
| 207 String m_unparsedFont; | 206 String m_unparsedFont; |
| 208 Font m_font; | 207 Font m_font; |
| 209 | 208 |
| 210 String m_unparsedFilter; | 209 String m_unparsedFilter; |
| 211 RefPtrWillBeMember<CSSValue> m_filterValue; | 210 Member<CSSValue> m_filterValue; |
| 212 mutable RefPtr<SkImageFilter> m_resolvedFilter; | 211 mutable RefPtr<SkImageFilter> m_resolvedFilter; |
| 213 | 212 |
| 214 // Text state. | 213 // Text state. |
| 215 TextAlign m_textAlign; | 214 TextAlign m_textAlign; |
| 216 TextBaseline m_textBaseline; | 215 TextBaseline m_textBaseline; |
| 217 Direction m_direction; | 216 Direction m_direction; |
| 218 | 217 |
| 219 bool m_realizedFont : 1; | 218 bool m_realizedFont : 1; |
| 220 bool m_isTransformInvertible : 1; | 219 bool m_isTransformInvertible : 1; |
| 221 bool m_hasClip : 1; | 220 bool m_hasClip : 1; |
| 222 bool m_hasComplexClip : 1; | 221 bool m_hasComplexClip : 1; |
| 223 mutable bool m_fillStyleDirty : 1; | 222 mutable bool m_fillStyleDirty : 1; |
| 224 mutable bool m_strokeStyleDirty : 1; | 223 mutable bool m_strokeStyleDirty : 1; |
| 225 mutable bool m_lineDashDirty : 1; | 224 mutable bool m_lineDashDirty : 1; |
| 226 | 225 |
| 227 bool m_imageSmoothingEnabled; | 226 bool m_imageSmoothingEnabled; |
| 228 SkFilterQuality m_imageSmoothingQuality; | 227 SkFilterQuality m_imageSmoothingQuality; |
| 229 | 228 |
| 230 ClipList m_clipList; | 229 ClipList m_clipList; |
| 231 }; | 230 }; |
| 232 | 231 |
| 233 } // namespace blink | 232 } // namespace blink |
| 234 | 233 |
| 235 #endif | 234 #endif |
| OLD | NEW |