OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * * Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * * Redistributions in binary form must reproduce the above | |
10 * copyright notice, this list of conditions and the following disclaimer | |
11 * in the documentation and/or other materials provided with the | |
12 * distribution. | |
13 * | |
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 */ | |
26 | |
27 #include "config.h" | |
28 | |
29 #include "core/html/canvas/WebGLContextAttributes.h" | |
30 | |
31 #include "core/frame/Settings.h" | |
32 | |
33 namespace blink { | |
34 | |
35 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(WebGLContextAttributes); | |
36 | |
37 PassRefPtrWillBeRawPtr<WebGLContextAttributes> WebGLContextAttributes::create() | |
38 { | |
39 return adoptRefWillBeNoop(new WebGLContextAttributes()); | |
40 } | |
41 | |
42 WebGLContextAttributes::WebGLContextAttributes() | |
43 : CanvasContextAttributes() | |
44 , m_alpha(true) | |
45 , m_depth(true) | |
46 , m_stencil(false) | |
47 , m_antialias(true) | |
48 , m_premultipliedAlpha(true) | |
49 , m_preserveDrawingBuffer(false) | |
50 , m_failIfMajorPerformanceCaveat(false) | |
51 { | |
52 } | |
53 | |
54 WebGLContextAttributes::WebGLContextAttributes(const WebGLContextAttributes& att
rs) | |
55 : CanvasContextAttributes() | |
56 , m_alpha(attrs.m_alpha) | |
57 , m_depth(attrs.m_depth) | |
58 , m_stencil(attrs.m_stencil) | |
59 , m_antialias(attrs.m_antialias) | |
60 , m_premultipliedAlpha(attrs.m_premultipliedAlpha) | |
61 , m_preserveDrawingBuffer(attrs.m_preserveDrawingBuffer) | |
62 , m_failIfMajorPerformanceCaveat(attrs.m_failIfMajorPerformanceCaveat) | |
63 { | |
64 } | |
65 | |
66 PassRefPtrWillBeRawPtr<WebGLContextAttributes> WebGLContextAttributes::clone() c
onst | |
67 { | |
68 return adoptRefWillBeNoop(new WebGLContextAttributes(*this)); | |
69 } | |
70 | |
71 bool WebGLContextAttributes::alpha() const | |
72 { | |
73 return m_alpha; | |
74 } | |
75 | |
76 void WebGLContextAttributes::setAlpha(bool alpha) | |
77 { | |
78 m_alpha = alpha; | |
79 } | |
80 | |
81 bool WebGLContextAttributes::depth() const | |
82 { | |
83 return m_depth; | |
84 } | |
85 | |
86 void WebGLContextAttributes::setDepth(bool depth) | |
87 { | |
88 m_depth = depth; | |
89 } | |
90 | |
91 bool WebGLContextAttributes::stencil() const | |
92 { | |
93 return m_stencil; | |
94 } | |
95 | |
96 void WebGLContextAttributes::setStencil(bool stencil) | |
97 { | |
98 m_stencil = stencil; | |
99 } | |
100 | |
101 bool WebGLContextAttributes::antialias() const | |
102 { | |
103 return m_antialias; | |
104 } | |
105 | |
106 void WebGLContextAttributes::setAntialias(bool antialias) | |
107 { | |
108 m_antialias = antialias; | |
109 } | |
110 | |
111 bool WebGLContextAttributes::premultipliedAlpha() const | |
112 { | |
113 return m_premultipliedAlpha; | |
114 } | |
115 | |
116 void WebGLContextAttributes::setPremultipliedAlpha(bool premultipliedAlpha) | |
117 { | |
118 m_premultipliedAlpha = premultipliedAlpha; | |
119 } | |
120 | |
121 bool WebGLContextAttributes::preserveDrawingBuffer() const | |
122 { | |
123 return m_preserveDrawingBuffer; | |
124 } | |
125 | |
126 void WebGLContextAttributes::setPreserveDrawingBuffer(bool preserveDrawingBuffer
) | |
127 { | |
128 m_preserveDrawingBuffer = preserveDrawingBuffer; | |
129 } | |
130 | |
131 bool WebGLContextAttributes::failIfMajorPerformanceCaveat() const | |
132 { | |
133 return m_failIfMajorPerformanceCaveat; | |
134 } | |
135 | |
136 void WebGLContextAttributes::setFailIfMajorPerformanceCaveat(bool failIfMajorPer
formanceCaveat) | |
137 { | |
138 m_failIfMajorPerformanceCaveat = failIfMajorPerformanceCaveat; | |
139 } | |
140 | |
141 blink::WebGraphicsContext3D::Attributes WebGLContextAttributes::attributes( | |
142 const blink::WebString& topDocumentURL, Settings* settings, unsigned webGLVe
rsion) const | |
143 { | |
144 blink::WebGraphicsContext3D::Attributes attrs; | |
145 | |
146 attrs.alpha = m_alpha; | |
147 attrs.depth = m_depth; | |
148 attrs.stencil = m_stencil; | |
149 attrs.antialias = m_antialias; | |
150 if (m_antialias) { | |
151 if (settings && !settings->openGLMultisamplingEnabled()) | |
152 attrs.antialias = false; | |
153 } | |
154 attrs.premultipliedAlpha = m_premultipliedAlpha; | |
155 attrs.failIfMajorPerformanceCaveat = m_failIfMajorPerformanceCaveat; | |
156 | |
157 attrs.noExtensions = true; | |
158 attrs.shareResources = false; | |
159 attrs.preferDiscreteGPU = true; | |
160 | |
161 attrs.topDocumentURL = topDocumentURL; | |
162 | |
163 attrs.webGL = true; | |
164 attrs.webGLVersion = webGLVersion; | |
165 | |
166 return attrs; | |
167 } | |
168 | |
169 } // namespace blink | |
OLD | NEW |