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