| 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 11 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 kBuffer, kRenderbuffer, kTexture, kVertexAttrib | 259 kBuffer, kRenderbuffer, kTexture, kVertexAttrib |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args,
ObjectType objectType) | 262 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args,
ObjectType objectType) |
| 263 { | 263 { |
| 264 if (args.Length() != 2) { | 264 if (args.Length() != 2) { |
| 265 throwNotEnoughArgumentsError(args.GetIsolate()); | 265 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 | 268 |
| 269 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 269 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a
rgs.Holder()); |
| 270 unsigned target = toInt32(args[0]); | 270 unsigned target = toInt32(args[0]); |
| 271 unsigned pname = toInt32(args[1]); | 271 unsigned pname = toInt32(args[1]); |
| 272 WebGLGetInfo info; | 272 WebGLGetInfo info; |
| 273 switch (objectType) { | 273 switch (objectType) { |
| 274 case kBuffer: | 274 case kBuffer: |
| 275 info = context->getBufferParameter(target, pname); | 275 info = context->getBufferParameter(target, pname); |
| 276 break; | 276 break; |
| 277 case kRenderbuffer: | 277 case kRenderbuffer: |
| 278 info = context->getRenderbufferParameter(target, pname); | 278 info = context->getRenderbufferParameter(target, pname); |
| 279 break; | 279 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 299 location = V8WebGLUniformLocation::toNative(value->ToObject()); | 299 location = V8WebGLUniformLocation::toNative(value->ToObject()); |
| 300 ok = true; | 300 ok = true; |
| 301 } | 301 } |
| 302 return location; | 302 return location; |
| 303 } | 303 } |
| 304 | 304 |
| 305 enum WhichProgramCall { | 305 enum WhichProgramCall { |
| 306 kProgramParameter, kUniform | 306 kProgramParameter, kUniform |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 309 void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& args) |
| 310 { | 310 { |
| 311 if (args.Length() < 1) { | 311 if (args.Length() < 1) { |
| 312 throwNotEnoughArgumentsError(args.GetIsolate()); | 312 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 | 315 |
| 316 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 316 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()))) { | 317 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 318 throwTypeError(args.GetIsolate()); | 318 throwTypeError(args.GetIsolate()); |
| 319 return; | 319 return; |
| 320 } | 320 } |
| 321 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 321 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; | 322 Vector<RefPtr<WebGLShader> > shaders; |
| 323 bool succeed = context->getAttachedShaders(program, shaders); | 323 bool succeed = context->getAttachedShaders(program, shaders); |
| 324 if (!succeed) { | 324 if (!succeed) { |
| 325 v8SetReturnValueNull(args); | 325 v8SetReturnValueNull(args); |
| 326 return; | 326 return; |
| 327 } | 327 } |
| 328 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); | 328 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); |
| 329 for (size_t ii = 0; ii < shaders.size(); ++ii) | 329 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())); | 330 array->Set(v8::Integer::New(ii, args.GetIsolate()), toV8(shaders[ii].get
(), args.Holder(), args.GetIsolate())); |
| 331 v8SetReturnValue(args, array); | 331 v8SetReturnValue(args, array); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 334 void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& args) |
| 335 { | 335 { |
| 336 getObjectParameter(args, kBuffer); | 336 getObjectParameter(args, kBuffer); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 339 void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) |
| 340 { | 340 { |
| 341 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder()
); | 341 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args.
Holder()); |
| 342 if (args.Length() < 1) { | 342 if (args.Length() < 1) { |
| 343 throwNotEnoughArgumentsError(args.GetIsolate()); | 343 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]); | 346 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, args[0]); |
| 347 RefPtr<WebGLExtension> extension(imp->getExtension(name)); | 347 RefPtr<WebGLExtension> extension(imp->getExtension(name)); |
| 348 v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIs
olate())); | 348 v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIs
olate())); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons
t v8::FunctionCallbackInfo<v8::Value>& args) | 351 void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom(
const v8::FunctionCallbackInfo<v8::Value>& args) |
| 352 { | 352 { |
| 353 if (args.Length() != 3) { | 353 if (args.Length() != 3) { |
| 354 throwNotEnoughArgumentsError(args.GetIsolate()); | 354 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 355 return; | 355 return; |
| 356 } | 356 } |
| 357 | 357 |
| 358 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 358 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a
rgs.Holder()); |
| 359 unsigned target = toInt32(args[0]); | 359 unsigned target = toInt32(args[0]); |
| 360 unsigned attachment = toInt32(args[1]); | 360 unsigned attachment = toInt32(args[1]); |
| 361 unsigned pname = toInt32(args[2]); | 361 unsigned pname = toInt32(args[2]); |
| 362 WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attac
hment, pname); | 362 WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attac
hment, pname); |
| 363 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 363 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& args) | 366 void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) |
| 367 { | 367 { |
| 368 if (args.Length() != 1) { | 368 if (args.Length() != 1) { |
| 369 throwNotEnoughArgumentsError(args.GetIsolate()); | 369 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 | 372 |
| 373 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 373 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a
rgs.Holder()); |
| 374 unsigned pname = toInt32(args[0]); | 374 unsigned pname = toInt32(args[0]); |
| 375 WebGLGetInfo info = context->getParameter(pname); | 375 WebGLGetInfo info = context->getParameter(pname); |
| 376 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 376 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) | 379 void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::Func
tionCallbackInfo<v8::Value>& args) |
| 380 { | 380 { |
| 381 if (args.Length() != 2) { | 381 if (args.Length() != 2) { |
| 382 throwNotEnoughArgumentsError(args.GetIsolate()); | 382 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 | 385 |
| 386 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 386 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()))) { | 387 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 388 throwTypeError(args.GetIsolate()); | 388 throwTypeError(args.GetIsolate()); |
| 389 return; | 389 return; |
| 390 } | 390 } |
| 391 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 391 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]); | 392 unsigned pname = toInt32(args[1]); |
| 393 WebGLGetInfo info = context->getProgramParameter(program, pname); | 393 WebGLGetInfo info = context->getProgramParameter(program, pname); |
| 394 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 394 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun
ctionCallbackInfo<v8::Value>& args) | 397 void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8:
:FunctionCallbackInfo<v8::Value>& args) |
| 398 { | 398 { |
| 399 getObjectParameter(args, kRenderbuffer); | 399 getObjectParameter(args, kRenderbuffer); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& args) | 402 void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& args) |
| 403 { | 403 { |
| 404 if (args.Length() != 2) { | 404 if (args.Length() != 2) { |
| 405 throwNotEnoughArgumentsError(args.GetIsolate()); | 405 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 | 408 |
| 409 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 409 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()))) { | 410 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasI
nstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 411 throwTypeError(args.GetIsolate()); | 411 throwTypeError(args.GetIsolate()); |
| 412 return; | 412 return; |
| 413 } | 413 } |
| 414 WebGLShader* shader = V8WebGLShader::HasInstance(args[0], args.GetIsolate(),
worldType(args.GetIsolate())) ? V8WebGLShader::toNative(v8::Handle<v8::Object>:
:Cast(args[0])) : 0; | 414 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]); | 415 unsigned pname = toInt32(args[1]); |
| 416 WebGLGetInfo info = context->getShaderParameter(shader, pname); | 416 WebGLGetInfo info = context->getShaderParameter(shader, pname); |
| 417 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 417 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& args) | 420 void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::F
unctionCallbackInfo<v8::Value>& args) |
| 421 { | 421 { |
| 422 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder()
); | 422 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args.
Holder()); |
| 423 if (imp->isContextLost()) { | 423 if (imp->isContextLost()) { |
| 424 v8SetReturnValueNull(args); | 424 v8SetReturnValueNull(args); |
| 425 return; | 425 return; |
| 426 } | 426 } |
| 427 | 427 |
| 428 Vector<String> value = imp->getSupportedExtensions(); | 428 Vector<String> value = imp->getSupportedExtensions(); |
| 429 v8::Local<v8::Array> array = v8::Array::New(value.size()); | 429 v8::Local<v8::Array> array = v8::Array::New(value.size()); |
| 430 for (size_t ii = 0; ii < value.size(); ++ii) | 430 for (size_t ii = 0; ii < value.size(); ++ii) |
| 431 array->Set(v8::Integer::New(ii, args.GetIsolate()), v8String(value[ii],
args.GetIsolate())); | 431 array->Set(v8::Integer::New(ii, args.GetIsolate()), v8String(value[ii],
args.GetIsolate())); |
| 432 v8SetReturnValue(args, array); | 432 v8SetReturnValue(args, array); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 435 void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 436 { | 436 { |
| 437 getObjectParameter(args, kTexture); | 437 getObjectParameter(args, kTexture); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 440 void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 441 { | 441 { |
| 442 if (args.Length() != 2) { | 442 if (args.Length() != 2) { |
| 443 throwNotEnoughArgumentsError(args.GetIsolate()); | 443 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 | 446 |
| 447 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 447 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()))) { | 448 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::Has
Instance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 449 throwTypeError(args.GetIsolate()); | 449 throwTypeError(args.GetIsolate()); |
| 450 return; | 450 return; |
| 451 } | 451 } |
| 452 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; | 452 WebGLProgram* program = V8WebGLProgram::HasInstance(args[0], args.GetIsolate
(), worldType(args.GetIsolate())) ? V8WebGLProgram::toNative(v8::Handle<v8::Obje
ct>::Cast(args[0])) : 0; |
| 453 | 453 |
| 454 if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocat
ion::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) { | 454 if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocat
ion::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 455 throwTypeError(args.GetIsolate()); | 455 throwTypeError(args.GetIsolate()); |
| 456 return; | 456 return; |
| 457 } | 457 } |
| 458 bool ok = false; | 458 bool ok = false; |
| 459 WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok, args.Ge
tIsolate()); | 459 WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok, args.Ge
tIsolate()); |
| 460 | 460 |
| 461 WebGLGetInfo info = context->getUniform(program, location); | 461 WebGLGetInfo info = context->getUniform(program, location); |
| 462 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); | 462 v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate())); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 465 void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 466 { | 466 { |
| 467 getObjectParameter(args, kVertexAttrib); | 467 getObjectParameter(args, kVertexAttrib); |
| 468 } | 468 } |
| 469 | 469 |
| 470 enum FunctionToCall { | 470 enum FunctionToCall { |
| 471 kUniform1v, kUniform2v, kUniform3v, kUniform4v, | 471 kUniform1v, kUniform2v, kUniform3v, kUniform4v, |
| 472 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v | 472 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v |
| 473 }; | 473 }; |
| 474 | 474 |
| 475 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) | 475 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 508 |
| 509 if (args.Length() != 2) { | 509 if (args.Length() != 2) { |
| 510 throwNotEnoughArgumentsError(args.GetIsolate()); | 510 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 511 return; | 511 return; |
| 512 } | 512 } |
| 513 | 513 |
| 514 bool ok = false; | 514 bool ok = false; |
| 515 int index = -1; | 515 int index = -1; |
| 516 WebGLUniformLocation* location = 0; | 516 WebGLUniformLocation* location = 0; |
| 517 | 517 |
| 518 if (isFunctionToCallForAttribute(functionToCall)) | 518 if (isFunctionToCallForAttribute(functionToCall)) { |
| 519 index = toInt32(args[0]); | 519 index = toInt32(args[0]); |
| 520 else { | 520 } else { |
| 521 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformL
ocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())))
{ | 521 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformL
ocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())))
{ |
| 522 throwTypeError(args.GetIsolate()); | 522 throwTypeError(args.GetIsolate()); |
| 523 return; | 523 return; |
| 524 } | 524 } |
| 525 location = toWebGLUniformLocation(args[0], ok, args.GetIsolate()); | 525 location = toWebGLUniformLocation(args[0], ok, args.GetIsolate()); |
| 526 } | 526 } |
| 527 | 527 |
| 528 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 528 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a
rgs.Holder()); |
| 529 | 529 |
| 530 if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.G
etIsolate()))) { | 530 if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.G
etIsolate()))) { |
| 531 Float32Array* array = V8Float32Array::toNative(args[1]->ToObject()); | 531 Float32Array* array = V8Float32Array::toNative(args[1]->ToObject()); |
| 532 ASSERT(array != NULL); | 532 ASSERT(array); |
| 533 switch (functionToCall) { | 533 switch (functionToCall) { |
| 534 case kUniform1v: context->uniform1fv(location, array); break; | 534 case kUniform1v: context->uniform1fv(location, array); break; |
| 535 case kUniform2v: context->uniform2fv(location, array); break; | 535 case kUniform2v: context->uniform2fv(location, array); break; |
| 536 case kUniform3v: context->uniform3fv(location, array); break; | 536 case kUniform3v: context->uniform3fv(location, array); break; |
| 537 case kUniform4v: context->uniform4fv(location, array); break; | 537 case kUniform4v: context->uniform4fv(location, array); break; |
| 538 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; | 538 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; |
| 539 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; | 539 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; |
| 540 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; | 540 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; |
| 541 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; | 541 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; |
| 542 default: ASSERT_NOT_REACHED(); break; | 542 default: ASSERT_NOT_REACHED(); break; |
| 543 } | 543 } |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 if (args[1].IsEmpty() || !args[1]->IsArray()) { | 547 if (args[1].IsEmpty() || !args[1]->IsArray()) { |
| 548 throwTypeError(args.GetIsolate()); | 548 throwTypeError(args.GetIsolate()); |
| 549 return; | 549 return; |
| 550 } | 550 } |
| 551 v8::Handle<v8::Array> array = | 551 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(); | 552 uint32_t len = array->Length(); |
| 554 float* data = jsArrayToFloatArray(array, len); | 553 float* data = jsArrayToFloatArray(array, len); |
| 555 if (!data) { | 554 if (!data) { |
| 556 // FIXME: consider different / better exception type. | 555 // FIXME: consider different / better exception type. |
| 557 setDOMException(SyntaxError, args.GetIsolate()); | 556 setDOMException(SyntaxError, args.GetIsolate()); |
| 558 return; | 557 return; |
| 559 } | 558 } |
| 560 switch (functionToCall) { | 559 switch (functionToCall) { |
| 561 case kUniform1v: context->uniform1fv(location, data, len); break; | 560 case kUniform1v: context->uniform1fv(location, data, len); break; |
| 562 case kUniform2v: context->uniform2fv(location, data, len); break; | 561 case kUniform2v: context->uniform2fv(location, data, len); break; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 581 // * glUniform3iv(GLUniformLocation location, Array data); | 580 // * glUniform3iv(GLUniformLocation location, Array data); |
| 582 // * glUniform3iv(GLUniformLocation location, Int32Array data); | 581 // * glUniform3iv(GLUniformLocation location, Int32Array data); |
| 583 // * glUniform4iv(GLUniformLocation location, Array data); | 582 // * glUniform4iv(GLUniformLocation location, Array data); |
| 584 // * glUniform4iv(GLUniformLocation location, Int32Array data); | 583 // * glUniform4iv(GLUniformLocation location, Int32Array data); |
| 585 | 584 |
| 586 if (args.Length() != 2) { | 585 if (args.Length() != 2) { |
| 587 throwNotEnoughArgumentsError(args.GetIsolate()); | 586 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 588 return; | 587 return; |
| 589 } | 588 } |
| 590 | 589 |
| 591 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 590 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()))) { | 591 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat
ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 593 throwTypeError(args.GetIsolate()); | 592 throwTypeError(args.GetIsolate()); |
| 594 return; | 593 return; |
| 595 } | 594 } |
| 596 bool ok = false; | 595 bool ok = false; |
| 597 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); | 596 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); |
| 598 | 597 |
| 599 if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.Get
Isolate()))) { | 598 if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.Get
Isolate()))) { |
| 600 Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); | 599 Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); |
| 601 ASSERT(array != NULL); | 600 ASSERT(array); |
| 602 switch (functionToCall) { | 601 switch (functionToCall) { |
| 603 case kUniform1v: context->uniform1iv(location, array); break; | 602 case kUniform1v: context->uniform1iv(location, array); break; |
| 604 case kUniform2v: context->uniform2iv(location, array); break; | 603 case kUniform2v: context->uniform2iv(location, array); break; |
| 605 case kUniform3v: context->uniform3iv(location, array); break; | 604 case kUniform3v: context->uniform3iv(location, array); break; |
| 606 case kUniform4v: context->uniform4iv(location, array); break; | 605 case kUniform4v: context->uniform4iv(location, array); break; |
| 607 default: ASSERT_NOT_REACHED(); break; | 606 default: ASSERT_NOT_REACHED(); break; |
| 608 } | 607 } |
| 609 return; | 608 return; |
| 610 } | 609 } |
| 611 | 610 |
| 612 if (args[1].IsEmpty() || !args[1]->IsArray()) { | 611 if (args[1].IsEmpty() || !args[1]->IsArray()) { |
| 613 throwTypeError(args.GetIsolate()); | 612 throwTypeError(args.GetIsolate()); |
| 614 return; | 613 return; |
| 615 } | 614 } |
| 616 v8::Handle<v8::Array> array = | 615 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(); | 616 uint32_t len = array->Length(); |
| 619 int* data = jsArrayToIntArray(array, len); | 617 int* data = jsArrayToIntArray(array, len); |
| 620 if (!data) { | 618 if (!data) { |
| 621 // FIXME: consider different / better exception type. | 619 // FIXME: consider different / better exception type. |
| 622 setDOMException(SyntaxError, args.GetIsolate()); | 620 setDOMException(SyntaxError, args.GetIsolate()); |
| 623 return; | 621 return; |
| 624 } | 622 } |
| 625 switch (functionToCall) { | 623 switch (functionToCall) { |
| 626 case kUniform1v: context->uniform1iv(location, data, len); break; | 624 case kUniform1v: context->uniform1iv(location, data, len); break; |
| 627 case kUniform2v: context->uniform2iv(location, data, len); break; | 625 case kUniform2v: context->uniform2iv(location, data, len); break; |
| 628 case kUniform3v: context->uniform3iv(location, data, len); break; | 626 case kUniform3v: context->uniform3iv(location, data, len); break; |
| 629 case kUniform4v: context->uniform4iv(location, data, len); break; | 627 case kUniform4v: context->uniform4iv(location, data, len); break; |
| 630 default: ASSERT_NOT_REACHED(); break; | 628 default: ASSERT_NOT_REACHED(); break; |
| 631 } | 629 } |
| 632 fastFree(data); | 630 fastFree(data); |
| 633 } | 631 } |
| 634 | 632 |
| 635 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 633 void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 636 { | 634 { |
| 637 vertexAttribAndUniformHelperf(args, kUniform1v); | 635 vertexAttribAndUniformHelperf(args, kUniform1v); |
| 638 } | 636 } |
| 639 | 637 |
| 640 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 638 void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 641 { | 639 { |
| 642 uniformHelperi(args, kUniform1v); | 640 uniformHelperi(args, kUniform1v); |
| 643 } | 641 } |
| 644 | 642 |
| 645 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 643 void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 646 { | 644 { |
| 647 vertexAttribAndUniformHelperf(args, kUniform2v); | 645 vertexAttribAndUniformHelperf(args, kUniform2v); |
| 648 } | 646 } |
| 649 | 647 |
| 650 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 648 void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 651 { | 649 { |
| 652 uniformHelperi(args, kUniform2v); | 650 uniformHelperi(args, kUniform2v); |
| 653 } | 651 } |
| 654 | 652 |
| 655 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 653 void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 656 { | 654 { |
| 657 vertexAttribAndUniformHelperf(args, kUniform3v); | 655 vertexAttribAndUniformHelperf(args, kUniform3v); |
| 658 } | 656 } |
| 659 | 657 |
| 660 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 658 void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 661 { | 659 { |
| 662 uniformHelperi(args, kUniform3v); | 660 uniformHelperi(args, kUniform3v); |
| 663 } | 661 } |
| 664 | 662 |
| 665 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 663 void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 666 { | 664 { |
| 667 vertexAttribAndUniformHelperf(args, kUniform4v); | 665 vertexAttribAndUniformHelperf(args, kUniform4v); |
| 668 } | 666 } |
| 669 | 667 |
| 670 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI
nfo<v8::Value>& args) | 668 void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallb
ackInfo<v8::Value>& args) |
| 671 { | 669 { |
| 672 uniformHelperi(args, kUniform4v); | 670 uniformHelperi(args, kUniform4v); |
| 673 } | 671 } |
| 674 | 672 |
| 675 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
int matrixSize) | 673 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
int matrixSize) |
| 676 { | 674 { |
| 677 // Forms: | 675 // Forms: |
| 678 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); | 676 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); |
| 679 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da
ta); | 677 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 680 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); | 678 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); |
| 681 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da
ta); | 679 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 682 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); | 680 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); |
| 683 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da
ta); | 681 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da
ta); |
| 684 // | 682 // |
| 685 // FIXME: need to change to accept Float32Array as well. | 683 // FIXME: need to change to accept Float32Array as well. |
| 686 if (args.Length() != 3) { | 684 if (args.Length() != 3) { |
| 687 throwNotEnoughArgumentsError(args.GetIsolate()); | 685 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 688 return; | 686 return; |
| 689 } | 687 } |
| 690 | 688 |
| 691 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Hold
er()); | 689 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(a
rgs.Holder()); |
| 692 | 690 |
| 693 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat
ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { | 691 if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocat
ion::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { |
| 694 throwTypeError(args.GetIsolate()); | 692 throwTypeError(args.GetIsolate()); |
| 695 return; | 693 return; |
| 696 } | 694 } |
| 697 bool ok = false; | 695 bool ok = false; |
| 698 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); | 696 WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok, args.Ge
tIsolate()); |
| 699 | 697 |
| 700 bool transpose = args[1]->BooleanValue(); | 698 bool transpose = args[1]->BooleanValue(); |
| 701 if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.G
etIsolate()))) { | 699 if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.G
etIsolate()))) { |
| 702 Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); | 700 Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); |
| 703 ASSERT(array != NULL); | 701 ASSERT(array); |
| 704 switch (matrixSize) { | 702 switch (matrixSize) { |
| 705 case 2: context->uniformMatrix2fv(location, transpose, array); break; | 703 case 2: context->uniformMatrix2fv(location, transpose, array); break; |
| 706 case 3: context->uniformMatrix3fv(location, transpose, array); break; | 704 case 3: context->uniformMatrix3fv(location, transpose, array); break; |
| 707 case 4: context->uniformMatrix4fv(location, transpose, array); break; | 705 case 4: context->uniformMatrix4fv(location, transpose, array); break; |
| 708 default: ASSERT_NOT_REACHED(); break; | 706 default: ASSERT_NOT_REACHED(); break; |
| 709 } | 707 } |
| 710 return; | 708 return; |
| 711 } | 709 } |
| 712 | 710 |
| 713 if (args[2].IsEmpty() || !args[2]->IsArray()) { | 711 if (args[2].IsEmpty() || !args[2]->IsArray()) { |
| 714 throwTypeError(args.GetIsolate()); | 712 throwTypeError(args.GetIsolate()); |
| 715 return; | 713 return; |
| 716 } | 714 } |
| 717 v8::Handle<v8::Array> array = | 715 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(); | 716 uint32_t len = array->Length(); |
| 720 float* data = jsArrayToFloatArray(array, len); | 717 float* data = jsArrayToFloatArray(array, len); |
| 721 if (!data) { | 718 if (!data) { |
| 722 // FIXME: consider different / better exception type. | 719 // FIXME: consider different / better exception type. |
| 723 setDOMException(SyntaxError, args.GetIsolate()); | 720 setDOMException(SyntaxError, args.GetIsolate()); |
| 724 return; | 721 return; |
| 725 } | 722 } |
| 726 switch (matrixSize) { | 723 switch (matrixSize) { |
| 727 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; | 724 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; |
| 728 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; | 725 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; |
| 729 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; | 726 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; |
| 730 default: ASSERT_NOT_REACHED(); break; | 727 default: ASSERT_NOT_REACHED(); break; |
| 731 } | 728 } |
| 732 fastFree(data); | 729 fastFree(data); |
| 733 } | 730 } |
| 734 | 731 |
| 735 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 732 void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::Functio
nCallbackInfo<v8::Value>& args) |
| 736 { | 733 { |
| 737 uniformMatrixHelper(args, 2); | 734 uniformMatrixHelper(args, 2); |
| 738 } | 735 } |
| 739 | 736 |
| 740 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 737 void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::Functio
nCallbackInfo<v8::Value>& args) |
| 741 { | 738 { |
| 742 uniformMatrixHelper(args, 3); | 739 uniformMatrixHelper(args, 3); |
| 743 } | 740 } |
| 744 | 741 |
| 745 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal
lbackInfo<v8::Value>& args) | 742 void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::Functio
nCallbackInfo<v8::Value>& args) |
| 746 { | 743 { |
| 747 uniformMatrixHelper(args, 4); | 744 uniformMatrixHelper(args, 4); |
| 748 } | 745 } |
| 749 | 746 |
| 750 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 747 void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 751 { | 748 { |
| 752 vertexAttribAndUniformHelperf(args, kVertexAttrib1v); | 749 vertexAttribAndUniformHelperf(args, kVertexAttrib1v); |
| 753 } | 750 } |
| 754 | 751 |
| 755 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 752 void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 756 { | 753 { |
| 757 vertexAttribAndUniformHelperf(args, kVertexAttrib2v); | 754 vertexAttribAndUniformHelperf(args, kVertexAttrib2v); |
| 758 } | 755 } |
| 759 | 756 |
| 760 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 757 void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 761 { | 758 { |
| 762 vertexAttribAndUniformHelperf(args, kVertexAttrib3v); | 759 vertexAttribAndUniformHelperf(args, kVertexAttrib3v); |
| 763 } | 760 } |
| 764 | 761 |
| 765 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& args) | 762 void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::Function
CallbackInfo<v8::Value>& args) |
| 766 { | 763 { |
| 767 vertexAttribAndUniformHelperf(args, kVertexAttrib4v); | 764 vertexAttribAndUniformHelperf(args, kVertexAttrib4v); |
| 768 } | 765 } |
| 769 | 766 |
| 770 } // namespace WebCore | 767 } // namespace WebCore |
| OLD | NEW |