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 "WebGLFloatArray.h"
34 #include "WebGLFramebuffer.h"
35 #include "WebGLIntArray.h"
36 #include "WebGLProgram.h"
37 #include "WebGLRenderbuffer.h"
38 #include "WebGLTexture.h"
39 #include "WebGLUnsignedByteArray.h"
40
41 namespace WebCore {
42
WebGLGetInfo(bool value)43 WebGLGetInfo::WebGLGetInfo(bool value)
44 : m_type(kTypeBool)
45 , m_bool(value)
46 {
47 }
48
WebGLGetInfo(float value)49 WebGLGetInfo::WebGLGetInfo(float value)
50 : m_type(kTypeFloat)
51 , m_float(value)
52 {
53 }
54
WebGLGetInfo(long value)55 WebGLGetInfo::WebGLGetInfo(long value)
56 : m_type(kTypeLong)
57 , m_long(value)
58 {
59 }
60
WebGLGetInfo()61 WebGLGetInfo::WebGLGetInfo()
62 : m_type(kTypeNull)
63 {
64 }
65
WebGLGetInfo(const String & value)66 WebGLGetInfo::WebGLGetInfo(const String& value)
67 : m_type(kTypeString)
68 , m_string(value)
69 {
70 }
71
WebGLGetInfo(unsigned long value)72 WebGLGetInfo::WebGLGetInfo(unsigned long value)
73 : m_type(kTypeUnsignedLong)
74 , m_unsignedLong(value)
75 {
76 }
77
WebGLGetInfo(PassRefPtr<WebGLBuffer> value)78 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLBuffer> value)
79 : m_type(kTypeWebGLBuffer)
80 , m_webglBuffer(value)
81 {
82 }
83
WebGLGetInfo(PassRefPtr<WebGLFloatArray> value)84 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLFloatArray> value)
85 : m_type(kTypeWebGLFloatArray)
86 , m_webglFloatArray(value)
87 {
88 }
89
WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value)90 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLFramebuffer> value)
91 : m_type(kTypeWebGLFramebuffer)
92 , m_webglFramebuffer(value)
93 {
94 }
95
WebGLGetInfo(PassRefPtr<WebGLIntArray> value)96 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLIntArray> value)
97 : m_type(kTypeWebGLIntArray)
98 , m_webglIntArray(value)
99 {
100 }
101
WebGLGetInfo(PassRefPtr<WebGLProgram> value)102 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLProgram> value)
103 : m_type(kTypeWebGLProgram)
104 , m_webglProgram(value)
105 {
106 }
107
WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value)108 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLRenderbuffer> value)
109 : m_type(kTypeWebGLRenderbuffer)
110 , m_webglRenderbuffer(value)
111 {
112 }
113
WebGLGetInfo(PassRefPtr<WebGLTexture> value)114 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLTexture> value)
115 : m_type(kTypeWebGLTexture)
116 , m_webglTexture(value)
117 {
118 }
119
WebGLGetInfo(PassRefPtr<WebGLUnsignedByteArray> value)120 WebGLGetInfo::WebGLGetInfo(PassRefPtr<WebGLUnsignedByteArray> value)
121 : m_type(kTypeWebGLUnsignedByteArray)
122 , m_webglUnsignedByteArray(value)
123 {
124 }
125
~WebGLGetInfo()126 WebGLGetInfo::~WebGLGetInfo()
127 {
128 }
129
getType() const130 WebGLGetInfo::Type WebGLGetInfo::getType() const
131 {
132 return m_type;
133 }
134
getBool() const135 bool WebGLGetInfo::getBool() const
136 {
137 ASSERT(getType() == kTypeBool);
138 return m_bool;
139 }
140
getFloat() const141 float WebGLGetInfo::getFloat() const
142 {
143 ASSERT(getType() == kTypeFloat);
144 return m_float;
145 }
146
getLong() const147 long WebGLGetInfo::getLong() const
148 {
149 ASSERT(getType() == kTypeLong);
150 return m_long;
151 }
152
getString() const153 const String& WebGLGetInfo::getString() const
154 {
155 ASSERT(getType() == kTypeString);
156 return m_string;
157 }
158
getUnsignedLong() const159 unsigned long WebGLGetInfo::getUnsignedLong() const
160 {
161 ASSERT(getType() == kTypeUnsignedLong);
162 return m_unsignedLong;
163 }
164
getWebGLBuffer() const165 PassRefPtr<WebGLBuffer> WebGLGetInfo::getWebGLBuffer() const
166 {
167 ASSERT(getType() == kTypeWebGLBuffer);
168 return m_webglBuffer;
169 }
170
getWebGLFloatArray() const171 PassRefPtr<WebGLFloatArray> WebGLGetInfo::getWebGLFloatArray() const
172 {
173 ASSERT(getType() == kTypeWebGLFloatArray);
174 return m_webglFloatArray;
175 }
176
getWebGLFramebuffer() const177 PassRefPtr<WebGLFramebuffer> WebGLGetInfo::getWebGLFramebuffer() const
178 {
179 ASSERT(getType() == kTypeWebGLFramebuffer);
180 return m_webglFramebuffer;
181 }
182
getWebGLIntArray() const183 PassRefPtr<WebGLIntArray> WebGLGetInfo::getWebGLIntArray() const
184 {
185 ASSERT(getType() == kTypeWebGLIntArray);
186 return m_webglIntArray;
187 }
188
getWebGLProgram() const189 PassRefPtr<WebGLProgram> WebGLGetInfo::getWebGLProgram() const
190 {
191 ASSERT(getType() == kTypeWebGLProgram);
192 return m_webglProgram;
193 }
194
getWebGLRenderbuffer() const195 PassRefPtr<WebGLRenderbuffer> WebGLGetInfo::getWebGLRenderbuffer() const
196 {
197 ASSERT(getType() == kTypeWebGLRenderbuffer);
198 return m_webglRenderbuffer;
199 }
200
getWebGLTexture() const201 PassRefPtr<WebGLTexture> WebGLGetInfo::getWebGLTexture() const
202 {
203 ASSERT(getType() == kTypeWebGLTexture);
204 return m_webglTexture;
205 }
206
getWebGLUnsignedByteArray() const207 PassRefPtr<WebGLUnsignedByteArray> WebGLGetInfo::getWebGLUnsignedByteArray() const
208 {
209 ASSERT(getType() == kTypeWebGLUnsignedByteArray);
210 return m_webglUnsignedByteArray;
211 }
212
213 } // namespace WebCore
214
215 #endif // ENABLE(3D_CANVAS)
216