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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 case GL_RG16I: | 279 case GL_RG16I: |
280 case GL_RG32UI: | 280 case GL_RG32UI: |
281 case GL_RG32I: | 281 case GL_RG32I: |
282 case GL_RGBA8UI: | 282 case GL_RGBA8UI: |
283 case GL_RGBA8I: | 283 case GL_RGBA8I: |
284 case GL_RGB10_A2UI: | 284 case GL_RGB10_A2UI: |
285 case GL_RGBA16UI: | 285 case GL_RGBA16UI: |
286 case GL_RGBA16I: | 286 case GL_RGBA16I: |
287 case GL_RGBA32UI: | 287 case GL_RGBA32UI: |
288 case GL_RGBA32I: | 288 case GL_RGBA32I: |
289 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 289 return WebGLAny(scriptState, DOMInt32Array::deprecatedCreateOrCrash(null
ptr, 0)); |
290 case GL_R8: | 290 case GL_R8: |
291 case GL_RG8: | 291 case GL_RG8: |
292 case GL_RGB8: | 292 case GL_RGB8: |
293 case GL_RGB565: | 293 case GL_RGB565: |
294 case GL_RGBA8: | 294 case GL_RGBA8: |
295 case GL_SRGB8_ALPHA8: | 295 case GL_SRGB8_ALPHA8: |
296 case GL_RGB5_A1: | 296 case GL_RGB5_A1: |
297 case GL_RGBA4: | 297 case GL_RGBA4: |
298 case GL_RGB10_A2: | 298 case GL_RGB10_A2: |
299 case GL_DEPTH_COMPONENT16: | 299 case GL_DEPTH_COMPONENT16: |
300 case GL_DEPTH_COMPONENT24: | 300 case GL_DEPTH_COMPONENT24: |
301 case GL_DEPTH_COMPONENT32F: | 301 case GL_DEPTH_COMPONENT32F: |
302 case GL_DEPTH24_STENCIL8: | 302 case GL_DEPTH24_STENCIL8: |
303 case GL_DEPTH32F_STENCIL8: | 303 case GL_DEPTH32F_STENCIL8: |
304 case GL_STENCIL_INDEX8: | 304 case GL_STENCIL_INDEX8: |
305 break; | 305 break; |
306 default: | 306 default: |
307 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); | 307 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); |
308 return ScriptValue::createNull(scriptState); | 308 return ScriptValue::createNull(scriptState); |
309 } | 309 } |
310 | 310 |
311 switch (pname) { | 311 switch (pname) { |
312 case GL_SAMPLES: | 312 case GL_SAMPLES: |
313 { | 313 { |
314 GLint length = -1; | 314 GLint length = -1; |
315 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); | 315 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); |
316 if (length <= 0) | 316 if (length <= 0) |
317 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 317 return WebGLAny(scriptState, DOMInt32Array::deprecatedCreateOrCr
ash(nullptr, 0)); |
318 | 318 |
319 OwnPtr<GLint[]> values = adoptArrayPtr(new GLint[length]); | 319 OwnPtr<GLint[]> values = adoptArrayPtr(new GLint[length]); |
320 for (GLint ii = 0; ii < length; ++ii) | 320 for (GLint ii = 0; ii < length; ++ii) |
321 values[ii] = 0; | 321 values[ii] = 0; |
322 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); | 322 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); |
323 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); | 323 RefPtr<DOMInt32Array> valueArray = DOMInt32Array::deprecatedCreateOr
Crash(values.get(), length); |
| 324 return WebGLAny(scriptState, valueArray.release()); |
324 } | 325 } |
325 default: | 326 default: |
326 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); | 327 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); |
327 return ScriptValue::createNull(scriptState); | 328 return ScriptValue::createNull(scriptState); |
328 } | 329 } |
329 } | 330 } |
330 | 331 |
331 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLe
num>& attachments) | 332 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLe
num>& attachments) |
332 { | 333 { |
333 if (isContextLost()) | 334 if (isContextLost()) |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); | 2017 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); |
2017 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); | 2018 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); |
2018 } | 2019 } |
2019 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: | 2020 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
2020 { | 2021 { |
2021 GLint uniformCount = 0; | 2022 GLint uniformCount = 0; |
2022 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount); | 2023 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount); |
2023 | 2024 |
2024 Vector<GLint> indices(uniformCount); | 2025 Vector<GLint> indices(uniformCount); |
2025 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, indices.data()); | 2026 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, indices.data()); |
2026 return WebGLAny(scriptState, DOMUint32Array::create(reinterpret_cast
<GLuint*>(indices.data()), indices.size())); | 2027 // FIXME: Should we consider throwing a RangeError exception instead
of crashing when array alloc fails. |
| 2028 return WebGLAny(scriptState, DOMUint32Array::deprecatedCreateOrCrash
(reinterpret_cast<GLuint*>(indices.data()), indices.size())); |
2027 } | 2029 } |
2028 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: | 2030 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
2029 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: | 2031 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
2030 { | 2032 { |
2031 GLint boolValue = 0; | 2033 GLint boolValue = 0; |
2032 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &boolValue); | 2034 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &boolValue); |
2033 return WebGLAny(scriptState, static_cast<bool>(boolValue)); | 2035 return WebGLAny(scriptState, static_cast<bool>(boolValue)); |
2034 } | 2036 } |
2035 default: | 2037 default: |
2036 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); | 2038 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2967 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2966 { | 2968 { |
2967 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2969 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2968 return m_readFramebufferBinding->colorBufferFormat(); | 2970 return m_readFramebufferBinding->colorBufferFormat(); |
2969 if (m_requestedAttributes.alpha()) | 2971 if (m_requestedAttributes.alpha()) |
2970 return GL_RGBA; | 2972 return GL_RGBA; |
2971 return GL_RGB; | 2973 return GL_RGB; |
2972 } | 2974 } |
2973 | 2975 |
2974 } // namespace blink | 2976 } // namespace blink |
OLD | NEW |