diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-04-19 13:09:06 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-04-19 13:25:44 +0200 |
commit | c807cab3001b1676a8f9c47811629f621027e8b2 (patch) | |
tree | 1f877d9d9d978810b9a17a0c259a83c0aae8b328 /components/script/dom/webglrenderingcontext.rs | |
parent | 5eb59935e3dcd1be1ebb41c8fadf449473bc28c4 (diff) | |
download | servo-c807cab3001b1676a8f9c47811629f621027e8b2.tar.gz servo-c807cab3001b1676a8f9c47811629f621027e8b2.zip |
webgl: Validate that the texture should be power of two if the level is
greater than 1
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 710b61fc162..408558d3031 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -304,10 +304,13 @@ impl WebGLRenderingContext { // If an attempt is made to call this function with no // WebGLTexture bound, an INVALID_OPERATION error is generated. - if texture.is_none() { - self.webgl_error(InvalidOperation); - return false; - } + let texture = match texture { + Some(texture) => texture, + None => { + self.webgl_error(InvalidOperation); + return false; + } + }; // GL_INVALID_ENUM is generated if data_type is not an accepted value. match data_type { @@ -372,6 +375,13 @@ impl WebGLRenderingContext { return false; } + // GL_INVALID_VALUE is generated if level is greater than zero and the + // texture and the texture is not power of two. + if level > 0 && !texture.is_power_of_two() { + self.webgl_error(InvalidValue); + return false; + } + // GL_INVALID_VALUE is generated if border is not 0. if border != 0 { self.webgl_error(InvalidValue); |