Commit 3a896bbd authored by qiankun.miao's avatar qiankun.miao Committed by Commit bot

Unify validation for TexImage{2D|3D}

BUG=295792
TEST=No functional changes, current conformance test covers the test.

Review URL: https://codereview.chromium.org/1543233002

Cr-Commit-Position: refs/heads/master@{#367122}
parent 164626d9
......@@ -855,23 +855,10 @@ void WebGL2RenderingContextBase::texStorage3D(GLenum target, GLsizei levels, GLe
tex->setTexStorageInfo(target, levels, internalformat, width, height, depth);
}
bool WebGL2RenderingContextBase::validateTexImage3D(const char* functionName, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type)
{
if (!validateTexFunc3DTarget(functionName, target))
return false;
if (!validateTexFuncLevel(functionName, target, level))
return false;
if (!validateTexFuncParameters(functionName, NotTexSubImage2D, target, level, internalformat, width, height, depth, border, format, type))
return false;
return true;
}
void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, DOMArrayBufferView* pixels)
{
if (isContextLost() || !validateTexImage3D("texImage3D", target, level, internalformat, width, height, depth, border, format, type)
if (isContextLost() || !validateTexFunc3DTarget("texImage3D", target)
|| !validateTexFunc("texImage3D", NotTexSubImage2D, SourceArrayBufferView, target, level, internalformat, width, height, depth, border, format, type, 0, 0, 0)
|| !validateTexFuncData("texImage3D", level, width, height, depth, format, type, pixels, NullAllowed))
return;
......@@ -884,14 +871,7 @@ void WebGL2RenderingContextBase::texImage3D(GLenum target, GLint level, GLint in
}
WebGLTexture* tex = validateTextureBinding("texImage3D", target, true);
if (!tex)
return;
if (tex->isImmutable()) {
synthesizeGLError(GL_INVALID_OPERATION, "texImage3D", "attempted to modify immutable texture");
return;
}
ASSERT(tex);
webContext()->texImage3D(target, level, convertTexInternalFormat(internalformat, type), width, height, depth, border, format, type, data);
tex->setLevelInfo(target, level, internalformat, width, height, depth, type);
}
......
......@@ -196,7 +196,6 @@ protected:
TexStorageType3D,
};
bool validateTexStorage(const char*, GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, TexStorageType);
bool validateTexImage3D(const char* functionName, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type);
bool validateTexSubImage3D(const char*, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth);
bool validateUniformBlockIndex(const char*, WebGLProgram*, GLuint);
......
......@@ -929,10 +929,10 @@ protected:
SourceImageBitmap,
};
// Helper function for tex{Sub}Image2D to check if the input format/type/level/target/width/height/border/xoffset/yoffset are valid.
// Helper function for tex{Sub}Image{2|3}D to check if the input format/type/level/target/width/height/depth/border/xoffset/yoffset/zoffset are valid.
// Otherwise, it would return quickly without doing other work.
bool validateTexFunc(const char* functionName, TexImageFunctionType, TexFuncValidationSourceType, GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset);
GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset, GLint zoffset);
// Helper function to check input width and height for functions {copy, compressed}Tex{Sub}Image.
// Generates GL error and returns false if width or height is invalid.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment