Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, &intValue); 2014 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, &intValue);
2014 return WebGLAny(scriptState, static_cast<unsigned>(intValue)); 2015 return WebGLAny(scriptState, static_cast<unsigned>(intValue));
2015 } 2016 }
2016 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 2017 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
2017 { 2018 {
2018 GLint uniformCount = 0; 2019 GLint uniformCount = 0;
2019 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount); 2020 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &uniformCount);
2020 2021
2021 Vector<GLint> indices(uniformCount); 2022 Vector<GLint> indices(uniformCount);
2022 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, indices.data()); 2023 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, indices.data());
2023 return WebGLAny(scriptState, DOMUint32Array::create(reinterpret_cast <GLuint*>(indices.data()), indices.size())); 2024 // FIXME: Should we consider throwing a RangeError exception instead of crashing when array alloc fails.
2025 return WebGLAny(scriptState, DOMUint32Array::deprecatedCreateOrCrash (reinterpret_cast<GLuint*>(indices.data()), indices.size()));
2024 } 2026 }
2025 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 2027 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
2026 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 2028 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
2027 { 2029 {
2028 GLint boolValue = 0; 2030 GLint boolValue = 0;
2029 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, &boolValue); 2031 webContext()->getActiveUniformBlockiv(objectOrZero(program), uniform BlockIndex, pname, &boolValue);
2030 return WebGLAny(scriptState, static_cast<bool>(boolValue)); 2032 return WebGLAny(scriptState, static_cast<bool>(boolValue));
2031 } 2033 }
2032 default: 2034 default:
2033 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in valid parameter name"); 2035 synthesizeGLError(GL_INVALID_ENUM, "getActiveUniformBlockParameter", "in valid parameter name");
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2964 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2963 { 2965 {
2964 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2966 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2965 return m_readFramebufferBinding->colorBufferFormat(); 2967 return m_readFramebufferBinding->colorBufferFormat();
2966 if (m_requestedAttributes.alpha()) 2968 if (m_requestedAttributes.alpha())
2967 return GL_RGBA; 2969 return GL_RGBA;
2968 return GL_RGB; 2970 return GL_RGB;
2969 } 2971 }
2970 2972
2971 } // namespace blink 2973 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698