OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef CanvasRenderingContext2D_h | 26 #ifndef CanvasRenderingContext2D_h |
27 #define CanvasRenderingContext2D_h | 27 #define CanvasRenderingContext2D_h |
28 | 28 |
29 #include "bindings/core/v8/ScriptWrappable.h" | 29 #include "bindings/core/v8/ScriptWrappable.h" |
30 #include "bindings/core/v8/UnionTypesCore.h" | 30 #include "bindings/core/v8/UnionTypesCore.h" |
31 #include "core/css/CSSFontSelectorClient.h" | 31 #include "core/css/CSSFontSelectorClient.h" |
32 #include "core/html/canvas/Canvas2DContextAttributes.h" | 32 #include "core/html/canvas/Canvas2DContextAttributes.h" |
| 33 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
33 #include "core/html/canvas/CanvasPathMethods.h" | 34 #include "core/html/canvas/CanvasPathMethods.h" |
34 #include "core/html/canvas/CanvasRenderingContext.h" | 35 #include "core/html/canvas/CanvasRenderingContext.h" |
35 #include "core/html/canvas/ClipList.h" | 36 #include "core/html/canvas/ClipList.h" |
36 #include "core/html/canvas/HitRegion.h" | 37 #include "core/html/canvas/HitRegion.h" |
37 #include "core/svg/SVGMatrixTearOff.h" | 38 #include "core/svg/SVGMatrixTearOff.h" |
38 #include "platform/fonts/Font.h" | 39 #include "platform/fonts/Font.h" |
39 #include "platform/graphics/Color.h" | 40 #include "platform/graphics/Color.h" |
40 #include "platform/geometry/FloatSize.h" | 41 #include "platform/geometry/FloatSize.h" |
41 #include "platform/graphics/GraphicsContext.h" | 42 #include "platform/graphics/GraphicsContext.h" |
42 #include "platform/graphics/GraphicsTypes.h" | 43 #include "platform/graphics/GraphicsTypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
63 class HTMLCanvasElement; | 64 class HTMLCanvasElement; |
64 class HTMLImageElement; | 65 class HTMLImageElement; |
65 class HTMLVideoElement; | 66 class HTMLVideoElement; |
66 class ImageData; | 67 class ImageData; |
67 class TextMetrics; | 68 class TextMetrics; |
68 | 69 |
69 typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrImageBitmap Canva
sImageSourceUnion; | 70 typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrImageBitmap Canva
sImageSourceUnion; |
70 | 71 |
71 typedef WillBeHeapHashMap<String, RefPtrWillBeMember<MutableStylePropertySet>> M
utableStylePropertyMap; | 72 typedef WillBeHeapHashMap<String, RefPtrWillBeMember<MutableStylePropertySet>> M
utableStylePropertyMap; |
72 | 73 |
| 74 enum Canvas2DContextStorage { |
| 75 PersistentStorage, |
| 76 DiscardableStorage |
| 77 }; |
| 78 |
73 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { | 79 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { |
74 DEFINE_WRAPPERTYPEINFO(); | 80 DEFINE_WRAPPERTYPEINFO(); |
75 public: | 81 public: |
76 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const Canvas2DContextAttributes* attrs, Document& document) | 82 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const CanvasContextCreationAttributes& attrs, Document& document) |
77 { | 83 { |
78 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, do
cument)); | 84 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, do
cument)); |
79 } | 85 } |
80 virtual ~CanvasRenderingContext2D(); | 86 virtual ~CanvasRenderingContext2D(); |
81 | 87 |
82 void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const; | 88 void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const; |
83 void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&); | 89 void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&); |
84 | 90 |
85 void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const; | 91 void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const; |
86 void setFillStyle(const StringOrCanvasGradientOrCanvasPattern&); | 92 void setFillStyle(const StringOrCanvasGradientOrCanvasPattern&); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void strokeText(const String& text, float x, float y); | 199 void strokeText(const String& text, float x, float y); |
194 void strokeText(const String& text, float x, float y, float maxWidth); | 200 void strokeText(const String& text, float x, float y, float maxWidth); |
195 PassRefPtrWillBeRawPtr<TextMetrics> measureText(const String& text); | 201 PassRefPtrWillBeRawPtr<TextMetrics> measureText(const String& text); |
196 | 202 |
197 LineCap getLineCap() const { return state().m_lineCap; } | 203 LineCap getLineCap() const { return state().m_lineCap; } |
198 LineJoin getLineJoin() const { return state().m_lineJoin; } | 204 LineJoin getLineJoin() const { return state().m_lineJoin; } |
199 | 205 |
200 bool imageSmoothingEnabled() const; | 206 bool imageSmoothingEnabled() const; |
201 void setImageSmoothingEnabled(bool); | 207 void setImageSmoothingEnabled(bool); |
202 | 208 |
203 PassRefPtrWillBeRawPtr<Canvas2DContextAttributes> getContextAttributes() con
st; | 209 void getContextAttributes(Canvas2DContextAttributes&) const; |
204 | 210 |
205 void drawFocusIfNeeded(Element*); | 211 void drawFocusIfNeeded(Element*); |
206 void drawFocusIfNeeded(Path2D*, Element*); | 212 void drawFocusIfNeeded(Path2D*, Element*); |
207 | 213 |
208 void addHitRegion(const HitRegionOptions&, ExceptionState&); | 214 void addHitRegion(const HitRegionOptions&, ExceptionState&); |
209 void removeHitRegion(const String& id); | 215 void removeHitRegion(const String& id); |
210 void clearHitRegions(); | 216 void clearHitRegions(); |
211 HitRegion* hitRegionAtPoint(const LayoutPoint&); | 217 HitRegion* hitRegionAtPoint(const LayoutPoint&); |
212 unsigned hitRegionsCount() const; | 218 unsigned hitRegionsCount() const; |
213 | 219 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 278 |
273 String m_unparsedFont; | 279 String m_unparsedFont; |
274 Font m_font; | 280 Font m_font; |
275 bool m_realizedFont; | 281 bool m_realizedFont; |
276 | 282 |
277 bool m_hasClip; | 283 bool m_hasClip; |
278 | 284 |
279 ClipList m_clipList; | 285 ClipList m_clipList; |
280 }; | 286 }; |
281 | 287 |
282 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes
* attrs, Document&); | 288 CanvasRenderingContext2D(HTMLCanvasElement*, const CanvasContextCreationAttr
ibutes& attrs, Document&); |
283 | 289 |
284 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } | 290 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } |
285 const State& state() const { return *m_stateStack.last(); } | 291 const State& state() const { return *m_stateStack.last(); } |
286 | 292 |
287 void applyLineDash() const; | 293 void applyLineDash() const; |
288 void setShadow(const FloatSize& offset, float blur, RGBA32 color); | 294 void setShadow(const FloatSize& offset, float blur, RGBA32 color); |
289 void applyShadow(ShadowMode = DrawShadowAndForeground); | 295 void applyShadow(ShadowMode = DrawShadowAndForeground); |
290 bool shouldDrawShadows() const; | 296 bool shouldDrawShadows() const; |
291 | 297 |
292 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); | 298 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 366 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
361 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 367 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
362 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 368 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
363 }; | 369 }; |
364 | 370 |
365 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); | 371 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); |
366 | 372 |
367 } // namespace blink | 373 } // namespace blink |
368 | 374 |
369 #endif // CanvasRenderingContext2D_h | 375 #endif // CanvasRenderingContext2D_h |
OLD | NEW |