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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 "core/html/canvas/Canvas2DContextAttributes.h" |
29 #include "core/html/canvas/CanvasPathMethods.h" | 30 #include "core/html/canvas/CanvasPathMethods.h" |
30 #include "core/html/canvas/CanvasRenderingContext.h" | 31 #include "core/html/canvas/CanvasRenderingContext.h" |
31 #include "core/platform/graphics/Color.h" | 32 #include "core/platform/graphics/Color.h" |
32 #include "core/platform/graphics/ColorSpace.h" | 33 #include "core/platform/graphics/ColorSpace.h" |
33 #include "core/platform/graphics/DashArray.h" | 34 #include "core/platform/graphics/DashArray.h" |
34 #include "core/platform/graphics/FloatSize.h" | 35 #include "core/platform/graphics/FloatSize.h" |
35 #include "core/platform/graphics/Font.h" | 36 #include "core/platform/graphics/Font.h" |
36 #include "core/platform/graphics/GraphicsTypes.h" | 37 #include "core/platform/graphics/GraphicsTypes.h" |
37 #include "core/platform/graphics/ImageBuffer.h" | 38 #include "core/platform/graphics/ImageBuffer.h" |
38 #include "core/platform/graphics/Path.h" | 39 #include "core/platform/graphics/Path.h" |
(...skipping 14 matching lines...) Expand all Loading... |
53 class HTMLCanvasElement; | 54 class HTMLCanvasElement; |
54 class HTMLImageElement; | 55 class HTMLImageElement; |
55 class HTMLVideoElement; | 56 class HTMLVideoElement; |
56 class ImageData; | 57 class ImageData; |
57 class TextMetrics; | 58 class TextMetrics; |
58 | 59 |
59 typedef int ExceptionCode; | 60 typedef int ExceptionCode; |
60 | 61 |
61 class CanvasRenderingContext2D : public CanvasRenderingContext, public CanvasPat
hMethods { | 62 class CanvasRenderingContext2D : public CanvasRenderingContext, public CanvasPat
hMethods { |
62 public: | 63 public: |
63 static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas
, bool usesCSSCompatibilityParseMode) | 64 static PassOwnPtr<CanvasRenderingContext2D> create(HTMLCanvasElement* canvas
, const Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode) |
64 { | 65 { |
65 return adoptPtr(new CanvasRenderingContext2D(canvas, usesCSSCompatibilit
yParseMode)); | 66 return adoptPtr(new CanvasRenderingContext2D(canvas, attrs, usesCSSCompa
tibilityParseMode)); |
66 } | 67 } |
67 virtual ~CanvasRenderingContext2D(); | 68 virtual ~CanvasRenderingContext2D(); |
68 | 69 |
69 CanvasStyle* strokeStyle() const; | 70 CanvasStyle* strokeStyle() const; |
70 void setStrokeStyle(PassRefPtr<CanvasStyle>); | 71 void setStrokeStyle(PassRefPtr<CanvasStyle>); |
71 | 72 |
72 CanvasStyle* fillStyle() const; | 73 CanvasStyle* fillStyle() const; |
73 void setFillStyle(PassRefPtr<CanvasStyle>); | 74 void setFillStyle(PassRefPtr<CanvasStyle>); |
74 | 75 |
75 float lineWidth() const; | 76 float lineWidth() const; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 void strokeText(const String& text, float x, float y); | 214 void strokeText(const String& text, float x, float y); |
214 void strokeText(const String& text, float x, float y, float maxWidth); | 215 void strokeText(const String& text, float x, float y, float maxWidth); |
215 PassRefPtr<TextMetrics> measureText(const String& text); | 216 PassRefPtr<TextMetrics> measureText(const String& text); |
216 | 217 |
217 LineCap getLineCap() const { return state().m_lineCap; } | 218 LineCap getLineCap() const { return state().m_lineCap; } |
218 LineJoin getLineJoin() const { return state().m_lineJoin; } | 219 LineJoin getLineJoin() const { return state().m_lineJoin; } |
219 | 220 |
220 bool webkitImageSmoothingEnabled() const; | 221 bool webkitImageSmoothingEnabled() const; |
221 void setWebkitImageSmoothingEnabled(bool); | 222 void setWebkitImageSmoothingEnabled(bool); |
222 | 223 |
| 224 PassRefPtr<Canvas2DContextAttributes> getContextAttributes() const; |
| 225 |
223 private: | 226 private: |
224 struct State : FontSelectorClient { | 227 struct State : FontSelectorClient { |
225 State(); | 228 State(); |
226 virtual ~State(); | 229 virtual ~State(); |
227 | 230 |
228 State(const State&); | 231 State(const State&); |
229 State& operator=(const State&); | 232 State& operator=(const State&); |
230 | 233 |
231 virtual void fontsNeedUpdate(FontSelector*) OVERRIDE; | 234 virtual void fontsNeedUpdate(FontSelector*) OVERRIDE; |
232 | 235 |
(...skipping 27 matching lines...) Expand all Loading... |
260 }; | 263 }; |
261 | 264 |
262 enum CanvasDidDrawOption { | 265 enum CanvasDidDrawOption { |
263 CanvasDidDrawApplyNone = 0, | 266 CanvasDidDrawApplyNone = 0, |
264 CanvasDidDrawApplyTransform = 1, | 267 CanvasDidDrawApplyTransform = 1, |
265 CanvasDidDrawApplyShadow = 1 << 1, | 268 CanvasDidDrawApplyShadow = 1 << 1, |
266 CanvasDidDrawApplyClip = 1 << 2, | 269 CanvasDidDrawApplyClip = 1 << 2, |
267 CanvasDidDrawApplyAll = 0xffffffff | 270 CanvasDidDrawApplyAll = 0xffffffff |
268 }; | 271 }; |
269 | 272 |
270 CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseM
ode); | 273 CanvasRenderingContext2D(HTMLCanvasElement*, const Canvas2DContextAttributes
* attrs, bool usesCSSCompatibilityParseMode); |
271 | 274 |
272 State& modifiableState() { ASSERT(!m_unrealizedSaveCount); return m_stateSta
ck.last(); } | 275 State& modifiableState() { ASSERT(!m_unrealizedSaveCount); return m_stateSta
ck.last(); } |
273 const State& state() const { return m_stateStack.last(); } | 276 const State& state() const { return m_stateStack.last(); } |
274 | 277 |
275 void applyLineDash() const; | 278 void applyLineDash() const; |
276 void setShadow(const FloatSize& offset, float blur, RGBA32 color); | 279 void setShadow(const FloatSize& offset, float blur, RGBA32 color); |
277 void applyShadow(); | 280 void applyShadow(); |
278 bool shouldDrawShadows() const; | 281 bool shouldDrawShadows() const; |
279 | 282 |
280 void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll); | 283 void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll); |
(...skipping 28 matching lines...) Expand all Loading... |
309 void inflateStrokeRect(FloatRect&) const; | 312 void inflateStrokeRect(FloatRect&) const; |
310 | 313 |
311 template<class T> void fullCanvasCompositedFill(const T&); | 314 template<class T> void fullCanvasCompositedFill(const T&); |
312 template<class T> void fullCanvasCompositedDrawImage(T*, ColorSpace, const F
loatRect&, const FloatRect&, CompositeOperator); | 315 template<class T> void fullCanvasCompositedDrawImage(T*, ColorSpace, const F
loatRect&, const FloatRect&, CompositeOperator); |
313 | 316 |
314 PassRefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx,
float sy, float sw, float sh, ExceptionCode&) const; | 317 PassRefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx,
float sy, float sw, float sh, ExceptionCode&) const; |
315 void putImageData(ImageData*, ImageBuffer::CoordinateSystem, float dx, float
dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionC
ode&); | 318 void putImageData(ImageData*, ImageBuffer::CoordinateSystem, float dx, float
dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionC
ode&); |
316 | 319 |
317 virtual bool is2d() const OVERRIDE { return true; } | 320 virtual bool is2d() const OVERRIDE { return true; } |
318 virtual bool isAccelerated() const OVERRIDE; | 321 virtual bool isAccelerated() const OVERRIDE; |
| 322 virtual bool hasAlpha() const OVERRIDE { return m_hasAlpha; } |
319 | 323 |
320 virtual bool isTransformInvertible() const { return state().m_invertibleCTM;
} | 324 virtual bool isTransformInvertible() const { return state().m_invertibleCTM;
} |
321 | 325 |
322 virtual PlatformLayer* platformLayer() const OVERRIDE; | 326 virtual PlatformLayer* platformLayer() const OVERRIDE; |
323 | 327 |
324 Vector<State, 1> m_stateStack; | 328 Vector<State, 1> m_stateStack; |
325 unsigned m_unrealizedSaveCount; | 329 unsigned m_unrealizedSaveCount; |
326 bool m_usesCSSCompatibilityParseMode; | 330 bool m_usesCSSCompatibilityParseMode; |
| 331 bool m_hasAlpha; |
327 }; | 332 }; |
328 | 333 |
329 } // namespace WebCore | 334 } // namespace WebCore |
330 | 335 |
331 #endif | 336 #endif |
OLD | NEW |