Chromium Code Reviews| Index: Source/modules/webgl/WebGLRenderingContextBase.cpp |
| diff --git a/Source/modules/webgl/WebGLRenderingContextBase.cpp b/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| index 696787cf60fa554671de79dacfc73eb0deaec480..ffbfce43ea474043a07665d3e37314a0e20b0edf 100644 |
| --- a/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| +++ b/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| @@ -1830,6 +1830,8 @@ void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu |
| { |
| if (isContextLost()) |
| return; |
| + if (!validateTexFuncLevel("copyTexImage2D", target, level)) |
| + return; |
| if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, level, internalformat, width, height, border, internalformat, GL_UNSIGNED_BYTE)) |
| return; |
| if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
| @@ -3982,6 +3984,7 @@ void WebGLRenderingContextBase::texImage2DBase(GLenum target, GLint level, GLenu |
| // All calling functions check isContextLost, so a duplicate check is not needed here. |
| // FIXME: Handle errors. |
| WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); |
| + ASSERT(validateTexFuncLevel("texImage2D", target, level)); |
| ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, level, internalformat, width, height, border, format, type)); |
| ASSERT(tex); |
| ASSERT(!isNPOTStrict() || !level || !WebGLTexture::isNPOT(width, height)); |
| @@ -4022,13 +4025,13 @@ void WebGLRenderingContextBase::texImage2DImpl(GLenum target, GLint level, GLenu |
| bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexImageFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset) |
| { |
| + if (!validateTexFuncLevel(functionName, target, level)) |
| + return false; |
| WebGLTexture* texture = validateTextureBinding(functionName, target, true); |
| if (!texture) |
| return false; |
| if (functionType == TexSubImage2D) { |
| - if (!validateTexFuncLevel(functionName, target, level)) |
| - return false; |
| if (!texture->isValid(target, level)) { |
| synthesizeGLError(GL_INVALID_OPERATION, "texSubImage2D", "no previously defined texture image"); |
| return false; |
| @@ -4116,7 +4119,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in |
| GLenum format, GLenum type, DOMArrayBufferView* pixels) |
| { |
| if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0) |
| - || !validateTexFuncData("texImage2D", level, width, height, internalformat, format, type, pixels, NullAllowed)) |
| + || !validateTexFuncData("texImage2D", level, width, height, format, type, pixels, NullAllowed)) |
| return; |
| void* data = pixels ? pixels->baseAddress() : 0; |
| Vector<uint8_t> tempData; |
| @@ -4391,6 +4394,7 @@ void WebGLRenderingContextBase::texSubImage2DBase(GLenum target, GLint level, GL |
| ASSERT_NOT_REACHED(); |
| return; |
| } |
| + ASSERT(validateTexFuncLevel("texSubImage2D", target, level)); |
| ASSERT(validateTexFuncParameters("texSubImage2D", TexSubImage2D, target, level, tex->getInternalFormat(target, level), width, height, 0, format, type)); |
| ASSERT(validateSize("texSubImage2D", xoffset, yoffset)); |
| ASSERT(validateSettableTexFormat("texSubImage2D", format)); |
| @@ -4440,9 +4444,8 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint |
| if (!texture) |
| return; |
| - GLenum internalformat = texture->getInternalFormat(target, level); |
| if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yoffset) |
| - || !validateTexFuncData("texSubImage2D", level, width, height, internalformat, format, type, pixels, NullNotAllowed)) |
| + || !validateTexFuncData("texSubImage2D", level, width, height, format, type, pixels, NullNotAllowed)) |
| return; |
| void* data = pixels->baseAddress(); |
| Vector<uint8_t> tempData; |
| @@ -5494,9 +5497,6 @@ bool WebGLRenderingContextBase::validateTexFuncDimensions(const char* functionNa |
| bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionName, TexImageFunctionType functionType, GLenum target, |
| GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type) |
| { |
| - if (!validateTexFuncLevel(functionName, target, level)) |
| - return false; |
| - |
| // We absolutely have to validate the format and type combination. |
| // The texImage2D entry points taking HTMLImage, etc. will produce |
| // temporary data based on this combination, so it must be legal. |
| @@ -5514,7 +5514,7 @@ bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionNa |
| return true; |
| } |
| -bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GLint level, GLsizei width, GLsizei height, GLenum internalformat, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition) |
|
Ken Russell (switch to Gerrit)
2015/09/01 22:52:49
It's surprising that this argument was unused. I w
qiankun
2015/09/02 09:49:07
I move formats and types validation out of validat
|
| +bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition) |
| { |
| // All calling functions check isContextLost, so a duplicate check is not needed here. |
| if (!pixels) { |