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 18 matching lines...) Expand all Loading... |
29 #include "bindings/core/v8/ScriptWrappable.h" | 29 #include "bindings/core/v8/ScriptWrappable.h" |
30 #include "core/css/CSSFontSelectorClient.h" | 30 #include "core/css/CSSFontSelectorClient.h" |
31 #include "core/html/canvas/Canvas2DContextAttributes.h" | 31 #include "core/html/canvas/Canvas2DContextAttributes.h" |
32 #include "core/html/canvas/CanvasPathMethods.h" | 32 #include "core/html/canvas/CanvasPathMethods.h" |
33 #include "core/html/canvas/CanvasRenderingContext.h" | 33 #include "core/html/canvas/CanvasRenderingContext.h" |
34 #include "core/html/canvas/HitRegion.h" | 34 #include "core/html/canvas/HitRegion.h" |
35 #include "core/svg/SVGMatrixTearOff.h" | 35 #include "core/svg/SVGMatrixTearOff.h" |
36 #include "platform/fonts/Font.h" | 36 #include "platform/fonts/Font.h" |
37 #include "platform/graphics/Color.h" | 37 #include "platform/graphics/Color.h" |
38 #include "platform/geometry/FloatSize.h" | 38 #include "platform/geometry/FloatSize.h" |
| 39 #include "platform/graphics/GraphicsContext.h" |
39 #include "platform/graphics/GraphicsTypes.h" | 40 #include "platform/graphics/GraphicsTypes.h" |
40 #include "platform/graphics/ImageBuffer.h" | 41 #include "platform/graphics/ImageBuffer.h" |
41 #include "platform/graphics/Path.h" | 42 #include "platform/graphics/Path.h" |
42 #include "platform/transforms/AffineTransform.h" | 43 #include "platform/transforms/AffineTransform.h" |
43 #include "wtf/HashMap.h" | 44 #include "wtf/HashMap.h" |
44 #include "wtf/ListHashSet.h" | 45 #include "wtf/ListHashSet.h" |
45 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
46 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
47 | 48 |
48 namespace blink { class WebLayer; } | 49 namespace blink { class WebLayer; } |
49 | 50 |
50 namespace blink { | 51 namespace blink { |
51 | 52 |
52 class CanvasImageSource; | 53 class CanvasImageSource; |
53 class CanvasGradient; | 54 class CanvasGradient; |
54 class CanvasPattern; | 55 class CanvasPattern; |
55 class CanvasStyle; | 56 class CanvasStyle; |
56 class Path2D; | 57 class Path2D; |
57 class Element; | 58 class Element; |
58 class ExceptionState; | 59 class ExceptionState; |
59 class FloatRect; | 60 class FloatRect; |
60 class GraphicsContext; | |
61 class HTMLCanvasElement; | 61 class HTMLCanvasElement; |
62 class HTMLImageElement; | 62 class HTMLImageElement; |
63 class HTMLVideoElement; | 63 class HTMLVideoElement; |
64 class ImageData; | 64 class ImageData; |
65 class TextMetrics; | 65 class TextMetrics; |
66 | 66 |
67 typedef WillBeHeapHashMap<String, RefPtrWillBeMember<MutableStylePropertySet> >
MutableStylePropertyMap; | 67 typedef WillBeHeapHashMap<String, RefPtrWillBeMember<MutableStylePropertySet> >
MutableStylePropertyMap; |
68 | 68 |
69 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { | 69 class CanvasRenderingContext2D final: public CanvasRenderingContext, public Scri
ptWrappable, public CanvasPathMethods { |
70 DEFINE_WRAPPERTYPEINFO(); | 70 DEFINE_WRAPPERTYPEINFO(); |
71 public: | 71 public: |
72 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityP
arseMode) | 72 static PassOwnPtrWillBeRawPtr<CanvasRenderingContext2D> create(HTMLCanvasEle
ment* canvas, const Canvas2DContextAttributes* attrs, Document& document) |
73 { | 73 { |
74 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, us
esCSSCompatibilityParseMode)); | 74 return adoptPtrWillBeNoop(new CanvasRenderingContext2D(canvas, attrs, do
cument)); |
75 } | 75 } |
76 virtual ~CanvasRenderingContext2D(); | 76 virtual ~CanvasRenderingContext2D(); |
77 | 77 |
78 CanvasStyle* strokeStyle() const; | 78 CanvasStyle* strokeStyle() const; |
79 void setStrokeStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); | 79 void setStrokeStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); |
80 | 80 |
81 CanvasStyle* fillStyle() const; | 81 CanvasStyle* fillStyle() const; |
82 void setFillStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); | 82 void setFillStyle(PassRefPtrWillBeRawPtr<CanvasStyle>); |
83 | 83 |
84 float lineWidth() const; | 84 float lineWidth() const; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 TextBaseline m_textBaseline; | 290 TextBaseline m_textBaseline; |
291 Direction m_direction; | 291 Direction m_direction; |
292 | 292 |
293 String m_unparsedFont; | 293 String m_unparsedFont; |
294 Font m_font; | 294 Font m_font; |
295 bool m_realizedFont; | 295 bool m_realizedFont; |
296 | 296 |
297 bool m_hasClip; | 297 bool m_hasClip; |
298 }; | 298 }; |
299 | 299 |
300 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes
* attrs, bool usesCSSCompatibilityParseMode); | 300 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes
* attrs, Document&); |
301 | 301 |
302 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } | 302 State& modifiableState() { ASSERT(!state().m_unrealizedSaveCount); return *m
_stateStack.last(); } |
303 const State& state() const { return *m_stateStack.last(); } | 303 const State& state() const { return *m_stateStack.last(); } |
304 | 304 |
305 void applyLineDash() const; | 305 void applyLineDash() const; |
306 void setShadow(const FloatSize& offset, float blur, RGBA32 color); | 306 void setShadow(const FloatSize& offset, float blur, RGBA32 color); |
307 void applyShadow(); | 307 void applyShadow(); |
308 bool shouldDrawShadows() const; | 308 bool shouldDrawShadows() const; |
309 | 309 |
310 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); | 310 void dispatchContextLostEvent(Timer<CanvasRenderingContext2D>*); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 virtual void setIsHidden(bool) override; | 362 virtual void setIsHidden(bool) override; |
363 | 363 |
364 virtual bool isTransformInvertible() const override { return state().m_inver
tibleCTM; } | 364 virtual bool isTransformInvertible() const override { return state().m_inver
tibleCTM; } |
365 | 365 |
366 virtual blink::WebLayer* platformLayer() const override; | 366 virtual blink::WebLayer* platformLayer() const override; |
367 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; | 367 TextDirection toTextDirection(Direction, RenderStyle** computedStyle = nullp
tr) const; |
368 | 368 |
369 WillBeHeapVector<OwnPtrWillBeMember<State> > m_stateStack; | 369 WillBeHeapVector<OwnPtrWillBeMember<State> > m_stateStack; |
370 OwnPtrWillBeMember<HitRegionManager> m_hitRegionManager; | 370 OwnPtrWillBeMember<HitRegionManager> m_hitRegionManager; |
371 bool m_usesCSSCompatibilityParseMode; | 371 bool m_usesCSSCompatibilityParseMode; |
| 372 GraphicsContext::AntiAliasingMode m_clipAntialiasing; |
372 bool m_hasAlpha; | 373 bool m_hasAlpha; |
373 bool m_isContextLost; | 374 bool m_isContextLost; |
374 bool m_contextRestorable; | 375 bool m_contextRestorable; |
375 Canvas2DContextStorage m_storageMode; | 376 Canvas2DContextStorage m_storageMode; |
376 MutableStylePropertyMap m_fetchedFonts; | 377 MutableStylePropertyMap m_fetchedFonts; |
377 ListHashSet<String> m_fetchedFontsLRUList; | 378 ListHashSet<String> m_fetchedFontsLRUList; |
378 unsigned m_tryRestoreContextAttemptCount; | 379 unsigned m_tryRestoreContextAttemptCount; |
379 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; | 380 Timer<CanvasRenderingContext2D> m_dispatchContextLostEventTimer; |
380 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; | 381 Timer<CanvasRenderingContext2D> m_dispatchContextRestoredEventTimer; |
381 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; | 382 Timer<CanvasRenderingContext2D> m_tryRestoreContextEventTimer; |
382 }; | 383 }; |
383 | 384 |
384 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); | 385 DEFINE_TYPE_CASTS(CanvasRenderingContext2D, CanvasRenderingContext, context, con
text->is2d(), context.is2d()); |
385 | 386 |
386 } // namespace blink | 387 } // namespace blink |
387 | 388 |
388 #endif // CanvasRenderingContext2D_h | 389 #endif // CanvasRenderingContext2D_h |
OLD | NEW |