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

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

Issue 1414853008: Validate pixel data array is enough for request by texImage3D and texSubImage3D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 660
661 if (!validateTexFuncFormatAndType(functionName, internalformat, format, type , level)) 661 if (!validateTexFuncFormatAndType(functionName, internalformat, format, type , level))
662 return false; 662 return false;
663 663
664 return true; 664 return true;
665 } 665 }
666 666
667 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, DOMArrayBufferView* pixels) 667 void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in ternalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, DOMArrayBufferView* pixels)
668 { 668 {
669 if (isContextLost() || !validateTexImage3D("texImage3D", target, level, inte rnalformat, format, type) 669 if (isContextLost() || !validateTexImage3D("texImage3D", target, level, inte rnalformat, format, type)
670 || !validateTexFuncData("texImage3D", level, width, height, format, type , pixels, NullAllowed)) 670 || !validateTexFuncData("texImage3D", level, width, height, depth, forma t, type, pixels, NullAllowed))
671 return; 671 return;
672 672
673 void* data = pixels ? pixels->baseAddress() : 0; 673 void* data = pixels ? pixels->baseAddress() : 0;
674 Vector<uint8_t> tempData; 674 Vector<uint8_t> tempData;
675 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { 675 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
676 // FIXME: WebGLImageConversion needs to be updated to accept image depth . 676 // FIXME: WebGLImageConversion needs to be updated to accept image depth .
677 notImplemented(); 677 notImplemented();
678 return; 678 return;
679 } 679 }
680 680
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (m_unpackAlignment != 1) 764 if (m_unpackAlignment != 1)
765 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); 765 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1);
766 webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, imageE xtractor.imageWidth(), imageExtractor.imageHeight(), 1, format, type, needConver sion ? data.data() : imagePixelData); 766 webContext()->texSubImage3D(target, level, xoffset, yoffset, zoffset, imageE xtractor.imageWidth(), imageExtractor.imageHeight(), 1, format, type, needConver sion ? data.data() : imagePixelData);
767 if (m_unpackAlignment != 1) 767 if (m_unpackAlignment != 1)
768 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 768 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
769 } 769 }
770 770
771 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei d epth, GLenum format, GLenum type, DOMArrayBufferView* pixels) 771 void WebGL2RenderingContextBase::texSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei d epth, GLenum format, GLenum type, DOMArrayBufferView* pixels)
772 { 772 {
773 if (isContextLost() || !pixels || !validateTexSubImage3D("texSubImage3D", ta rget, level, xoffset, yoffset, zoffset, format, type, width, height, depth) 773 if (isContextLost() || !pixels || !validateTexSubImage3D("texSubImage3D", ta rget, level, xoffset, yoffset, zoffset, format, type, width, height, depth)
774 || !validateTexFuncData("texSubImage3D", level, width, height, format, t ype, pixels, NullAllowed)) 774 || !validateTexFuncData("texSubImage3D", level, width, height, depth, fo rmat, type, pixels, NullAllowed))
775 return; 775 return;
776 776
777 // FIXME: Ensure pixels is large enough to contain the desired texture dimen sions. 777 // FIXME: Ensure pixels is large enough to contain the desired texture dimen sions.
778 778
779 void* data = pixels->baseAddress(); 779 void* data = pixels->baseAddress();
780 Vector<uint8_t> tempData; 780 Vector<uint8_t> tempData;
781 bool changeUnpackAlignment = false; 781 bool changeUnpackAlignment = false;
782 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { 782 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
783 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, 783 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e,
784 m_unpackAlignment, 784 m_unpackAlignment,
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 3082 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
3083 { 3083 {
3084 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 3084 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
3085 return m_readFramebufferBinding->colorBufferFormat(); 3085 return m_readFramebufferBinding->colorBufferFormat();
3086 if (m_requestedAttributes.alpha()) 3086 if (m_requestedAttributes.alpha())
3087 return GL_RGBA; 3087 return GL_RGBA;
3088 return GL_RGB; 3088 return GL_RGB;
3089 } 3089 }
3090 3090
3091 } // namespace blink 3091 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698