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 15 matching lines...) Expand all Loading... |
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 "bindings/core/v8/V8WebGLRenderingContext.h" | 32 #include "bindings/core/v8/V8WebGLRenderingContext.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionMessages.h" | 34 #include "bindings/core/v8/ExceptionMessages.h" |
35 #include "bindings/core/v8/V8ANGLEInstancedArrays.h" | 35 #include "bindings/core/v8/V8ANGLEInstancedArrays.h" |
| 36 #include "bindings/core/v8/V8ArrayBufferView.h" |
36 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
37 #include "bindings/core/v8/V8EXTBlendMinMax.h" | 38 #include "bindings/core/v8/V8EXTBlendMinMax.h" |
38 #include "bindings/core/v8/V8EXTFragDepth.h" | 39 #include "bindings/core/v8/V8EXTFragDepth.h" |
39 #include "bindings/core/v8/V8EXTShaderTextureLOD.h" | 40 #include "bindings/core/v8/V8EXTShaderTextureLOD.h" |
40 #include "bindings/core/v8/V8EXTTextureFilterAnisotropic.h" | 41 #include "bindings/core/v8/V8EXTTextureFilterAnisotropic.h" |
| 42 #include "bindings/core/v8/V8Float32Array.h" |
41 #include "bindings/core/v8/V8HTMLCanvasElement.h" | 43 #include "bindings/core/v8/V8HTMLCanvasElement.h" |
42 #include "bindings/core/v8/V8HTMLImageElement.h" | 44 #include "bindings/core/v8/V8HTMLImageElement.h" |
43 #include "bindings/core/v8/V8HTMLVideoElement.h" | 45 #include "bindings/core/v8/V8HTMLVideoElement.h" |
44 #include "bindings/core/v8/V8HiddenValue.h" | 46 #include "bindings/core/v8/V8HiddenValue.h" |
45 #include "bindings/core/v8/V8ImageData.h" | 47 #include "bindings/core/v8/V8ImageData.h" |
| 48 #include "bindings/core/v8/V8Int32Array.h" |
46 #include "bindings/core/v8/V8OESElementIndexUint.h" | 49 #include "bindings/core/v8/V8OESElementIndexUint.h" |
47 #include "bindings/core/v8/V8OESStandardDerivatives.h" | 50 #include "bindings/core/v8/V8OESStandardDerivatives.h" |
48 #include "bindings/core/v8/V8OESTextureFloat.h" | 51 #include "bindings/core/v8/V8OESTextureFloat.h" |
49 #include "bindings/core/v8/V8OESTextureFloatLinear.h" | 52 #include "bindings/core/v8/V8OESTextureFloatLinear.h" |
50 #include "bindings/core/v8/V8OESTextureHalfFloat.h" | 53 #include "bindings/core/v8/V8OESTextureHalfFloat.h" |
51 #include "bindings/core/v8/V8OESTextureHalfFloatLinear.h" | 54 #include "bindings/core/v8/V8OESTextureHalfFloatLinear.h" |
52 #include "bindings/core/v8/V8OESVertexArrayObject.h" | 55 #include "bindings/core/v8/V8OESVertexArrayObject.h" |
| 56 #include "bindings/core/v8/V8Uint32Array.h" |
| 57 #include "bindings/core/v8/V8Uint8Array.h" |
53 #include "bindings/core/v8/V8WebGLBuffer.h" | 58 #include "bindings/core/v8/V8WebGLBuffer.h" |
54 #include "bindings/core/v8/V8WebGLCompressedTextureATC.h" | 59 #include "bindings/core/v8/V8WebGLCompressedTextureATC.h" |
55 #include "bindings/core/v8/V8WebGLCompressedTextureETC1.h" | 60 #include "bindings/core/v8/V8WebGLCompressedTextureETC1.h" |
56 #include "bindings/core/v8/V8WebGLCompressedTexturePVRTC.h" | 61 #include "bindings/core/v8/V8WebGLCompressedTexturePVRTC.h" |
57 #include "bindings/core/v8/V8WebGLCompressedTextureS3TC.h" | 62 #include "bindings/core/v8/V8WebGLCompressedTextureS3TC.h" |
58 #include "bindings/core/v8/V8WebGLDebugRendererInfo.h" | 63 #include "bindings/core/v8/V8WebGLDebugRendererInfo.h" |
59 #include "bindings/core/v8/V8WebGLDebugShaders.h" | 64 #include "bindings/core/v8/V8WebGLDebugShaders.h" |
60 #include "bindings/core/v8/V8WebGLDepthTexture.h" | 65 #include "bindings/core/v8/V8WebGLDepthTexture.h" |
61 #include "bindings/core/v8/V8WebGLDrawBuffers.h" | 66 #include "bindings/core/v8/V8WebGLDrawBuffers.h" |
62 #include "bindings/core/v8/V8WebGLFramebuffer.h" | 67 #include "bindings/core/v8/V8WebGLFramebuffer.h" |
63 #include "bindings/core/v8/V8WebGLLoseContext.h" | 68 #include "bindings/core/v8/V8WebGLLoseContext.h" |
64 #include "bindings/core/v8/V8WebGLProgram.h" | 69 #include "bindings/core/v8/V8WebGLProgram.h" |
65 #include "bindings/core/v8/V8WebGLRenderbuffer.h" | 70 #include "bindings/core/v8/V8WebGLRenderbuffer.h" |
66 #include "bindings/core/v8/V8WebGLShader.h" | 71 #include "bindings/core/v8/V8WebGLShader.h" |
67 #include "bindings/core/v8/V8WebGLTexture.h" | 72 #include "bindings/core/v8/V8WebGLTexture.h" |
68 #include "bindings/core/v8/V8WebGLUniformLocation.h" | 73 #include "bindings/core/v8/V8WebGLUniformLocation.h" |
69 #include "bindings/core/v8/V8WebGLVertexArrayObjectOES.h" | 74 #include "bindings/core/v8/V8WebGLVertexArrayObjectOES.h" |
70 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" | |
71 #include "bindings/core/v8/custom/V8Float32ArrayCustom.h" | |
72 #include "bindings/core/v8/custom/V8Int16ArrayCustom.h" | |
73 #include "bindings/core/v8/custom/V8Int32ArrayCustom.h" | |
74 #include "bindings/core/v8/custom/V8Int8ArrayCustom.h" | |
75 #include "bindings/core/v8/custom/V8Uint16ArrayCustom.h" | |
76 #include "bindings/core/v8/custom/V8Uint32ArrayCustom.h" | |
77 #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" | |
78 #include "core/dom/ExceptionCode.h" | 75 #include "core/dom/ExceptionCode.h" |
79 #include "core/html/canvas/WebGLRenderingContext.h" | 76 #include "core/html/canvas/WebGLRenderingContext.h" |
80 #include "platform/NotImplemented.h" | 77 #include "platform/NotImplemented.h" |
81 #include "wtf/FastMalloc.h" | |
82 #include <limits> | |
83 | 78 |
84 namespace blink { | 79 namespace blink { |
85 | 80 |
86 static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& args, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) | 81 static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& args, v8::Handle<v8:
:Object> creationContext, v8::Isolate* isolate) |
87 { | 82 { |
88 switch (args.getType()) { | 83 switch (args.getType()) { |
89 case WebGLGetInfo::kTypeBool: | 84 case WebGLGetInfo::kTypeBool: |
90 return v8Boolean(args.getBool(), isolate); | 85 return v8Boolean(args.getBool(), isolate); |
91 case WebGLGetInfo::kTypeBoolArray: { | 86 case WebGLGetInfo::kTypeBoolArray: { |
92 const Vector<bool>& value = args.getBoolArray(); | 87 const Vector<bool>& value = args.getBoolArray(); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 exceptionState.throwIfNeeded(); | 501 exceptionState.throwIfNeeded(); |
507 return; | 502 return; |
508 } | 503 } |
509 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in
fo.GetIsolate()); | 504 location = toWebGLUniformLocation(info[uniformLocationArgumentIndex], in
fo.GetIsolate()); |
510 } | 505 } |
511 | 506 |
512 WebGLRenderingContext* context = V8WebGLRenderingContext::toImpl(info.Holder
()); | 507 WebGLRenderingContext* context = V8WebGLRenderingContext::toImpl(info.Holder
()); |
513 | 508 |
514 const int indexArrayArgument = 1; | 509 const int indexArrayArgument = 1; |
515 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate())
) { | 510 if (V8Float32Array::hasInstance(info[indexArrayArgument], info.GetIsolate())
) { |
516 Float32Array* array = V8Float32Array::toImpl(info[indexArrayArgument]->T
oObject()); | 511 DOMFloat32Array* array = V8Float32Array::toImpl(info[indexArrayArgument]
->ToObject()); |
517 ASSERT(array); | 512 ASSERT(array); |
518 switch (functionToCall) { | 513 switch (functionToCall) { |
519 case kUniform1v: context->uniform1fv(location, array); break; | 514 case kUniform1v: context->uniform1fv(location, array); break; |
520 case kUniform2v: context->uniform2fv(location, array); break; | 515 case kUniform2v: context->uniform2fv(location, array); break; |
521 case kUniform3v: context->uniform3fv(location, array); break; | 516 case kUniform3v: context->uniform3fv(location, array); break; |
522 case kUniform4v: context->uniform4fv(location, array); break; | 517 case kUniform4v: context->uniform4fv(location, array); break; |
523 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; | 518 case kVertexAttrib1v: context->vertexAttrib1fv(index, array); break; |
524 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; | 519 case kVertexAttrib2v: context->vertexAttrib2fv(index, array); break; |
525 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; | 520 case kVertexAttrib3v: context->vertexAttrib3fv(index, array); break; |
526 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; | 521 case kVertexAttrib4v: context->vertexAttrib4fv(index, array); break; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 WebGLRenderingContext* context = V8WebGLRenderingContext::toImpl(info.Holder
()); | 572 WebGLRenderingContext* context = V8WebGLRenderingContext::toImpl(info.Holder
()); |
578 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde
x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex],
info.GetIsolate())) { | 573 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde
x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex],
info.GetIsolate())) { |
579 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); | 574 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); |
580 exceptionState.throwIfNeeded(); | 575 exceptionState.throwIfNeeded(); |
581 return; | 576 return; |
582 } | 577 } |
583 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); | 578 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); |
584 | 579 |
585 const int indexArrayArgumentIndex = 1; | 580 const int indexArrayArgumentIndex = 1; |
586 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate
())) { | 581 if (V8Int32Array::hasInstance(info[indexArrayArgumentIndex], info.GetIsolate
())) { |
587 Int32Array* array = V8Int32Array::toImpl(info[indexArrayArgumentIndex]->
ToObject()); | 582 DOMInt32Array* array = V8Int32Array::toImpl(info[indexArrayArgumentIndex
]->ToObject()); |
588 ASSERT(array); | 583 ASSERT(array); |
589 switch (functionToCall) { | 584 switch (functionToCall) { |
590 case kUniform1v: context->uniform1iv(location, array); break; | 585 case kUniform1v: context->uniform1iv(location, array); break; |
591 case kUniform2v: context->uniform2iv(location, array); break; | 586 case kUniform2v: context->uniform2iv(location, array); break; |
592 case kUniform3v: context->uniform3iv(location, array); break; | 587 case kUniform3v: context->uniform3iv(location, array); break; |
593 case kUniform4v: context->uniform4iv(location, array); break; | 588 case kUniform4v: context->uniform4iv(location, array); break; |
594 default: ASSERT_NOT_REACHED(); break; | 589 default: ASSERT_NOT_REACHED(); break; |
595 } | 590 } |
596 return; | 591 return; |
597 } | 592 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde
x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex],
info.GetIsolate())) { | 684 if (info.Length() > 0 && !isUndefinedOrNull(info[uniformLocationArgumentInde
x]) && !V8WebGLUniformLocation::hasInstance(info[uniformLocationArgumentIndex],
info.GetIsolate())) { |
690 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); | 685 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect
Type(uniformLocationArgumentIndex + 1, "WebGLUniformLocation")); |
691 exceptionState.throwIfNeeded(); | 686 exceptionState.throwIfNeeded(); |
692 return; | 687 return; |
693 } | 688 } |
694 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); | 689 WebGLUniformLocation* location = toWebGLUniformLocation(info[uniformLocation
ArgumentIndex], info.GetIsolate()); |
695 | 690 |
696 bool transpose = info[1]->BooleanValue(); | 691 bool transpose = info[1]->BooleanValue(); |
697 const int arrayArgumentIndex = 2; | 692 const int arrayArgumentIndex = 2; |
698 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate())
) { | 693 if (V8Float32Array::hasInstance(info[arrayArgumentIndex], info.GetIsolate())
) { |
699 Float32Array* array = V8Float32Array::toImpl(info[arrayArgumentIndex]->T
oObject()); | 694 DOMFloat32Array* array = V8Float32Array::toImpl(info[arrayArgumentIndex]
->ToObject()); |
700 ASSERT(array); | 695 ASSERT(array); |
701 switch (matrixSize) { | 696 switch (matrixSize) { |
702 case 2: context->uniformMatrix2fv(location, transpose, array); break; | 697 case 2: context->uniformMatrix2fv(location, transpose, array); break; |
703 case 3: context->uniformMatrix3fv(location, transpose, array); break; | 698 case 3: context->uniformMatrix3fv(location, transpose, array); break; |
704 case 4: context->uniformMatrix4fv(location, transpose, array); break; | 699 case 4: context->uniformMatrix4fv(location, transpose, array); break; |
705 default: ASSERT_NOT_REACHED(); break; | 700 default: ASSERT_NOT_REACHED(); break; |
706 } | 701 } |
707 return; | 702 return; |
708 } | 703 } |
709 | 704 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); | 759 vertexAttribAndUniformHelperf(info, kVertexAttrib3v, exceptionState); |
765 } | 760 } |
766 | 761 |
767 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) | 762 void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCall
backInfo<v8::Value>& info) |
768 { | 763 { |
769 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); | 764 ExceptionState exceptionState(ExceptionState::ExecutionContext, "vertexAttri
b4fv", "WebGLRenderingContext", info.Holder(), info.GetIsolate()); |
770 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); | 765 vertexAttribAndUniformHelperf(info, kVertexAttrib4v, exceptionState); |
771 } | 766 } |
772 | 767 |
773 } // namespace blink | 768 } // namespace blink |
OLD | NEW |