OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/webgl/WebGL2RenderingContextBase.h" | 6 #include "modules/webgl/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/modules/v8/WebGLAny.h" | 8 #include "bindings/modules/v8/WebGLAny.h" |
9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
11 #include "core/html/HTMLVideoElement.h" | 11 #include "core/html/HTMLVideoElement.h" |
12 #include "core/html/ImageData.h" | 12 #include "core/html/ImageData.h" |
13 #include "modules/webgl/WebGLActiveInfo.h" | 13 #include "modules/webgl/WebGLActiveInfo.h" |
14 #include "modules/webgl/WebGLBuffer.h" | 14 #include "modules/webgl/WebGLBuffer.h" |
15 #include "modules/webgl/WebGLFenceSync.h" | 15 #include "modules/webgl/WebGLFenceSync.h" |
16 #include "modules/webgl/WebGLFramebuffer.h" | 16 #include "modules/webgl/WebGLFramebuffer.h" |
17 #include "modules/webgl/WebGLProgram.h" | 17 #include "modules/webgl/WebGLProgram.h" |
18 #include "modules/webgl/WebGLQuery.h" | 18 #include "modules/webgl/WebGLQuery.h" |
19 #include "modules/webgl/WebGLRenderbuffer.h" | 19 #include "modules/webgl/WebGLRenderbuffer.h" |
20 #include "modules/webgl/WebGLSampler.h" | 20 #include "modules/webgl/WebGLSampler.h" |
21 #include "modules/webgl/WebGLSync.h" | 21 #include "modules/webgl/WebGLSync.h" |
22 #include "modules/webgl/WebGLTexture.h" | 22 #include "modules/webgl/WebGLTexture.h" |
23 #include "modules/webgl/WebGLTransformFeedback.h" | 23 #include "modules/webgl/WebGLTransformFeedback.h" |
24 #include "modules/webgl/WebGLUniformLocation.h" | 24 #include "modules/webgl/WebGLUniformLocation.h" |
25 #include "modules/webgl/WebGLVertexArrayObject.h" | 25 #include "modules/webgl/WebGLVertexArrayObject.h" |
26 | |
27 #include "platform/NotImplemented.h" | 26 #include "platform/NotImplemented.h" |
| 27 #include "wtf/OwnPtr.h" |
| 28 #include "wtf/PassOwnPtr.h" |
28 | 29 |
29 namespace blink { | 30 namespace blink { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 WGC3Dsync syncObjectOrZero(const WebGLSync* object) | 34 WGC3Dsync syncObjectOrZero(const WebGLSync* object) |
34 { | 35 { |
35 return object ? object->object() : 0; | 36 return object ? object->object() : 0; |
36 } | 37 } |
37 | 38 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return ScriptValue::createNull(scriptState); | 170 return ScriptValue::createNull(scriptState); |
170 | 171 |
171 switch (pname) { | 172 switch (pname) { |
172 case GL_SAMPLES: | 173 case GL_SAMPLES: |
173 { | 174 { |
174 GLint length = -1; | 175 GLint length = -1; |
175 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); | 176 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); |
176 if (length <= 0) | 177 if (length <= 0) |
177 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 178 return WebGLAny(scriptState, DOMInt32Array::create(0)); |
178 | 179 |
179 scoped_ptr<GLint[]> values(new GLint[length]); | 180 OwnPtr<GLint[]> values = adoptArrayPtr(new GLint[length]); |
180 for (GLint ii = 0; ii < length; ++ii) | 181 for (GLint ii = 0; ii < length; ++ii) |
181 values[ii] = 0; | 182 values[ii] = 0; |
182 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); | 183 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); |
183 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); | 184 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); |
184 } | 185 } |
185 default: | 186 default: |
186 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); | 187 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); |
187 return ScriptValue::createNull(scriptState); | 188 return ScriptValue::createNull(scriptState); |
188 } | 189 } |
189 } | 190 } |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", pro
gram)) | 1777 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", pro
gram)) |
1777 return String(); | 1778 return String(); |
1778 | 1779 |
1779 GLint maxNameLength = -1; | 1780 GLint maxNameLength = -1; |
1780 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MA
X_NAME_LENGTH, &maxNameLength); | 1781 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MA
X_NAME_LENGTH, &maxNameLength); |
1781 if (maxNameLength <= 0) { | 1782 if (maxNameLength <= 0) { |
1782 // This state indicates that there are no active uniform blocks | 1783 // This state indicates that there are no active uniform blocks |
1783 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); | 1784 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); |
1784 return String(); | 1785 return String(); |
1785 } | 1786 } |
1786 scoped_ptr<GLchar[]> name(new GLchar[maxNameLength]); | 1787 OwnPtr<GLchar[]> name = adoptArrayPtr(new GLchar[maxNameLength]); |
1787 GLsizei length; | 1788 GLsizei length; |
1788 webContext()->getActiveUniformBlockName(objectOrZero(program), uniformBlockI
ndex, maxNameLength, &length, name.get()); | 1789 webContext()->getActiveUniformBlockName(objectOrZero(program), uniformBlockI
ndex, maxNameLength, &length, name.get()); |
1789 return String(name.get(), length); | 1790 return String(name.get(), length); |
1790 } | 1791 } |
1791 | 1792 |
1792 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) | 1793 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) |
1793 { | 1794 { |
1794 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) | 1795 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) |
1795 return; | 1796 return; |
1796 | 1797 |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2546 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2546 { | 2547 { |
2547 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2548 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2548 return m_readFramebufferBinding->colorBufferFormat(); | 2549 return m_readFramebufferBinding->colorBufferFormat(); |
2549 if (m_requestedAttributes.alpha()) | 2550 if (m_requestedAttributes.alpha()) |
2550 return GL_RGBA; | 2551 return GL_RGBA; |
2551 return GL_RGB; | 2552 return GL_RGB; |
2552 } | 2553 } |
2553 | 2554 |
2554 } // namespace blink | 2555 } // namespace blink |
OLD | NEW |