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