mirror of
https://github.com/servo/servo.git
synced 2025-06-10 01:23:13 +00:00
webgl: Implement component narrowing checks for CopyTexImage2D.
This commit is contained in:
parent
7e4cf13f5b
commit
778b48fa47
2 changed files with 41 additions and 11 deletions
|
@ -1928,6 +1928,47 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let framebuffer_format = match self.bound_framebuffer.get() {
|
||||||
|
Some(fb) => match fb.attachment(constants::COLOR_ATTACHMENT0) {
|
||||||
|
Some(WebGLFramebufferAttachmentRoot::Renderbuffer(rb)) => {
|
||||||
|
TexFormat::from_gl_constant(rb.internal_format())
|
||||||
|
},
|
||||||
|
Some(WebGLFramebufferAttachmentRoot::Texture(texture)) => {
|
||||||
|
texture.image_info_for_target(&target, 0).internal_format()
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
let attrs = self.GetContextAttributes().unwrap();
|
||||||
|
Some(if attrs.alpha {
|
||||||
|
TexFormat::RGBA
|
||||||
|
} else {
|
||||||
|
TexFormat::RGB
|
||||||
|
})
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let framebuffer_format = match framebuffer_format {
|
||||||
|
Some(f) => f,
|
||||||
|
None => {
|
||||||
|
self.webgl_error(InvalidOperation);
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
match (framebuffer_format, internal_format) {
|
||||||
|
(a, b) if a == b => (),
|
||||||
|
(TexFormat::RGBA, TexFormat::RGB) => (),
|
||||||
|
(TexFormat::RGBA, TexFormat::Alpha) => (),
|
||||||
|
(TexFormat::RGBA, TexFormat::Luminance) => (),
|
||||||
|
(TexFormat::RGBA, TexFormat::LuminanceAlpha) => (),
|
||||||
|
(TexFormat::RGB, TexFormat::Luminance) => (),
|
||||||
|
_ => {
|
||||||
|
self.webgl_error(InvalidOperation);
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// NB: TexImage2D depth is always equal to 1
|
// NB: TexImage2D depth is always equal to 1
|
||||||
handle_potential_webgl_error!(
|
handle_potential_webgl_error!(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[copy-tex-image-2d-formats.html]
|
|
||||||
bug: https://github.com/servo/servo/issues/20595
|
|
||||||
[WebGL test #32: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D ALPHA from RGB]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #40: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D RGBA from RGB]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #36: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D LUMINANCE_ALPHA from RGB]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue