mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
webgl: Validate that the texture should be power of two if the level is
greater than 1
This commit is contained in:
parent
5eb59935e3
commit
c807cab300
2 changed files with 18 additions and 4 deletions
|
@ -304,10 +304,13 @@ impl WebGLRenderingContext {
|
||||||
|
|
||||||
// If an attempt is made to call this function with no
|
// If an attempt is made to call this function with no
|
||||||
// WebGLTexture bound, an INVALID_OPERATION error is generated.
|
// WebGLTexture bound, an INVALID_OPERATION error is generated.
|
||||||
if texture.is_none() {
|
let texture = match texture {
|
||||||
|
Some(texture) => texture,
|
||||||
|
None => {
|
||||||
self.webgl_error(InvalidOperation);
|
self.webgl_error(InvalidOperation);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// GL_INVALID_ENUM is generated if data_type is not an accepted value.
|
// GL_INVALID_ENUM is generated if data_type is not an accepted value.
|
||||||
match data_type {
|
match data_type {
|
||||||
|
@ -372,6 +375,13 @@ impl WebGLRenderingContext {
|
||||||
return false;
|
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.
|
// GL_INVALID_VALUE is generated if border is not 0.
|
||||||
if border != 0 {
|
if border != 0 {
|
||||||
self.webgl_error(InvalidValue);
|
self.webgl_error(InvalidValue);
|
||||||
|
|
|
@ -227,6 +227,10 @@ impl WebGLTexture {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_power_of_two(&self) -> bool {
|
||||||
|
self.image_info_at_face(0, 0).is_power_of_two()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> {
|
pub fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> {
|
||||||
let base_image_info = self.image_info_at_face(0, first_level);
|
let base_image_info = self.image_info_at_face(0, first_level);
|
||||||
if !base_image_info.is_initialized() {
|
if !base_image_info.is_initialized() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue