Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.h

Issue 211503006: Implementation of 2D canvas context lost/restored events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: adding missing file Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Apple Inc. All rights reserv ed.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 float shadowBlur() const; 106 float shadowBlur() const;
107 void setShadowBlur(float); 107 void setShadowBlur(float);
108 108
109 String shadowColor() const; 109 String shadowColor() const;
110 void setShadowColor(const String&); 110 void setShadowColor(const String&);
111 111
112 float globalAlpha() const; 112 float globalAlpha() const;
113 void setGlobalAlpha(float); 113 void setGlobalAlpha(float);
114 114
115 bool isContextLost() const;
116
115 String globalCompositeOperation() const; 117 String globalCompositeOperation() const;
116 void setGlobalCompositeOperation(const String&); 118 void setGlobalCompositeOperation(const String&);
117 119
118 void save() { ++m_stateStack.last().m_unrealizedSaveCount; } 120 void save() { ++m_stateStack.last().m_unrealizedSaveCount; }
119 void restore(); 121 void restore();
120 122
121 PassRefPtr<SVGMatrixTearOff> currentTransform() const 123 PassRefPtr<SVGMatrixTearOff> currentTransform() const
122 { 124 {
123 return SVGMatrixTearOff::create(state().m_transform); 125 return SVGMatrixTearOff::create(state().m_transform);
124 } 126 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 LineJoin getLineJoin() const { return state().m_lineJoin; } 228 LineJoin getLineJoin() const { return state().m_lineJoin; }
227 229
228 bool imageSmoothingEnabled() const; 230 bool imageSmoothingEnabled() const;
229 void setImageSmoothingEnabled(bool); 231 void setImageSmoothingEnabled(bool);
230 232
231 PassRefPtr<Canvas2DContextAttributes> getContextAttributes() const; 233 PassRefPtr<Canvas2DContextAttributes> getContextAttributes() const;
232 234
233 void drawFocusIfNeeded(Element*); 235 void drawFocusIfNeeded(Element*);
234 bool drawCustomFocusRing(Element*); 236 bool drawCustomFocusRing(Element*);
235 237
238 void loseContext();
239 void restoreContext();
240
236 private: 241 private:
237 struct State FINAL : CSSFontSelectorClient { 242 struct State FINAL : CSSFontSelectorClient {
238 State(); 243 State();
239 virtual ~State(); 244 virtual ~State();
240 245
241 State(const State&); 246 State(const State&);
242 State& operator=(const State&); 247 State& operator=(const State&);
243 248
244 // CSSFontSelectorClient implementation 249 // CSSFontSelectorClient implementation
245 virtual void fontsNeedUpdate(CSSFontSelector*) OVERRIDE; 250 virtual void fontsNeedUpdate(CSSFontSelector*) OVERRIDE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes * attrs, bool usesCSSCompatibilityParseMode); 283 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes * attrs, bool usesCSSCompatibilityParseMode);
279 284
280 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return m_ stateStack.last(); } 285 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return m_ stateStack.last(); }
281 const State& state() const { return m_stateStack.last(); } 286 const State& state() const { return m_stateStack.last(); }
282 287
283 void applyLineDash() const; 288 void applyLineDash() const;
284 void setShadow(const FloatSize& offset, float blur, RGBA32 color); 289 void setShadow(const FloatSize& offset, float blur, RGBA32 color);
285 void applyShadow(); 290 void applyShadow();
286 bool shouldDrawShadows() const; 291 bool shouldDrawShadows() const;
287 292
293 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*);
294 void dispatchContextRestoredEvent(Timer<CanvasRenderingContext2D>*);
295 void tryRestoreSurfaceEvent(Timer<CanvasRenderingContext2D>*);
Stephen White 2014/03/25 23:25:04 Naming nit: does "surface" really have a meaning a
296
288 bool computeDirtyRect(const FloatRect& localBounds, FloatRect*); 297 bool computeDirtyRect(const FloatRect& localBounds, FloatRect*);
289 bool computeDirtyRect(const FloatRect& localBounds, const FloatRect& transfo rmedClipBounds, FloatRect*); 298 bool computeDirtyRect(const FloatRect& localBounds, const FloatRect& transfo rmedClipBounds, FloatRect*);
290 void didDraw(const FloatRect&); 299 void didDraw(const FloatRect&);
291 300
292 GraphicsContext* drawingContext() const; 301 GraphicsContext* drawingContext() const;
293 302
294 void unwindStateStack(); 303 void unwindStateStack();
295 void realizeSaves(); 304 void realizeSaves();
296 305
297 void applyStrokePattern(); 306 void applyStrokePattern();
(...skipping 30 matching lines...) Expand all
328 virtual bool isAccelerated() const OVERRIDE; 337 virtual bool isAccelerated() const OVERRIDE;
329 virtual bool hasAlpha() const OVERRIDE { return m_hasAlpha; } 338 virtual bool hasAlpha() const OVERRIDE { return m_hasAlpha; }
330 339
331 virtual bool isTransformInvertible() const OVERRIDE { return state().m_inver tibleCTM; } 340 virtual bool isTransformInvertible() const OVERRIDE { return state().m_inver tibleCTM; }
332 341
333 virtual blink::WebLayer* platformLayer() const OVERRIDE; 342 virtual blink::WebLayer* platformLayer() const OVERRIDE;
334 343
335 Vector<State, 1> m_stateStack; 344 Vector<State, 1> m_stateStack;
336 bool m_usesCSSCompatibilityParseMode; 345 bool m_usesCSSCompatibilityParseMode;
337 bool m_hasAlpha; 346 bool m_hasAlpha;
347 bool m_isContextLost;
348 bool m_contextRestorable;
349 Canvas2DContextStorage m_storageMode;
338 MutableStylePropertyMap m_fetchedFonts; 350 MutableStylePropertyMap m_fetchedFonts;
351 unsigned m_tryRestoreSurfaceAttemptCount;
352 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer;
353 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer;
354 Timer<CanvasRenderingContext2D> m_tryRestoreSurfaceEventTimer;
339 }; 355 };
340 356
341 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con text->is2d(), context.is2d()); 357 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con text->is2d(), context.is2d());
342 358
343 } // namespace WebCore 359 } // namespace WebCore
344 360
345 #endif 361 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698