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 23 matching lines...) Expand all Loading... |
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 |
73 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { | 74 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { |
74 DEFINE_WRAPPERTYPEINFO(); | 75 DEFINE_WRAPPERTYPEINFO(); |
75 public: | 76 public: |
76 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const Canvas2DContextAttributes* attrs, Document& document) | 77 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const CanvasContextCreationAttributes& attrs, Document& document) |
77 { | 78 { |
78 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, do
cument)); | 79 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, do
cument)); |
79 } | 80 } |
80 virtual ~CanvasRenderingContext2D(); | 81 virtual ~CanvasRenderingContext2D(); |
81 | 82 |
82 void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const; | 83 void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const; |
83 void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&); | 84 void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&); |
84 | 85 |
85 void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const; | 86 void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const; |
86 void setFillStyle(const StringOrCanvasGradientOrCanvasPattern&); | 87 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); | 194 void strokeText(const String& text, float x, float y); |
194 void strokeText(const String& text, float x, float y, float maxWidth); | 195 void strokeText(const String& text, float x, float y, float maxWidth); |
195 PassRefPtrWillBeRawPtr<TextMetrics> measureText(const String& text); | 196 PassRefPtrWillBeRawPtr<TextMetrics> measureText(const String& text); |
196 | 197 |
197 LineCap getLineCap() const { return state().m_lineCap; } | 198 LineCap getLineCap() const { return state().m_lineCap; } |
198 LineJoin getLineJoin() const { return state().m_lineJoin; } | 199 LineJoin getLineJoin() const { return state().m_lineJoin; } |
199 | 200 |
200 bool imageSmoothingEnabled() const; | 201 bool imageSmoothingEnabled() const; |
201 void setImageSmoothingEnabled(bool); | 202 void setImageSmoothingEnabled(bool); |
202 | 203 |
203 PassRefPtrWillBeRawPtr<Canvas2DContextAttributes> getContextAttributes() con
st; | 204 void getContextAttributes(Canvas2DContextAttributes&) const; |
204 | 205 |
205 void drawFocusIfNeeded(Element*); | 206 void drawFocusIfNeeded(Element*); |
206 void drawFocusIfNeeded(Path2D*, Element*); | 207 void drawFocusIfNeeded(Path2D*, Element*); |
207 | 208 |
208 void addHitRegion(const HitRegionOptions&, ExceptionState&); | 209 void addHitRegion(const HitRegionOptions&, ExceptionState&); |
209 void removeHitRegion(const String& id); | 210 void removeHitRegion(const String& id); |
210 void clearHitRegions(); | 211 void clearHitRegions(); |
211 HitRegion* hitRegionAtPoint(const LayoutPoint&); | 212 HitRegion* hitRegionAtPoint(const LayoutPoint&); |
212 unsigned hitRegionsCount() const; | 213 unsigned hitRegionsCount() const; |
213 | 214 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 273 |
273 String m_unparsedFont; | 274 String m_unparsedFont; |
274 Font m_font; | 275 Font m_font; |
275 bool m_realizedFont; | 276 bool m_realizedFont; |
276 | 277 |
277 bool m_hasClip; | 278 bool m_hasClip; |
278 | 279 |
279 ClipList m_clipList; | 280 ClipList m_clipList; |
280 }; | 281 }; |
281 | 282 |
282 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes
* attrs, Document&); | 283 CanvasRenderingContext2D(HTMLCanvasElement*, const CanvasContextCreationAttr
ibutes& attrs, Document&); |
283 | 284 |
284 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } | 285 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } |
285 const State& state() const { return *m_stateStack.last(); } | 286 const State& state() const { return *m_stateStack.last(); } |
286 | 287 |
287 void applyLineDash() const; | 288 void applyLineDash() const; |
288 void setShadow(const FloatSize& offset, float blur, RGBA32 color); | 289 void setShadow(const FloatSize& offset, float blur, RGBA32 color); |
289 void applyShadow(ShadowMode = DrawShadowAndForeground); | 290 void applyShadow(ShadowMode = DrawShadowAndForeground); |
290 bool shouldDrawShadows() const; | 291 bool shouldDrawShadows() const; |
291 | 292 |
292 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); | 293 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 virtual WebLayer* platformLayer() const override; | 347 virtual WebLayer* platformLayer() const override; |
347 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; | 348 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; |
348 | 349 |
349 WillBeHeapVector<OwnPtrWillBeMember<State>> m_stateStack; | 350 WillBeHeapVector<OwnPtrWillBeMember<State>> m_stateStack; |
350 OwnPtrWillBeMember<HitRegionManager> m_hitRegionManager; | 351 OwnPtrWillBeMember<HitRegionManager> m_hitRegionManager; |
351 bool m_usesCSSCompatibilityParseMode; | 352 bool m_usesCSSCompatibilityParseMode; |
352 AntiAliasingMode m_clipAntialiasing; | 353 AntiAliasingMode m_clipAntialiasing; |
353 bool m_hasAlpha; | 354 bool m_hasAlpha; |
354 bool m_isContextLost; | 355 bool m_isContextLost; |
355 bool m_contextRestorable; | 356 bool m_contextRestorable; |
356 Canvas2DContextStorage m_storageMode; | |
357 MutableStylePropertyMap m_fetchedFonts; | 357 MutableStylePropertyMap m_fetchedFonts; |
358 ListHashSet<String> m_fetchedFontsLRUList; | 358 ListHashSet<String> m_fetchedFontsLRUList; |
359 unsigned m_tryRestoreContextAttemptCount; | 359 unsigned m_tryRestoreContextAttemptCount; |
360 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 360 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
361 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 361 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
362 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 362 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
363 }; | 363 }; |
364 | 364 |
365 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); | 365 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); |
366 | 366 |
367 } // namespace blink | 367 } // namespace blink |
368 | 368 |
369 #endif // CanvasRenderingContext2D_h | 369 #endif // CanvasRenderingContext2D_h |
OLD | NEW |