mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
webgl: Implement FLIP_Y_AXIS unpacking flag for TexImage, TexSubImage.
This fixes a couple of tests doing RGBA/ubyte image uploads with flipping. Other tests with flipping get their expectations changed, because some other feature is missing (premultiplication or ImageData/canvas format conversion)
This commit is contained in:
parent
73bb75989f
commit
2e6eb547a8
14 changed files with 563 additions and 1806 deletions
|
@ -471,6 +471,36 @@ impl WebGLRenderingContext {
|
||||||
return Ok(expected_byte_length);
|
return Ok(expected_byte_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Flips the pixels in the Vec on the Y axis if
|
||||||
|
/// UNPACK_FLIP_Y_WEBGL is currently enabled.
|
||||||
|
fn flip_teximage_y(&self,
|
||||||
|
pixels: Vec<u8>,
|
||||||
|
internal_format: TexFormat,
|
||||||
|
data_type: TexDataType,
|
||||||
|
width: usize,
|
||||||
|
height: usize) -> Vec<u8> {
|
||||||
|
if !self.texture_unpacking_settings.get().contains(FLIP_Y_AXIS) {
|
||||||
|
return pixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cpp = (data_type.element_size() *
|
||||||
|
internal_format.components() / data_type.components_per_element()) as usize;
|
||||||
|
|
||||||
|
let stride = width * cpp;
|
||||||
|
|
||||||
|
// This should have already been validated.
|
||||||
|
assert!(stride * height <= pixels.len());
|
||||||
|
|
||||||
|
let mut flipped = Vec::<u8>::with_capacity(pixels.len());
|
||||||
|
|
||||||
|
for y in 0..height {
|
||||||
|
let flipped_y = height - 1 - y;
|
||||||
|
flipped.extend_from_slice(&pixels[(flipped_y * stride)..((flipped_y + 1) * stride)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
flipped
|
||||||
|
}
|
||||||
|
|
||||||
fn tex_image_2d(&self,
|
fn tex_image_2d(&self,
|
||||||
texture: Root<WebGLTexture>,
|
texture: Root<WebGLTexture>,
|
||||||
target: TexImageTarget,
|
target: TexImageTarget,
|
||||||
|
@ -487,7 +517,8 @@ impl WebGLRenderingContext {
|
||||||
// TODO(emilio): premultiply here.
|
// TODO(emilio): premultiply here.
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(emilio): Flip Y axis if necessary here
|
let pixels = self.flip_teximage_y(pixels, internal_format, data_type,
|
||||||
|
width as usize, height as usize);
|
||||||
|
|
||||||
// TexImage2D depth is always equal to 1
|
// TexImage2D depth is always equal to 1
|
||||||
handle_potential_webgl_error!(self, texture.initialize(target,
|
handle_potential_webgl_error!(self, texture.initialize(target,
|
||||||
|
@ -497,7 +528,7 @@ impl WebGLRenderingContext {
|
||||||
level,
|
level,
|
||||||
Some(data_type)));
|
Some(data_type)));
|
||||||
|
|
||||||
// TODO(emilio): Invert axis, convert colorspace, premultiply alpha if requested
|
// TODO(emilio): convert colorspace, premultiply alpha if requested
|
||||||
let msg = WebGLCommand::TexImage2D(target.as_gl_constant(), level as i32,
|
let msg = WebGLCommand::TexImage2D(target.as_gl_constant(), level as i32,
|
||||||
internal_format.as_gl_constant() as i32,
|
internal_format.as_gl_constant() as i32,
|
||||||
width as i32, height as i32,
|
width as i32, height as i32,
|
||||||
|
@ -542,9 +573,10 @@ impl WebGLRenderingContext {
|
||||||
return self.webgl_error(InvalidOperation);
|
return self.webgl_error(InvalidOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(emilio): Flip Y axis if necessary here
|
let pixels = self.flip_teximage_y(pixels, format, data_type,
|
||||||
|
width as usize, height as usize);
|
||||||
|
|
||||||
// TODO(emilio): Invert axis, convert colorspace, premultiply alpha if requested
|
// TODO(emilio): convert colorspace, premultiply alpha if requested
|
||||||
let msg = WebGLCommand::TexSubImage2D(target.as_gl_constant(),
|
let msg = WebGLCommand::TexSubImage2D(target.as_gl_constant(),
|
||||||
level as i32, xoffset, yoffset,
|
level as i32, xoffset, yoffset,
|
||||||
width as i32, height as i32,
|
width as i32, height as i32,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-canvas-rgb565.html]
|
[tex-image-and-sub-image-2d-with-canvas-rgb565.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: at (0, 16) expected: 255,0,0 was 255,227,0]
|
[WebGL test #0: at (0, 16) expected: 255,0,0 was 123,227,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-canvas-rgba4444.html]
|
[tex-image-and-sub-image-2d-with-canvas-rgba4444.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: at (0, 16) expected: 255,0,0 was 255,255,0]
|
[WebGL test #0: at (0, 16) expected: 255,0,0 was 119,255,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-canvas-rgba5551.html]
|
[tex-image-and-sub-image-2d-with-canvas-rgba5551.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (0, 16) expected: 255,0,0 was 123,231,0]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 16) expected: 255,0,0 was 255,231,0]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 16) expected: 255,0,0 was 255,230,0]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[tex-image-and-sub-image-2d-with-canvas.html]
|
|
||||||
type: testharness
|
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 16) expected: 255,0,0 was 0,255,0]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-data-rgb565.html]
|
[tex-image-and-sub-image-2d-with-image-data-rgb565.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,227,0,255]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,28,255,255]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,0,0,0]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-data-rgba4444.html]
|
[tex-image-and-sub-image-2d-with-image-data-rgba4444.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,255,0,255]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,0,255,255]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-data-rgba5551.html]
|
[tex-image-and-sub-image-2d-with-image-data-rgba5551.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,231,0,255]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,24,255,255]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,25,255,255]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 0,0,0,0]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-data.html]
|
|
||||||
type: testharness
|
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (0, 0) expected: 0,255,0,255 was 255,0,0,255]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-rgb565.html]
|
[tex-image-and-sub-image-2d-with-image-rgb565.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,227,0]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 0,28,255]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-rgba4444.html]
|
[tex-image-and-sub-image-2d-with-image-rgba4444.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,255,0]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 0,0,255]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
[tex-image-and-sub-image-2d-with-image-rgba5551.html]
|
[tex-image-and-sub-image-2d-with-image-rgba5551.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,231,0]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 0,24,255]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 0,25,255]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[tex-image-and-sub-image-2d-with-image.html]
|
|
||||||
type: testharness
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 255,0,0]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #0: at (4, 4) expected: 0,255,0 was 0,0,0]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue