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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 break; | 318 break; |
319 } | 319 } |
320 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); | 320 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); |
321 } | 321 } |
322 | 322 |
323 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
v8::Isolate* isolate) | 323 static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value,
v8::Isolate* isolate) |
324 { | 324 { |
325 return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value); | 325 return V8WebGLUniformLocation::toNativeWithTypeCheck(isolate, value); |
326 } | 326 } |
327 | 327 |
328 enum WhichProgramCall { | |
329 kProgramParameter, kUniform | |
330 }; | |
331 | |
332 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) | |
333 { | |
334 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached
Shaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | |
335 if (info.Length() < 1) { | |
336 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | |
337 exceptionState.throwIfNeeded(); | |
338 return; | |
339 } | |
340 | |
341 const int programArgumentIndex = 0; | |
342 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold
er()); | |
343 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && !
V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { | |
344 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(programArgumentIndex + 1, "WebGLProgram")); | |
345 exceptionState.throwIfNeeded(); | |
346 return; | |
347 } | |
348 WebGLProgram* program = V8WebGLProgram::toNativeWithTypeCheck(info.GetIsolat
e(), info[programArgumentIndex]); | |
349 Vector<RefPtr<WebGLShader> > shaders; | |
350 bool succeed = context->getAttachedShaders(program, shaders); | |
351 if (!succeed) { | |
352 v8SetReturnValueNull(info); | |
353 return; | |
354 } | |
355 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size(
)); | |
356 for (size_t ii = 0; ii < shaders.size(); ++ii) | |
357 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get
(), info.Holder(), info.GetIsolate())); | |
358 v8SetReturnValue(info, array); | |
359 } | |
360 | |
361 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) | 328 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC
allbackInfo<v8::Value>& info) |
362 { | 329 { |
363 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa
rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 330 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa
rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
364 getObjectParameter(info, kBuffer, exceptionState); | 331 getObjectParameter(info, kBuffer, exceptionState); |
365 } | 332 } |
366 | 333 |
367 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) | 334 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
368 { | 335 { |
369 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio
n", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 336 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio
n", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
370 WebGLRenderingContext* impl = V8WebGLRenderingContext::toNative(info.Holder(
)); | 337 WebGLRenderingContext* impl = V8WebGLRenderingContext::toNative(info.Holder(
)); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); | 809 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); |
843 } | 810 } |
844 | 811 |
845 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) | 812 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
846 { | 813 { |
847 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 814 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
848 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); | 815 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); |
849 } | 816 } |
850 | 817 |
851 } // namespace WebCore | 818 } // namespace WebCore |
OLD | NEW |