|
1 /* |
|
2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
|
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * 1. Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * 2. Redistributions in binary form must reproduce the above copyright |
|
11 * notice, this list of conditions and the following disclaimer in the |
|
12 * documentation and/or other materials provided with the distribution. |
|
13 * |
|
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
|
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
|
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
22 * 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 #if ENABLE(3D_CANVAS) |
|
30 |
|
31 #include "WebGLGetInfo.h" |
|
32 #include "WebGLBuffer.h" |
|
33 #include "Float32Array.h" |
|
34 #include "WebGLFramebuffer.h" |
|
35 #include "Int32Array.h" |
|
36 #include "WebGLProgram.h" |
|
37 #include "WebGLRenderbuffer.h" |
|
38 #include "WebGLTexture.h" |
|
39 #include "Uint8Array.h" |
|
40 |
|
41 namespace WebCore { |
|
42 |
|
43 WebGLGetInfo::WebGLGetInfo(bool value) |
|
44 : m_type(kTypeBool) |
|
45 , m_bool(value) |
|
46 { |
|
47 } |
|
48 |
|
49 WebGLGetInfo::WebGLGetInfo(const bool* value, int size) |
|
50 : m_type(kTypeBoolArray) |
|
51 { |
|
52 if (!value || size <=0) |
|
53 return; |
|
54 m_boolArray.resize(size); |
|
55 for (int ii = 0; ii < size; ++ii) |
|
56 m_boolArray[ii] = value[ii]; |
|
57 } |
|
58 |
|
59 WebGLGetInfo::WebGLGetInfo(float value) |
|
60 : m_type(kTypeFloat) |
|
61 , m_float(value) |
|
62 { |
|
63 } |
|
64 |
|
65 WebGLGetInfo::WebGLGetInfo(long value) |
|
66 : m_type(kTypeLong) |
|
67 , m_long(value) |
|
68 { |
|
69 } |
|
70 |
|
71 WebGLGetInfo::WebGLGetInfo() |
|
72 : m_type(kTypeNull) |
|
73 { |
|
74 } |
|
75 |
|
76 WebGLGetInfo::WebGLGetInfo(const String& value) |
|
77 : m_type(kTypeString) |
|
78 , m_string(value) |
|
79 { |
|
80 } |
|
81 |
|
82 WebGLGetInfo::WebGLGetInfo(unsigned long value) |
|
83 : m_type(kTypeUnsignedLong) |
|
84 , m_unsignedLong(value) |
|
85 { |
|
86 } |
|
87 |
|
88 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLBuffer> value) |
|
89 : m_type(kTypeWebGLBuffer) |
|
90 , m_webglBuffer(value) |
|
91 { |
|
92 } |
|
93 |
|
94 WebGLGetInfo::WebGLGetInfo(PassRefPtr<Float32Array> value) |
|
95 : m_type(kTypeWebGLFloatArray) |
|
96 , m_webglFloatArray(value) |
|
97 { |
|
98 } |
|
99 |
|
100 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value) |
|
101 : m_type(kTypeWebGLFramebuffer) |
|
102 , m_webglFramebuffer(value) |
|
103 { |
|
104 } |
|
105 |
|
106 WebGLGetInfo::WebGLGetInfo(PassRefPtr<Int32Array> value) |
|
107 : m_type(kTypeWebGLIntArray) |
|
108 , m_webglIntArray(value) |
|
109 { |
|
110 } |
|
111 |
|
112 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLProgram> value) |
|
113 : m_type(kTypeWebGLProgram) |
|
114 , m_webglProgram(value) |
|
115 { |
|
116 } |
|
117 |
|
118 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value) |
|
119 : m_type(kTypeWebGLRenderbuffer) |
|
120 , m_webglRenderbuffer(value) |
|
121 { |
|
122 } |
|
123 |
|
124 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLTexture> value) |
|
125 : m_type(kTypeWebGLTexture) |
|
126 , m_webglTexture(value) |
|
127 { |
|
128 } |
|
129 |
|
130 WebGLGetInfo::WebGLGetInfo(PassRefPtr<Uint8Array> value) |
|
131 : m_type(kTypeWebGLUnsignedByteArray) |
|
132 , m_webglUnsignedByteArray(value) |
|
133 { |
|
134 } |
|
135 |
|
136 WebGLGetInfo::~WebGLGetInfo() |
|
137 { |
|
138 } |
|
139 |
|
140 WebGLGetInfo::Type WebGLGetInfo::getType() const |
|
141 { |
|
142 return m_type; |
|
143 } |
|
144 |
|
145 bool WebGLGetInfo::getBool() const |
|
146 { |
|
147 ASSERT(getType() == kTypeBool); |
|
148 return m_bool; |
|
149 } |
|
150 |
|
151 const Vector<bool>& WebGLGetInfo::getBoolArray() const |
|
152 { |
|
153 ASSERT(getType() == kTypeBoolArray); |
|
154 return m_boolArray; |
|
155 } |
|
156 |
|
157 float WebGLGetInfo::getFloat() const |
|
158 { |
|
159 ASSERT(getType() == kTypeFloat); |
|
160 return m_float; |
|
161 } |
|
162 |
|
163 long WebGLGetInfo::getLong() const |
|
164 { |
|
165 ASSERT(getType() == kTypeLong); |
|
166 return m_long; |
|
167 } |
|
168 |
|
169 const String& WebGLGetInfo::getString() const |
|
170 { |
|
171 ASSERT(getType() == kTypeString); |
|
172 return m_string; |
|
173 } |
|
174 |
|
175 unsigned long WebGLGetInfo::getUnsignedLong() const |
|
176 { |
|
177 ASSERT(getType() == kTypeUnsignedLong); |
|
178 return m_unsignedLong; |
|
179 } |
|
180 |
|
181 PassRefPtr<WebGLBuffer> WebGLGetInfo::getWebGLBuffer() const |
|
182 { |
|
183 ASSERT(getType() == kTypeWebGLBuffer); |
|
184 return m_webglBuffer; |
|
185 } |
|
186 |
|
187 PassRefPtr<Float32Array> WebGLGetInfo::getWebGLFloatArray() const |
|
188 { |
|
189 ASSERT(getType() == kTypeWebGLFloatArray); |
|
190 return m_webglFloatArray; |
|
191 } |
|
192 |
|
193 PassRefPtr<WebGLFramebuffer> WebGLGetInfo::getWebGLFramebuffer() const |
|
194 { |
|
195 ASSERT(getType() == kTypeWebGLFramebuffer); |
|
196 return m_webglFramebuffer; |
|
197 } |
|
198 |
|
199 PassRefPtr<Int32Array> WebGLGetInfo::getWebGLIntArray() const |
|
200 { |
|
201 ASSERT(getType() == kTypeWebGLIntArray); |
|
202 return m_webglIntArray; |
|
203 } |
|
204 |
|
205 PassRefPtr<WebGLProgram> WebGLGetInfo::getWebGLProgram() const |
|
206 { |
|
207 ASSERT(getType() == kTypeWebGLProgram); |
|
208 return m_webglProgram; |
|
209 } |
|
210 |
|
211 PassRefPtr<WebGLRenderbuffer> WebGLGetInfo::getWebGLRenderbuffer() const |
|
212 { |
|
213 ASSERT(getType() == kTypeWebGLRenderbuffer); |
|
214 return m_webglRenderbuffer; |
|
215 } |
|
216 |
|
217 PassRefPtr<WebGLTexture> WebGLGetInfo::getWebGLTexture() const |
|
218 { |
|
219 ASSERT(getType() == kTypeWebGLTexture); |
|
220 return m_webglTexture; |
|
221 } |
|
222 |
|
223 PassRefPtr<Uint8Array> WebGLGetInfo::getWebGLUnsignedByteArray() const |
|
224 { |
|
225 ASSERT(getType() == kTypeWebGLUnsignedByteArray); |
|
226 return m_webglUnsignedByteArray; |
|
227 } |
|
228 |
|
229 } // namespace WebCore |
|
230 |
|
231 #endif // ENABLE(3D_CANVAS) |