Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed typo in gypi, was only causing issues on Windows (?!?) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8WebGLRenderingContext.h" 32 #include "V8WebGLRenderingContextBase.h"
33 33
34 #include "V8ANGLEInstancedArrays.h" 34 #include "V8ANGLEInstancedArrays.h"
35 #include "V8EXTFragDepth.h" 35 #include "V8EXTFragDepth.h"
36 #include "V8EXTTextureFilterAnisotropic.h" 36 #include "V8EXTTextureFilterAnisotropic.h"
37 #include "V8HTMLCanvasElement.h" 37 #include "V8HTMLCanvasElement.h"
38 #include "V8HTMLImageElement.h" 38 #include "V8HTMLImageElement.h"
39 #include "V8HTMLVideoElement.h" 39 #include "V8HTMLVideoElement.h"
40 #include "V8ImageData.h" 40 #include "V8ImageData.h"
41 #include "V8OESElementIndexUint.h" 41 #include "V8OESElementIndexUint.h"
42 #include "V8OESStandardDerivatives.h" 42 #include "V8OESStandardDerivatives.h"
(...skipping 22 matching lines...) Expand all
65 #include "bindings/v8/V8Binding.h" 65 #include "bindings/v8/V8Binding.h"
66 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" 66 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
67 #include "bindings/v8/custom/V8Float32ArrayCustom.h" 67 #include "bindings/v8/custom/V8Float32ArrayCustom.h"
68 #include "bindings/v8/custom/V8Int16ArrayCustom.h" 68 #include "bindings/v8/custom/V8Int16ArrayCustom.h"
69 #include "bindings/v8/custom/V8Int32ArrayCustom.h" 69 #include "bindings/v8/custom/V8Int32ArrayCustom.h"
70 #include "bindings/v8/custom/V8Int8ArrayCustom.h" 70 #include "bindings/v8/custom/V8Int8ArrayCustom.h"
71 #include "bindings/v8/custom/V8Uint16ArrayCustom.h" 71 #include "bindings/v8/custom/V8Uint16ArrayCustom.h"
72 #include "bindings/v8/custom/V8Uint32ArrayCustom.h" 72 #include "bindings/v8/custom/V8Uint32ArrayCustom.h"
73 #include "bindings/v8/custom/V8Uint8ArrayCustom.h" 73 #include "bindings/v8/custom/V8Uint8ArrayCustom.h"
74 #include "core/dom/ExceptionCode.h" 74 #include "core/dom/ExceptionCode.h"
75 #include "core/html/canvas/WebGLRenderingContext.h" 75 #include "core/html/canvas/WebGLRenderingContextBase.h"
76 #include "platform/NotImplemented.h" 76 #include "platform/NotImplemented.h"
77 #include "wtf/FastMalloc.h" 77 #include "wtf/FastMalloc.h"
78 #include <limits> 78 #include <limits>
79 79
80 namespace WebCore { 80 namespace WebCore {
81 81
82 // Allocates new storage via fastMalloc. 82 // Allocates new storage via fastMalloc.
83 // Returns NULL if array failed to convert for any reason. 83 // Returns 0 if array failed to convert for any reason.
84 static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len, Exc eptionState& exceptionState) 84 static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len, Exc eptionState& exceptionState)
85 { 85 {
86 // Convert the data element-by-element. 86 // Convert the data element-by-element.
87 if (len > std::numeric_limits<uint32_t>::max() / sizeof(float)) { 87 if (len > std::numeric_limits<uint32_t>::max() / sizeof(float)) {
88 exceptionState.throwTypeError("Array length exceeds supported limit."); 88 exceptionState.throwTypeError("Array length exceeds supported limit.");
89 return 0; 89 return 0;
90 } 90 }
91 float* data = static_cast<float*>(fastMalloc(len * sizeof(float))); 91 float* data = static_cast<float*>(fastMalloc(len * sizeof(float)));
92 92
93 for (uint32_t i = 0; i < len; i++) { 93 for (uint32_t i = 0; i < len; i++) {
94 v8::Local<v8::Value> val = array->Get(i); 94 v8::Local<v8::Value> val = array->Get(i);
95 float value = toFloat(val, exceptionState); 95 float value = toFloat(val, exceptionState);
96 if (exceptionState.hadException()) { 96 if (exceptionState.hadException()) {
97 fastFree(data); 97 fastFree(data);
98 return 0; 98 return 0;
99 } 99 }
100 data[i] = value; 100 data[i] = value;
101 } 101 }
102 return data; 102 return data;
103 } 103 }
104 104
105 // Allocates new storage via fastMalloc. 105 // Allocates new storage via fastMalloc.
106 // Returns NULL if array failed to convert for any reason. 106 // Returns 0 if array failed to convert for any reason.
107 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len, Excepti onState& exceptionState) 107 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len, Excepti onState& exceptionState)
108 { 108 {
109 // Convert the data element-by-element. 109 // Convert the data element-by-element.
110 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int)) { 110 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int)) {
111 exceptionState.throwTypeError("Array length exceeds supported limit."); 111 exceptionState.throwTypeError("Array length exceeds supported limit.");
112 return 0; 112 return 0;
113 } 113 }
114 int* data = static_cast<int*>(fastMalloc(len * sizeof(int))); 114 int* data = static_cast<int*>(fastMalloc(len * sizeof(int)));
115 115
116 for (uint32_t i = 0; i < len; i++) { 116 for (uint32_t i = 0; i < len; i++) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 } 176 }
177 177
178 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate) 178 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate)
179 { 179 {
180 if (!extension) 180 if (!extension)
181 return v8::Null(isolate); 181 return v8::Null(isolate);
182 v8::Handle<v8::Value> extensionObject; 182 v8::Handle<v8::Value> extensionObject;
183 const char* referenceName = 0; 183 const char* referenceName = 0;
184 switch (extension->name()) { 184 switch (extension->name()) {
185 case WebGLExtension::ANGLEInstancedArraysName: 185 case ANGLEInstancedArraysName:
186 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate); 186 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate);
187 referenceName = "angleInstancedArraysName"; 187 referenceName = "angleInstancedArraysName";
188 break; 188 break;
189 case WebGLExtension::EXTFragDepthName: 189 case EXTFragDepthName:
190 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate); 190 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate);
191 referenceName = "extFragDepthName"; 191 referenceName = "extFragDepthName";
192 break; 192 break;
193 case WebGLExtension::EXTTextureFilterAnisotropicName: 193 case EXTTextureFilterAnisotropicName:
194 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate); 194 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate);
195 referenceName = "extTextureFilterAnisotropicName"; 195 referenceName = "extTextureFilterAnisotropicName";
196 break; 196 break;
197 case WebGLExtension::OESElementIndexUintName: 197 case OESElementIndexUintName:
198 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate); 198 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate);
199 referenceName = "oesElementIndexUintName"; 199 referenceName = "oesElementIndexUintName";
200 break; 200 break;
201 case WebGLExtension::OESStandardDerivativesName: 201 case OESStandardDerivativesName:
202 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate); 202 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate);
203 referenceName = "oesStandardDerivativesName"; 203 referenceName = "oesStandardDerivativesName";
204 break; 204 break;
205 case WebGLExtension::OESTextureFloatName: 205 case OESTextureFloatName:
206 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate); 206 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate);
207 referenceName = "oesTextureFloatName"; 207 referenceName = "oesTextureFloatName";
208 break; 208 break;
209 case WebGLExtension::OESTextureFloatLinearName: 209 case OESTextureFloatLinearName:
210 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate); 210 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate);
211 referenceName = "oesTextureFloatLinearName"; 211 referenceName = "oesTextureFloatLinearName";
212 break; 212 break;
213 case WebGLExtension::OESTextureHalfFloatName: 213 case OESTextureHalfFloatName:
214 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate); 214 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate);
215 referenceName = "oesTextureHalfFloatName"; 215 referenceName = "oesTextureHalfFloatName";
216 break; 216 break;
217 case WebGLExtension::OESTextureHalfFloatLinearName: 217 case OESTextureHalfFloatLinearName:
218 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate); 218 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate);
219 referenceName = "oesTextureHalfFloatLinearName"; 219 referenceName = "oesTextureHalfFloatLinearName";
220 break; 220 break;
221 case WebGLExtension::OESVertexArrayObjectName: 221 case OESVertexArrayObjectName:
222 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate); 222 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate);
223 referenceName = "oesVertexArrayObjectName"; 223 referenceName = "oesVertexArrayObjectName";
224 break; 224 break;
225 case WebGLExtension::WebGLCompressedTextureATCName: 225 case WebGLCompressedTextureATCName:
226 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate); 226 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate);
227 referenceName = "webGLCompressedTextureATCName"; 227 referenceName = "webGLCompressedTextureATCName";
228 break; 228 break;
229 case WebGLExtension::WebGLCompressedTexturePVRTCName: 229 case WebGLCompressedTexturePVRTCName:
230 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate); 230 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate);
231 referenceName = "webGLCompressedTexturePVRTCName"; 231 referenceName = "webGLCompressedTexturePVRTCName";
232 break; 232 break;
233 case WebGLExtension::WebGLCompressedTextureS3TCName: 233 case WebGLCompressedTextureS3TCName:
234 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate); 234 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate);
235 referenceName = "webGLCompressedTextureS3TCName"; 235 referenceName = "webGLCompressedTextureS3TCName";
236 break; 236 break;
237 case WebGLExtension::WebGLDebugRendererInfoName: 237 case WebGLDebugRendererInfoName:
238 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate); 238 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate);
239 referenceName = "webGLDebugRendererInfoName"; 239 referenceName = "webGLDebugRendererInfoName";
240 break; 240 break;
241 case WebGLExtension::WebGLDebugShadersName: 241 case WebGLDebugShadersName:
242 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate); 242 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate);
243 referenceName = "webGLDebugShadersName"; 243 referenceName = "webGLDebugShadersName";
244 break; 244 break;
245 case WebGLExtension::WebGLDepthTextureName: 245 case WebGLDepthTextureName:
246 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate); 246 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate);
247 referenceName = "webGLDepthTextureName"; 247 referenceName = "webGLDepthTextureName";
248 break; 248 break;
249 case WebGLExtension::WebGLDrawBuffersName: 249 case WebGLDrawBuffersName:
250 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate); 250 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate);
251 referenceName = "webGLDrawBuffersName"; 251 referenceName = "webGLDrawBuffersName";
252 break; 252 break;
253 case WebGLExtension::WebGLLoseContextName: 253 case WebGLLoseContextName:
254 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate); 254 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate);
255 referenceName = "webGLLoseContextName"; 255 referenceName = "webGLLoseContextName";
256 break; 256 break;
257 case WebGLExtensionNameCount:
258 notImplemented();
259 return v8::Undefined(isolate);
257 } 260 }
258 ASSERT(!extensionObject.IsEmpty()); 261 ASSERT(!extensionObject.IsEmpty());
259 setHiddenValue(isolate, contextObject, referenceName, extensionObject); 262 setHiddenValue(isolate, contextObject, referenceName, extensionObject);
260 return extensionObject; 263 return extensionObject;
261 } 264 }
262 265
263 enum ObjectType { 266 enum ObjectType {
264 kBuffer, kRenderbuffer, kTexture, kVertexAttrib 267 kBuffer, kRenderbuffer, kTexture, kVertexAttrib
265 }; 268 };
266 269
267 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& info, ObjectType objectType, ExceptionState& exceptionState) 270 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& info, ObjectType objectType, ExceptionState& exceptionState)
268 { 271 {
269 if (info.Length() != 2) { 272 if (info.Length() != 2) {
270 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 273 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
271 exceptionState.throwIfNeeded(); 274 exceptionState.throwIfNeeded();
272 return; 275 return;
273 } 276 }
274 277
275 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 278 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
276 unsigned target = toInt32(info[0], exceptionState); 279 unsigned target = toInt32(info[0], exceptionState);
277 if (exceptionState.throwIfNeeded()) 280 if (exceptionState.throwIfNeeded())
278 return; 281 return;
279 unsigned pname = toInt32(info[1], exceptionState); 282 unsigned pname = toInt32(info[1], exceptionState);
280 if (exceptionState.throwIfNeeded()) 283 if (exceptionState.throwIfNeeded())
281 return; 284 return;
282 WebGLGetInfo args; 285 WebGLGetInfo args;
283 switch (objectType) { 286 switch (objectType) {
284 case kBuffer: 287 case kBuffer:
285 args = context->getBufferParameter(target, pname); 288 args = context->getBufferParameter(target, pname);
(...skipping 17 matching lines...) Expand all
303 306
304 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, v8::Isolate* isolate) 307 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, v8::Isolate* isolate)
305 { 308 {
306 return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value); 309 return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value);
307 } 310 }
308 311
309 enum WhichProgramCall { 312 enum WhichProgramCall {
310 kProgramParameter, kUniform 313 kProgramParameter, kUniform
311 }; 314 };
312 315
313 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 316 void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
314 { 317 {
315 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached Shaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 318 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached Shaders", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
316 if (info.Length() < 1) { 319 if (info.Length() < 1) {
317 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 320 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
318 exceptionState.throwIfNeeded(); 321 exceptionState.throwIfNeeded();
319 return; 322 return;
320 } 323 }
321 324
322 const int programArgumentIndex = 0; 325 const int programArgumentIndex = 0;
323 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 326 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
324 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 327 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
325 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram")); 328 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram"));
326 exceptionState.throwIfNeeded(); 329 exceptionState.throwIfNeeded();
327 return; 330 return;
328 } 331 }
329 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]); 332 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]);
330 Vector<RefPtr<WebGLShader> > shaders; 333 Vector<RefPtr<WebGLShader> > shaders;
331 bool succeed = context->getAttachedShaders(program, shaders); 334 bool succeed = context->getAttachedShaders(program, shaders);
332 if (!succeed) { 335 if (!succeed) {
333 v8SetReturnValueNull(info); 336 v8SetReturnValueNull(info);
334 return; 337 return;
335 } 338 }
336 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size( )); 339 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size( ));
337 for (size_t ii = 0; ii < shaders.size(); ++ii) 340 for (size_t ii = 0; ii < shaders.size(); ++ii)
338 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get (), info.Holder(), info.GetIsolate())); 341 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get (), info.Holder(), info.GetIsolate()));
339 v8SetReturnValue(info, array); 342 v8SetReturnValue(info, array);
340 } 343 }
341 344
342 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 345 void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
343 { 346 {
344 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 347 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa rameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
345 getObjectParameter(info, kBuffer, exceptionState); 348 getObjectParameter(info, kBuffer, exceptionState);
346 } 349 }
347 350
348 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& info) 351 void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info)
349 { 352 {
350 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio n", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 353 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio n", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
351 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder() ); 354 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info. Holder());
352 if (info.Length() < 1) { 355 if (info.Length() < 1) {
353 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 356 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
354 exceptionState.throwIfNeeded(); 357 exceptionState.throwIfNeeded();
355 return; 358 return;
356 } 359 }
357 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); 360 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]);
358 RefPtr<WebGLExtension> extension(imp->getExtension(name)); 361 RefPtr<WebGLExtension> extension(imp->getExtension(name));
359 v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIs olate())); 362 v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIs olate()));
360 } 363 }
361 364
362 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons t v8::FunctionCallbackInfo<v8::Value>& info) 365 void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom( const v8::FunctionCallbackInfo<v8::Value>& info)
363 { 366 {
364 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebuf ferAttachmentParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate ()); 367 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebuf ferAttachmentParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIso late());
365 if (info.Length() != 3) { 368 if (info.Length() != 3) {
366 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length())); 369 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length()));
367 exceptionState.throwIfNeeded(); 370 exceptionState.throwIfNeeded();
368 return; 371 return;
369 } 372 }
370 373
371 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 374 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
372 unsigned target = toInt32(info[0]); 375 unsigned target = toInt32(info[0]);
373 unsigned attachment = toInt32(info[1], exceptionState); 376 unsigned attachment = toInt32(info[1], exceptionState);
374 if (exceptionState.throwIfNeeded()) 377 if (exceptionState.throwIfNeeded())
375 return; 378 return;
376 unsigned pname = toInt32(info[2], exceptionState); 379 unsigned pname = toInt32(info[2], exceptionState);
377 if (exceptionState.throwIfNeeded()) 380 if (exceptionState.throwIfNeeded())
378 return; 381 return;
379 WebGLGetInfo args = context->getFramebufferAttachmentParameter(target, attac hment, pname); 382 WebGLGetInfo args = context->getFramebufferAttachmentParameter(target, attac hment, pname);
380 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 383 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
381 } 384 }
382 385
383 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& info) 386 void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info)
384 { 387 {
385 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParamete r", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 388 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParamete r", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
386 if (info.Length() != 1) { 389 if (info.Length() != 1) {
387 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 390 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
388 exceptionState.throwIfNeeded(); 391 exceptionState.throwIfNeeded();
389 return; 392 return;
390 } 393 }
391 394
392 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 395 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
393 unsigned pname = toInt32(info[0], exceptionState); 396 unsigned pname = toInt32(info[0], exceptionState);
394 if (exceptionState.throwIfNeeded()) 397 if (exceptionState.throwIfNeeded())
395 return; 398 return;
396 WebGLGetInfo args = context->getParameter(pname); 399 WebGLGetInfo args = context->getParameter(pname);
397 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 400 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
398 } 401 }
399 402
400 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& info) 403 void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::Func tionCallbackInfo<v8::Value>& info)
401 { 404 {
402 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramP arameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 405 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramP arameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
403 if (info.Length() != 2) { 406 if (info.Length() != 2) {
404 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 407 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
405 exceptionState.throwIfNeeded(); 408 exceptionState.throwIfNeeded();
406 return; 409 return;
407 } 410 }
408 411
409 const int programArgumentIndex = 0; 412 const int programArgumentIndex = 0;
410 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 413 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
411 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 414 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
412 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram")); 415 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram"));
413 exceptionState.throwIfNeeded(); 416 exceptionState.throwIfNeeded();
414 return; 417 return;
415 } 418 }
416 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]); 419 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]);
417 unsigned pname = toInt32(info[1], exceptionState); 420 unsigned pname = toInt32(info[1], exceptionState);
418 if (exceptionState.throwIfNeeded()) 421 if (exceptionState.throwIfNeeded())
419 return; 422 return;
420 WebGLGetInfo args = context->getProgramParameter(program, pname); 423 WebGLGetInfo args = context->getProgramParameter(program, pname);
421 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 424 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
422 } 425 }
423 426
424 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun ctionCallbackInfo<v8::Value>& info) 427 void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8: :FunctionCallbackInfo<v8::Value>& info)
425 { 428 {
426 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu fferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 429 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu fferParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
427 getObjectParameter(info, kRenderbuffer, exceptionState); 430 getObjectParameter(info, kRenderbuffer, exceptionState);
428 } 431 }
429 432
430 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 433 void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
431 { 434 {
432 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 435 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa rameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
433 if (info.Length() != 2) { 436 if (info.Length() != 2) {
434 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 437 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
435 exceptionState.throwIfNeeded(); 438 exceptionState.throwIfNeeded();
436 return; 439 return;
437 } 440 }
438 441
439 const int shaderArgumentIndex = 0; 442 const int shaderArgumentIndex = 0;
440 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 443 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
441 if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V 8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) { 444 if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V 8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) {
442 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(shaderArgumentIndex + 1, "WebGLShader")); 445 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(shaderArgumentIndex + 1, "WebGLShader"));
443 exceptionState.throwIfNeeded(); 446 exceptionState.throwIfNeeded();
444 return; 447 return;
445 } 448 }
446 WebGLShader* shader = V8WebGLShader::toNativeWithTypeCheck(info.GetIsolate() , info[shaderArgumentIndex]); 449 WebGLShader* shader = V8WebGLShader::toNativeWithTypeCheck(info.GetIsolate() , info[shaderArgumentIndex]);
447 unsigned pname = toInt32(info[1], exceptionState); 450 unsigned pname = toInt32(info[1], exceptionState);
448 if (exceptionState.throwIfNeeded()) 451 if (exceptionState.throwIfNeeded())
449 return; 452 return;
450 WebGLGetInfo args = context->getShaderParameter(shader, pname); 453 WebGLGetInfo args = context->getShaderParameter(shader, pname);
451 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 454 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
452 } 455 }
453 456
454 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info) 457 void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::F unctionCallbackInfo<v8::Value>& info)
455 { 458 {
456 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder() ); 459 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info. Holder());
457 if (imp->isContextLost()) { 460 if (imp->isContextLost()) {
458 v8SetReturnValueNull(info); 461 v8SetReturnValueNull(info);
459 return; 462 return;
460 } 463 }
461 464
462 Vector<String> value = imp->getSupportedExtensions(); 465 Vector<String> value = imp->getSupportedExtensions();
463 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), value.size()) ; 466 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), value.size()) ;
464 for (size_t ii = 0; ii < value.size(); ++ii) 467 for (size_t ii = 0; ii < value.size(); ++ii)
465 array->Set(v8::Integer::New(info.GetIsolate(), ii), v8String(info.GetIso late(), value[ii])); 468 array->Set(v8::Integer::New(info.GetIsolate(), ii), v8String(info.GetIso late(), value[ii]));
466 v8SetReturnValue(info, array); 469 v8SetReturnValue(info, array);
467 } 470 }
468 471
469 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 472 void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
470 { 473 {
471 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParam eter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 474 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParam eter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
472 getObjectParameter(info, kTexture, exceptionState); 475 getObjectParameter(info, kTexture, exceptionState);
473 } 476 }
474 477
475 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 478 void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
476 { 479 {
477 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 480 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
478 if (info.Length() != 2) { 481 if (info.Length() != 2) {
479 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 482 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
480 exceptionState.throwIfNeeded(); 483 exceptionState.throwIfNeeded();
481 return; 484 return;
482 } 485 }
483 486
484 const int programArgumentIndex = 0; 487 const int programArgumentIndex = 0;
485 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 488 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
486 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 489 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) {
487 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram")); 490 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(programArgumentIndex + 1, "WebGLProgram"));
488 exceptionState.throwIfNeeded(); 491 exceptionState.throwIfNeeded();
489 return; 492 return;
490 } 493 }
491 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]); 494 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat e(), info[programArgumentIndex]);
492 495
493 const int uniformArgumentIndex = 1; 496 const int uniformArgumentIndex = 1;
494 if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && ! V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate( ))) { 497 if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && ! V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate( ))) {
495 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformArgumentIndex + 1, "WebGLUniformLocation")); 498 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformArgumentIndex + 1, "WebGLUniformLocation"));
496 exceptionState.throwIfNeeded(); 499 exceptionState.throwIfNeeded();
497 return; 500 return;
498 } 501 }
499 const int uniformLocationArgumentIndex = 1; 502 const int uniformLocationArgumentIndex = 1;
500 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 503 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
501 504
502 WebGLGetInfo args = context->getUniform(program, location); 505 WebGLGetInfo args = context->getUniform(program, location);
503 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 506 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
504 } 507 }
505 508
506 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 509 void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
507 { 510 {
508 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAt trib", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 511 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAt trib", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
509 getObjectParameter(info, kVertexAttrib, exceptionState); 512 getObjectParameter(info, kVertexAttrib, exceptionState);
510 } 513 }
511 514
512 enum FunctionToCall { 515 enum FunctionToCall {
513 kUniform1v, kUniform2v, kUniform3v, kUniform4v, 516 kUniform1v, kUniform2v, kUniform3v, kUniform4v,
514 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v 517 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v
515 }; 518 };
516 519
517 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) 520 bool isFunctionToCallForAttribute(FunctionToCall functionToCall)
518 { 521 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } else { 567 } else {
565 const int uniformLocationArgumentIndex = 0; 568 const int uniformLocationArgumentIndex = 0;
566 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgument Index]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentInde x], info.GetIsolate())) { 569 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgument Index]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentInde x], info.GetIsolate())) {
567 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncor rectType(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); 570 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncor rectType(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
568 exceptionState.throwIfNeeded(); 571 exceptionState.throwIfNeeded();
569 return; 572 return;
570 } 573 }
571 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in fo.GetIsolate()); 574 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in fo.GetIsolate());
572 } 575 }
573 576
574 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 577 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
575 578
576 const int indexArrayArgument = 1; 579 const int indexArrayArgument = 1;
577 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate()) ) { 580 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate()) ) {
578 Float32Array* array = V8Float32Array::toNative(info[indexArrayArgument]- >ToObject()); 581 Float32Array* array = V8Float32Array::toNative(info[indexArrayArgument]- >ToObject());
579 ASSERT(array != NULL); 582 ASSERT(array);
580 switch (functionToCall) { 583 switch (functionToCall) {
581 case kUniform1v: context->uniform1fv(location, array); break; 584 case kUniform1v: context->uniform1fv(location, array); break;
582 case kUniform2v: context->uniform2fv(location, array); break; 585 case kUniform2v: context->uniform2fv(location, array); break;
583 case kUniform3v: context->uniform3fv(location, array); break; 586 case kUniform3v: context->uniform3fv(location, array); break;
584 case kUniform4v: context->uniform4fv(location, array); break; 587 case kUniform4v: context->uniform4fv(location, array); break;
585 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; 588 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break;
586 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; 589 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break;
587 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; 590 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break;
588 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; 591 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break;
589 default: ASSERT_NOT_REACHED(); break; 592 default: ASSERT_NOT_REACHED(); break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // * glUniform4iv(GLUniformLocation location, Array data); 636 // * glUniform4iv(GLUniformLocation location, Array data);
634 // * glUniform4iv(GLUniformLocation location, Int32Array data); 637 // * glUniform4iv(GLUniformLocation location, Int32Array data);
635 638
636 if (info.Length() != 2) { 639 if (info.Length() != 2) {
637 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 640 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
638 exceptionState.throwIfNeeded(); 641 exceptionState.throwIfNeeded();
639 return; 642 return;
640 } 643 }
641 644
642 const int uniformLocationArgumentIndex = 0; 645 const int uniformLocationArgumentIndex = 0;
643 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 646 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
644 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) { 647 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
645 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); 648 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
646 exceptionState.throwIfNeeded(); 649 exceptionState.throwIfNeeded();
647 return; 650 return;
648 } 651 }
649 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 652 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
650 653
651 const int indexArrayArgumentIndex = 1; 654 const int indexArrayArgumentIndex = 1;
652 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate ())) { 655 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate ())) {
653 Int32Array* array = V8Int32Array::toNative(info[indexArrayArgumentIndex] ->ToObject()); 656 Int32Array* array = V8Int32Array::toNative(info[indexArrayArgumentIndex] ->ToObject());
654 ASSERT(array != NULL); 657 ASSERT(array);
655 switch (functionToCall) { 658 switch (functionToCall) {
656 case kUniform1v: context->uniform1iv(location, array); break; 659 case kUniform1v: context->uniform1iv(location, array); break;
657 case kUniform2v: context->uniform2iv(location, array); break; 660 case kUniform2v: context->uniform2iv(location, array); break;
658 case kUniform3v: context->uniform3iv(location, array); break; 661 case kUniform3v: context->uniform3iv(location, array); break;
659 case kUniform4v: context->uniform4iv(location, array); break; 662 case kUniform4v: context->uniform4iv(location, array); break;
660 default: ASSERT_NOT_REACHED(); break; 663 default: ASSERT_NOT_REACHED(); break;
661 } 664 }
662 return; 665 return;
663 } 666 }
664 667
(...skipping 16 matching lines...) Expand all
681 switch (functionToCall) { 684 switch (functionToCall) {
682 case kUniform1v: context->uniform1iv(location, data, len); break; 685 case kUniform1v: context->uniform1iv(location, data, len); break;
683 case kUniform2v: context->uniform2iv(location, data, len); break; 686 case kUniform2v: context->uniform2iv(location, data, len); break;
684 case kUniform3v: context->uniform3iv(location, data, len); break; 687 case kUniform3v: context->uniform3iv(location, data, len); break;
685 case kUniform4v: context->uniform4iv(location, data, len); break; 688 case kUniform4v: context->uniform4iv(location, data, len); break;
686 default: ASSERT_NOT_REACHED(); break; 689 default: ASSERT_NOT_REACHED(); break;
687 } 690 }
688 fastFree(data); 691 fastFree(data);
689 } 692 }
690 693
691 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 694 void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
692 { 695 {
693 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 696 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
694 vertexAttribAndUniformHelperf(info, kUniform1v, exceptionState); 697 vertexAttribAndUniformHelperf(info, kUniform1v, exceptionState);
695 } 698 }
696 699
697 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 700 void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
698 { 701 {
699 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 702 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
700 uniformHelperi(info, kUniform1v, exceptionState); 703 uniformHelperi(info, kUniform1v, exceptionState);
701 } 704 }
702 705
703 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 706 void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
704 { 707 {
705 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 708 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
706 vertexAttribAndUniformHelperf(info, kUniform2v, exceptionState); 709 vertexAttribAndUniformHelperf(info, kUniform2v, exceptionState);
707 } 710 }
708 711
709 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 712 void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
710 { 713 {
711 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 714 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
712 uniformHelperi(info, kUniform2v, exceptionState); 715 uniformHelperi(info, kUniform2v, exceptionState);
713 } 716 }
714 717
715 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 718 void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
716 { 719 {
717 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 720 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
718 vertexAttribAndUniformHelperf(info, kUniform3v, exceptionState); 721 vertexAttribAndUniformHelperf(info, kUniform3v, exceptionState);
719 } 722 }
720 723
721 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 724 void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
722 { 725 {
723 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 726 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
724 uniformHelperi(info, kUniform3v, exceptionState); 727 uniformHelperi(info, kUniform3v, exceptionState);
725 } 728 }
726 729
727 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 730 void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
728 { 731 {
729 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 732 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
730 vertexAttribAndUniformHelperf(info, kUniform4v, exceptionState); 733 vertexAttribAndUniformHelperf(info, kUniform4v, exceptionState);
731 } 734 }
732 735
733 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 736 void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
734 { 737 {
735 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 738 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
736 uniformHelperi(info, kUniform4v, exceptionState); 739 uniformHelperi(info, kUniform4v, exceptionState);
737 } 740 }
738 741
739 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& info, int matrixSize, ExceptionState& exceptionState) 742 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& info, int matrixSize, ExceptionState& exceptionState)
740 { 743 {
741 // Forms: 744 // Forms:
742 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); 745 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data);
743 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta); 746 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta);
744 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); 747 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data);
745 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta); 748 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta);
746 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); 749 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data);
747 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta); 750 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta);
748 // 751 //
749 // FIXME: need to change to accept Float32Array as well. 752 // FIXME: need to change to accept Float32Array as well.
750 if (info.Length() != 3) { 753 if (info.Length() != 3) {
751 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length())); 754 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length()));
752 exceptionState.throwIfNeeded(); 755 exceptionState.throwIfNeeded();
753 return; 756 return;
754 } 757 }
755 758
756 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 759 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
757 760
758 const int uniformLocationArgumentIndex = 0; 761 const int uniformLocationArgumentIndex = 0;
759 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) { 762 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
760 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); 763 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation"));
761 exceptionState.throwIfNeeded(); 764 exceptionState.throwIfNeeded();
762 return; 765 return;
763 } 766 }
764 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 767 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
765 768
766 bool transpose = info[1]->BooleanValue(); 769 bool transpose = info[1]->BooleanValue();
767 const int arrayArgumentIndex = 2; 770 const int arrayArgumentIndex = 2;
768 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate()) ) { 771 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate()) ) {
769 Float32Array* array = V8Float32Array::toNative(info[arrayArgumentIndex]- >ToObject()); 772 Float32Array* array = V8Float32Array::toNative(info[arrayArgumentIndex]- >ToObject());
770 ASSERT(array != NULL); 773 ASSERT(array);
771 switch (matrixSize) { 774 switch (matrixSize) {
772 case 2: context->uniformMatrix2fv(location, transpose, array); break; 775 case 2: context->uniformMatrix2fv(location, transpose, array); break;
773 case 3: context->uniformMatrix3fv(location, transpose, array); break; 776 case 3: context->uniformMatrix3fv(location, transpose, array); break;
774 case 4: context->uniformMatrix4fv(location, transpose, array); break; 777 case 4: context->uniformMatrix4fv(location, transpose, array); break;
775 default: ASSERT_NOT_REACHED(); break; 778 default: ASSERT_NOT_REACHED(); break;
776 } 779 }
777 return; 780 return;
778 } 781 }
779 782
780 if (info[arrayArgumentIndex].IsEmpty() || !info[arrayArgumentIndex]->IsArray ()) { 783 if (info[arrayArgumentIndex].IsEmpty() || !info[arrayArgumentIndex]->IsArray ()) {
(...skipping 14 matching lines...) Expand all
795 } 798 }
796 switch (matrixSize) { 799 switch (matrixSize) {
797 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; 800 case 2: context->uniformMatrix2fv(location, transpose, data, len); break;
798 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; 801 case 3: context->uniformMatrix3fv(location, transpose, data, len); break;
799 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; 802 case 4: context->uniformMatrix4fv(location, transpose, data, len); break;
800 default: ASSERT_NOT_REACHED(); break; 803 default: ASSERT_NOT_REACHED(); break;
801 } 804 }
802 fastFree(data); 805 fastFree(data);
803 } 806 }
804 807
805 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 808 void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
806 { 809 {
807 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 810 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
808 uniformMatrixHelper(info, 2, exceptionState); 811 uniformMatrixHelper(info, 2, exceptionState);
809 } 812 }
810 813
811 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 814 void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
812 { 815 {
813 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 816 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
814 uniformMatrixHelper(info, 3, exceptionState); 817 uniformMatrixHelper(info, 3, exceptionState);
815 } 818 }
816 819
817 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 820 void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
818 { 821 {
819 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 822 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
820 uniformMatrixHelper(info, 4, exceptionState); 823 uniformMatrixHelper(info, 4, exceptionState);
821 } 824 }
822 825
823 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 826 void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
824 { 827 {
825 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b1fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 828 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b1fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
826 vertexAttribAndUniformHelperf(info, kVertexAttrib1v, exceptionState); 829 vertexAttribAndUniformHelperf(info, kVertexAttrib1v, exceptionState);
827 } 830 }
828 831
829 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 832 void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
830 { 833 {
831 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 834 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
832 vertexAttribAndUniformHelperf(info, kVertexAttrib2v, exceptionState); 835 vertexAttribAndUniformHelperf(info, kVertexAttrib2v, exceptionState);
833 } 836 }
834 837
835 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 838 void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
836 { 839 {
837 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 840 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
838 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); 841 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState);
839 } 842 }
840 843
841 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 844 void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
842 { 845 {
843 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 846 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
844 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); 847 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState);
845 } 848 }
846 849
847 } // namespace WebCore 850 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698