| 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" |
| (...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 GLuint WebGL2RenderingContextBase::getUniformBlockIndex(WebGLProgram* program, c
onst String& uniformBlockName) | 2309 GLuint WebGL2RenderingContextBase::getUniformBlockIndex(WebGLProgram* program, c
onst String& uniformBlockName) |
| 2310 { | 2310 { |
| 2311 if (isContextLost() || !validateWebGLObject("getUniformBlockIndex", program)
) | 2311 if (isContextLost() || !validateWebGLObject("getUniformBlockIndex", program)
) |
| 2312 return 0; | 2312 return 0; |
| 2313 if (!validateString("getUniformBlockIndex", uniformBlockName)) | 2313 if (!validateString("getUniformBlockIndex", uniformBlockName)) |
| 2314 return 0; | 2314 return 0; |
| 2315 | 2315 |
| 2316 return webContext()->getUniformBlockIndex(objectOrZero(program), uniformBloc
kName.utf8().data()); | 2316 return webContext()->getUniformBlockIndex(objectOrZero(program), uniformBloc
kName.utf8().data()); |
| 2317 } | 2317 } |
| 2318 | 2318 |
| 2319 bool WebGL2RenderingContextBase::validateUniformBlockIndex(const char* functionN
ame, WebGLProgram* program, GLuint blockIndex) | |
| 2320 { | |
| 2321 GLint activeUniformBlocks = 0; | |
| 2322 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCKS,
&activeUniformBlocks); | |
| 2323 if (blockIndex >= static_cast<GLuint>(activeUniformBlocks)) { | |
| 2324 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid uniform block
index"); | |
| 2325 return false; | |
| 2326 } | |
| 2327 return true; | |
| 2328 } | |
| 2329 | |
| 2330 ScriptValue WebGL2RenderingContextBase::getActiveUniformBlockParameter(ScriptSta
te* scriptState, WebGLProgram* program, GLuint uniformBlockIndex, GLenum pname) | 2319 ScriptValue WebGL2RenderingContextBase::getActiveUniformBlockParameter(ScriptSta
te* scriptState, WebGLProgram* program, GLuint uniformBlockIndex, GLenum pname) |
| 2331 { | 2320 { |
| 2332 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockParameter"
, program)) | 2321 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockParameter"
, program)) |
| 2333 return ScriptValue::createNull(scriptState); | 2322 return ScriptValue::createNull(scriptState); |
| 2334 | 2323 |
| 2335 if (!validateUniformBlockIndex("getActiveUniformBlockParameter", program, un
iformBlockIndex)) | |
| 2336 return ScriptValue::createNull(scriptState); | |
| 2337 | |
| 2338 switch (pname) { | 2324 switch (pname) { |
| 2339 case GL_UNIFORM_BLOCK_BINDING: | 2325 case GL_UNIFORM_BLOCK_BINDING: |
| 2340 case GL_UNIFORM_BLOCK_DATA_SIZE: | 2326 case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 2341 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: | 2327 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 2342 { | 2328 { |
| 2343 GLint intValue = 0; | 2329 GLint intValue = 0; |
| 2344 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); | 2330 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); |
| 2345 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); | 2331 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); |
| 2346 } | 2332 } |
| 2347 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: | 2333 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2364 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); | 2350 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); |
| 2365 return ScriptValue::createNull(scriptState); | 2351 return ScriptValue::createNull(scriptState); |
| 2366 } | 2352 } |
| 2367 } | 2353 } |
| 2368 | 2354 |
| 2369 String WebGL2RenderingContextBase::getActiveUniformBlockName(WebGLProgram* progr
am, GLuint uniformBlockIndex) | 2355 String WebGL2RenderingContextBase::getActiveUniformBlockName(WebGLProgram* progr
am, GLuint uniformBlockIndex) |
| 2370 { | 2356 { |
| 2371 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", pro
gram)) | 2357 if (isContextLost() || !validateWebGLObject("getActiveUniformBlockName", pro
gram)) |
| 2372 return String(); | 2358 return String(); |
| 2373 | 2359 |
| 2374 if (!validateUniformBlockIndex("getActiveUniformBlockName", program, uniform
BlockIndex)) | |
| 2375 return String(); | |
| 2376 | |
| 2377 GLint maxNameLength = -1; | 2360 GLint maxNameLength = -1; |
| 2378 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MA
X_NAME_LENGTH, &maxNameLength); | 2361 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORM_BLOCK_MA
X_NAME_LENGTH, &maxNameLength); |
| 2379 if (maxNameLength <= 0) { | 2362 if (maxNameLength <= 0) { |
| 2380 // This state indicates that there are no active uniform blocks | 2363 // This state indicates that there are no active uniform blocks |
| 2381 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); | 2364 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniformBlockName", "invali
d uniform block index"); |
| 2382 return String(); | 2365 return String(); |
| 2383 } | 2366 } |
| 2384 OwnPtr<GLchar[]> name = adoptArrayPtr(new GLchar[maxNameLength]); | 2367 OwnPtr<GLchar[]> name = adoptArrayPtr(new GLchar[maxNameLength]); |
| 2385 GLsizei length; | 2368 GLsizei length; |
| 2386 webContext()->getActiveUniformBlockName(objectOrZero(program), uniformBlockI
ndex, maxNameLength, &length, name.get()); | 2369 webContext()->getActiveUniformBlockName(objectOrZero(program), uniformBlockI
ndex, maxNameLength, &length, name.get()); |
| 2387 return String(name.get(), length); | 2370 return String(name.get(), length); |
| 2388 } | 2371 } |
| 2389 | 2372 |
| 2390 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) | 2373 void WebGL2RenderingContextBase::uniformBlockBinding(WebGLProgram* program, GLui
nt uniformBlockIndex, GLuint uniformBlockBinding) |
| 2391 { | 2374 { |
| 2392 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) | 2375 if (isContextLost() || !validateWebGLObject("uniformBlockBinding", program)) |
| 2393 return; | 2376 return; |
| 2394 | 2377 |
| 2395 if (!validateUniformBlockIndex("uniformBlockBinding", program, uniformBlockI
ndex)) | |
| 2396 return; | |
| 2397 | |
| 2398 webContext()->uniformBlockBinding(objectOrZero(program), uniformBlockIndex,
uniformBlockBinding); | 2378 webContext()->uniformBlockBinding(objectOrZero(program), uniformBlockIndex,
uniformBlockBinding); |
| 2399 } | 2379 } |
| 2400 | 2380 |
| 2401 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() | 2381 WebGLVertexArrayObject* WebGL2RenderingContextBase::createVertexArray() |
| 2402 { | 2382 { |
| 2403 if (isContextLost()) | 2383 if (isContextLost()) |
| 2404 return nullptr; | 2384 return nullptr; |
| 2405 | 2385 |
| 2406 WebGLVertexArrayObject* o = WebGLVertexArrayObject::create(this, WebGLVertex
ArrayObjectBase::VaoTypeUser); | 2386 WebGLVertexArrayObject* o = WebGLVertexArrayObject::create(this, WebGLVertex
ArrayObjectBase::VaoTypeUser); |
| 2407 addContextObject(o); | 2387 addContextObject(o); |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3279 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
| 3300 { | 3280 { |
| 3301 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3281 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
| 3302 return m_readFramebufferBinding->colorBufferFormat(); | 3282 return m_readFramebufferBinding->colorBufferFormat(); |
| 3303 if (m_requestedAttributes.alpha()) | 3283 if (m_requestedAttributes.alpha()) |
| 3304 return GL_RGBA; | 3284 return GL_RGBA; |
| 3305 return GL_RGB; | 3285 return GL_RGB; |
| 3306 } | 3286 } |
| 3307 | 3287 |
| 3308 } // namespace blink | 3288 } // namespace blink |
| OLD | NEW |