Merge some byte swap/premultiply functions in their own crate

This commit is contained in:
Anthony Ramine 2018-10-06 00:40:48 +02:00
parent a2e3dd4e86
commit 784fbb2bc1
18 changed files with 85 additions and 96 deletions

View file

@ -24,6 +24,7 @@ ipc-channel = "0.11"
log = "0.4"
num-traits = "0.2"
offscreen_gl_context = {version = "0.21", features = ["serde", "osmesa"]}
pixels = {path = "../pixels"}
serde_bytes = "0.10"
servo_config = {path = "../config"}
webrender = {git = "https://github.com/servo/webrender"}

View file

@ -7,6 +7,7 @@ use canvas_data::*;
use canvas_traits::canvas::*;
use euclid::Size2D;
use ipc_channel::ipc::{self, IpcSender};
use pixels;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::thread;
@ -141,7 +142,7 @@ impl<'a> CanvasPaintThread <'a> {
let data = match imagedata {
None => vec![0; image_size.width as usize * image_size.height as usize * 4],
Some(mut data) => {
byte_swap(&mut data);
pixels::byte_swap_colors_inplace(&mut data);
data.into()
},
};

View file

@ -15,6 +15,7 @@ extern crate ipc_channel;
#[macro_use] extern crate log;
extern crate num_traits;
extern crate offscreen_gl_context;
extern crate pixels;
extern crate serde_bytes;
extern crate servo_config;
extern crate webrender;

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use canvas_traits::canvas::byte_swap;
use canvas_traits::webgl::*;
use euclid::Size2D;
use fnv::FnvHashMap;
use gleam::gl;
use ipc_channel::ipc::IpcBytesSender;
use offscreen_gl_context::{GLContext, GLContextAttributes, GLLimits, NativeGLContextMethods};
use pixels;
use std::thread;
use super::gl_context::{GLContextFactory, GLContextWrapper};
use webrender;
@ -562,7 +562,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
let src_slice = &orig_pixels[src_start .. src_start + stride];
(&mut pixels[dst_start .. dst_start + stride]).clone_from_slice(&src_slice[..stride]);
}
byte_swap(&mut pixels);
pixels::byte_swap_colors_inplace(&mut pixels);
pixels
}