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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 case GL_RG16I: | 326 case GL_RG16I: |
327 case GL_RG32UI: | 327 case GL_RG32UI: |
328 case GL_RG32I: | 328 case GL_RG32I: |
329 case GL_RGBA8UI: | 329 case GL_RGBA8UI: |
330 case GL_RGBA8I: | 330 case GL_RGBA8I: |
331 case GL_RGB10_A2UI: | 331 case GL_RGB10_A2UI: |
332 case GL_RGBA16UI: | 332 case GL_RGBA16UI: |
333 case GL_RGBA16I: | 333 case GL_RGBA16I: |
334 case GL_RGBA32UI: | 334 case GL_RGBA32UI: |
335 case GL_RGBA32I: | 335 case GL_RGBA32I: |
336 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 336 return WebGLAny(scriptState, DOMInt32Array::deprecatedCreateOrCrash(null
ptr, 0)); |
337 case GL_R8: | 337 case GL_R8: |
338 case GL_RG8: | 338 case GL_RG8: |
339 case GL_RGB8: | 339 case GL_RGB8: |
340 case GL_RGB565: | 340 case GL_RGB565: |
341 case GL_RGBA8: | 341 case GL_RGBA8: |
342 case GL_SRGB8_ALPHA8: | 342 case GL_SRGB8_ALPHA8: |
343 case GL_RGB5_A1: | 343 case GL_RGB5_A1: |
344 case GL_RGBA4: | 344 case GL_RGBA4: |
345 case GL_RGB10_A2: | 345 case GL_RGB10_A2: |
346 case GL_DEPTH_COMPONENT16: | 346 case GL_DEPTH_COMPONENT16: |
347 case GL_DEPTH_COMPONENT24: | 347 case GL_DEPTH_COMPONENT24: |
348 case GL_DEPTH_COMPONENT32F: | 348 case GL_DEPTH_COMPONENT32F: |
349 case GL_DEPTH24_STENCIL8: | 349 case GL_DEPTH24_STENCIL8: |
350 case GL_DEPTH32F_STENCIL8: | 350 case GL_DEPTH32F_STENCIL8: |
351 case GL_STENCIL_INDEX8: | 351 case GL_STENCIL_INDEX8: |
352 break; | 352 break; |
353 default: | 353 default: |
354 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); | 354 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d internalformat"); |
355 return ScriptValue::createNull(scriptState); | 355 return ScriptValue::createNull(scriptState); |
356 } | 356 } |
357 | 357 |
358 switch (pname) { | 358 switch (pname) { |
359 case GL_SAMPLES: | 359 case GL_SAMPLES: |
360 { | 360 { |
361 GLint length = -1; | 361 GLint length = -1; |
362 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); | 362 webContext()->getInternalformativ(target, internalformat, GL_NUM_SAM
PLE_COUNTS, 1, &length); |
363 if (length <= 0) | 363 if (length <= 0) |
364 return WebGLAny(scriptState, DOMInt32Array::create(0)); | 364 return WebGLAny(scriptState, DOMInt32Array::deprecatedCreateOrCr
ash(nullptr, 0)); |
365 | 365 |
366 OwnPtr<GLint[]> values = adoptArrayPtr(new GLint[length]); | 366 OwnPtr<GLint[]> values = adoptArrayPtr(new GLint[length]); |
367 for (GLint ii = 0; ii < length; ++ii) | 367 for (GLint ii = 0; ii < length; ++ii) |
368 values[ii] = 0; | 368 values[ii] = 0; |
369 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); | 369 webContext()->getInternalformativ(target, internalformat, GL_SAMPLES
, length, values.get()); |
370 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len
gth)); | 370 RefPtr<DOMInt32Array> valueArray = DOMInt32Array::deprecatedCreateOr
Crash(values.get(), length); |
| 371 return WebGLAny(scriptState, valueArray.release()); |
371 } | 372 } |
372 default: | 373 default: |
373 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); | 374 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali
d parameter name"); |
374 return ScriptValue::createNull(scriptState); | 375 return ScriptValue::createNull(scriptState); |
375 } | 376 } |
376 } | 377 } |
377 | 378 |
378 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLe
num>& attachments) | 379 void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLe
num>& attachments) |
379 { | 380 { |
380 if (isContextLost()) | 381 if (isContextLost()) |
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); | 2123 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &intValue); |
2123 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); | 2124 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); |
2124 } | 2125 } |
2125 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: | 2126 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
2126 { | 2127 { |
2127 GLint uniformCount = 0; | 2128 GLint uniformCount = 0; |
2128 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount); | 2129 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount); |
2129 | 2130 |
2130 Vector<GLint> indices(uniformCount); | 2131 Vector<GLint> indices(uniformCount); |
2131 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, indices.data()); | 2132 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, indices.data()); |
2132 return WebGLAny(scriptState, DOMUint32Array::create(reinterpret_cast
<GLuint*>(indices.data()), indices.size())); | 2133 // TODO(junov): crbug.com/536816 |
| 2134 // We should consider throwing a RangeError exception instead |
| 2135 // of crashing when array allocation fails. Doing so may require |
| 2136 // amending the WebGL specification. |
| 2137 return WebGLAny(scriptState, DOMUint32Array::deprecatedCreateOrCrash
(reinterpret_cast<GLuint*>(indices.data()), indices.size())); |
2133 } | 2138 } |
2134 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: | 2139 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
2135 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: | 2140 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
2136 { | 2141 { |
2137 GLint boolValue = 0; | 2142 GLint boolValue = 0; |
2138 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &boolValue); | 2143 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform
BlockIndex, pname, &boolValue); |
2139 return WebGLAny(scriptState, static_cast<bool>(boolValue)); | 2144 return WebGLAny(scriptState, static_cast<bool>(boolValue)); |
2140 } | 2145 } |
2141 default: | 2146 default: |
2142 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); | 2147 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in
valid parameter name"); |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3071 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 3076 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
3072 { | 3077 { |
3073 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 3078 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
3074 return m_readFramebufferBinding->colorBufferFormat(); | 3079 return m_readFramebufferBinding->colorBufferFormat(); |
3075 if (m_requestedAttributes.alpha()) | 3080 if (m_requestedAttributes.alpha()) |
3076 return GL_RGBA; | 3081 return GL_RGBA; |
3077 return GL_RGB; | 3082 return GL_RGB; |
3078 } | 3083 } |
3079 | 3084 |
3080 } // namespace blink | 3085 } // namespace blink |
OLD | NEW |