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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2370703003: Validate internalformat/format/type for uploading DOM elements to texture (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 70d9cf301bc3dc51a20b8a18a76ffbd420f4fdeb..9c62a0bbb631bd5bf5885ae1a43c7cf410299dea 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -774,6 +774,33 @@ static const GLenum kSupportedInternalFormatsTexImageES3[] = {
GL_DEPTH32F_STENCIL8,
};
+// ES3 enums supported by TexImageSource
+static const GLenum kSupportedInternalFormatsTexImageSourceES3[] = {
+ GL_R8,
+ GL_R16F,
+ GL_R32F,
+ GL_R8UI,
+ GL_RG8,
+ GL_RG16F,
+ GL_RG32F,
+ GL_RG8UI,
+ GL_RGB8,
+ GL_SRGB8,
+ GL_RGB565,
+ GL_R11F_G11F_B10F,
+ GL_RGB9_E5,
+ GL_RGB16F,
+ GL_RGB32F,
+ GL_RGB8UI,
+ GL_RGBA8,
+ GL_SRGB8_ALPHA8,
+ GL_RGB5_A1,
+ GL_RGBA4,
+ GL_RGBA16F,
+ GL_RGBA32F,
+ GL_RGBA8UI,
+};
+
// ES2 enums
static const GLenum kSupportedFormatsES2[] = {
GL_RGB,
@@ -809,6 +836,18 @@ static const GLenum kSupportedFormatsES3[] = {
GL_DEPTH_STENCIL,
};
+// ES3 enums supported by TexImageSource
+static const GLenum kSupportedFormatsTexImageSourceES3[] = {
+ GL_RED,
+ GL_RED_INTEGER,
+ GL_RG,
+ GL_RG_INTEGER,
+ GL_RGB,
+ GL_RGB_INTEGER,
+ GL_RGBA,
+ GL_RGBA_INTEGER,
+};
+
// ES2 enums
static const GLenum kSupportedTypesES2[] = {
GL_UNSIGNED_BYTE,
@@ -850,6 +889,17 @@ static const GLenum kSupportedTypesES3[] = {
GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
};
+// ES3 enums supported by TexImageSource
+static const GLenum kSupportedTypesTexImageSourceES3[] = {
+ GL_UNSIGNED_SHORT,
+ GL_SHORT,
+ GL_UNSIGNED_INT,
+ GL_INT,
+ GL_HALF_FLOAT,
+ GL_FLOAT,
+ GL_UNSIGNED_INT_10F_11F_11F_REV,
+};
+
bool isUnsignedIntegerFormat(GLenum internalformat)
{
switch (internalformat) {
@@ -4030,7 +4080,7 @@ bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexIma
if (!validateTexFuncLevel(functionName, target, level))
return false;
- if (!validateTexFuncParameters(functionName, functionType, target, level, internalformat, width, height, depth, border, format, type))
+ if (!validateTexFuncParameters(functionName, functionType, sourceType, target, level, internalformat, width, height, depth, border, format, type))
return false;
if (functionType == TexSubImage) {
@@ -5526,13 +5576,19 @@ bool WebGLRenderingContextBase::validateShaderSource(const String& string)
return true;
}
-bool WebGLRenderingContextBase::validateTexFuncFormatAndType(const char* functionName, TexImageFunctionType functionType, GLenum internalformat, GLenum format, GLenum type, GLint level)
+bool WebGLRenderingContextBase::validateTexFuncFormatAndType(const char* functionName, TexImageFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum internalformat, GLenum format, GLenum type, GLint level)
{
if (!m_isWebGL2FormatsTypesAdded && isWebGL2OrHigher()) {
- ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES3);
- ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsTexImageES3);
- ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES3);
- ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES3);
+ if (sourceType == SourceHTMLImageElement || sourceType == SourceHTMLCanvasElement || sourceType == SourceHTMLVideoElement) {
qiankun 2016/09/26 14:34:11 I am not sure should SourceImageData and SourceIma
Ken Russell (switch to Gerrit) 2016/09/26 22:19:43 Yes, the same rules apply to all of the types in t
qiankun 2016/09/27 10:22:25 I added another function WebGLRenderingContextBase
+ ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsTexImageSourceES3);
+ ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsTexImageSourceES3);
+ ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesTexImageSourceES3);
+ } else {
+ ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES3);
+ ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsTexImageES3);
+ ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES3);
+ ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES3);
+ }
m_isWebGL2FormatsTypesAdded = true;
}
@@ -5678,13 +5734,13 @@ bool WebGLRenderingContextBase::validateTexFuncDimensions(const char* functionNa
return true;
}
-bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionName, TexImageFunctionType functionType, GLenum target,
+bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionName, TexImageFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum target,
GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type)
{
// 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.
- if (!validateTexFuncFormatAndType(functionName, functionType, internalformat, format, type, level))
+ if (!validateTexFuncFormatAndType(functionName, functionType, sourceType, internalformat, format, type, level))
return false;
if (!validateTexFuncDimensions(functionName, functionType, target, level, width, height, depth))
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698