mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
add premultiply table for PutImageData
This commit is contained in:
parent
50b14e6670
commit
9e348e2e8e
5 changed files with 4108 additions and 15 deletions
|
@ -17,6 +17,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
|||
use ipc_channel::router::ROUTER;
|
||||
use layers::platform::surface::NativeSurface;
|
||||
use num::ToPrimitive;
|
||||
use premultiplytable::PREMULTIPLY_TABLE;
|
||||
use std::borrow::ToOwned;
|
||||
use std::mem;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
|
@ -597,11 +598,10 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
let mut src_offset = src_line;
|
||||
for _ in 0 .. dest_rect.size.width {
|
||||
// Premultiply alpha and swap RGBA -> BGRA.
|
||||
// TODO: may want a precomputed premultiply table to make this fast. (#6969)
|
||||
let alpha = imagedata[src_offset + 3] as f32 / 255.;
|
||||
dest.push((imagedata[src_offset + 2] as f32 * alpha) as u8);
|
||||
dest.push((imagedata[src_offset + 1] as f32 * alpha) as u8);
|
||||
dest.push((imagedata[src_offset + 0] as f32 * alpha) as u8);
|
||||
let alpha = imagedata[src_offset + 3] as usize;
|
||||
dest.push(PREMULTIPLY_TABLE[256 * alpha + imagedata[src_offset + 2] as usize]);
|
||||
dest.push(PREMULTIPLY_TABLE[256 * alpha + imagedata[src_offset + 1] as usize]);
|
||||
dest.push(PREMULTIPLY_TABLE[256 * alpha + imagedata[src_offset + 0] as usize]);
|
||||
dest.push(imagedata[src_offset + 3]);
|
||||
src_offset += 4;
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ extern crate offscreen_gl_context;
|
|||
extern crate util;
|
||||
|
||||
pub mod canvas_paint_task;
|
||||
mod premultiplytable;
|
||||
pub mod webgl_paint_task;
|
||||
|
|
4102
components/canvas/premultiplytable.rs
Normal file
4102
components/canvas/premultiplytable.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue