OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
8 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
10 * | 10 * |
(...skipping 18 matching lines...) Expand all Loading... | |
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 */ | 31 */ |
32 | 32 |
33 #include "config.h" | 33 #include "config.h" |
34 #include "CanvasRenderingContext2D.h" | 34 #include "CanvasRenderingContext2D.h" |
35 | 35 |
36 #include "CSSFontSelector.h" | 36 #include "CSSFontSelector.h" |
37 #include "CSSParser.h" | 37 #include "CSSParser.h" |
38 #include "CSSPropertyNames.h" | 38 #include "CSSPropertyNames.h" |
39 #include "Canvas2DContextAttributes.h" | |
39 #include "CanvasGradient.h" | 40 #include "CanvasGradient.h" |
40 #include "CanvasPattern.h" | 41 #include "CanvasPattern.h" |
41 #include "CanvasStyle.h" | 42 #include "CanvasStyle.h" |
42 #include "DOMPath.h" | 43 #include "DOMPath.h" |
43 #include "ExceptionCode.h" | 44 #include "ExceptionCode.h" |
44 #include "ExceptionCodePlaceholder.h" | 45 #include "ExceptionCodePlaceholder.h" |
45 #include "HTMLCanvasElement.h" | 46 #include "HTMLCanvasElement.h" |
46 #include "HTMLImageElement.h" | 47 #include "HTMLImageElement.h" |
47 #include "HTMLMediaElement.h" | 48 #include "HTMLMediaElement.h" |
48 #include "HTMLNames.h" | 49 #include "HTMLNames.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 DashArray convertedLineDash(lineDash.size()); | 111 DashArray convertedLineDash(lineDash.size()); |
111 for (size_t i = 0; i < lineDash.size(); ++i) | 112 for (size_t i = 0; i < lineDash.size(); ++i) |
112 convertedLineDash[i] = static_cast<DashArrayElement>(lineDash[i]); | 113 convertedLineDash[i] = static_cast<DashArrayElement>(lineDash[i]); |
113 c->setLineDash(convertedLineDash, m_canvasContext->lineDashOffset()); | 114 c->setLineDash(convertedLineDash, m_canvasContext->lineDashOffset()); |
114 } | 115 } |
115 | 116 |
116 private: | 117 private: |
117 CanvasRenderingContext2D* m_canvasContext; | 118 CanvasRenderingContext2D* m_canvasContext; |
118 }; | 119 }; |
119 | 120 |
120 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, bo ol usesCSSCompatibilityParseMode) | 121 CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement* canvas, co nst Canvas2DContextAttributes* attrs, bool usesCSSCompatibilityParseMode) |
121 : CanvasRenderingContext(canvas) | 122 : CanvasRenderingContext(canvas) |
122 , m_stateStack(1) | 123 , m_stateStack(1) |
123 , m_unrealizedSaveCount(0) | 124 , m_unrealizedSaveCount(0) |
124 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) | 125 , m_usesCSSCompatibilityParseMode(usesCSSCompatibilityParseMode) |
126 , m_hasAlpha(!attrs || attrs->alpha()) | |
125 { | 127 { |
126 ScriptWrappable::init(this); | 128 ScriptWrappable::init(this); |
127 } | 129 } |
128 | 130 |
129 void CanvasRenderingContext2D::unwindStateStack() | 131 void CanvasRenderingContext2D::unwindStateStack() |
130 { | 132 { |
131 // Ensure that the state stack in the ImageBuffer's context | 133 // Ensure that the state stack in the ImageBuffer's context |
132 // is cleared before destruction, to avoid assertions in the | 134 // is cleared before destruction, to avoid assertions in the |
133 // GraphicsContext dtor. | 135 // GraphicsContext dtor. |
134 if (size_t stackSize = m_stateStack.size()) { | 136 if (size_t stackSize = m_stateStack.size()) { |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2243 if (enabled == state().m_imageSmoothingEnabled) | 2245 if (enabled == state().m_imageSmoothingEnabled) |
2244 return; | 2246 return; |
2245 | 2247 |
2246 realizeSaves(); | 2248 realizeSaves(); |
2247 modifiableState().m_imageSmoothingEnabled = enabled; | 2249 modifiableState().m_imageSmoothingEnabled = enabled; |
2248 GraphicsContext* c = drawingContext(); | 2250 GraphicsContext* c = drawingContext(); |
2249 if (c) | 2251 if (c) |
2250 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); | 2252 c->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone); |
2251 } | 2253 } |
2252 | 2254 |
2255 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const | |
2256 { | |
2257 // We always need to return a new Canvas2DContextAttributes object to | |
2258 // prevent the user from mutating any cached version. | |
jamesr
2013/04/26 18:30:09
i don't follow - what is the 'user' here? javascri
Stephen White
2013/04/26 18:53:18
This comment was lifted from WebGLRenderingContext
| |
2259 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); | |
2260 attributes->setAlpha(m_hasAlpha); | |
2261 return attributes.release(); | |
2262 } | |
2263 | |
2253 } // namespace WebCore | 2264 } // namespace WebCore |
OLD | NEW |