| OLD | NEW |
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int ival = toInt32(val, ok); | 115 int ival = toInt32(val, ok); |
| 116 if (!ok) { | 116 if (!ok) { |
| 117 fastFree(data); | 117 fastFree(data); |
| 118 return 0; | 118 return 0; |
| 119 } | 119 } |
| 120 data[i] = ival; | 120 data[i] = ival; |
| 121 } | 121 } |
| 122 return data; | 122 return data; |
| 123 } | 123 } |
| 124 | 124 |
| 125 static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) | 125 static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& args, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) |
| 126 { | 126 { |
| 127 switch (info.getType()) { | 127 switch (args.getType()) { |
| 128 case WebGLGetInfo::kTypeBool: | 128 case WebGLGetInfo::kTypeBool: |
| 129 return v8::Boolean::New(info.getBool()); | 129 return v8::Boolean::New(args.getBool()); |
| 130 case WebGLGetInfo::kTypeBoolArray: { | 130 case WebGLGetInfo::kTypeBoolArray: { |
| 131 const Vector<bool>& value = info.getBoolArray(); | 131 const Vector<bool>& value = args.getBoolArray(); |
| 132 v8::Local<v8::Array> array = v8::Array::New(value.size()); | 132 v8::Local<v8::Array> array = v8::Array::New(value.size()); |
| 133 for (size_t ii = 0; ii < value.size(); ++ii) | 133 for (size_t ii = 0; ii < value.size(); ++ii) |
| 134 array->Set(v8::Integer::New(ii, isolate), v8::Boolean::New(value[ii]
)); | 134 array->Set(v8::Integer::New(ii, isolate), v8::Boolean::New(value[ii]
)); |
| 135 return array; | 135 return array; |
| 136 } | 136 } |
| 137 case WebGLGetInfo::kTypeFloat: | 137 case WebGLGetInfo::kTypeFloat: |
| 138 return v8::Number::New(isolate, info.getFloat()); | 138 return v8::Number::New(isolate, args.getFloat()); |
| 139 case WebGLGetInfo::kTypeInt: | 139 case WebGLGetInfo::kTypeInt: |
| 140 return v8::Integer::New(info.getInt(), isolate); | 140 return v8::Integer::New(args.getInt(), isolate); |
| 141 case WebGLGetInfo::kTypeNull: | 141 case WebGLGetInfo::kTypeNull: |
| 142 return v8::Null(isolate); | 142 return v8::Null(isolate); |
| 143 case WebGLGetInfo::kTypeString: | 143 case WebGLGetInfo::kTypeString: |
| 144 return v8String(info.getString(), isolate); | 144 return v8String(args.getString(), isolate); |
| 145 case WebGLGetInfo::kTypeUnsignedInt: | 145 case WebGLGetInfo::kTypeUnsignedInt: |
| 146 return v8::Integer::NewFromUnsigned(info.getUnsignedInt(), isolate); | 146 return v8::Integer::NewFromUnsigned(args.getUnsignedInt(), isolate); |
| 147 case WebGLGetInfo::kTypeWebGLBuffer: | 147 case WebGLGetInfo::kTypeWebGLBuffer: |
| 148 return toV8(info.getWebGLBuffer(), creationContext, isolate); | 148 return toV8(args.getWebGLBuffer(), creationContext, isolate); |
| 149 case WebGLGetInfo::kTypeWebGLFloatArray: | 149 case WebGLGetInfo::kTypeWebGLFloatArray: |
| 150 return toV8(info.getWebGLFloatArray(), creationContext, isolate); | 150 return toV8(args.getWebGLFloatArray(), creationContext, isolate); |
| 151 case WebGLGetInfo::kTypeWebGLFramebuffer: | 151 case WebGLGetInfo::kTypeWebGLFramebuffer: |
| 152 return toV8(info.getWebGLFramebuffer(), creationContext, isolate); | 152 return toV8(args.getWebGLFramebuffer(), creationContext, isolate); |
| 153 case WebGLGetInfo::kTypeWebGLIntArray: | 153 case WebGLGetInfo::kTypeWebGLIntArray: |
| 154 return toV8(info.getWebGLIntArray(), creationContext, isolate); | 154 return toV8(args.getWebGLIntArray(), creationContext, isolate); |
| 155 // FIXME: implement WebGLObjectArray | 155 // FIXME: implement WebGLObjectArray |
| 156 // case WebGLGetInfo::kTypeWebGLObjectArray: | 156 // case WebGLGetInfo::kTypeWebGLObjectArray: |
| 157 case WebGLGetInfo::kTypeWebGLProgram: | 157 case WebGLGetInfo::kTypeWebGLProgram: |
| 158 return toV8(info.getWebGLProgram(), creationContext, isolate); | 158 return toV8(args.getWebGLProgram(), creationContext, isolate); |
| 159 case WebGLGetInfo::kTypeWebGLRenderbuffer: | 159 case WebGLGetInfo::kTypeWebGLRenderbuffer: |
| 160 return toV8(info.getWebGLRenderbuffer(), creationContext, isolate); | 160 return toV8(args.getWebGLRenderbuffer(), creationContext, isolate); |
| 161 case WebGLGetInfo::kTypeWebGLTexture: | 161 case WebGLGetInfo::kTypeWebGLTexture: |
| 162 return toV8(info.getWebGLTexture(), creationContext, isolate); | 162 return toV8(args.getWebGLTexture(), creationContext, isolate); |
| 163 case WebGLGetInfo::kTypeWebGLUnsignedByteArray: | 163 case WebGLGetInfo::kTypeWebGLUnsignedByteArray: |
| 164 return toV8(info.getWebGLUnsignedByteArray(), creationContext, isolate); | 164 return toV8(args.getWebGLUnsignedByteArray(), creationContext, isolate); |
| 165 case WebGLGetInfo::kTypeWebGLUnsignedIntArray: | 165 case WebGLGetInfo::kTypeWebGLUnsignedIntArray: |
| 166 return toV8(info.getWebGLUnsignedIntArray(), creationContext, isolate); | 166 return toV8(args.getWebGLUnsignedIntArray(), creationContext, isolate); |
| 167 case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: | 167 case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: |
| 168 return toV8(info.getWebGLVertexArrayObjectOES(), creationContext, isolat
e); | 168 return toV8(args.getWebGLVertexArrayObjectOES(), creationContext, isolat
e); |
| 169 default: | 169 default: |
| 170 notImplemented(); | 170 notImplemented(); |
| 171 return v8::Undefined(isolate); | 171 return v8::Undefined(isolate); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
::Object> contextObject, v8::Isolate* isolate) | 175 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
::Object> contextObject, v8::Isolate* isolate) |
| 176 { | 176 { |
| 177 if (!extension) | 177 if (!extension) |
| 178 return v8::Null(isolate); | 178 return v8::Null(isolate); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 253 } |
| 254 ASSERT(!extensionObject.IsEmpty()); | 254 ASSERT(!extensionObject.IsEmpty()); |
| 255 V8HiddenPropertyName::setNamedHiddenReference(contextObject, referenceName,
extensionObject); | 255 V8HiddenPropertyName::setNamedHiddenReference(contextObject, referenceName,
extensionObject); |
| 256 return extensionObject; | 256 return extensionObject; |
| 257 } | 257 } |
| 258 | 258 |
| 259 enum ObjectType { | 259 enum ObjectType { |
| 260 kBuffer, kRenderbuffer, kTexture, kVertexAttrib | 260 kBuffer, kRenderbuffer, kTexture, kVertexAttrib |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args,
ObjectType objectType, const char* method) | 263 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& info,
ObjectType objectType, const char* method) |
| 264 { | 264 { |
| 265 if (args.Length() != 2) { | 265 if (info.Length() != 2) { |
| 266 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, args.Length())), args.GetIso
late()); | 266 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIso
late()); |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 | 269 |
| 270 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 270 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 271 unsigned target = toInt32(args[0]); | 271 unsigned target = toInt32(info[0]); |
| 272 unsigned pname = toInt32(args[1]); | 272 unsigned pname = toInt32(info[1]); |
| 273 WebGLGetInfo info; | 273 WebGLGetInfo args; |
| 274 switch (objectType) { | 274 switch (objectType) { |
| 275 case kBuffer: | 275 case kBuffer: |
| 276 info = context->getBufferParameter(target, pname); | 276 args = context->getBufferParameter(target, pname); |
| 277 break; | 277 break; |
| 278 case kRenderbuffer: | 278 case kRenderbuffer: |
| 279 info = context->getRenderbufferParameter(target, pname); | 279 args = context->getRenderbufferParameter(target, pname); |
| 280 break; | 280 break; |
| 281 case kTexture: | 281 case kTexture: |
| 282 info = context->getTexParameter(target, pname); | 282 args = context->getTexParameter(target, pname); |
| 283 break; | 283 break; |
| 284 case kVertexAttrib: | 284 case kVertexAttrib: |
| 285 // target => index | 285 // target => index |
| 286 info = context->getVertexAttrib(target, pname); | 286 args = context->getVertexAttrib(target, pname); |
| 287 break; | 287 break; |
| 288 default: | 288 default: |
| 289 notImplemented(); | 289 notImplemented(); |
| 290 break; | 290 break; |
| 291 } | 291 } |
| 292 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 292 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 293 } | 293 } |
| 294 | 294 |
| 295 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
bool& ok, v8::Isolate* isolate) | 295 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
bool& ok, v8::Isolate* isolate) |
| 296 { | 296 { |
| 297 ok = false; | 297 ok = false; |
| 298 WebGLUniformLocation* location = 0; | 298 WebGLUniformLocation* location = 0; |
| 299 if (V8WebGLUniformLocation::HasInstance(value, isolate, worldType(isolate)))
{ | 299 if (V8WebGLUniformLocation::HasInstance(value, isolate, worldType(isolate)))
{ |
| 300 location = V8WebGLUniformLocation::toNative(value->ToObject()); | 300 location = V8WebGLUniformLocation::toNative(value->ToObject()); |
| 301 ok = true; | 301 ok = true; |
| 302 } | 302 } |
| 303 return location; | 303 return location; |
| 304 } | 304 } |
| 305 | 305 |
| 306 enum WhichProgramCall { | 306 enum WhichProgramCall { |
| 307 kProgramParameter, kUniform | 307 kProgramParameter, kUniform |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 310 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 311 { | 311 { |
| 312 if (args.Length() < 1) { | 312 if (info.Length() < 1) { |
| 313 throwTypeError(ExceptionMessages::failedToExecute("getAttachedShaders",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(1, args.Length())
), args.GetIsolate()); | 313 throwTypeError(ExceptionMessages::failedToExecute("getAttachedShaders",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(1, info.Length())
), info.GetIsolate()); |
| 314 return; | 314 return; |
| 315 } | 315 } |
| 316 | 316 |
| 317 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 317 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 318 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 318 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLProgram::Has
Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 319 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 319 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 320 return; | 320 return; |
| 321 } | 321 } |
| 322 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 322 WebGLProgram* program = V8WebGLProgram::HasInstance(info[0], info.GetIsolate
(), worldType(info.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(info[0])) : 0; |
| 323 Vector<RefPtr<WebGLShader> > shaders; | 323 Vector<RefPtr<WebGLShader> > shaders; |
| 324 bool succeed = context->getAttachedShaders(program, shaders); | 324 bool succeed = context->getAttachedShaders(program, shaders); |
| 325 if (!succeed) { | 325 if (!succeed) { |
| 326 v8SetReturnValueNull(args); | 326 v8SetReturnValueNull(info); |
| 327 return; | 327 return; |
| 328 } | 328 } |
| 329 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); | 329 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); |
| 330 for (size_t ii = 0; ii < shaders.size(); ++ii) | 330 for (size_t ii = 0; ii < shaders.size(); ++ii) |
| 331 array->Set(v8::Integer::New(ii, args.GetIsolate()), toV8(shaders[ii].get
(), args.Holder(), args.GetIsolate())); | 331 array->Set(v8::Integer::New(ii, info.GetIsolate()), toV8(shaders[ii].get
(), info.Holder(), info.GetIsolate())); |
| 332 v8SetReturnValue(args, array); | 332 v8SetReturnValue(info, array); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 335 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 336 { | 336 { |
| 337 getObjectParameter(args, kBuffer, "getBufferParameter"); | 337 getObjectParameter(info, kBuffer, "getBufferParameter"); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 340 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 341 { | 341 { |
| 342 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder()
); | 342 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder()
); |
| 343 if (args.Length() < 1) { | 343 if (info.Length() < 1) { |
| 344 throwTypeError(ExceptionMessages::failedToExecute("getExtension", "WebGL
RenderingContext", ExceptionMessages::notEnoughArguments(1, args.Length())), arg
s.GetIsolate()); | 344 throwTypeError(ExceptionMessages::failedToExecute("getExtension", "WebGL
RenderingContext", ExceptionMessages::notEnoughArguments(1, info.Length())), inf
o.GetIsolate()); |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]); | 347 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); |
| 348 RefPtr<WebGLExtension> extension(imp->getExtension(name)); | 348 RefPtr<WebGLExtension> extension(imp->getExtension(name)); |
| 349 v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIs
olate())); | 349 v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIs
olate())); |
| 350 } | 350 } |
| 351 | 351 |
| 352 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons
t v8::FunctionCallbackInfo<v8::Value>& args) | 352 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons
t v8::FunctionCallbackInfo<v8::Value>& info) |
| 353 { | 353 { |
| 354 if (args.Length() != 3) { | 354 if (info.Length() != 3) { |
| 355 throwTypeError(ExceptionMessages::failedToExecute("getFramebufferAttachm
entParameter", "WebGLRenderingContext", ExceptionMessages::notEnoughArguments(3,
args.Length())), args.GetIsolate()); | 355 throwTypeError(ExceptionMessages::failedToExecute("getFramebufferAttachm
entParameter", "WebGLRenderingContext", ExceptionMessages::notEnoughArguments(3,
info.Length())), info.GetIsolate()); |
| 356 return; | 356 return; |
| 357 } | 357 } |
| 358 | 358 |
| 359 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 359 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 360 unsigned target = toInt32(args[0]); | 360 unsigned target = toInt32(info[0]); |
| 361 unsigned attachment = toInt32(args[1]); | 361 unsigned attachment = toInt32(info[1]); |
| 362 unsigned pname = toInt32(args[2]); | 362 unsigned pname = toInt32(info[2]); |
| 363 WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attac
hment, pname); | 363 WebGLGetInfo args = context->getFramebufferAttachmentParameter(target, attac
hment, pname); |
| 364 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 364 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 367 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| 368 { | 368 { |
| 369 if (args.Length() != 1) { | 369 if (info.Length() != 1) { |
| 370 throwTypeError(ExceptionMessages::failedToExecute("getParameter", "WebGL
RenderingContext", ExceptionMessages::notEnoughArguments(1, args.Length())), arg
s.GetIsolate()); | 370 throwTypeError(ExceptionMessages::failedToExecute("getParameter", "WebGL
RenderingContext", ExceptionMessages::notEnoughArguments(1, info.Length())), inf
o.GetIsolate()); |
| 371 return; | 371 return; |
| 372 } | 372 } |
| 373 | 373 |
| 374 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 374 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 375 unsigned pname = toInt32(args[0]); | 375 unsigned pname = toInt32(info[0]); |
| 376 WebGLGetInfo info = context->getParameter(pname); | 376 WebGLGetInfo args = context->getParameter(pname); |
| 377 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 377 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) | 380 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function
CallbackInfo<v8::Value>& info) |
| 381 { | 381 { |
| 382 if (args.Length() != 2) { | 382 if (info.Length() != 2) { |
| 383 throwTypeError(ExceptionMessages::failedToExecute("getProgramParameter",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(2, args.Length()
)), args.GetIsolate()); | 383 throwTypeError(ExceptionMessages::failedToExecute("getProgramParameter",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(2, info.Length()
)), info.GetIsolate()); |
| 384 return; | 384 return; |
| 385 } | 385 } |
| 386 | 386 |
| 387 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 387 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 388 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 388 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLProgram::Has
Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 389 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 389 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 392 WebGLProgram* program = V8WebGLProgram::HasInstance(info[0], info.GetIsolate
(), worldType(info.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(info[0])) : 0; |
| 393 unsigned pname = toInt32(args[1]); | 393 unsigned pname = toInt32(info[1]); |
| 394 WebGLGetInfo info = context->getProgramParameter(program, pname); | 394 WebGLGetInfo args = context->getProgramParameter(program, pname); |
| 395 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 395 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 396 } | 396 } |
| 397 | 397 |
| 398 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun
ctionCallbackInfo<v8::Value>& args) | 398 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun
ctionCallbackInfo<v8::Value>& info) |
| 399 { | 399 { |
| 400 getObjectParameter(args, kRenderbuffer, "getRenderbufferParameter"); | 400 getObjectParameter(info, kRenderbuffer, "getRenderbufferParameter"); |
| 401 } | 401 } |
| 402 | 402 |
| 403 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 403 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 404 { | 404 { |
| 405 if (args.Length() != 2) { | 405 if (info.Length() != 2) { |
| 406 throwTypeError(ExceptionMessages::failedToExecute("getShaderParameter",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(2, args.Length())
), args.GetIsolate()); | 406 throwTypeError(ExceptionMessages::failedToExecute("getShaderParameter",
"WebGLRenderingContext", ExceptionMessages::notEnoughArguments(2, info.Length())
), info.GetIsolate()); |
| 407 return; | 407 return; |
| 408 } | 408 } |
| 409 | 409 |
| 410 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 410 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 411 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasI
nstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 411 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLShader::HasI
nstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 412 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 412 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 413 return; | 413 return; |
| 414 } | 414 } |
| 415 WebGLShader* shader = V8WebGLShader::HasInstance(args[0], args.GetIsolate(),
worldType(args.GetIsolate())) ? V8WebGLShader::toNative(v8::Handle<v8::Object>:
:Cast(args[0])) : 0; | 415 WebGLShader* shader = V8WebGLShader::HasInstance(info[0], info.GetIsolate(),
worldType(info.GetIsolate())) ? V8WebGLShader::toNative(v8::Handle<v8::Object>:
:Cast(info[0])) : 0; |
| 416 unsigned pname = toInt32(args[1]); | 416 unsigned pname = toInt32(info[1]); |
| 417 WebGLGetInfo info = context->getShaderParameter(shader, pname); | 417 WebGLGetInfo args = context->getShaderParameter(shader, pname); |
| 418 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 418 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& args) | 421 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
| 422 { | 422 { |
| 423 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder()
); | 423 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder()
); |
| 424 if (imp->isContextLost()) { | 424 if (imp->isContextLost()) { |
| 425 v8SetReturnValueNull(args); | 425 v8SetReturnValueNull(info); |
| 426 return; | 426 return; |
| 427 } | 427 } |
| 428 | 428 |
| 429 Vector<String> value = imp->getSupportedExtensions(); | 429 Vector<String> value = imp->getSupportedExtensions(); |
| 430 v8::Local<v8::Array> array = v8::Array::New(value.size()); | 430 v8::Local<v8::Array> array = v8::Array::New(value.size()); |
| 431 for (size_t ii = 0; ii < value.size(); ++ii) | 431 for (size_t ii = 0; ii < value.size(); ++ii) |
| 432 array->Set(v8::Integer::New(ii, args.GetIsolate()), v8String(value[ii],
args.GetIsolate())); | 432 array->Set(v8::Integer::New(ii, info.GetIsolate()), v8String(value[ii],
info.GetIsolate())); |
| 433 v8SetReturnValue(args, array); | 433 v8SetReturnValue(info, array); |
| 434 } | 434 } |
| 435 | 435 |
| 436 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 436 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 437 { | 437 { |
| 438 getObjectParameter(args, kTexture, "getTexParameter"); | 438 getObjectParameter(info, kTexture, "getTexParameter"); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 441 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 442 { | 442 { |
| 443 if (args.Length() != 2) { | 443 if (info.Length() != 2) { |
| 444 throwTypeError(ExceptionMessages::failedToExecute("getUniform", "WebGLRe
nderingContext", ExceptionMessages::notEnoughArguments(2, args.Length())), args.
GetIsolate()); | 444 throwTypeError(ExceptionMessages::failedToExecute("getUniform", "WebGLRe
nderingContext", ExceptionMessages::notEnoughArguments(2, info.Length())), info.
GetIsolate()); |
| 445 return; | 445 return; |
| 446 } | 446 } |
| 447 | 447 |
| 448 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 448 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 449 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 449 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLProgram::Has
Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 450 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 450 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 451 return; | 451 return; |
| 452 } | 452 } |
| 453 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 453 WebGLProgram* program = V8WebGLProgram::HasInstance(info[0], info.GetIsolate
(), worldType(info.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(info[0])) : 0; |
| 454 | 454 |
| 455 if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocat
ion::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) { | 455 if (info.Length() > 1 && !isUndefinedOrNull(info[1]) && !V8WebGLUniformLocat
ion::HasInstance(info[1], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 456 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 456 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 457 return; | 457 return; |
| 458 } | 458 } |
| 459 bool ok = false; | 459 bool ok = false; |
| 460 WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok, args.Ge
tIsolate()); | 460 WebGLUniformLocation* location = toWebGLUniformLocation(info[1], ok, info.Ge
tIsolate()); |
| 461 | 461 |
| 462 WebGLGetInfo info = context->getUniform(program, location); | 462 WebGLGetInfo args = context->getUniform(program, location); |
| 463 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 463 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 464 } | 464 } |
| 465 | 465 |
| 466 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 466 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 467 { | 467 { |
| 468 getObjectParameter(args, kVertexAttrib, "getVertexAttrib"); | 468 getObjectParameter(info, kVertexAttrib, "getVertexAttrib"); |
| 469 } | 469 } |
| 470 | 470 |
| 471 enum FunctionToCall { | 471 enum FunctionToCall { |
| 472 kUniform1v, kUniform2v, kUniform3v, kUniform4v, | 472 kUniform1v, kUniform2v, kUniform3v, kUniform4v, |
| 473 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v | 473 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v |
| 474 }; | 474 }; |
| 475 | 475 |
| 476 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) | 476 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) |
| 477 { | 477 { |
| 478 switch (functionToCall) { | 478 switch (functionToCall) { |
| 479 case kVertexAttrib1v: | 479 case kVertexAttrib1v: |
| 480 case kVertexAttrib2v: | 480 case kVertexAttrib2v: |
| 481 case kVertexAttrib3v: | 481 case kVertexAttrib3v: |
| 482 case kVertexAttrib4v: | 482 case kVertexAttrib4v: |
| 483 return true; | 483 return true; |
| 484 default: | 484 default: |
| 485 break; | 485 break; |
| 486 } | 486 } |
| 487 return false; | 487 return false; |
| 488 } | 488 } |
| 489 | 489 |
| 490 static void vertexAttribAndUniformHelperf(const v8::FunctionCallbackInfo<v8::Val
ue>& args, FunctionToCall functionToCall, const char* method) | 490 static void vertexAttribAndUniformHelperf(const v8::FunctionCallbackInfo<v8::Val
ue>& info, FunctionToCall functionToCall, const char* method) |
| 491 { | 491 { |
| 492 // Forms: | 492 // Forms: |
| 493 // * glUniform1fv(WebGLUniformLocation location, Array data); | 493 // * glUniform1fv(WebGLUniformLocation location, Array data); |
| 494 // * glUniform1fv(WebGLUniformLocation location, Float32Array data); | 494 // * glUniform1fv(WebGLUniformLocation location, Float32Array data); |
| 495 // * glUniform2fv(WebGLUniformLocation location, Array data); | 495 // * glUniform2fv(WebGLUniformLocation location, Array data); |
| 496 // * glUniform2fv(WebGLUniformLocation location, Float32Array data); | 496 // * glUniform2fv(WebGLUniformLocation location, Float32Array data); |
| 497 // * glUniform3fv(WebGLUniformLocation location, Array data); | 497 // * glUniform3fv(WebGLUniformLocation location, Array data); |
| 498 // * glUniform3fv(WebGLUniformLocation location, Float32Array data); | 498 // * glUniform3fv(WebGLUniformLocation location, Float32Array data); |
| 499 // * glUniform4fv(WebGLUniformLocation location, Array data); | 499 // * glUniform4fv(WebGLUniformLocation location, Array data); |
| 500 // * glUniform4fv(WebGLUniformLocation location, Float32Array data); | 500 // * glUniform4fv(WebGLUniformLocation location, Float32Array data); |
| 501 // * glVertexAttrib1fv(GLint index, Array data); | 501 // * glVertexAttrib1fv(GLint index, Array data); |
| 502 // * glVertexAttrib1fv(GLint index, Float32Array data); | 502 // * glVertexAttrib1fv(GLint index, Float32Array data); |
| 503 // * glVertexAttrib2fv(GLint index, Array data); | 503 // * glVertexAttrib2fv(GLint index, Array data); |
| 504 // * glVertexAttrib2fv(GLint index, Float32Array data); | 504 // * glVertexAttrib2fv(GLint index, Float32Array data); |
| 505 // * glVertexAttrib3fv(GLint index, Array data); | 505 // * glVertexAttrib3fv(GLint index, Array data); |
| 506 // * glVertexAttrib3fv(GLint index, Float32Array data); | 506 // * glVertexAttrib3fv(GLint index, Float32Array data); |
| 507 // * glVertexAttrib4fv(GLint index, Array data); | 507 // * glVertexAttrib4fv(GLint index, Array data); |
| 508 // * glVertexAttrib4fv(GLint index, Float32Array data); | 508 // * glVertexAttrib4fv(GLint index, Float32Array data); |
| 509 | 509 |
| 510 if (args.Length() != 2) { | 510 if (info.Length() != 2) { |
| 511 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, args.Length())), args.GetIso
late()); | 511 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIso
late()); |
| 512 return; | 512 return; |
| 513 } | 513 } |
| 514 | 514 |
| 515 bool ok = false; | 515 bool ok = false; |
| 516 int index = -1; | 516 int index = -1; |
| 517 WebGLUniformLocation* location = 0; | 517 WebGLUniformLocation* location = 0; |
| 518 | 518 |
| 519 if (isFunctionToCallForAttribute(functionToCall)) | 519 if (isFunctionToCallForAttribute(functionToCall)) |
| 520 index = toInt32(args[0]); | 520 index = toInt32(info[0]); |
| 521 else { | 521 else { |
| 522 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformL
ocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())))
{ | 522 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLUniformL
ocation::HasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate())))
{ |
| 523 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 523 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 524 return; | 524 return; |
| 525 } | 525 } |
| 526 location = toWebGLUniformLocation(args[0], ok, args.GetIsolate()); | 526 location = toWebGLUniformLocation(info[0], ok, info.GetIsolate()); |
| 527 } | 527 } |
| 528 | 528 |
| 529 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 529 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 530 | 530 |
| 531 if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.G
etIsolate()))) { | 531 if (V8Float32Array::HasInstance(info[1], info.GetIsolate(), worldType(info.G
etIsolate()))) { |
| 532 Float32Array* array = V8Float32Array::toNative(args[1]->ToObject()); | 532 Float32Array* array = V8Float32Array::toNative(info[1]->ToObject()); |
| 533 ASSERT(array != NULL); | 533 ASSERT(array != NULL); |
| 534 switch (functionToCall) { | 534 switch (functionToCall) { |
| 535 case kUniform1v: context->uniform1fv(location, array); break; | 535 case kUniform1v: context->uniform1fv(location, array); break; |
| 536 case kUniform2v: context->uniform2fv(location, array); break; | 536 case kUniform2v: context->uniform2fv(location, array); break; |
| 537 case kUniform3v: context->uniform3fv(location, array); break; | 537 case kUniform3v: context->uniform3fv(location, array); break; |
| 538 case kUniform4v: context->uniform4fv(location, array); break; | 538 case kUniform4v: context->uniform4fv(location, array); break; |
| 539 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; | 539 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; |
| 540 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; | 540 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; |
| 541 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; | 541 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; |
| 542 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; | 542 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; |
| 543 default: ASSERT_NOT_REACHED(); break; | 543 default: ASSERT_NOT_REACHED(); break; |
| 544 } | 544 } |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 if (args[1].IsEmpty() || !args[1]->IsArray()) { | 548 if (info[1].IsEmpty() || !info[1]->IsArray()) { |
| 549 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 549 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 550 return; | 550 return; |
| 551 } | 551 } |
| 552 v8::Handle<v8::Array> array = | 552 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(info[1]); |
| 553 v8::Local<v8::Array>::Cast(args[1]); | |
| 554 uint32_t len = array->Length(); | 553 uint32_t len = array->Length(); |
| 555 float* data = jsArrayToFloatArray(array, len); | 554 float* data = jsArrayToFloatArray(array, len); |
| 556 if (!data) { | 555 if (!data) { |
| 557 // FIXME: consider different / better exception type. | 556 // FIXME: consider different / better exception type. |
| 558 setDOMException(SyntaxError, args.GetIsolate()); | 557 setDOMException(SyntaxError, info.GetIsolate()); |
| 559 return; | 558 return; |
| 560 } | 559 } |
| 561 switch (functionToCall) { | 560 switch (functionToCall) { |
| 562 case kUniform1v: context->uniform1fv(location, data, len); break; | 561 case kUniform1v: context->uniform1fv(location, data, len); break; |
| 563 case kUniform2v: context->uniform2fv(location, data, len); break; | 562 case kUniform2v: context->uniform2fv(location, data, len); break; |
| 564 case kUniform3v: context->uniform3fv(location, data, len); break; | 563 case kUniform3v: context->uniform3fv(location, data, len); break; |
| 565 case kUniform4v: context->uniform4fv(location, data, len); break; | 564 case kUniform4v: context->uniform4fv(location, data, len); break; |
| 566 case kVertexAttrib1v: context->vertexAttrib1fv(index, data, len); break; | 565 case kVertexAttrib1v: context->vertexAttrib1fv(index, data, len); break; |
| 567 case kVertexAttrib2v: context->vertexAttrib2fv(index, data, len); break; | 566 case kVertexAttrib2v: context->vertexAttrib2fv(index, data, len); break; |
| 568 case kVertexAttrib3v: context->vertexAttrib3fv(index, data, len); break; | 567 case kVertexAttrib3v: context->vertexAttrib3fv(index, data, len); break; |
| 569 case kVertexAttrib4v: context->vertexAttrib4fv(index, data, len); break; | 568 case kVertexAttrib4v: context->vertexAttrib4fv(index, data, len); break; |
| 570 default: ASSERT_NOT_REACHED(); break; | 569 default: ASSERT_NOT_REACHED(); break; |
| 571 } | 570 } |
| 572 fastFree(data); | 571 fastFree(data); |
| 573 } | 572 } |
| 574 | 573 |
| 575 static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& args, Func
tionToCall functionToCall, const char* method) | 574 static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& info, Func
tionToCall functionToCall, const char* method) |
| 576 { | 575 { |
| 577 // Forms: | 576 // Forms: |
| 578 // * glUniform1iv(GLUniformLocation location, Array data); | 577 // * glUniform1iv(GLUniformLocation location, Array data); |
| 579 // * glUniform1iv(GLUniformLocation location, Int32Array data); | 578 // * glUniform1iv(GLUniformLocation location, Int32Array data); |
| 580 // * glUniform2iv(GLUniformLocation location, Array data); | 579 // * glUniform2iv(GLUniformLocation location, Array data); |
| 581 // * glUniform2iv(GLUniformLocation location, Int32Array data); | 580 // * glUniform2iv(GLUniformLocation location, Int32Array data); |
| 582 // * glUniform3iv(GLUniformLocation location, Array data); | 581 // * glUniform3iv(GLUniformLocation location, Array data); |
| 583 // * glUniform3iv(GLUniformLocation location, Int32Array data); | 582 // * glUniform3iv(GLUniformLocation location, Int32Array data); |
| 584 // * glUniform4iv(GLUniformLocation location, Array data); | 583 // * glUniform4iv(GLUniformLocation location, Array data); |
| 585 // * glUniform4iv(GLUniformLocation location, Int32Array data); | 584 // * glUniform4iv(GLUniformLocation location, Int32Array data); |
| 586 | 585 |
| 587 if (args.Length() != 2) { | 586 if (info.Length() != 2) { |
| 588 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, args.Length())), args.GetIso
late()); | 587 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIso
late()); |
| 589 return; | 588 return; |
| 590 } | 589 } |
| 591 | 590 |
| 592 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 591 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 593 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat
ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 592 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLUniformLocat
ion::HasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 594 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 593 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 595 return; | 594 return; |
| 596 } | 595 } |
| 597 bool ok = false; | 596 bool ok = false; |
| 598 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); | 597 WebGLUniformLocation* location = toWebGLUniformLocation(info[0], ok, info.Ge
tIsolate()); |
| 599 | 598 |
| 600 if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.Get
Isolate()))) { | 599 if (V8Int32Array::HasInstance(info[1], info.GetIsolate(), worldType(info.Get
Isolate()))) { |
| 601 Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); | 600 Int32Array* array = V8Int32Array::toNative(info[1]->ToObject()); |
| 602 ASSERT(array != NULL); | 601 ASSERT(array != NULL); |
| 603 switch (functionToCall) { | 602 switch (functionToCall) { |
| 604 case kUniform1v: context->uniform1iv(location, array); break; | 603 case kUniform1v: context->uniform1iv(location, array); break; |
| 605 case kUniform2v: context->uniform2iv(location, array); break; | 604 case kUniform2v: context->uniform2iv(location, array); break; |
| 606 case kUniform3v: context->uniform3iv(location, array); break; | 605 case kUniform3v: context->uniform3iv(location, array); break; |
| 607 case kUniform4v: context->uniform4iv(location, array); break; | 606 case kUniform4v: context->uniform4iv(location, array); break; |
| 608 default: ASSERT_NOT_REACHED(); break; | 607 default: ASSERT_NOT_REACHED(); break; |
| 609 } | 608 } |
| 610 return; | 609 return; |
| 611 } | 610 } |
| 612 | 611 |
| 613 if (args[1].IsEmpty() || !args[1]->IsArray()) { | 612 if (info[1].IsEmpty() || !info[1]->IsArray()) { |
| 614 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 613 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 615 return; | 614 return; |
| 616 } | 615 } |
| 617 v8::Handle<v8::Array> array = | 616 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(info[1]); |
| 618 v8::Local<v8::Array>::Cast(args[1]); | |
| 619 uint32_t len = array->Length(); | 617 uint32_t len = array->Length(); |
| 620 int* data = jsArrayToIntArray(array, len); | 618 int* data = jsArrayToIntArray(array, len); |
| 621 if (!data) { | 619 if (!data) { |
| 622 // FIXME: consider different / better exception type. | 620 // FIXME: consider different / better exception type. |
| 623 setDOMException(SyntaxError, args.GetIsolate()); | 621 setDOMException(SyntaxError, info.GetIsolate()); |
| 624 return; | 622 return; |
| 625 } | 623 } |
| 626 switch (functionToCall) { | 624 switch (functionToCall) { |
| 627 case kUniform1v: context->uniform1iv(location, data, len); break; | 625 case kUniform1v: context->uniform1iv(location, data, len); break; |
| 628 case kUniform2v: context->uniform2iv(location, data, len); break; | 626 case kUniform2v: context->uniform2iv(location, data, len); break; |
| 629 case kUniform3v: context->uniform3iv(location, data, len); break; | 627 case kUniform3v: context->uniform3iv(location, data, len); break; |
| 630 case kUniform4v: context->uniform4iv(location, data, len); break; | 628 case kUniform4v: context->uniform4iv(location, data, len); break; |
| 631 default: ASSERT_NOT_REACHED(); break; | 629 default: ASSERT_NOT_REACHED(); break; |
| 632 } | 630 } |
| 633 fastFree(data); | 631 fastFree(data); |
| 634 } | 632 } |
| 635 | 633 |
| 636 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 634 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 637 { | 635 { |
| 638 vertexAttribAndUniformHelperf(args, kUniform1v, "uniform1fv"); | 636 vertexAttribAndUniformHelperf(info, kUniform1v, "uniform1fv"); |
| 639 } | 637 } |
| 640 | 638 |
| 641 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 639 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 642 { | 640 { |
| 643 uniformHelperi(args, kUniform1v, "uniform1iv"); | 641 uniformHelperi(info, kUniform1v, "uniform1iv"); |
| 644 } | 642 } |
| 645 | 643 |
| 646 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 644 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 647 { | 645 { |
| 648 vertexAttribAndUniformHelperf(args, kUniform2v, "uniform2fv"); | 646 vertexAttribAndUniformHelperf(info, kUniform2v, "uniform2fv"); |
| 649 } | 647 } |
| 650 | 648 |
| 651 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 649 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 652 { | 650 { |
| 653 uniformHelperi(args, kUniform2v, "uniform2iv"); | 651 uniformHelperi(info, kUniform2v, "uniform2iv"); |
| 654 } | 652 } |
| 655 | 653 |
| 656 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 654 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 657 { | 655 { |
| 658 vertexAttribAndUniformHelperf(args, kUniform3v, "uniform3fv"); | 656 vertexAttribAndUniformHelperf(info, kUniform3v, "uniform3fv"); |
| 659 } | 657 } |
| 660 | 658 |
| 661 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 659 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 662 { | 660 { |
| 663 uniformHelperi(args, kUniform3v, "uniform3iv"); | 661 uniformHelperi(info, kUniform3v, "uniform3iv"); |
| 664 } | 662 } |
| 665 | 663 |
| 666 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 664 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 667 { | 665 { |
| 668 vertexAttribAndUniformHelperf(args, kUniform4v, "uniform4fv"); | 666 vertexAttribAndUniformHelperf(info, kUniform4v, "uniform4fv"); |
| 669 } | 667 } |
| 670 | 668 |
| 671 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 669 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 672 { | 670 { |
| 673 uniformHelperi(args, kUniform4v, "uniform4iv"); | 671 uniformHelperi(info, kUniform4v, "uniform4iv"); |
| 674 } | 672 } |
| 675 | 673 |
| 676 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
int matrixSize, const char* method) | 674 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& info,
int matrixSize, const char* method) |
| 677 { | 675 { |
| 678 // Forms: | 676 // Forms: |
| 679 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); | 677 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); |
| 680 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da
ta); | 678 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 681 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); | 679 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); |
| 682 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da
ta); | 680 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 683 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); | 681 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); |
| 684 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da
ta); | 682 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 685 // | 683 // |
| 686 // FIXME: need to change to accept Float32Array as well. | 684 // FIXME: need to change to accept Float32Array as well. |
| 687 if (args.Length() != 3) { | 685 if (info.Length() != 3) { |
| 688 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, args.Length())), args.GetIso
late()); | 686 throwTypeError(ExceptionMessages::failedToExecute(method, "WebGLRenderin
gContext", ExceptionMessages::notEnoughArguments(2, info.Length())), info.GetIso
late()); |
| 689 return; | 687 return; |
| 690 } | 688 } |
| 691 | 689 |
| 692 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 690 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 693 | 691 |
| 694 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat
ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 692 if (info.Length() > 0 && !isUndefinedOrNull(info[0]) && !V8WebGLUniformLocat
ion::HasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { |
| 695 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 693 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 696 return; | 694 return; |
| 697 } | 695 } |
| 698 bool ok = false; | 696 bool ok = false; |
| 699 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); | 697 WebGLUniformLocation* location = toWebGLUniformLocation(info[0], ok, info.Ge
tIsolate()); |
| 700 | 698 |
| 701 bool transpose = args[1]->BooleanValue(); | 699 bool transpose = info[1]->BooleanValue(); |
| 702 if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.G
etIsolate()))) { | 700 if (V8Float32Array::HasInstance(info[2], info.GetIsolate(), worldType(info.G
etIsolate()))) { |
| 703 Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); | 701 Float32Array* array = V8Float32Array::toNative(info[2]->ToObject()); |
| 704 ASSERT(array != NULL); | 702 ASSERT(array != NULL); |
| 705 switch (matrixSize) { | 703 switch (matrixSize) { |
| 706 case 2: context->uniformMatrix2fv(location, transpose, array); break; | 704 case 2: context->uniformMatrix2fv(location, transpose, array); break; |
| 707 case 3: context->uniformMatrix3fv(location, transpose, array); break; | 705 case 3: context->uniformMatrix3fv(location, transpose, array); break; |
| 708 case 4: context->uniformMatrix4fv(location, transpose, array); break; | 706 case 4: context->uniformMatrix4fv(location, transpose, array); break; |
| 709 default: ASSERT_NOT_REACHED(); break; | 707 default: ASSERT_NOT_REACHED(); break; |
| 710 } | 708 } |
| 711 return; | 709 return; |
| 712 } | 710 } |
| 713 | 711 |
| 714 if (args[2].IsEmpty() || !args[2]->IsArray()) { | 712 if (info[2].IsEmpty() || !info[2]->IsArray()) { |
| 715 throwUninformativeAndGenericTypeError(args.GetIsolate()); | 713 throwUninformativeAndGenericTypeError(info.GetIsolate()); |
| 716 return; | 714 return; |
| 717 } | 715 } |
| 718 v8::Handle<v8::Array> array = | 716 v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(info[2]); |
| 719 v8::Local<v8::Array>::Cast(args[2]); | |
| 720 uint32_t len = array->Length(); | 717 uint32_t len = array->Length(); |
| 721 float* data = jsArrayToFloatArray(array, len); | 718 float* data = jsArrayToFloatArray(array, len); |
| 722 if (!data) { | 719 if (!data) { |
| 723 // FIXME: consider different / better exception type. | 720 // FIXME: consider different / better exception type. |
| 724 setDOMException(SyntaxError, args.GetIsolate()); | 721 setDOMException(SyntaxError, info.GetIsolate()); |
| 725 return; | 722 return; |
| 726 } | 723 } |
| 727 switch (matrixSize) { | 724 switch (matrixSize) { |
| 728 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; | 725 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; |
| 729 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; | 726 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; |
| 730 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; | 727 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; |
| 731 default: ASSERT_NOT_REACHED(); break; | 728 default: ASSERT_NOT_REACHED(); break; |
| 732 } | 729 } |
| 733 fastFree(data); | 730 fastFree(data); |
| 734 } | 731 } |
| 735 | 732 |
| 736 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 733 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 737 { | 734 { |
| 738 uniformMatrixHelper(args, 2, "uniformMatrix2fv"); | 735 uniformMatrixHelper(info, 2, "uniformMatrix2fv"); |
| 739 } | 736 } |
| 740 | 737 |
| 741 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 738 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 742 { | 739 { |
| 743 uniformMatrixHelper(args, 3, "uniformMatrix3fv"); | 740 uniformMatrixHelper(info, 3, "uniformMatrix3fv"); |
| 744 } | 741 } |
| 745 | 742 |
| 746 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 743 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 747 { | 744 { |
| 748 uniformMatrixHelper(args, 4, "uniformMatrix4fv"); | 745 uniformMatrixHelper(info, 4, "uniformMatrix4fv"); |
| 749 } | 746 } |
| 750 | 747 |
| 751 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 748 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 752 { | 749 { |
| 753 vertexAttribAndUniformHelperf(args, kVertexAttrib1v, "vertexAttrib1fv"); | 750 vertexAttribAndUniformHelperf(info, kVertexAttrib1v, "vertexAttrib1fv"); |
| 754 } | 751 } |
| 755 | 752 |
| 756 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 753 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 757 { | 754 { |
| 758 vertexAttribAndUniformHelperf(args, kVertexAttrib2v, "vertexAttrib2fv"); | 755 vertexAttribAndUniformHelperf(info, kVertexAttrib2v, "vertexAttrib2fv"); |
| 759 } | 756 } |
| 760 | 757 |
| 761 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 758 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 762 { | 759 { |
| 763 vertexAttribAndUniformHelperf(args, kVertexAttrib3v, "vertexAttrib3fv"); | 760 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, "vertexAttrib3fv"); |
| 764 } | 761 } |
| 765 | 762 |
| 766 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 763 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 767 { | 764 { |
| 768 vertexAttribAndUniformHelperf(args, kVertexAttrib4v, "vertexAttrib4fv"); | 765 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, "vertexAttrib4fv"); |
| 769 } | 766 } |
| 770 | 767 |
| 771 } // namespace WebCore | 768 } // namespace WebCore |
| OLD | NEW |