OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 class HitTestCanvasResult; | 60 class HitTestCanvasResult; |
61 class Path2D; | 61 class Path2D; |
62 class TextMetrics; | 62 class TextMetrics; |
63 | 63 |
64 typedef CSSImageValueOrHTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrIm ageBitmapOrOffscreenCanvas | 64 typedef CSSImageValueOrHTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrIm ageBitmapOrOffscreenCanvas |
65 CanvasImageSourceUnion; | 65 CanvasImageSourceUnion; |
66 | 66 |
67 class MODULES_EXPORT CanvasRenderingContext2D final | 67 class MODULES_EXPORT CanvasRenderingContext2D final |
68 : public CanvasRenderingContext, | 68 : public CanvasRenderingContext, |
69 public BaseRenderingContext2D, | 69 public BaseRenderingContext2D, |
70 public WebThread::TaskObserver, | |
71 public SVGResourceClient { | 70 public SVGResourceClient { |
72 DEFINE_WRAPPERTYPEINFO(); | 71 DEFINE_WRAPPERTYPEINFO(); |
73 USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2D); | 72 USING_GARBAGE_COLLECTED_MIXIN(CanvasRenderingContext2D); |
74 USING_PRE_FINALIZER(CanvasRenderingContext2D, dispose); | |
75 | 73 |
76 public: | 74 public: |
77 class Factory : public CanvasRenderingContextFactory { | 75 class Factory : public CanvasRenderingContextFactory { |
78 WTF_MAKE_NONCOPYABLE(Factory); | 76 WTF_MAKE_NONCOPYABLE(Factory); |
79 | 77 |
80 public: | 78 public: |
81 Factory() {} | 79 Factory() {} |
82 ~Factory() override {} | 80 ~Factory() override {} |
83 | 81 |
84 CanvasRenderingContext* create(HTMLCanvasElement* canvas, | 82 CanvasRenderingContext* create(HTMLCanvasElement* canvas, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 void clearHitRegions(); | 133 void clearHitRegions(); |
136 HitRegion* hitRegionAtPoint(const FloatPoint&); | 134 HitRegion* hitRegionAtPoint(const FloatPoint&); |
137 unsigned hitRegionsCount() const override; | 135 unsigned hitRegionsCount() const override; |
138 | 136 |
139 void loseContext(LostContextMode) override; | 137 void loseContext(LostContextMode) override; |
140 void didSetSurfaceSize() override; | 138 void didSetSurfaceSize() override; |
141 | 139 |
142 void restoreCanvasMatrixClipStack(PaintCanvas*) const override; | 140 void restoreCanvasMatrixClipStack(PaintCanvas*) const override; |
143 | 141 |
144 // TaskObserver implementation | 142 // TaskObserver implementation |
145 void didProcessTask() override; | 143 void didProcessTask() final; |
146 void willProcessTask() override {} | |
147 | 144 |
148 void styleDidChange(const ComputedStyle* oldStyle, | 145 void styleDidChange(const ComputedStyle* oldStyle, |
149 const ComputedStyle& newStyle) override; | 146 const ComputedStyle& newStyle) override; |
150 HitTestCanvasResult* getControlAndIdIfHitRegionExists( | 147 HitTestCanvasResult* getControlAndIdIfHitRegionExists( |
151 const LayoutPoint& location) override; | 148 const LayoutPoint& location) override; |
152 String getIdFromControl(const Element*) override; | 149 String getIdFromControl(const Element*) override; |
153 | 150 |
154 // SVGResourceClient implementation | 151 // SVGResourceClient implementation |
155 TreeScope* treeScope() override; | 152 TreeScope* treeScope() override; |
156 void resourceContentChanged() override; | 153 void resourceContentChanged() override; |
(...skipping 15 matching lines...) Expand all Loading... | |
172 bool hasImageBuffer() const final; | 169 bool hasImageBuffer() const final; |
173 ImageBuffer* imageBuffer() const final; | 170 ImageBuffer* imageBuffer() const final; |
174 | 171 |
175 bool parseColorOrCurrentColor(Color&, const String& colorString) const final; | 172 bool parseColorOrCurrentColor(Color&, const String& colorString) const final; |
176 | 173 |
177 PaintCanvas* drawingCanvas() const final; | 174 PaintCanvas* drawingCanvas() const final; |
178 PaintCanvas* existingDrawingCanvas() const final; | 175 PaintCanvas* existingDrawingCanvas() const final; |
179 void disableDeferral(DisableDeferralReason) final; | 176 void disableDeferral(DisableDeferralReason) final; |
180 | 177 |
181 AffineTransform baseTransform() const final; | 178 AffineTransform baseTransform() const final; |
182 void didDraw(const SkIRect& dirtyRect) final; | 179 void didDraw(const SkIRect& dirtyRect) final; |
xlai (Olivia)
2017/02/08 17:58:40
Both BaseRenderingContext2D and CanvasRenderingCon
Justin Novosad
2017/02/08 18:43:12
That is intentional, but I will add a comment to t
| |
183 | 180 |
184 bool stateHasFilter() final; | 181 bool stateHasFilter() final; |
185 sk_sp<SkImageFilter> stateGetFilter() final; | 182 sk_sp<SkImageFilter> stateGetFilter() final; |
186 void snapshotStateForFilter() final; | 183 void snapshotStateForFilter() final; |
187 | 184 |
188 void validateStateStack() const final; | 185 void validateStateStack() const final; |
189 | 186 |
190 PassRefPtr<Image> getImage(AccelerationHint, SnapshotReason) const final; | 187 PassRefPtr<Image> getImage(AccelerationHint, SnapshotReason) const final; |
191 | 188 |
192 bool isAccelerationOptimalForCanvasContent() const; | 189 bool isAccelerationOptimalForCanvasContent() const; |
193 | 190 |
194 void resetUsageTracking(); | 191 void resetUsageTracking(); |
195 | 192 |
196 void incrementFrameCount() { m_usageCounters.numFramesSinceReset++; } | 193 void incrementFrameCount() { m_usageCounters.numFramesSinceReset++; } |
197 | 194 |
198 bool isPaintable() const final { return hasImageBuffer(); } | 195 bool isPaintable() const final { return hasImageBuffer(); } |
199 | 196 |
200 ColorBehavior drawImageColorBehavior() const final; | 197 ColorBehavior drawImageColorBehavior() const final; |
201 | 198 |
202 void willDrawImage(CanvasImageSource*) const final; | 199 void willDrawImage(CanvasImageSource*) const final; |
203 | 200 |
204 private: | 201 private: |
205 friend class CanvasRenderingContext2DAutoRestoreSkCanvas; | 202 friend class CanvasRenderingContext2DAutoRestoreSkCanvas; |
206 | 203 |
207 CanvasRenderingContext2D(HTMLCanvasElement*, | 204 CanvasRenderingContext2D(HTMLCanvasElement*, |
208 const CanvasContextCreationAttributes& attrs, | 205 const CanvasContextCreationAttributes& attrs, |
209 Document&); | 206 Document&); |
210 | 207 |
211 void dispose(); | |
212 | |
213 void dispatchContextLostEvent(TimerBase*); | 208 void dispatchContextLostEvent(TimerBase*); |
214 void dispatchContextRestoredEvent(TimerBase*); | 209 void dispatchContextRestoredEvent(TimerBase*); |
215 void tryRestoreContextEvent(TimerBase*); | 210 void tryRestoreContextEvent(TimerBase*); |
216 | 211 |
217 void pruneLocalFontCache(size_t targetSize); | 212 void pruneLocalFontCache(size_t targetSize); |
218 void schedulePruneLocalFontCacheIfNeeded(); | |
219 | 213 |
220 void scrollPathIntoViewInternal(const Path&); | 214 void scrollPathIntoViewInternal(const Path&); |
221 | 215 |
222 void drawTextInternal(const String&, | 216 void drawTextInternal(const String&, |
223 double x, | 217 double x, |
224 double y, | 218 double y, |
225 CanvasRenderingContext2DState::PaintType, | 219 CanvasRenderingContext2DState::PaintType, |
226 double* maxWidth = nullptr); | 220 double* maxWidth = nullptr); |
227 | 221 |
228 const Font& accessFont(); | 222 const Font& accessFont(); |
(...skipping 21 matching lines...) Expand all Loading... | |
250 Member<HitRegionManager> m_hitRegionManager; | 244 Member<HitRegionManager> m_hitRegionManager; |
251 LostContextMode m_contextLostMode; | 245 LostContextMode m_contextLostMode; |
252 bool m_contextRestorable; | 246 bool m_contextRestorable; |
253 unsigned m_tryRestoreContextAttemptCount; | 247 unsigned m_tryRestoreContextAttemptCount; |
254 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 248 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
255 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 249 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
256 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 250 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
257 | 251 |
258 FilterOperations m_filterOperations; | 252 FilterOperations m_filterOperations; |
259 HashMap<String, Font> m_fontsResolvedUsingCurrentStyle; | 253 HashMap<String, Font> m_fontsResolvedUsingCurrentStyle; |
260 bool m_pruneLocalFontCacheScheduled; | 254 bool m_shouldPruneLocalFontCache; |
261 ListHashSet<String> m_fontLRUList; | 255 ListHashSet<String> m_fontLRUList; |
262 }; | 256 }; |
263 | 257 |
264 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, | 258 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, |
265 CanvasRenderingContext, | 259 CanvasRenderingContext, |
266 context, | 260 context, |
267 context->is2d() && context->canvas(), | 261 context->is2d() && context->canvas(), |
268 context.is2d() && context.canvas()); | 262 context.is2d() && context.canvas()); |
269 | 263 |
270 } // namespace blink | 264 } // namespace blink |
271 | 265 |
272 #endif // CanvasRenderingContext2D_h | 266 #endif // CanvasRenderingContext2D_h |
OLD | NEW |