Refactor validation checks for texture uploads

https://bugs.webkit.org/show_bug.cgi?id=111012

Patch by Jun Jiang <jun.a.jiang@intel.com> on 2013-03-27
Reviewed by Kenneth Russell.

Move the validation checks to the entry level of tex{Sub}Image2D, return early for invalid parameters and avoid duplicated checks.
Moreover, turn all the validation checks at the bottom level - tex{Sub}Image2DBase into assertions.

Already covered by current tests.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::copyTexSubImage2D):
(WebCore::WebGLRenderingContext::texImage2DBase):
(WebCore::WebGLRenderingContext::texImage2DImpl):
(WebCore::WebGLRenderingContext::validateTexFunc): A helper function for tex{Sub}Image2D to check input parameters.
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::texSubImage2DBase):
(WebCore::WebGLRenderingContext::texSubImage2DImpl):
(WebCore::WebGLRenderingContext::texSubImage2D):
(WebCore::WebGLRenderingContext::validateHTMLImageElement):
(WebCore::WebGLRenderingContext::validateHTMLCanvasElement):
(WebCore::WebGLRenderingContext::validateHTMLVideoElement):
* html/canvas/WebGLRenderingContext.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147042 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 078b8c80
2013-03-27 Jun Jiang <jun.a.jiang@intel.com>
Refactor validation checks for texture uploads
https://bugs.webkit.org/show_bug.cgi?id=111012
Reviewed by Kenneth Russell.
Move the validation checks to the entry level of tex{Sub}Image2D, return early for invalid parameters and avoid duplicated checks.
Moreover, turn all the validation checks at the bottom level - tex{Sub}Image2DBase into assertions.
Already covered by current tests.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::copyTexSubImage2D):
(WebCore::WebGLRenderingContext::texImage2DBase):
(WebCore::WebGLRenderingContext::texImage2DImpl):
(WebCore::WebGLRenderingContext::validateTexFunc): A helper function for tex{Sub}Image2D to check input parameters.
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::texSubImage2DBase):
(WebCore::WebGLRenderingContext::texSubImage2DImpl):
(WebCore::WebGLRenderingContext::texSubImage2D):
(WebCore::WebGLRenderingContext::validateHTMLImageElement):
(WebCore::WebGLRenderingContext::validateHTMLCanvasElement):
(WebCore::WebGLRenderingContext::validateHTMLVideoElement):
* html/canvas/WebGLRenderingContext.h:
2013-03-27 Arnaud Renevier <a.renevier@sisa.samsung.com>
remove parentsOnly variable in codeGenerator.pm
......@@ -607,6 +607,19 @@ public:
TexSubImage2D,
};
enum TexFuncValidationSourceType {
SourceArrayBufferView,
SourceImageData,
SourceHTMLImageElement,
SourceHTMLCanvasElement,
SourceHTMLVideoElement,
};
// Helper function for tex{Sub}Image2D to check if the input format/type/level/target/width/height/border/xoffset/yoffset are valid.
// Otherwise, it would return quickly without doing other work.
bool validateTexFunc(const char* functionName, TexFuncValidationFunctionType, TexFuncValidationSourceType, GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width,
GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, GC3Dint xoffset, GC3Dint yoffset);
// Helper function to check input parameters for functions {copy}Tex{Sub}Image.
// Generates GL error and returns false if parameters are invalid.
bool validateTexFuncParameters(const char* functionName,
......@@ -698,8 +711,16 @@ public:
// Return the current bound buffer to target, or 0 if parameters are invalid.
WebGLBuffer* validateBufferDataParameters(const char* functionName, GC3Denum target, GC3Denum usage);
// Helper function for tex{Sub}Image2D to make sure image is ready.
bool validateHTMLImageElement(const char* functionName, HTMLImageElement*);
// Helper function for tex{Sub}Image2D to make sure image is ready and wouldn't taint Origin.
bool validateHTMLImageElement(const char* functionName, HTMLImageElement*, ExceptionCode&);
// Helper function for tex{Sub}Image2D to make sure canvas is ready and wouldn't taint Origin.
bool validateHTMLCanvasElement(const char* functionName, HTMLCanvasElement*, ExceptionCode&);
#if ENABLE(VIDEO)
// Helper function for tex{Sub}Image2D to make sure video is ready wouldn't taint Origin.
bool validateHTMLVideoElement(const char* functionName, HTMLVideoElement*, ExceptionCode&);
#endif
// Helper functions for vertexAttribNf{v}.
void vertexAttribfImpl(const char* functionName, GC3Duint index, GC3Dsizei expectedSize, GC3Dfloat, GC3Dfloat, GC3Dfloat, GC3Dfloat);
......
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