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

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: Revamped extension testing, added featureLevel Created 7 years, 3 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/V8HiddenPropertyName.h" 65 #include "bindings/v8/V8HiddenPropertyName.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 "core/platform/NotImplemented.h" 76 #include "core/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) 84 static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len)
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 return 0; 88 return 0;
89 float* data = static_cast<float*>(fastMalloc(len * sizeof(float))); 89 float* data = static_cast<float*>(fastMalloc(len * sizeof(float)));
90 90
91 for (uint32_t i = 0; i < len; i++) { 91 for (uint32_t i = 0; i < len; i++) {
92 v8::Local<v8::Value> val = array->Get(i); 92 v8::Local<v8::Value> val = array->Get(i);
93 if (!val->IsNumber()) { 93 if (!val->IsNumber()) {
94 fastFree(data); 94 fastFree(data);
95 return 0; 95 return 0;
96 } 96 }
97 data[i] = toFloat(val); 97 data[i] = toFloat(val);
98 } 98 }
99 return data; 99 return data;
100 } 100 }
101 101
102 // Allocates new storage via fastMalloc. 102 // Allocates new storage via fastMalloc.
103 // Returns NULL if array failed to convert for any reason. 103 // Returns 0 if array failed to convert for any reason.
104 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len) 104 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len)
105 { 105 {
106 // Convert the data element-by-element. 106 // Convert the data element-by-element.
107 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int)) 107 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int))
108 return 0; 108 return 0;
109 int* data = static_cast<int*>(fastMalloc(len * sizeof(int))); 109 int* data = static_cast<int*>(fastMalloc(len * sizeof(int)));
110 110
111 for (uint32_t i = 0; i < len; i++) { 111 for (uint32_t i = 0; i < len; i++) {
112 v8::Local<v8::Value> val = array->Get(i); 112 v8::Local<v8::Value> val = array->Get(i);
113 bool ok; 113 bool ok;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 } 172 }
173 173
174 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate) 174 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate)
175 { 175 {
176 if (!extension) 176 if (!extension)
177 return v8::Null(isolate); 177 return v8::Null(isolate);
178 v8::Handle<v8::Value> extensionObject; 178 v8::Handle<v8::Value> extensionObject;
179 const char* referenceName = 0; 179 const char* referenceName = 0;
180 switch (extension->getName()) { 180 switch (extension->getName()) {
181 case WebGLExtension::ANGLEInstancedArraysName: 181 case ANGLEInstancedArraysName:
182 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate); 182 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate);
183 referenceName = "angleInstancedArraysName"; 183 referenceName = "angleInstancedArraysName";
184 break; 184 break;
185 case WebGLExtension::EXTFragDepthName: 185 case EXTFragDepthName:
186 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate); 186 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate);
187 referenceName = "extFragDepthName"; 187 referenceName = "extFragDepthName";
188 break; 188 break;
189 case WebGLExtension::EXTTextureFilterAnisotropicName: 189 case EXTTextureFilterAnisotropicName:
190 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate); 190 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate);
191 referenceName = "extTextureFilterAnisotropicName"; 191 referenceName = "extTextureFilterAnisotropicName";
192 break; 192 break;
193 case WebGLExtension::OESElementIndexUintName: 193 case OESElementIndexUintName:
194 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate); 194 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate);
195 referenceName = "oesElementIndexUintName"; 195 referenceName = "oesElementIndexUintName";
196 break; 196 break;
197 case WebGLExtension::OESStandardDerivativesName: 197 case OESStandardDerivativesName:
198 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate); 198 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate);
199 referenceName = "oesStandardDerivativesName"; 199 referenceName = "oesStandardDerivativesName";
200 break; 200 break;
201 case WebGLExtension::OESTextureFloatName: 201 case OESTextureFloatName:
202 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate); 202 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate);
203 referenceName = "oesTextureFloatName"; 203 referenceName = "oesTextureFloatName";
204 break; 204 break;
205 case WebGLExtension::OESTextureFloatLinearName: 205 case OESTextureFloatLinearName:
206 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate); 206 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate);
207 referenceName = "oesTextureFloatLinearName"; 207 referenceName = "oesTextureFloatLinearName";
208 break; 208 break;
209 case WebGLExtension::OESTextureHalfFloatName: 209 case OESTextureHalfFloatName:
210 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate); 210 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate);
211 referenceName = "oesTextureHalfFloatName"; 211 referenceName = "oesTextureHalfFloatName";
212 break; 212 break;
213 case WebGLExtension::OESTextureHalfFloatLinearName: 213 case OESTextureHalfFloatLinearName:
214 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate); 214 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate);
215 referenceName = "oesTextureHalfFloatLinearName"; 215 referenceName = "oesTextureHalfFloatLinearName";
216 break; 216 break;
217 case WebGLExtension::OESVertexArrayObjectName: 217 case OESVertexArrayObjectName:
218 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate); 218 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate);
219 referenceName = "oesVertexArrayObjectName"; 219 referenceName = "oesVertexArrayObjectName";
220 break; 220 break;
221 case WebGLExtension::WebGLCompressedTextureATCName: 221 case WebGLCompressedTextureATCName:
222 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate); 222 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate);
223 referenceName = "webGLCompressedTextureATCName"; 223 referenceName = "webGLCompressedTextureATCName";
224 case WebGLExtension::WebGLCompressedTexturePVRTCName: 224 case WebGLCompressedTexturePVRTCName:
225 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate); 225 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate);
226 referenceName = "webGLCompressedTexturePVRTCName"; 226 referenceName = "webGLCompressedTexturePVRTCName";
227 break; 227 break;
228 case WebGLExtension::WebGLCompressedTextureS3TCName: 228 case WebGLCompressedTextureS3TCName:
229 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate); 229 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate);
230 referenceName = "webGLCompressedTextureS3TCName"; 230 referenceName = "webGLCompressedTextureS3TCName";
231 break; 231 break;
232 case WebGLExtension::WebGLDebugRendererInfoName: 232 case WebGLDebugRendererInfoName:
233 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate); 233 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate);
234 referenceName = "webGLDebugRendererInfoName"; 234 referenceName = "webGLDebugRendererInfoName";
235 break; 235 break;
236 case WebGLExtension::WebGLDebugShadersName: 236 case WebGLDebugShadersName:
237 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate); 237 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate);
238 referenceName = "webGLDebugShadersName"; 238 referenceName = "webGLDebugShadersName";
239 break; 239 break;
240 case WebGLExtension::WebGLDepthTextureName: 240 case WebGLDepthTextureName:
241 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate); 241 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate);
242 referenceName = "webGLDepthTextureName"; 242 referenceName = "webGLDepthTextureName";
243 break; 243 break;
244 case WebGLExtension::WebGLDrawBuffersName: 244 case WebGLDrawBuffersName:
245 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate); 245 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate);
246 referenceName = "webGLDrawBuffersName"; 246 referenceName = "webGLDrawBuffersName";
247 break; 247 break;
248 case WebGLExtension::WebGLLoseContextName: 248 case WebGLLoseContextName:
249 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate); 249 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate);
250 referenceName = "webGLLoseContextName"; 250 referenceName = "webGLLoseContextName";
251 break; 251 break;
252 case WebGLExtensionNameCount:
253 notImplemented();
254 return v8::Undefined(isolate);
252 } 255 }
253 ASSERT(!extensionObject.IsEmpty()); 256 ASSERT(!extensionObject.IsEmpty());
254 V8HiddenPropertyName::setNamedHiddenReference(contextObject, referenceName, extensionObject); 257 V8HiddenPropertyName::setNamedHiddenReference(contextObject, referenceName, extensionObject);
255 return extensionObject; 258 return extensionObject;
256 } 259 }
257 260
258 enum ObjectType { 261 enum ObjectType {
259 kBuffer, kRenderbuffer, kTexture, kVertexAttrib 262 kBuffer, kRenderbuffer, kTexture, kVertexAttrib
260 }; 263 };
261 264
262 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args, ObjectType objectType) 265 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args, ObjectType objectType)
263 { 266 {
264 if (args.Length() != 2) { 267 if (args.Length() != 2) {
265 throwNotEnoughArgumentsError(args.GetIsolate()); 268 throwNotEnoughArgumentsError(args.GetIsolate());
266 return; 269 return;
267 } 270 }
268 271
269 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 272 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
270 unsigned target = toInt32(args[0]); 273 unsigned target = toInt32(args[0]);
271 unsigned pname = toInt32(args[1]); 274 unsigned pname = toInt32(args[1]);
272 WebGLGetInfo info; 275 WebGLGetInfo info;
273 switch (objectType) { 276 switch (objectType) {
274 case kBuffer: 277 case kBuffer:
275 info = context->getBufferParameter(target, pname); 278 info = context->getBufferParameter(target, pname);
276 break; 279 break;
277 case kRenderbuffer: 280 case kRenderbuffer:
278 info = context->getRenderbufferParameter(target, pname); 281 info = context->getRenderbufferParameter(target, pname);
279 break; 282 break;
(...skipping 19 matching lines...) Expand all
299 location = V8WebGLUniformLocation::toNative(value->ToObject()); 302 location = V8WebGLUniformLocation::toNative(value->ToObject());
300 ok = true; 303 ok = true;
301 } 304 }
302 return location; 305 return location;
303 } 306 }
304 307
305 enum WhichProgramCall { 308 enum WhichProgramCall {
306 kProgramParameter, kUniform 309 kProgramParameter, kUniform
307 }; 310 };
308 311
309 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& args) 312 void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& args)
310 { 313 {
311 if (args.Length() < 1) { 314 if (args.Length() < 1) {
312 throwNotEnoughArgumentsError(args.GetIsolate()); 315 throwNotEnoughArgumentsError(args.GetIsolate());
313 return; 316 return;
314 } 317 }
315 318
316 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 319 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
317 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 320 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
318 throwTypeError(args.GetIsolate()); 321 throwTypeError(args.GetIsolate());
319 return; 322 return;
320 } 323 }
321 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0; 324 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0;
322 Vector<RefPtr<WebGLShader> > shaders; 325 Vector<RefPtr<WebGLShader> > shaders;
323 bool succeed = context->getAttachedShaders(program, shaders); 326 bool succeed = context->getAttachedShaders(program, shaders);
324 if (!succeed) { 327 if (!succeed) {
325 v8SetReturnValueNull(args); 328 v8SetReturnValueNull(args);
326 return; 329 return;
327 } 330 }
328 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); 331 v8::Local<v8::Array> array = v8::Array::New(shaders.size());
329 for (size_t ii = 0; ii < shaders.size(); ++ii) 332 for (size_t ii = 0; ii < shaders.size(); ++ii)
330 array->Set(v8::Integer::New(ii, args.GetIsolate()), toV8(shaders[ii].get (), args.Holder(), args.GetIsolate())); 333 array->Set(v8::Integer::New(ii, args.GetIsolate()), toV8(shaders[ii].get (), args.Holder(), args.GetIsolate()));
331 v8SetReturnValue(args, array); 334 v8SetReturnValue(args, array);
332 } 335 }
333 336
334 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& args) 337 void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& args)
335 { 338 {
336 getObjectParameter(args, kBuffer); 339 getObjectParameter(args, kBuffer);
337 } 340 }
338 341
339 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& args) 342 void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& args)
340 { 343 {
341 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder() ); 344 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args. Holder());
342 if (args.Length() < 1) { 345 if (args.Length() < 1) {
343 throwNotEnoughArgumentsError(args.GetIsolate()); 346 throwNotEnoughArgumentsError(args.GetIsolate());
344 return; 347 return;
345 } 348 }
346 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]); 349 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]);
347 RefPtr<WebGLExtension> extension(imp->getExtension(name)); 350 RefPtr<WebGLExtension> extension(imp->getExtension(name));
348 v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIs olate())); 351 v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIs olate()));
349 } 352 }
350 353
351 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons t v8::FunctionCallbackInfo<v8::Value>& args) 354 void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom( const v8::FunctionCallbackInfo<v8::Value>& args)
352 { 355 {
353 if (args.Length() != 3) { 356 if (args.Length() != 3) {
354 throwNotEnoughArgumentsError(args.GetIsolate()); 357 throwNotEnoughArgumentsError(args.GetIsolate());
355 return; 358 return;
356 } 359 }
357 360
358 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 361 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
359 unsigned target = toInt32(args[0]); 362 unsigned target = toInt32(args[0]);
360 unsigned attachment = toInt32(args[1]); 363 unsigned attachment = toInt32(args[1]);
361 unsigned pname = toInt32(args[2]); 364 unsigned pname = toInt32(args[2]);
362 WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attac hment, pname); 365 WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attac hment, pname);
363 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); 366 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
364 } 367 }
365 368
366 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& args) 369 void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& args)
367 { 370 {
368 if (args.Length() != 1) { 371 if (args.Length() != 1) {
369 throwNotEnoughArgumentsError(args.GetIsolate()); 372 throwNotEnoughArgumentsError(args.GetIsolate());
370 return; 373 return;
371 } 374 }
372 375
373 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 376 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
374 unsigned pname = toInt32(args[0]); 377 unsigned pname = toInt32(args[0]);
375 WebGLGetInfo info = context->getParameter(pname); 378 WebGLGetInfo info = context->getParameter(pname);
376 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); 379 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
377 } 380 }
378 381
379 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& args) 382 void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::Func tionCallbackInfo<v8::Value>& args)
380 { 383 {
381 if (args.Length() != 2) { 384 if (args.Length() != 2) {
382 throwNotEnoughArgumentsError(args.GetIsolate()); 385 throwNotEnoughArgumentsError(args.GetIsolate());
383 return; 386 return;
384 } 387 }
385 388
386 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 389 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
387 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 390 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
388 throwTypeError(args.GetIsolate()); 391 throwTypeError(args.GetIsolate());
389 return; 392 return;
390 } 393 }
391 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0; 394 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0;
392 unsigned pname = toInt32(args[1]); 395 unsigned pname = toInt32(args[1]);
393 WebGLGetInfo info = context->getProgramParameter(program, pname); 396 WebGLGetInfo info = context->getProgramParameter(program, pname);
394 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); 397 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
395 } 398 }
396 399
397 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun ctionCallbackInfo<v8::Value>& args) 400 void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8: :FunctionCallbackInfo<v8::Value>& args)
398 { 401 {
399 getObjectParameter(args, kRenderbuffer); 402 getObjectParameter(args, kRenderbuffer);
400 } 403 }
401 404
402 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& args) 405 void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& args)
403 { 406 {
404 if (args.Length() != 2) { 407 if (args.Length() != 2) {
405 throwNotEnoughArgumentsError(args.GetIsolate()); 408 throwNotEnoughArgumentsError(args.GetIsolate());
406 return; 409 return;
407 } 410 }
408 411
409 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 412 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
410 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasI nstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 413 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasI nstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
411 throwTypeError(args.GetIsolate()); 414 throwTypeError(args.GetIsolate());
412 return; 415 return;
413 } 416 }
414 WebGLShader* shader = V8WebGLShader::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())) ? V8WebGLShader::toNative(v8::Handle<v8::Object>: :Cast(args[0])) : 0; 417 WebGLShader* shader = V8WebGLShader::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())) ? V8WebGLShader::toNative(v8::Handle<v8::Object>: :Cast(args[0])) : 0;
415 unsigned pname = toInt32(args[1]); 418 unsigned pname = toInt32(args[1]);
416 WebGLGetInfo info = context->getShaderParameter(shader, pname); 419 WebGLGetInfo info = context->getShaderParameter(shader, pname);
417 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); 420 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
418 } 421 }
419 422
420 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& args) 423 void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::F unctionCallbackInfo<v8::Value>& args)
421 { 424 {
422 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder() ); 425 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args. Holder());
423 if (imp->isContextLost()) { 426 if (imp->isContextLost()) {
424 v8SetReturnValueNull(args); 427 v8SetReturnValueNull(args);
425 return; 428 return;
426 } 429 }
427 430
428 Vector<String> value = imp->getSupportedExtensions(); 431 Vector<String> value = imp->getSupportedExtensions();
429 v8::Local<v8::Array> array = v8::Array::New(value.size()); 432 v8::Local<v8::Array> array = v8::Array::New(value.size());
430 for (size_t ii = 0; ii < value.size(); ++ii) 433 for (size_t ii = 0; ii < value.size(); ++ii)
431 array->Set(v8::Integer::New(ii, args.GetIsolate()), v8String(value[ii], args.GetIsolate())); 434 array->Set(v8::Integer::New(ii, args.GetIsolate()), v8String(value[ii], args.GetIsolate()));
432 v8SetReturnValue(args, array); 435 v8SetReturnValue(args, array);
433 } 436 }
434 437
435 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 438 void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
436 { 439 {
437 getObjectParameter(args, kTexture); 440 getObjectParameter(args, kTexture);
438 } 441 }
439 442
440 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 443 void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
441 { 444 {
442 if (args.Length() != 2) { 445 if (args.Length() != 2) {
443 throwNotEnoughArgumentsError(args.GetIsolate()); 446 throwNotEnoughArgumentsError(args.GetIsolate());
444 return; 447 return;
445 } 448 }
446 449
447 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 450 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
448 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 451 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
449 throwTypeError(args.GetIsolate()); 452 throwTypeError(args.GetIsolate());
450 return; 453 return;
451 } 454 }
452 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0; 455 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate (), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje ct>::Cast(args[0])) : 0;
453 456
454 if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocat ion::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) { 457 if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocat ion::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) {
455 throwTypeError(args.GetIsolate()); 458 throwTypeError(args.GetIsolate());
456 return; 459 return;
457 } 460 }
458 bool ok = false; 461 bool ok = false;
459 WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok, args.Ge tIsolate()); 462 WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok, args.Ge tIsolate());
460 463
461 WebGLGetInfo info = context->getUniform(program, location); 464 WebGLGetInfo info = context->getUniform(program, location);
462 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); 465 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
463 } 466 }
464 467
465 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 468 void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
466 { 469 {
467 getObjectParameter(args, kVertexAttrib); 470 getObjectParameter(args, kVertexAttrib);
468 } 471 }
469 472
470 enum FunctionToCall { 473 enum FunctionToCall {
471 kUniform1v, kUniform2v, kUniform3v, kUniform4v, 474 kUniform1v, kUniform2v, kUniform3v, kUniform4v,
472 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v 475 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v
473 }; 476 };
474 477
475 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) 478 bool isFunctionToCallForAttribute(FunctionToCall functionToCall)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 511
509 if (args.Length() != 2) { 512 if (args.Length() != 2) {
510 throwNotEnoughArgumentsError(args.GetIsolate()); 513 throwNotEnoughArgumentsError(args.GetIsolate());
511 return; 514 return;
512 } 515 }
513 516
514 bool ok = false; 517 bool ok = false;
515 int index = -1; 518 int index = -1;
516 WebGLUniformLocation* location = 0; 519 WebGLUniformLocation* location = 0;
517 520
518 if (isFunctionToCallForAttribute(functionToCall)) 521 if (isFunctionToCallForAttribute(functionToCall)) {
519 index = toInt32(args[0]); 522 index = toInt32(args[0]);
520 else { 523 } else {
521 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformL ocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 524 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformL ocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
522 throwTypeError(args.GetIsolate()); 525 throwTypeError(args.GetIsolate());
523 return; 526 return;
524 } 527 }
525 location = toWebGLUniformLocation(args[0], ok, args.GetIsolate()); 528 location = toWebGLUniformLocation(args[0], ok, args.GetIsolate());
526 } 529 }
527 530
528 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 531 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
529 532
530 if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.G etIsolate()))) { 533 if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.G etIsolate()))) {
531 Float32Array* array = V8Float32Array::toNative(args[1]->ToObject()); 534 Float32Array* array = V8Float32Array::toNative(args[1]->ToObject());
532 ASSERT(array != NULL); 535 ASSERT(array);
533 switch (functionToCall) { 536 switch (functionToCall) {
534 case kUniform1v: context->uniform1fv(location, array); break; 537 case kUniform1v: context->uniform1fv(location, array); break;
535 case kUniform2v: context->uniform2fv(location, array); break; 538 case kUniform2v: context->uniform2fv(location, array); break;
536 case kUniform3v: context->uniform3fv(location, array); break; 539 case kUniform3v: context->uniform3fv(location, array); break;
537 case kUniform4v: context->uniform4fv(location, array); break; 540 case kUniform4v: context->uniform4fv(location, array); break;
538 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; 541 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break;
539 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; 542 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break;
540 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; 543 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break;
541 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; 544 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break;
542 default: ASSERT_NOT_REACHED(); break; 545 default: ASSERT_NOT_REACHED(); break;
543 } 546 }
544 return; 547 return;
545 } 548 }
546 549
547 if (args[1].IsEmpty() || !args[1]->IsArray()) { 550 if (args[1].IsEmpty() || !args[1]->IsArray()) {
548 throwTypeError(args.GetIsolate()); 551 throwTypeError(args.GetIsolate());
549 return; 552 return;
550 } 553 }
551 v8::Handle<v8::Array> array = 554 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
552 v8::Local<v8::Array>::Cast(args[1]);
553 uint32_t len = array->Length(); 555 uint32_t len = array->Length();
554 float* data = jsArrayToFloatArray(array, len); 556 float* data = jsArrayToFloatArray(array, len);
555 if (!data) { 557 if (!data) {
556 // FIXME: consider different / better exception type. 558 // FIXME: consider different / better exception type.
557 setDOMException(SyntaxError, args.GetIsolate()); 559 setDOMException(SyntaxError, args.GetIsolate());
558 return; 560 return;
559 } 561 }
560 switch (functionToCall) { 562 switch (functionToCall) {
561 case kUniform1v: context->uniform1fv(location, data, len); break; 563 case kUniform1v: context->uniform1fv(location, data, len); break;
562 case kUniform2v: context->uniform2fv(location, data, len); break; 564 case kUniform2v: context->uniform2fv(location, data, len); break;
(...skipping 18 matching lines...) Expand all
581 // * glUniform3iv(GLUniformLocation location, Array data); 583 // * glUniform3iv(GLUniformLocation location, Array data);
582 // * glUniform3iv(GLUniformLocation location, Int32Array data); 584 // * glUniform3iv(GLUniformLocation location, Int32Array data);
583 // * glUniform4iv(GLUniformLocation location, Array data); 585 // * glUniform4iv(GLUniformLocation location, Array data);
584 // * glUniform4iv(GLUniformLocation location, Int32Array data); 586 // * glUniform4iv(GLUniformLocation location, Int32Array data);
585 587
586 if (args.Length() != 2) { 588 if (args.Length() != 2) {
587 throwNotEnoughArgumentsError(args.GetIsolate()); 589 throwNotEnoughArgumentsError(args.GetIsolate());
588 return; 590 return;
589 } 591 }
590 592
591 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 593 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
592 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 594 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
593 throwTypeError(args.GetIsolate()); 595 throwTypeError(args.GetIsolate());
594 return; 596 return;
595 } 597 }
596 bool ok = false; 598 bool ok = false;
597 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge tIsolate()); 599 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge tIsolate());
598 600
599 if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.Get Isolate()))) { 601 if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.Get Isolate()))) {
600 Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); 602 Int32Array* array = V8Int32Array::toNative(args[1]->ToObject());
601 ASSERT(array != NULL); 603 ASSERT(array);
602 switch (functionToCall) { 604 switch (functionToCall) {
603 case kUniform1v: context->uniform1iv(location, array); break; 605 case kUniform1v: context->uniform1iv(location, array); break;
604 case kUniform2v: context->uniform2iv(location, array); break; 606 case kUniform2v: context->uniform2iv(location, array); break;
605 case kUniform3v: context->uniform3iv(location, array); break; 607 case kUniform3v: context->uniform3iv(location, array); break;
606 case kUniform4v: context->uniform4iv(location, array); break; 608 case kUniform4v: context->uniform4iv(location, array); break;
607 default: ASSERT_NOT_REACHED(); break; 609 default: ASSERT_NOT_REACHED(); break;
608 } 610 }
609 return; 611 return;
610 } 612 }
611 613
612 if (args[1].IsEmpty() || !args[1]->IsArray()) { 614 if (args[1].IsEmpty() || !args[1]->IsArray()) {
613 throwTypeError(args.GetIsolate()); 615 throwTypeError(args.GetIsolate());
614 return; 616 return;
615 } 617 }
616 v8::Handle<v8::Array> array = 618 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
617 v8::Local<v8::Array>::Cast(args[1]);
618 uint32_t len = array->Length(); 619 uint32_t len = array->Length();
619 int* data = jsArrayToIntArray(array, len); 620 int* data = jsArrayToIntArray(array, len);
620 if (!data) { 621 if (!data) {
621 // FIXME: consider different / better exception type. 622 // FIXME: consider different / better exception type.
622 setDOMException(SyntaxError, args.GetIsolate()); 623 setDOMException(SyntaxError, args.GetIsolate());
623 return; 624 return;
624 } 625 }
625 switch (functionToCall) { 626 switch (functionToCall) {
626 case kUniform1v: context->uniform1iv(location, data, len); break; 627 case kUniform1v: context->uniform1iv(location, data, len); break;
627 case kUniform2v: context->uniform2iv(location, data, len); break; 628 case kUniform2v: context->uniform2iv(location, data, len); break;
628 case kUniform3v: context->uniform3iv(location, data, len); break; 629 case kUniform3v: context->uniform3iv(location, data, len); break;
629 case kUniform4v: context->uniform4iv(location, data, len); break; 630 case kUniform4v: context->uniform4iv(location, data, len); break;
630 default: ASSERT_NOT_REACHED(); break; 631 default: ASSERT_NOT_REACHED(); break;
631 } 632 }
632 fastFree(data); 633 fastFree(data);
633 } 634 }
634 635
635 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 636 void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
636 { 637 {
637 vertexAttribAndUniformHelperf(args, kUniform1v); 638 vertexAttribAndUniformHelperf(args, kUniform1v);
638 } 639 }
639 640
640 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 641 void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
641 { 642 {
642 uniformHelperi(args, kUniform1v); 643 uniformHelperi(args, kUniform1v);
643 } 644 }
644 645
645 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 646 void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
646 { 647 {
647 vertexAttribAndUniformHelperf(args, kUniform2v); 648 vertexAttribAndUniformHelperf(args, kUniform2v);
648 } 649 }
649 650
650 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 651 void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
651 { 652 {
652 uniformHelperi(args, kUniform2v); 653 uniformHelperi(args, kUniform2v);
653 } 654 }
654 655
655 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 656 void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
656 { 657 {
657 vertexAttribAndUniformHelperf(args, kUniform3v); 658 vertexAttribAndUniformHelperf(args, kUniform3v);
658 } 659 }
659 660
660 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 661 void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
661 { 662 {
662 uniformHelperi(args, kUniform3v); 663 uniformHelperi(args, kUniform3v);
663 } 664 }
664 665
665 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 666 void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
666 { 667 {
667 vertexAttribAndUniformHelperf(args, kUniform4v); 668 vertexAttribAndUniformHelperf(args, kUniform4v);
668 } 669 }
669 670
670 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& args) 671 void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& args)
671 { 672 {
672 uniformHelperi(args, kUniform4v); 673 uniformHelperi(args, kUniform4v);
673 } 674 }
674 675
675 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args, int matrixSize) 676 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args, int matrixSize)
676 { 677 {
677 // Forms: 678 // Forms:
678 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); 679 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data);
679 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta); 680 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta);
680 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); 681 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data);
681 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta); 682 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta);
682 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); 683 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data);
683 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta); 684 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta);
684 // 685 //
685 // FIXME: need to change to accept Float32Array as well. 686 // FIXME: need to change to accept Float32Array as well.
686 if (args.Length() != 3) { 687 if (args.Length() != 3) {
687 throwNotEnoughArgumentsError(args.GetIsolate()); 688 throwNotEnoughArgumentsError(args.GetIsolate());
688 return; 689 return;
689 } 690 }
690 691
691 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold er()); 692 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a rgs.Holder());
692 693
693 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { 694 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
694 throwTypeError(args.GetIsolate()); 695 throwTypeError(args.GetIsolate());
695 return; 696 return;
696 } 697 }
697 bool ok = false; 698 bool ok = false;
698 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge tIsolate()); 699 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge tIsolate());
699 700
700 bool transpose = args[1]->BooleanValue(); 701 bool transpose = args[1]->BooleanValue();
701 if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.G etIsolate()))) { 702 if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.G etIsolate()))) {
702 Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); 703 Float32Array* array = V8Float32Array::toNative(args[2]->ToObject());
703 ASSERT(array != NULL); 704 ASSERT(array);
704 switch (matrixSize) { 705 switch (matrixSize) {
705 case 2: context->uniformMatrix2fv(location, transpose, array); break; 706 case 2: context->uniformMatrix2fv(location, transpose, array); break;
706 case 3: context->uniformMatrix3fv(location, transpose, array); break; 707 case 3: context->uniformMatrix3fv(location, transpose, array); break;
707 case 4: context->uniformMatrix4fv(location, transpose, array); break; 708 case 4: context->uniformMatrix4fv(location, transpose, array); break;
708 default: ASSERT_NOT_REACHED(); break; 709 default: ASSERT_NOT_REACHED(); break;
709 } 710 }
710 return; 711 return;
711 } 712 }
712 713
713 if (args[2].IsEmpty() || !args[2]->IsArray()) { 714 if (args[2].IsEmpty() || !args[2]->IsArray()) {
714 throwTypeError(args.GetIsolate()); 715 throwTypeError(args.GetIsolate());
715 return; 716 return;
716 } 717 }
717 v8::Handle<v8::Array> array = 718 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[2]);
718 v8::Local<v8::Array>::Cast(args[2]);
719 uint32_t len = array->Length(); 719 uint32_t len = array->Length();
720 float* data = jsArrayToFloatArray(array, len); 720 float* data = jsArrayToFloatArray(array, len);
721 if (!data) { 721 if (!data) {
722 // FIXME: consider different / better exception type. 722 // FIXME: consider different / better exception type.
723 setDOMException(SyntaxError, args.GetIsolate()); 723 setDOMException(SyntaxError, args.GetIsolate());
724 return; 724 return;
725 } 725 }
726 switch (matrixSize) { 726 switch (matrixSize) {
727 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; 727 case 2: context->uniformMatrix2fv(location, transpose, data, len); break;
728 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; 728 case 3: context->uniformMatrix3fv(location, transpose, data, len); break;
729 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; 729 case 4: context->uniformMatrix4fv(location, transpose, data, len); break;
730 default: ASSERT_NOT_REACHED(); break; 730 default: ASSERT_NOT_REACHED(); break;
731 } 731 }
732 fastFree(data); 732 fastFree(data);
733 } 733 }
734 734
735 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& args) 735 void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& args)
736 { 736 {
737 uniformMatrixHelper(args, 2); 737 uniformMatrixHelper(args, 2);
738 } 738 }
739 739
740 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& args) 740 void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& args)
741 { 741 {
742 uniformMatrixHelper(args, 3); 742 uniformMatrixHelper(args, 3);
743 } 743 }
744 744
745 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& args) 745 void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& args)
746 { 746 {
747 uniformMatrixHelper(args, 4); 747 uniformMatrixHelper(args, 4);
748 } 748 }
749 749
750 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 750 void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
751 { 751 {
752 vertexAttribAndUniformHelperf(args, kVertexAttrib1v); 752 vertexAttribAndUniformHelperf(args, kVertexAttrib1v);
753 } 753 }
754 754
755 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 755 void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
756 { 756 {
757 vertexAttribAndUniformHelperf(args, kVertexAttrib2v); 757 vertexAttribAndUniformHelperf(args, kVertexAttrib2v);
758 } 758 }
759 759
760 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 760 void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
761 { 761 {
762 vertexAttribAndUniformHelperf(args, kVertexAttrib3v); 762 vertexAttribAndUniformHelperf(args, kVertexAttrib3v);
763 } 763 }
764 764
765 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& args) 765 void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& args)
766 { 766 {
767 vertexAttribAndUniformHelperf(args, kVertexAttrib4v); 767 vertexAttribAndUniformHelperf(args, kVertexAttrib4v);
768 } 768 }
769 769
770 } // namespace WebCore 770 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698