| 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; // overrides |
| 180 // BaseRenderingContext2D and |
| 181 // CanvasRenderingContext |
| 183 | 182 |
| 184 bool stateHasFilter() final; | 183 bool stateHasFilter() final; |
| 185 sk_sp<SkImageFilter> stateGetFilter() final; | 184 sk_sp<SkImageFilter> stateGetFilter() final; |
| 186 void snapshotStateForFilter() final; | 185 void snapshotStateForFilter() final; |
| 187 | 186 |
| 188 void validateStateStack() const final; | 187 void validateStateStack() const final; |
| 189 | 188 |
| 190 PassRefPtr<Image> getImage(AccelerationHint, SnapshotReason) const final; | 189 PassRefPtr<Image> getImage(AccelerationHint, SnapshotReason) const final; |
| 191 | 190 |
| 192 bool isAccelerationOptimalForCanvasContent() const; | 191 bool isAccelerationOptimalForCanvasContent() const; |
| 193 | 192 |
| 194 void resetUsageTracking(); | 193 void resetUsageTracking(); |
| 195 | 194 |
| 196 void incrementFrameCount() { m_usageCounters.numFramesSinceReset++; } | 195 void incrementFrameCount() { m_usageCounters.numFramesSinceReset++; } |
| 197 | 196 |
| 198 bool isPaintable() const final { return hasImageBuffer(); } | 197 bool isPaintable() const final { return hasImageBuffer(); } |
| 199 | 198 |
| 200 ColorBehavior drawImageColorBehavior() const final; | 199 ColorBehavior drawImageColorBehavior() const final; |
| 201 | 200 |
| 202 void willDrawImage(CanvasImageSource*) const final; | 201 void willDrawImage(CanvasImageSource*) const final; |
| 203 | 202 |
| 204 private: | 203 private: |
| 205 friend class CanvasRenderingContext2DAutoRestoreSkCanvas; | 204 friend class CanvasRenderingContext2DAutoRestoreSkCanvas; |
| 206 | 205 |
| 207 CanvasRenderingContext2D(HTMLCanvasElement*, | 206 CanvasRenderingContext2D(HTMLCanvasElement*, |
| 208 const CanvasContextCreationAttributes& attrs, | 207 const CanvasContextCreationAttributes& attrs, |
| 209 Document&); | 208 Document&); |
| 210 | 209 |
| 211 void dispose(); | |
| 212 | |
| 213 void dispatchContextLostEvent(TimerBase*); | 210 void dispatchContextLostEvent(TimerBase*); |
| 214 void dispatchContextRestoredEvent(TimerBase*); | 211 void dispatchContextRestoredEvent(TimerBase*); |
| 215 void tryRestoreContextEvent(TimerBase*); | 212 void tryRestoreContextEvent(TimerBase*); |
| 216 | 213 |
| 217 void pruneLocalFontCache(size_t targetSize); | 214 void pruneLocalFontCache(size_t targetSize); |
| 218 void schedulePruneLocalFontCacheIfNeeded(); | |
| 219 | 215 |
| 220 void scrollPathIntoViewInternal(const Path&); | 216 void scrollPathIntoViewInternal(const Path&); |
| 221 | 217 |
| 222 void drawTextInternal(const String&, | 218 void drawTextInternal(const String&, |
| 223 double x, | 219 double x, |
| 224 double y, | 220 double y, |
| 225 CanvasRenderingContext2DState::PaintType, | 221 CanvasRenderingContext2DState::PaintType, |
| 226 double* maxWidth = nullptr); | 222 double* maxWidth = nullptr); |
| 227 | 223 |
| 228 const Font& accessFont(); | 224 const Font& accessFont(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 250 Member<HitRegionManager> m_hitRegionManager; | 246 Member<HitRegionManager> m_hitRegionManager; |
| 251 LostContextMode m_contextLostMode; | 247 LostContextMode m_contextLostMode; |
| 252 bool m_contextRestorable; | 248 bool m_contextRestorable; |
| 253 unsigned m_tryRestoreContextAttemptCount; | 249 unsigned m_tryRestoreContextAttemptCount; |
| 254 TaskRunnerTimer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 250 TaskRunnerTimer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
| 255 TaskRunnerTimer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 251 TaskRunnerTimer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
| 256 TaskRunnerTimer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 252 TaskRunnerTimer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
| 257 | 253 |
| 258 FilterOperations m_filterOperations; | 254 FilterOperations m_filterOperations; |
| 259 HashMap<String, Font> m_fontsResolvedUsingCurrentStyle; | 255 HashMap<String, Font> m_fontsResolvedUsingCurrentStyle; |
| 260 bool m_pruneLocalFontCacheScheduled; | 256 bool m_shouldPruneLocalFontCache; |
| 261 ListHashSet<String> m_fontLRUList; | 257 ListHashSet<String> m_fontLRUList; |
| 262 }; | 258 }; |
| 263 | 259 |
| 264 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, | 260 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, |
| 265 CanvasRenderingContext, | 261 CanvasRenderingContext, |
| 266 context, | 262 context, |
| 267 context->is2d() && context->canvas(), | 263 context->is2d() && context->canvas(), |
| 268 context.is2d() && context.canvas()); | 264 context.is2d() && context.canvas()); |
| 269 | 265 |
| 270 } // namespace blink | 266 } // namespace blink |
| 271 | 267 |
| 272 #endif // CanvasRenderingContext2D_h | 268 #endif // CanvasRenderingContext2D_h |
| OLD | NEW |