| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 break; | 296 break; |
| 297 default: | 297 default: |
| 298 notImplemented(); | 298 notImplemented(); |
| 299 break; | 299 break; |
| 300 } | 300 } |
| 301 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); | 301 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 302 } | 302 } |
| 303 | 303 |
| 304 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
v8::Isolate* isolate) | 304 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
v8::Isolate* isolate) |
| 305 { | 305 { |
| 306 if (!V8WebGLUniformLocation::hasInstance(value, isolate)) | 306 return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value); |
| 307 return 0; | |
| 308 return V8WebGLUniformLocation::toNative(value->ToObject()); | |
| 309 } | 307 } |
| 310 | 308 |
| 311 enum WhichProgramCall { | 309 enum WhichProgramCall { |
| 312 kProgramParameter, kUniform | 310 kProgramParameter, kUniform |
| 313 }; | 311 }; |
| 314 | 312 |
| 315 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) | 313 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 316 { | 314 { |
| 317 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached
Shaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 315 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached
Shaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
| 318 if (info.Length() < 1) { | 316 if (info.Length() < 1) { |
| 319 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 317 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 320 exceptionState.throwIfNeeded(); | 318 exceptionState.throwIfNeeded(); |
| 321 return; | 319 return; |
| 322 } | 320 } |
| 323 | 321 |
| 324 const int programArgumentIndex = 0; | 322 const int programArgumentIndex = 0; |
| 325 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); | 323 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 326 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { | 324 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { |
| 327 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); | 325 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); |
| 328 exceptionState.throwIfNeeded(); | 326 exceptionState.throwIfNeeded(); |
| 329 return; | 327 return; |
| 330 } | 328 } |
| 331 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate
()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0; | 329 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat
e(), info[programArgumentIndex]); |
| 332 Vector<RefPtr<WebGLShader> > shaders; | 330 Vector<RefPtr<WebGLShader> > shaders; |
| 333 bool succeed = context->getAttachedShaders(program, shaders); | 331 bool succeed = context->getAttachedShaders(program, shaders); |
| 334 if (!succeed) { | 332 if (!succeed) { |
| 335 v8SetReturnValueNull(info); | 333 v8SetReturnValueNull(info); |
| 336 return; | 334 return; |
| 337 } | 335 } |
| 338 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size(
)); | 336 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size(
)); |
| 339 for (size_t ii = 0; ii < shaders.size(); ++ii) | 337 for (size_t ii = 0; ii < shaders.size(); ++ii) |
| 340 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get
(), info.Holder(), info.GetIsolate())); | 338 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get
(), info.Holder(), info.GetIsolate())); |
| 341 v8SetReturnValue(info, array); | 339 v8SetReturnValue(info, array); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 return; | 406 return; |
| 409 } | 407 } |
| 410 | 408 |
| 411 const int programArgumentIndex = 0; | 409 const int programArgumentIndex = 0; |
| 412 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); | 410 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 413 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { | 411 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { |
| 414 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); | 412 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); |
| 415 exceptionState.throwIfNeeded(); | 413 exceptionState.throwIfNeeded(); |
| 416 return; | 414 return; |
| 417 } | 415 } |
| 418 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate
()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0; | 416 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat
e(), info[programArgumentIndex]); |
| 419 unsigned pname = toInt32(info[1], exceptionState); | 417 unsigned pname = toInt32(info[1], exceptionState); |
| 420 if (exceptionState.throwIfNeeded()) | 418 if (exceptionState.throwIfNeeded()) |
| 421 return; | 419 return; |
| 422 WebGLGetInfo args = context->getProgramParameter(program, pname); | 420 WebGLGetInfo args = context->getProgramParameter(program, pname); |
| 423 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); | 421 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 424 } | 422 } |
| 425 | 423 |
| 426 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun
ctionCallbackInfo<v8::Value>& info) | 424 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun
ctionCallbackInfo<v8::Value>& info) |
| 427 { | 425 { |
| 428 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu
fferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 426 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu
fferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
| 429 getObjectParameter(info, kRenderbuffer, exceptionState); | 427 getObjectParameter(info, kRenderbuffer, exceptionState); |
| 430 } | 428 } |
| 431 | 429 |
| 432 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) | 430 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
| 433 { | 431 { |
| 434 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa
rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 432 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa
rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
| 435 if (info.Length() != 2) { | 433 if (info.Length() != 2) { |
| 436 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 434 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 437 exceptionState.throwIfNeeded(); | 435 exceptionState.throwIfNeeded(); |
| 438 return; | 436 return; |
| 439 } | 437 } |
| 440 | 438 |
| 441 const int shaderArgumentIndex = 0; | 439 const int shaderArgumentIndex = 0; |
| 442 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); | 440 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 443 if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V
8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) { | 441 if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V
8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) { |
| 444 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(s
haderArgumentIndex + 1, "is not a WebGLShader object.")); | 442 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(s
haderArgumentIndex + 1, "is not a WebGLShader object.")); |
| 445 exceptionState.throwIfNeeded(); | 443 exceptionState.throwIfNeeded(); |
| 446 return; | 444 return; |
| 447 } | 445 } |
| 448 WebGLShader* shader = V8WebGLShader::hasInstance(info[shaderArgumentIndex],
info.GetIsolate()) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(info[0
])) : 0; | 446 WebGLShader* shader = V8WebGLShader::toNativeWithTypeCheck(info.GetIsolate()
, info[shaderArgumentIndex]); |
| 449 unsigned pname = toInt32(info[1], exceptionState); | 447 unsigned pname = toInt32(info[1], exceptionState); |
| 450 if (exceptionState.throwIfNeeded()) | 448 if (exceptionState.throwIfNeeded()) |
| 451 return; | 449 return; |
| 452 WebGLGetInfo args = context->getShaderParameter(shader, pname); | 450 WebGLGetInfo args = context->getShaderParameter(shader, pname); |
| 453 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); | 451 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
| 454 } | 452 } |
| 455 | 453 |
| 456 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& info) | 454 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
ionCallbackInfo<v8::Value>& info) |
| 457 { | 455 { |
| 458 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder()
); | 456 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder()
); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 483 return; | 481 return; |
| 484 } | 482 } |
| 485 | 483 |
| 486 const int programArgumentIndex = 0; | 484 const int programArgumentIndex = 0; |
| 487 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); | 485 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); |
| 488 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { | 486 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { |
| 489 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); | 487 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p
rogramArgumentIndex + 1, "is not a WebGLProgram object.")); |
| 490 exceptionState.throwIfNeeded(); | 488 exceptionState.throwIfNeeded(); |
| 491 return; | 489 return; |
| 492 } | 490 } |
| 493 WebGLProgram* program = V8WebGLProgram::hasInstance(info[programArgumentInde
x], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(i
nfo[0])) : 0; | 491 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat
e(), info[programArgumentIndex]); |
| 494 | 492 |
| 495 const int uniformArgumentIndex = 1; | 493 const int uniformArgumentIndex = 1; |
| 496 if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && !
V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate(
))) { | 494 if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && !
V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate(
))) { |
| 497 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u
niformArgumentIndex + 1, "is not a WebGLUniformLocation object.")); | 495 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u
niformArgumentIndex + 1, "is not a WebGLUniformLocation object.")); |
| 498 exceptionState.throwIfNeeded(); | 496 exceptionState.throwIfNeeded(); |
| 499 return; | 497 return; |
| 500 } | 498 } |
| 501 const int uniformLocationArgumentIndex = 1; | 499 const int uniformLocationArgumentIndex = 1; |
| 502 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); | 500 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); |
| 503 | 501 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); | 838 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); |
| 841 } | 839 } |
| 842 | 840 |
| 843 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) | 841 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
| 844 { | 842 { |
| 845 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 843 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
| 846 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); | 844 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); |
| 847 } | 845 } |
| 848 | 846 |
| 849 } // namespace WebCore | 847 } // namespace WebCore |
| OLD | NEW |