mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
GetImageData should return un-premultiplied alpha values
This commit is contained in:
parent
1b54e9c30c
commit
fee8abe5a2
37 changed files with 12 additions and 181 deletions
|
@ -901,7 +901,18 @@ impl<'a> CanvasRenderingContext2DMethods for &'a CanvasRenderingContext2D {
|
||||||
self.ipc_renderer
|
self.ipc_renderer
|
||||||
.send(CanvasMsg::Canvas2d(Canvas2dMsg::GetImageData(dest_rect, canvas_size, sender)))
|
.send(CanvasMsg::Canvas2d(Canvas2dMsg::GetImageData(dest_rect, canvas_size, sender)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let data = receiver.recv().unwrap();
|
let mut data = receiver.recv().unwrap();
|
||||||
|
|
||||||
|
// Un-premultiply alpha
|
||||||
|
// TODO: may want a precomputed un-premultiply table to make this fast.
|
||||||
|
// https://github.com/servo/servo/issues/6969
|
||||||
|
for chunk in data.chunks_mut(4) {
|
||||||
|
let alpha = chunk[3] as f32 / 255.;
|
||||||
|
chunk[0] = (chunk[0] as f32 / alpha) as u8;
|
||||||
|
chunk[1] = (chunk[1] as f32 / alpha) as u8;
|
||||||
|
chunk[2] = (chunk[2] as f32 / alpha) as u8;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), Some(data)))
|
Ok(ImageData::new(self.global.root().r(), sw.abs().to_u32().unwrap(), sh.abs().to_u32().unwrap(), Some(data)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.copy.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.copy]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.destination-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.destination-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.destination-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.destination-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.destination-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.destination-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.destination-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.destination-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.source-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.source-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.source-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.source-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.source-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.source-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.source-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.source-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.canvas.xor.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.canvas.xor]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.copy.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.copy]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.destination-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.destination-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.destination-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.destination-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.destination-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.destination-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.destination-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.destination-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.source-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.source-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.source-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.source-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.source-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.source-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.source-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.source-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.image.xor.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.image.xor]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.copy.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.copy]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.destination-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.destination-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.destination-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.destination-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.destination-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.destination-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.destination-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.destination-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.source-atop.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.source-atop]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.source-in.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.source-in]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.source-out.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.source-out]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.source-over.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.source-over]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.composite.transparent.xor.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.composite.transparent.xor]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.fillStyle.parse.hsla-1.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.fillStyle.parse.hsla-1]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.fillStyle.parse.rgba-num-1.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.fillStyle.parse.rgba-num-1]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.fillStyle.parse.rgba-num-2.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.fillStyle.parse.rgba-num-2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.fillStyle.parse.rgba-percent.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.fillStyle.parse.rgba-percent]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.gradient.interpolate.colouralpha.html]
|
|
||||||
type: testharness
|
|
||||||
[Canvas test: 2d.gradient.interpolate.colouralpha]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[2d.imageData.get.nonpremul.html]
|
|
||||||
type: testharness
|
|
||||||
[getImageData() returns non-premultiplied colours]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue