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

Side by Side Diff: Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-wrote patch by hand (too much to rebase) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "V8WebGLRenderingContext.h" 32 #include "V8WebGLRenderingContextBase.h"
33 33
34 #include "V8ANGLEInstancedArrays.h" 34 #include "V8ANGLEInstancedArrays.h"
35 #include "V8EXTFragDepth.h" 35 #include "V8EXTFragDepth.h"
36 #include "V8EXTTextureFilterAnisotropic.h" 36 #include "V8EXTTextureFilterAnisotropic.h"
37 #include "V8HTMLCanvasElement.h" 37 #include "V8HTMLCanvasElement.h"
38 #include "V8HTMLImageElement.h" 38 #include "V8HTMLImageElement.h"
39 #include "V8HTMLVideoElement.h" 39 #include "V8HTMLVideoElement.h"
40 #include "V8ImageData.h" 40 #include "V8ImageData.h"
41 #include "V8OESElementIndexUint.h" 41 #include "V8OESElementIndexUint.h"
42 #include "V8OESStandardDerivatives.h" 42 #include "V8OESStandardDerivatives.h"
(...skipping 22 matching lines...) Expand all
65 #include "bindings/v8/V8Binding.h" 65 #include "bindings/v8/V8Binding.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 "platform/NotImplemented.h" 76 #include "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, Exc eptionState& exceptionState) 84 static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len, Exc eptionState& exceptionState)
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 exceptionState.throwTypeError("Array length exceeds supported limit."); 88 exceptionState.throwTypeError("Array length exceeds supported limit.");
89 return 0; 89 return 0;
90 } 90 }
91 float* data = static_cast<float*>(fastMalloc(len * sizeof(float))); 91 float* data = static_cast<float*>(fastMalloc(len * sizeof(float)));
92 92
93 for (uint32_t i = 0; i < len; i++) { 93 for (uint32_t i = 0; i < len; i++) {
94 v8::Local<v8::Value> val = array->Get(i); 94 v8::Local<v8::Value> val = array->Get(i);
95 float value = toFloat(val, exceptionState); 95 float value = toFloat(val, exceptionState);
96 if (exceptionState.hadException()) { 96 if (exceptionState.hadException()) {
97 fastFree(data); 97 fastFree(data);
98 return 0; 98 return 0;
99 } 99 }
100 data[i] = value; 100 data[i] = value;
101 } 101 }
102 return data; 102 return data;
103 } 103 }
104 104
105 // Allocates new storage via fastMalloc. 105 // Allocates new storage via fastMalloc.
106 // Returns NULL if array failed to convert for any reason. 106 // Returns 0 if array failed to convert for any reason.
107 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len, Excepti onState& exceptionState) 107 static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len, Excepti onState& exceptionState)
108 { 108 {
109 // Convert the data element-by-element. 109 // Convert the data element-by-element.
110 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int)) { 110 if (len > std::numeric_limits<uint32_t>::max() / sizeof(int)) {
111 exceptionState.throwTypeError("Array length exceeds supported limit."); 111 exceptionState.throwTypeError("Array length exceeds supported limit.");
112 return 0; 112 return 0;
113 } 113 }
114 int* data = static_cast<int*>(fastMalloc(len * sizeof(int))); 114 int* data = static_cast<int*>(fastMalloc(len * sizeof(int)));
115 115
116 for (uint32_t i = 0; i < len; i++) { 116 for (uint32_t i = 0; i < len; i++) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 } 176 }
177 177
178 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate) 178 static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 ::Object> contextObject, v8::Isolate* isolate)
179 { 179 {
180 if (!extension) 180 if (!extension)
181 return v8::Null(isolate); 181 return v8::Null(isolate);
182 v8::Handle<v8::Value> extensionObject; 182 v8::Handle<v8::Value> extensionObject;
183 const char* referenceName = 0; 183 const char* referenceName = 0;
184 switch (extension->name()) { 184 switch (extension->name()) {
185 case WebGLExtension::ANGLEInstancedArraysName: 185 case ANGLEInstancedArraysName:
186 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate); 186 extensionObject = toV8(static_cast<ANGLEInstancedArrays*>(extension), co ntextObject, isolate);
187 referenceName = "angleInstancedArraysName"; 187 referenceName = "angleInstancedArraysName";
188 break; 188 break;
189 case WebGLExtension::EXTFragDepthName: 189 case EXTFragDepthName:
190 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate); 190 extensionObject = toV8(static_cast<EXTFragDepth*>(extension), contextObj ect, isolate);
191 referenceName = "extFragDepthName"; 191 referenceName = "extFragDepthName";
192 break; 192 break;
193 case WebGLExtension::EXTTextureFilterAnisotropicName: 193 case EXTTextureFilterAnisotropicName:
194 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate); 194 extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extensi on), contextObject, isolate);
195 referenceName = "extTextureFilterAnisotropicName"; 195 referenceName = "extTextureFilterAnisotropicName";
196 break; 196 break;
197 case WebGLExtension::OESElementIndexUintName: 197 case OESElementIndexUintName:
198 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate); 198 extensionObject = toV8(static_cast<OESElementIndexUint*>(extension), con textObject, isolate);
199 referenceName = "oesElementIndexUintName"; 199 referenceName = "oesElementIndexUintName";
200 break; 200 break;
201 case WebGLExtension::OESStandardDerivativesName: 201 case OESStandardDerivativesName:
202 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate); 202 extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), contextObject, isolate);
203 referenceName = "oesStandardDerivativesName"; 203 referenceName = "oesStandardDerivativesName";
204 break; 204 break;
205 case WebGLExtension::OESTextureFloatName: 205 case OESTextureFloatName:
206 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate); 206 extensionObject = toV8(static_cast<OESTextureFloat*>(extension), context Object, isolate);
207 referenceName = "oesTextureFloatName"; 207 referenceName = "oesTextureFloatName";
208 break; 208 break;
209 case WebGLExtension::OESTextureFloatLinearName: 209 case OESTextureFloatLinearName:
210 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate); 210 extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), c ontextObject, isolate);
211 referenceName = "oesTextureFloatLinearName"; 211 referenceName = "oesTextureFloatLinearName";
212 break; 212 break;
213 case WebGLExtension::OESTextureHalfFloatName: 213 case OESTextureHalfFloatName:
214 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate); 214 extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), con textObject, isolate);
215 referenceName = "oesTextureHalfFloatName"; 215 referenceName = "oesTextureHalfFloatName";
216 break; 216 break;
217 case WebGLExtension::OESTextureHalfFloatLinearName: 217 case OESTextureHalfFloatLinearName:
218 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate); 218 extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension ), contextObject, isolate);
219 referenceName = "oesTextureHalfFloatLinearName"; 219 referenceName = "oesTextureHalfFloatLinearName";
220 break; 220 break;
221 case WebGLExtension::OESVertexArrayObjectName: 221 case OESVertexArrayObjectName:
222 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate); 222 extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), co ntextObject, isolate);
223 referenceName = "oesVertexArrayObjectName"; 223 referenceName = "oesVertexArrayObjectName";
224 break; 224 break;
225 case WebGLExtension::WebGLCompressedTextureATCName: 225 case WebGLCompressedTextureATCName:
226 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate); 226 extensionObject = toV8(static_cast<WebGLCompressedTextureATC*>(extension ), contextObject, isolate);
227 referenceName = "webGLCompressedTextureATCName"; 227 referenceName = "webGLCompressedTextureATCName";
228 break; 228 break;
229 case WebGLExtension::WebGLCompressedTexturePVRTCName: 229 case WebGLCompressedTexturePVRTCName:
230 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate); 230 extensionObject = toV8(static_cast<WebGLCompressedTexturePVRTC*>(extensi on), contextObject, isolate);
231 referenceName = "webGLCompressedTexturePVRTCName"; 231 referenceName = "webGLCompressedTexturePVRTCName";
232 break; 232 break;
233 case WebGLExtension::WebGLCompressedTextureS3TCName: 233 case WebGLCompressedTextureS3TCName:
234 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate); 234 extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extensio n), contextObject, isolate);
235 referenceName = "webGLCompressedTextureS3TCName"; 235 referenceName = "webGLCompressedTextureS3TCName";
236 break; 236 break;
237 case WebGLExtension::WebGLDebugRendererInfoName: 237 case WebGLDebugRendererInfoName:
238 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate); 238 extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), contextObject, isolate);
239 referenceName = "webGLDebugRendererInfoName"; 239 referenceName = "webGLDebugRendererInfoName";
240 break; 240 break;
241 case WebGLExtension::WebGLDebugShadersName: 241 case WebGLDebugShadersName:
242 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate); 242 extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), conte xtObject, isolate);
243 referenceName = "webGLDebugShadersName"; 243 referenceName = "webGLDebugShadersName";
244 break; 244 break;
245 case WebGLExtension::WebGLDepthTextureName: 245 case WebGLDepthTextureName:
246 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate); 246 extensionObject = toV8(static_cast<WebGLDepthTexture*>(extension), conte xtObject, isolate);
247 referenceName = "webGLDepthTextureName"; 247 referenceName = "webGLDepthTextureName";
248 break; 248 break;
249 case WebGLExtension::WebGLDrawBuffersName: 249 case WebGLDrawBuffersName:
250 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate); 250 extensionObject = toV8(static_cast<WebGLDrawBuffers*>(extension), contex tObject, isolate);
251 referenceName = "webGLDrawBuffersName"; 251 referenceName = "webGLDrawBuffersName";
252 break; 252 break;
253 case WebGLExtension::WebGLLoseContextName: 253 case WebGLLoseContextName:
254 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate); 254 extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), contex tObject, isolate);
255 referenceName = "webGLLoseContextName"; 255 referenceName = "webGLLoseContextName";
256 break; 256 break;
257 case WebGLExtensionNameCount:
258 notImplemented();
259 return v8::Undefined(isolate);
257 } 260 }
258 ASSERT(!extensionObject.IsEmpty()); 261 ASSERT(!extensionObject.IsEmpty());
259 setHiddenValue(isolate, contextObject, referenceName, extensionObject); 262 setHiddenValue(isolate, contextObject, referenceName, extensionObject);
260 return extensionObject; 263 return extensionObject;
261 } 264 }
262 265
263 enum ObjectType { 266 enum ObjectType {
264 kBuffer, kRenderbuffer, kTexture, kVertexAttrib 267 kBuffer, kRenderbuffer, kTexture, kVertexAttrib
265 }; 268 };
266 269
267 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& info, ObjectType objectType, ExceptionState& exceptionState) 270 static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& info, ObjectType objectType, ExceptionState& exceptionState)
268 { 271 {
269 if (info.Length() != 2) { 272 if (info.Length() != 2) {
270 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 273 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
271 exceptionState.throwIfNeeded(); 274 exceptionState.throwIfNeeded();
272 return; 275 return;
273 } 276 }
274 277
275 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 278 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
276 unsigned target = toInt32(info[0], exceptionState); 279 unsigned target = toInt32(info[0], exceptionState);
277 if (exceptionState.throwIfNeeded()) 280 if (exceptionState.throwIfNeeded())
278 return; 281 return;
279 unsigned pname = toInt32(info[1], exceptionState); 282 unsigned pname = toInt32(info[1], exceptionState);
280 if (exceptionState.throwIfNeeded()) 283 if (exceptionState.throwIfNeeded())
281 return; 284 return;
282 WebGLGetInfo args; 285 WebGLGetInfo args;
283 switch (objectType) { 286 switch (objectType) {
284 case kBuffer: 287 case kBuffer:
285 args = context->getBufferParameter(target, pname); 288 args = context->getBufferParameter(target, pname);
(...skipping 19 matching lines...) Expand all
305 { 308 {
306 if (!V8WebGLUniformLocation::hasInstance(value, isolate)) 309 if (!V8WebGLUniformLocation::hasInstance(value, isolate))
307 return 0; 310 return 0;
308 return V8WebGLUniformLocation::toNative(value->ToObject()); 311 return V8WebGLUniformLocation::toNative(value->ToObject());
309 } 312 }
310 313
311 enum WhichProgramCall { 314 enum WhichProgramCall {
312 kProgramParameter, kUniform 315 kProgramParameter, kUniform
313 }; 316 };
314 317
315 void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 318 void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
316 { 319 {
317 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached Shaders", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 320 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getAttached Shaders", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
318 if (info.Length() < 1) { 321 if (info.Length() < 1) {
319 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 322 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
320 exceptionState.throwIfNeeded(); 323 exceptionState.throwIfNeeded();
321 return; 324 return;
322 } 325 }
323 326
324 const int programArgumentIndex = 0; 327 const int programArgumentIndex = 0;
325 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 328 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
326 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 329 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.")); 330 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p rogramArgumentIndex + 1, "is not a WebGLProgram object."));
328 exceptionState.throwIfNeeded(); 331 exceptionState.throwIfNeeded();
329 return; 332 return;
330 } 333 }
331 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate ()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0; 334 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate ()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
332 Vector<RefPtr<WebGLShader> > shaders; 335 Vector<RefPtr<WebGLShader> > shaders;
333 bool succeed = context->getAttachedShaders(program, shaders); 336 bool succeed = context->getAttachedShaders(program, shaders);
334 if (!succeed) { 337 if (!succeed) {
335 v8SetReturnValueNull(info); 338 v8SetReturnValueNull(info);
336 return; 339 return;
337 } 340 }
338 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size( )); 341 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), shaders.size( ));
339 for (size_t ii = 0; ii < shaders.size(); ++ii) 342 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())); 343 array->Set(v8::Integer::New(info.GetIsolate(), ii), toV8(shaders[ii].get (), info.Holder(), info.GetIsolate()));
341 v8SetReturnValue(info, array); 344 v8SetReturnValue(info, array);
342 } 345 }
343 346
344 void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 347 void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
345 { 348 {
346 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 349 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getBufferPa rameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
347 getObjectParameter(info, kBuffer, exceptionState); 350 getObjectParameter(info, kBuffer, exceptionState);
348 } 351 }
349 352
350 void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& info) 353 void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info)
351 { 354 {
352 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio n", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 355 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getExtensio n", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
353 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder() ); 356 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info. Holder());
354 if (info.Length() < 1) { 357 if (info.Length() < 1) {
355 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 358 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
356 exceptionState.throwIfNeeded(); 359 exceptionState.throwIfNeeded();
357 return; 360 return;
358 } 361 }
359 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); 362 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]);
360 RefPtr<WebGLExtension> extension(imp->getExtension(name)); 363 RefPtr<WebGLExtension> extension(imp->getExtension(name));
361 v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIs olate())); 364 v8SetReturnValue(info, toV8Object(extension.get(), info.Holder(), info.GetIs olate()));
362 } 365 }
363 366
364 void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons t v8::FunctionCallbackInfo<v8::Value>& info) 367 void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom( const v8::FunctionCallbackInfo<v8::Value>& info)
365 { 368 {
366 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebuf ferAttachmentParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate ()); 369 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getFramebuf ferAttachmentParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIso late());
367 if (info.Length() != 3) { 370 if (info.Length() != 3) {
368 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length())); 371 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length()));
369 exceptionState.throwIfNeeded(); 372 exceptionState.throwIfNeeded();
370 return; 373 return;
371 } 374 }
372 375
373 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 376 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
374 unsigned target = toInt32(info[0]); 377 unsigned target = toInt32(info[0]);
375 unsigned attachment = toInt32(info[1], exceptionState); 378 unsigned attachment = toInt32(info[1], exceptionState);
376 if (exceptionState.throwIfNeeded()) 379 if (exceptionState.throwIfNeeded())
377 return; 380 return;
378 unsigned pname = toInt32(info[2], exceptionState); 381 unsigned pname = toInt32(info[2], exceptionState);
379 if (exceptionState.throwIfNeeded()) 382 if (exceptionState.throwIfNeeded())
380 return; 383 return;
381 WebGLGetInfo args = context->getFramebufferAttachmentParameter(target, attac hment, pname); 384 WebGLGetInfo args = context->getFramebufferAttachmentParameter(target, attac hment, pname);
382 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 385 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
383 } 386 }
384 387
385 void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbac kInfo<v8::Value>& info) 388 void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info)
386 { 389 {
387 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParamete r", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 390 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getParamete r", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
388 if (info.Length() != 1) { 391 if (info.Length() != 1) {
389 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 392 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
390 exceptionState.throwIfNeeded(); 393 exceptionState.throwIfNeeded();
391 return; 394 return;
392 } 395 }
393 396
394 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 397 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
395 unsigned pname = toInt32(info[0], exceptionState); 398 unsigned pname = toInt32(info[0], exceptionState);
396 if (exceptionState.throwIfNeeded()) 399 if (exceptionState.throwIfNeeded())
397 return; 400 return;
398 WebGLGetInfo args = context->getParameter(pname); 401 WebGLGetInfo args = context->getParameter(pname);
399 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 402 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
400 } 403 }
401 404
402 void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& info) 405 void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::Func tionCallbackInfo<v8::Value>& info)
403 { 406 {
404 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramP arameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 407 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getProgramP arameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
405 if (info.Length() != 2) { 408 if (info.Length() != 2) {
406 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 409 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
407 exceptionState.throwIfNeeded(); 410 exceptionState.throwIfNeeded();
408 return; 411 return;
409 } 412 }
410 413
411 const int programArgumentIndex = 0; 414 const int programArgumentIndex = 0;
412 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 415 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
413 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 416 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.")); 417 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p rogramArgumentIndex + 1, "is not a WebGLProgram object."));
415 exceptionState.throwIfNeeded(); 418 exceptionState.throwIfNeeded();
416 return; 419 return;
417 } 420 }
418 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate ()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0; 421 WebGLProgram* program = V8WebGLProgram::hasInstance(info[0], info.GetIsolate ()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0;
419 unsigned pname = toInt32(info[1], exceptionState); 422 unsigned pname = toInt32(info[1], exceptionState);
420 if (exceptionState.throwIfNeeded()) 423 if (exceptionState.throwIfNeeded())
421 return; 424 return;
422 WebGLGetInfo args = context->getProgramParameter(program, pname); 425 WebGLGetInfo args = context->getProgramParameter(program, pname);
423 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 426 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
424 } 427 }
425 428
426 void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::Fun ctionCallbackInfo<v8::Value>& info) 429 void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8: :FunctionCallbackInfo<v8::Value>& info)
427 { 430 {
428 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu fferParameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 431 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRenderbu fferParameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
429 getObjectParameter(info, kRenderbuffer, exceptionState); 432 getObjectParameter(info, kRenderbuffer, exceptionState);
430 } 433 }
431 434
432 void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC allbackInfo<v8::Value>& info) 435 void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info)
433 { 436 {
434 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa rameter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 437 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getShaderPa rameter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
435 if (info.Length() != 2) { 438 if (info.Length() != 2) {
436 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 439 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
437 exceptionState.throwIfNeeded(); 440 exceptionState.throwIfNeeded();
438 return; 441 return;
439 } 442 }
440 443
441 const int shaderArgumentIndex = 0; 444 const int shaderArgumentIndex = 0;
442 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 445 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
443 if (info.Length() > 0 && !isUndefinedOrNull(info[shaderArgumentIndex]) && !V 8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate())) { 446 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.")); 447 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(s haderArgumentIndex + 1, "is not a WebGLShader object."));
445 exceptionState.throwIfNeeded(); 448 exceptionState.throwIfNeeded();
446 return; 449 return;
447 } 450 }
448 WebGLShader* shader = V8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate()) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(info[0 ])) : 0; 451 WebGLShader* shader = V8WebGLShader::hasInstance(info[shaderArgumentIndex], info.GetIsolate()) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(info[0 ])) : 0;
449 unsigned pname = toInt32(info[1], exceptionState); 452 unsigned pname = toInt32(info[1], exceptionState);
450 if (exceptionState.throwIfNeeded()) 453 if (exceptionState.throwIfNeeded())
451 return; 454 return;
452 WebGLGetInfo args = context->getShaderParameter(shader, pname); 455 WebGLGetInfo args = context->getShaderParameter(shader, pname);
453 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 456 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
454 } 457 }
455 458
456 void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct ionCallbackInfo<v8::Value>& info) 459 void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::F unctionCallbackInfo<v8::Value>& info)
457 { 460 {
458 WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(info.Holder() ); 461 WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(info. Holder());
459 if (imp->isContextLost()) { 462 if (imp->isContextLost()) {
460 v8SetReturnValueNull(info); 463 v8SetReturnValueNull(info);
461 return; 464 return;
462 } 465 }
463 466
464 Vector<String> value = imp->getSupportedExtensions(); 467 Vector<String> value = imp->getSupportedExtensions();
465 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), value.size()) ; 468 v8::Local<v8::Array> array = v8::Array::New(info.GetIsolate(), value.size()) ;
466 for (size_t ii = 0; ii < value.size(); ++ii) 469 for (size_t ii = 0; ii < value.size(); ++ii)
467 array->Set(v8::Integer::New(info.GetIsolate(), ii), v8String(info.GetIso late(), value[ii])); 470 array->Set(v8::Integer::New(info.GetIsolate(), ii), v8String(info.GetIso late(), value[ii]));
468 v8SetReturnValue(info, array); 471 v8SetReturnValue(info, array);
469 } 472 }
470 473
471 void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 474 void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
472 { 475 {
473 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParam eter", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 476 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getTexParam eter", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
474 getObjectParameter(info, kTexture, exceptionState); 477 getObjectParameter(info, kTexture, exceptionState);
475 } 478 }
476 479
477 void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 480 void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
478 { 481 {
479 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 482 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getUniform" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
480 if (info.Length() != 2) { 483 if (info.Length() != 2) {
481 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 484 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
482 exceptionState.throwIfNeeded(); 485 exceptionState.throwIfNeeded();
483 return; 486 return;
484 } 487 }
485 488
486 const int programArgumentIndex = 0; 489 const int programArgumentIndex = 0;
487 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 490 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
488 if (info.Length() > 0 && !isUndefinedOrNull(info[programArgumentIndex]) && ! V8WebGLProgram::hasInstance(info[programArgumentIndex], info.GetIsolate())) { 491 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.")); 492 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(p rogramArgumentIndex + 1, "is not a WebGLProgram object."));
490 exceptionState.throwIfNeeded(); 493 exceptionState.throwIfNeeded();
491 return; 494 return;
492 } 495 }
493 WebGLProgram* program = V8WebGLProgram::hasInstance(info[programArgumentInde x], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(i nfo[0])) : 0; 496 WebGLProgram* program = V8WebGLProgram::hasInstance(info[programArgumentInde x], info.GetIsolate()) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(i nfo[0])) : 0;
494 497
495 const int uniformArgumentIndex = 1; 498 const int uniformArgumentIndex = 1;
496 if (info.Length() > 1 && !isUndefinedOrNull(info[uniformArgumentIndex]) && ! V8WebGLUniformLocation::hasInstance(info[uniformArgumentIndex], info.GetIsolate( ))) { 499 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.")); 500 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u niformArgumentIndex + 1, "is not a WebGLUniformLocation object."));
498 exceptionState.throwIfNeeded(); 501 exceptionState.throwIfNeeded();
499 return; 502 return;
500 } 503 }
501 const int uniformLocationArgumentIndex = 1; 504 const int uniformLocationArgumentIndex = 1;
502 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 505 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
503 506
504 WebGLGetInfo args = context->getUniform(program, location); 507 WebGLGetInfo args = context->getUniform(program, location);
505 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate())); 508 v8SetReturnValue(info, toV8Object(args, info.Holder(), info.GetIsolate()));
506 } 509 }
507 510
508 void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 511 void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
509 { 512 {
510 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAt trib", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 513 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getVertexAt trib", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
511 getObjectParameter(info, kVertexAttrib, exceptionState); 514 getObjectParameter(info, kVertexAttrib, exceptionState);
512 } 515 }
513 516
514 enum FunctionToCall { 517 enum FunctionToCall {
515 kUniform1v, kUniform2v, kUniform3v, kUniform4v, 518 kUniform1v, kUniform2v, kUniform3v, kUniform4v,
516 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v 519 kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v
517 }; 520 };
518 521
519 bool isFunctionToCallForAttribute(FunctionToCall functionToCall) 522 bool isFunctionToCallForAttribute(FunctionToCall functionToCall)
520 { 523 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } else { 569 } else {
567 const int uniformLocationArgumentIndex = 0; 570 const int uniformLocationArgumentIndex = 0;
568 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgument Index]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentInde x], info.GetIsolate())) { 571 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgument Index]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentInde x], info.GetIsolate())) {
569 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentTy pe(uniformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object.")); 572 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentTy pe(uniformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
570 exceptionState.throwIfNeeded(); 573 exceptionState.throwIfNeeded();
571 return; 574 return;
572 } 575 }
573 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in fo.GetIsolate()); 576 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in fo.GetIsolate());
574 } 577 }
575 578
576 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 579 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
577 580
578 const int indexArrayArgument = 1; 581 const int indexArrayArgument = 1;
579 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate()) ) { 582 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate()) ) {
580 Float32Array* array = V8Float32Array::toNative(info[indexArrayArgument]- >ToObject()); 583 Float32Array* array = V8Float32Array::toNative(info[indexArrayArgument]- >ToObject());
581 ASSERT(array != NULL); 584 ASSERT(array);
582 switch (functionToCall) { 585 switch (functionToCall) {
583 case kUniform1v: context->uniform1fv(location, array); break; 586 case kUniform1v: context->uniform1fv(location, array); break;
584 case kUniform2v: context->uniform2fv(location, array); break; 587 case kUniform2v: context->uniform2fv(location, array); break;
585 case kUniform3v: context->uniform3fv(location, array); break; 588 case kUniform3v: context->uniform3fv(location, array); break;
586 case kUniform4v: context->uniform4fv(location, array); break; 589 case kUniform4v: context->uniform4fv(location, array); break;
587 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; 590 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break;
588 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; 591 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break;
589 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; 592 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break;
590 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; 593 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break;
591 default: ASSERT_NOT_REACHED(); break; 594 default: ASSERT_NOT_REACHED(); break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // * glUniform4iv(GLUniformLocation location, Array data); 638 // * glUniform4iv(GLUniformLocation location, Array data);
636 // * glUniform4iv(GLUniformLocation location, Int32Array data); 639 // * glUniform4iv(GLUniformLocation location, Int32Array data);
637 640
638 if (info.Length() != 2) { 641 if (info.Length() != 2) {
639 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 642 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
640 exceptionState.throwIfNeeded(); 643 exceptionState.throwIfNeeded();
641 return; 644 return;
642 } 645 }
643 646
644 const int uniformLocationArgumentIndex = 0; 647 const int uniformLocationArgumentIndex = 0;
645 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 648 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
646 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) { 649 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
647 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u niformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object.")); 650 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u niformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
648 exceptionState.throwIfNeeded(); 651 exceptionState.throwIfNeeded();
649 return; 652 return;
650 } 653 }
651 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 654 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
652 655
653 const int indexArrayArgumentIndex = 1; 656 const int indexArrayArgumentIndex = 1;
654 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate ())) { 657 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate ())) {
655 Int32Array* array = V8Int32Array::toNative(info[indexArrayArgumentIndex] ->ToObject()); 658 Int32Array* array = V8Int32Array::toNative(info[indexArrayArgumentIndex] ->ToObject());
656 ASSERT(array != NULL); 659 ASSERT(array);
657 switch (functionToCall) { 660 switch (functionToCall) {
658 case kUniform1v: context->uniform1iv(location, array); break; 661 case kUniform1v: context->uniform1iv(location, array); break;
659 case kUniform2v: context->uniform2iv(location, array); break; 662 case kUniform2v: context->uniform2iv(location, array); break;
660 case kUniform3v: context->uniform3iv(location, array); break; 663 case kUniform3v: context->uniform3iv(location, array); break;
661 case kUniform4v: context->uniform4iv(location, array); break; 664 case kUniform4v: context->uniform4iv(location, array); break;
662 default: ASSERT_NOT_REACHED(); break; 665 default: ASSERT_NOT_REACHED(); break;
663 } 666 }
664 return; 667 return;
665 } 668 }
666 669
(...skipping 16 matching lines...) Expand all
683 switch (functionToCall) { 686 switch (functionToCall) {
684 case kUniform1v: context->uniform1iv(location, data, len); break; 687 case kUniform1v: context->uniform1iv(location, data, len); break;
685 case kUniform2v: context->uniform2iv(location, data, len); break; 688 case kUniform2v: context->uniform2iv(location, data, len); break;
686 case kUniform3v: context->uniform3iv(location, data, len); break; 689 case kUniform3v: context->uniform3iv(location, data, len); break;
687 case kUniform4v: context->uniform4iv(location, data, len); break; 690 case kUniform4v: context->uniform4iv(location, data, len); break;
688 default: ASSERT_NOT_REACHED(); break; 691 default: ASSERT_NOT_REACHED(); break;
689 } 692 }
690 fastFree(data); 693 fastFree(data);
691 } 694 }
692 695
693 void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 696 void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
694 { 697 {
695 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 698 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
696 vertexAttribAndUniformHelperf(info, kUniform1v, exceptionState); 699 vertexAttribAndUniformHelperf(info, kUniform1v, exceptionState);
697 } 700 }
698 701
699 void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 702 void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
700 { 703 {
701 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 704 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform1iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
702 uniformHelperi(info, kUniform1v, exceptionState); 705 uniformHelperi(info, kUniform1v, exceptionState);
703 } 706 }
704 707
705 void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 708 void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
706 { 709 {
707 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 710 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
708 vertexAttribAndUniformHelperf(info, kUniform2v, exceptionState); 711 vertexAttribAndUniformHelperf(info, kUniform2v, exceptionState);
709 } 712 }
710 713
711 void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 714 void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
712 { 715 {
713 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 716 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform2iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
714 uniformHelperi(info, kUniform2v, exceptionState); 717 uniformHelperi(info, kUniform2v, exceptionState);
715 } 718 }
716 719
717 void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 720 void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
718 { 721 {
719 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 722 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
720 vertexAttribAndUniformHelperf(info, kUniform3v, exceptionState); 723 vertexAttribAndUniformHelperf(info, kUniform3v, exceptionState);
721 } 724 }
722 725
723 void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 726 void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
724 { 727 {
725 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 728 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform3iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
726 uniformHelperi(info, kUniform3v, exceptionState); 729 uniformHelperi(info, kUniform3v, exceptionState);
727 } 730 }
728 731
729 void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 732 void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
730 { 733 {
731 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 734 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4fv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
732 vertexAttribAndUniformHelperf(info, kUniform4v, exceptionState); 735 vertexAttribAndUniformHelperf(info, kUniform4v, exceptionState);
733 } 736 }
734 737
735 void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackI nfo<v8::Value>& info) 738 void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallb ackInfo<v8::Value>& info)
736 { 739 {
737 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv" , "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 740 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniform4iv" , "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
738 uniformHelperi(info, kUniform4v, exceptionState); 741 uniformHelperi(info, kUniform4v, exceptionState);
739 } 742 }
740 743
741 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& info, int matrixSize, ExceptionState& exceptionState) 744 static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& info, int matrixSize, ExceptionState& exceptionState)
742 { 745 {
743 // Forms: 746 // Forms:
744 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); 747 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data);
745 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta); 748 // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array da ta);
746 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); 749 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data);
747 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta); 750 // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array da ta);
748 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); 751 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data);
749 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta); 752 // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array da ta);
750 // 753 //
751 // FIXME: need to change to accept Float32Array as well. 754 // FIXME: need to change to accept Float32Array as well.
752 if (info.Length() != 3) { 755 if (info.Length() != 3) {
753 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length())); 756 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, i nfo.Length()));
754 exceptionState.throwIfNeeded(); 757 exceptionState.throwIfNeeded();
755 return; 758 return;
756 } 759 }
757 760
758 WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(info.Hold er()); 761 WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(i nfo.Holder());
759 762
760 const int uniformLocationArgumentIndex = 0; 763 const int uniformLocationArgumentIndex = 0;
761 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) { 764 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex], info.GetIsolate())) {
762 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u niformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object.")); 765 exceptionState.throwTypeError(ExceptionMessages::incorrectArgumentType(u niformLocationArgumentIndex + 1, "is not a WebGLUniformLocation object."));
763 exceptionState.throwIfNeeded(); 766 exceptionState.throwIfNeeded();
764 return; 767 return;
765 } 768 }
766 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate()); 769 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation ArgumentIndex], info.GetIsolate());
767 770
768 bool transpose = info[1]->BooleanValue(); 771 bool transpose = info[1]->BooleanValue();
769 const int arrayArgumentIndex = 2; 772 const int arrayArgumentIndex = 2;
770 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate()) ) { 773 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate()) ) {
771 Float32Array* array = V8Float32Array::toNative(info[arrayArgumentIndex]- >ToObject()); 774 Float32Array* array = V8Float32Array::toNative(info[arrayArgumentIndex]- >ToObject());
772 ASSERT(array != NULL); 775 ASSERT(array);
773 switch (matrixSize) { 776 switch (matrixSize) {
774 case 2: context->uniformMatrix2fv(location, transpose, array); break; 777 case 2: context->uniformMatrix2fv(location, transpose, array); break;
775 case 3: context->uniformMatrix3fv(location, transpose, array); break; 778 case 3: context->uniformMatrix3fv(location, transpose, array); break;
776 case 4: context->uniformMatrix4fv(location, transpose, array); break; 779 case 4: context->uniformMatrix4fv(location, transpose, array); break;
777 default: ASSERT_NOT_REACHED(); break; 780 default: ASSERT_NOT_REACHED(); break;
778 } 781 }
779 return; 782 return;
780 } 783 }
781 784
782 if (info[arrayArgumentIndex].IsEmpty() || !info[arrayArgumentIndex]->IsArray ()) { 785 if (info[arrayArgumentIndex].IsEmpty() || !info[arrayArgumentIndex]->IsArray ()) {
(...skipping 14 matching lines...) Expand all
797 } 800 }
798 switch (matrixSize) { 801 switch (matrixSize) {
799 case 2: context->uniformMatrix2fv(location, transpose, data, len); break; 802 case 2: context->uniformMatrix2fv(location, transpose, data, len); break;
800 case 3: context->uniformMatrix3fv(location, transpose, data, len); break; 803 case 3: context->uniformMatrix3fv(location, transpose, data, len); break;
801 case 4: context->uniformMatrix4fv(location, transpose, data, len); break; 804 case 4: context->uniformMatrix4fv(location, transpose, data, len); break;
802 default: ASSERT_NOT_REACHED(); break; 805 default: ASSERT_NOT_REACHED(); break;
803 } 806 }
804 fastFree(data); 807 fastFree(data);
805 } 808 }
806 809
807 void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 810 void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
808 { 811 {
809 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 812 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
810 uniformMatrixHelper(info, 2, exceptionState); 813 uniformMatrixHelper(info, 2, exceptionState);
811 } 814 }
812 815
813 void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 816 void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
814 { 817 {
815 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 818 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
816 uniformMatrixHelper(info, 3, exceptionState); 819 uniformMatrixHelper(info, 3, exceptionState);
817 } 820 }
818 821
819 void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCal lbackInfo<v8::Value>& info) 822 void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::Functio nCallbackInfo<v8::Value>& info)
820 { 823 {
821 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 824 ExceptionState exceptionState(ExceptionState::ExecutionContext, "uniformMatr ix4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
822 uniformMatrixHelper(info, 4, exceptionState); 825 uniformMatrixHelper(info, 4, exceptionState);
823 } 826 }
824 827
825 void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 828 void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
826 { 829 {
827 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b1fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 830 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b1fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
828 vertexAttribAndUniformHelperf(info, kVertexAttrib1v, exceptionState); 831 vertexAttribAndUniformHelperf(info, kVertexAttrib1v, exceptionState);
829 } 832 }
830 833
831 void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 834 void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
832 { 835 {
833 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b2fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 836 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b2fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
834 vertexAttribAndUniformHelperf(info, kVertexAttrib2v, exceptionState); 837 vertexAttribAndUniformHelperf(info, kVertexAttrib2v, exceptionState);
835 } 838 }
836 839
837 void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 840 void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
838 { 841 {
839 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b3fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 842 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b3fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
840 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); 843 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState);
841 } 844 }
842 845
843 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall backInfo<v8::Value>& info) 846 void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::Function CallbackInfo<v8::Value>& info)
844 { 847 {
845 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); 848 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri b4fv", "WebGLRenderingContextBase", info.Holder(), info.GetIsolate());
846 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); 849 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState);
847 } 850 }
848 851
849 } // namespace WebCore 852 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698