diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index c1dfc58938b..934af35ad48 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -52,10 +52,6 @@ git = "https://github.com/servo/rust-azure" [dependencies.layers] git = "https://github.com/servo/rust-layers" -[dependencies.png] -git = "https://github.com/servo/rust-png" -features = [ "serde-serialization" ] - [dependencies.clipboard] git = "https://github.com/aweinstock314/rust-clipboard" @@ -72,6 +68,7 @@ features = [ "serde_serialization" ] [dependencies] app_units = "0.1" +image = "0.3.14" log = "0.3" num = "0.1.24" time = "0.1.17" diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 919f68b0bde..932c73f94bb 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -16,7 +16,8 @@ use gfx::paint_task::{ChromeToPaintMsg, PaintRequest}; use gfx_traits::color; use gleam::gl; use gleam::gl::types::{GLint, GLsizei}; -use ipc_channel::ipc; +use image::{DynamicImage, ImageFormat, RgbImage}; +use ipc_channel::ipc::{self, IpcSharedMemory}; use ipc_channel::router::ROUTER; use layers::geometry::{DevicePixel, LayerPixel}; use layers::layers::{BufferRequest, Layer, LayerBuffer, LayerBufferSet}; @@ -27,18 +28,18 @@ use layers::scene::Scene; use layout_traits::LayoutControlChan; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind}; use msg::compositor_msg::{LayerProperties, ScrollPolicy}; -use msg::constellation_msg::AnimationState; use msg::constellation_msg::Msg as ConstellationMsg; +use msg::constellation_msg::{AnimationState, Image, PixelFormat}; use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData}; use pipeline::CompositionPipeline; -use png; use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest}; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use scrolling::ScrollingTimerProxy; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::{HashMap, HashSet}; +use std::fs::File; use std::mem as std_mem; use std::rc::Rc; use std::slice::bytes::copy_memory; @@ -1521,7 +1522,7 @@ impl IOCompositor { /// for some reason. If CompositeTarget is Window or Png no image data is returned; /// in the latter case the image is written directly to a file. If CompositeTarget /// is WindowAndPng Ok(Some(png::Image)) is returned. - pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Result, ()> { + pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Result, ()> { if !self.context.is_some() { return Err(()) @@ -1573,13 +1574,19 @@ impl IOCompositor { let rv = match target { CompositeTarget::Window => None, CompositeTarget::WindowAndPng => { - Some(self.draw_png(framebuffer_ids, texture_ids, width, height)) + let img = self.draw_img(framebuffer_ids, texture_ids, width, height); + Some(Image { + width: img.width(), + height: img.height(), + format: PixelFormat::RGB8, + bytes: IpcSharedMemory::from_bytes(&*img), + }) } CompositeTarget::PngFile => { - let mut img = self.draw_png(framebuffer_ids, texture_ids, width, height); + let img = self.draw_img(framebuffer_ids, texture_ids, width, height); let path = opts::get().output_file.as_ref().unwrap(); - let res = png::store_png(&mut img, &path); - assert!(res.is_ok(), format!("Error writing png: {}", res.unwrap_err())); + let mut file = File::create(path).unwrap(); + DynamicImage::ImageRgb8(img).save(&mut file, ImageFormat::PNG).unwrap(); None } }; @@ -1596,12 +1603,12 @@ impl IOCompositor { Ok(rv) } - fn draw_png(&self, + fn draw_img(&self, framebuffer_ids: Vec, texture_ids: Vec, width: usize, height: usize) - -> png::Image { + -> RgbImage { let mut pixels = gl::read_pixels(0, 0, width as gl::GLsizei, height as gl::GLsizei, @@ -1622,11 +1629,7 @@ impl IOCompositor { copy_memory(&src_slice[..stride], &mut pixels[dst_start .. dst_start + stride]); } - png::Image { - width: width as u32, - height: height as u32, - pixels: png::PixelsByColorType::RGB8(pixels), - } + RgbImage::from_raw(width as u32, height as u32, pixels).unwrap() } fn composite_if_necessary(&mut self, reason: CompositingReason) { diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index b4388ed5132..cff97842653 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -13,8 +13,7 @@ use layers::platform::surface::{NativeDisplay, NativeSurface}; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerProperties}; use msg::compositor_msg::{PaintListener, ScriptToCompositorMsg}; use msg::constellation_msg::{AnimationState, ConstellationChan, PipelineId}; -use msg::constellation_msg::{Key, KeyModifiers, KeyState}; -use png; +use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState}; use profile_traits::mem; use profile_traits::time; use std::fmt::{Debug, Error, Formatter}; @@ -193,7 +192,7 @@ pub enum Msg { /// Changes the cursor. SetCursor(Cursor), /// Composite to a PNG file and return the Image over a passed channel. - CreatePng(IpcSender>), + CreatePng(IpcSender>), /// Informs the compositor that the paint task for the given pipeline has exited. PaintTaskExited(PipelineId), /// Alerts the compositor that the viewport has been constrained in some manner diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 1a0ea4012a3..b8d6355bee2 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -33,6 +33,7 @@ extern crate euclid; extern crate gfx; extern crate gfx_traits; extern crate gleam; +extern crate image; extern crate ipc_channel; extern crate layers; extern crate layout_traits; @@ -40,7 +41,6 @@ extern crate msg; extern crate net_traits; extern crate num; extern crate offscreen_gl_context; -extern crate png; extern crate script_traits; extern crate style_traits; extern crate time; diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index 966c7c3b732..6a67a0bc53e 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -22,10 +22,6 @@ git = "https://github.com/servo/rust-azure" [dependencies.layers] git = "https://github.com/servo/rust-layers" -[dependencies.png] -git = "https://github.com/servo/rust-png" -features = [ "serde-serialization" ] - [dependencies.hyper] version = "0.6" features = [ "serde-serialization" ] diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 857161c316d..f874a59b42e 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -11,10 +11,9 @@ use euclid::scale_factor::ScaleFactor; use euclid::size::{Size2D, TypedSize2D}; use hyper::header::Headers; use hyper::method::Method; -use ipc_channel::ipc::IpcSender; +use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use layers::geometry::DevicePixel; use offscreen_gl_context::GLContextAttributes; -use png::Image; use std::cell::Cell; use std::collections::HashMap; use std::fmt; @@ -372,7 +371,24 @@ pub enum WebDriverCommandMsg { LoadUrl(PipelineId, LoadData, IpcSender), Refresh(PipelineId, IpcSender), ScriptCommand(PipelineId, WebDriverScriptCommand), - TakeScreenshot(PipelineId, IpcSender>) + TakeScreenshot(PipelineId, IpcSender>), +} + +#[derive(Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)] +pub enum PixelFormat { + K8, // Luminance channel only + KA8, // Luminance + alpha + RGB8, // RGB, 8 bits per channel + RGBA8, // RGB + alpha, 8 bits per channel +} + +#[derive(Deserialize, Serialize, HeapSizeOf)] +pub struct Image { + pub width: u32, + pub height: u32, + pub format: PixelFormat, + #[ignore_heap_size_of = "Defined in ipc-channel"] + pub bytes: IpcSharedMemory, } /// Similar to net::resource_task::LoadData diff --git a/components/msg/lib.rs b/components/msg/lib.rs index f1d6902a39b..e5be66832f0 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -2,7 +2,7 @@ * 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/. */ -#![feature(custom_derive, plugin)] +#![feature(custom_attribute, custom_derive, plugin)] #![plugin(serde_macros, plugins)] extern crate app_units; @@ -19,7 +19,6 @@ extern crate io_surface; extern crate ipc_channel; extern crate layers; extern crate offscreen_gl_context; -extern crate png; extern crate rustc_serialize; extern crate serde; extern crate style_traits; diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 70de430d096..5ffec7acda7 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -19,10 +19,6 @@ path = "../devtools_traits" [dependencies.plugins] path = "../plugins" -[dependencies.png] -git = "https://github.com/servo/rust-png" -features = [ "serde-serialization" ] - [dependencies.hyper] version = "0.6" features = [ "serde-serialization" ] diff --git a/components/net/lib.rs b/components/net/lib.rs index 7fd1bf3c0be..d09d28fa5ba 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -21,7 +21,6 @@ extern crate hyper; extern crate ipc_channel; extern crate net_traits; extern crate openssl; -extern crate png; extern crate rustc_serialize; extern crate time; extern crate url; diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs index fd6ee5620a0..853fb0556ca 100644 --- a/components/net_traits/image/base.rs +++ b/components/net_traits/image/base.rs @@ -5,30 +5,13 @@ use ipc_channel::ipc::IpcSharedMemory; use piston_image::{self, DynamicImage, GenericImage}; use stb_image::image as stb_image2; -use std::error::Error; -use util::mem::HeapSizeOf; use util::vec::byte_swap; +pub use msg::constellation_msg::{Image, PixelFormat}; + // FIXME: Images must not be copied every frame. Instead we should atomically // reference count them. -#[derive(Deserialize, Serialize, HeapSizeOf)] -pub enum PixelFormat { - K8, // Luminance channel only - KA8, // Luminance + alpha - RGB8, // RGB, 8 bits per channel - RGBA8, // RGB + alpha, 8 bits per channel -} - -#[derive(Deserialize, Serialize, HeapSizeOf)] -pub struct Image { - pub width: u32, - pub height: u32, - pub format: PixelFormat, - #[ignore_heap_size_of = "Defined in ipc-channel"] - pub bytes: IpcSharedMemory, -} - // TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this. fn byte_swap_and_premultiply(data: &mut [u8]) { let length = data.len(); diff --git a/components/net_traits/image_cache_task.rs b/components/net_traits/image_cache_task.rs index 52a40b3111d..5eab6e1d800 100644 --- a/components/net_traits/image_cache_task.rs +++ b/components/net_traits/image_cache_task.rs @@ -2,8 +2,8 @@ * 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 image::base::Image; use ipc_channel::ipc::{self, IpcSender}; +use msg::constellation_msg::Image; use std::sync::Arc; use url::Url; use util::mem::HeapSizeOf; diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 916d5316ee1..81316af0056 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -15,6 +15,7 @@ dependencies = [ "gfx_tests 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_app 0.0.1", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "layout 0.0.1", "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -22,7 +23,6 @@ dependencies = [ "net 0.0.1", "net_tests 0.0.1", "net_traits 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile 0.0.1", "profile_traits 0.0.1", "script 0.0.1", @@ -260,6 +260,7 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "layout_traits 0.0.1", @@ -269,7 +270,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", "script_traits 0.0.1", "style_traits 0.0.1", @@ -1164,7 +1164,6 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1187,7 +1186,6 @@ dependencies = [ "net_traits 0.0.1", "openssl 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1380,18 +1378,6 @@ dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png" -version = "0.1.0" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "gcc 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "png-sys 1.6.16 (git+https://github.com/servo/rust-png)", - "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "png" version = "0.3.1" @@ -1403,14 +1389,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png-sys" -version = "1.6.16" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "profile" version = "0.0.1" @@ -2011,11 +1989,11 @@ name = "webdriver_server" version = "0.0.1" dependencies = [ "hyper 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 6ced02d7d45..53cb92be4d1 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -16,6 +16,9 @@ test = false doc = false bench = false +[dev-dependencies] +image = "0.3.14" + [dev-dependencies.gfx_tests] path = "../../tests/unit/gfx" @@ -36,10 +39,6 @@ name = "reftest" path = "../../tests/reftest.rs" harness = false -[dependencies.png] -git = "https://github.com/servo/rust-png" -features = [ "serde-serialization" ] - [features] default = ["glutin_app", "window", "webdriver"] window = ["glutin_app/window"] diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml index 684781882d8..de64abc12ed 100644 --- a/components/webdriver_server/Cargo.toml +++ b/components/webdriver_server/Cargo.toml @@ -19,10 +19,6 @@ path = "../util" [dependencies.webdriver] git = "https://github.com/jgraham/webdriver-rust.git" -[dependencies.png] -git = "https://github.com/servo/rust-png" -features = [ "serde-serialization" ] - [dependencies.ipc-channel] git = "https://github.com/pcwalton/ipc-channel" @@ -31,6 +27,7 @@ version = "0.2" features = [ "serde_serialization" ] [dependencies] +image = "0.3.14" log = "0.3" hyper = "0.6" rustc-serialize = "0.3.4" diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index c00f36c070a..2dd240df887 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -11,9 +11,9 @@ #[macro_use] extern crate log; extern crate hyper; +extern crate image; extern crate ipc_channel; extern crate msg; -extern crate png; extern crate regex; extern crate rustc_serialize; extern crate url; @@ -22,10 +22,11 @@ extern crate uuid; extern crate webdriver; use hyper::method::Method::{self, Post}; +use image::{DynamicImage, ImageFormat, RgbImage}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, FrameId, LoadData, PipelineId}; -use msg::constellation_msg::{NavigationDirection, WebDriverCommandMsg}; +use msg::constellation_msg::{NavigationDirection, PixelFormat, WebDriverCommandMsg}; use msg::webdriver_msg::{LoadStatus, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverScriptCommand}; use regex::Captures; use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64}; @@ -615,24 +616,26 @@ impl Handler { sleep_ms(interval) } - let mut img = match img { + let img = match img { Some(img) => img, None => return Err(WebDriverError::new(ErrorStatus::Timeout, "Taking screenshot timed out")), }; - let img_vec = match png::to_vec(&mut img) { - Ok(x) => x, - Err(_) => return Err(WebDriverError::new(ErrorStatus::UnknownError, - "Taking screenshot failed")) - }; + // The compositor always sends RGB pixels. + assert!(img.format == PixelFormat::RGB8, "Unexpected screenshot pixel format"); + let rgb = RgbImage::from_raw(img.width, img.height, img.bytes.to_vec()).unwrap(); + + let mut png_data = Vec::new(); + DynamicImage::ImageRgb8(rgb).save(&mut png_data, ImageFormat::PNG).unwrap(); + let config = Config { char_set: CharacterSet::Standard, newline: Newline::LF, pad: true, line_length: None }; - let encoded = img_vec.to_base64(config); + let encoded = png_data.to_base64(config); Ok(WebDriverResponse::Generic(ValueResponse::new(encoded.to_json()))) } diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index f8d9f30c099..6e9d864d59f 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -251,6 +251,7 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "layout_traits 0.0.1", @@ -260,7 +261,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", "script_traits 0.0.1", "style_traits 0.0.1", @@ -1114,7 +1114,6 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1137,7 +1136,6 @@ dependencies = [ "net_traits 0.0.1", "openssl 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1314,18 +1312,6 @@ dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png" -version = "0.1.0" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "gcc 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "png-sys 1.6.16 (git+https://github.com/servo/rust-png)", - "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "png" version = "0.3.1" @@ -1337,14 +1323,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png-sys" -version = "1.6.16" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "profile" version = "0.0.1" @@ -1581,7 +1559,6 @@ dependencies = [ "msg 0.0.1", "net 0.0.1", "net_traits 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile 0.0.1", "profile_traits 0.0.1", "script 0.0.1", @@ -1942,11 +1919,11 @@ name = "webdriver_server" version = "0.0.1" dependencies = [ "hyper 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 17ca79a1cdd..2d5cfde9476 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -222,6 +222,7 @@ dependencies = [ "gfx 0.0.1", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "image 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "layout_traits 0.0.1", @@ -231,7 +232,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile_traits 0.0.1", "script_traits 0.0.1", "style_traits 0.0.1", @@ -985,7 +985,6 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1008,7 +1007,6 @@ dependencies = [ "net_traits 0.0.1", "openssl 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1176,18 +1174,6 @@ dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png" -version = "0.1.0" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "gcc 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "png-sys 1.6.16 (git+https://github.com/servo/rust-png)", - "serde 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "png" version = "0.3.1" @@ -1199,14 +1185,6 @@ dependencies = [ "num 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "png-sys" -version = "1.6.16" -source = "git+https://github.com/servo/rust-png#b8c2bf074719e5a39b9e4423989f5f06fa79317d" -dependencies = [ - "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "profile" version = "0.0.1" @@ -1442,7 +1420,6 @@ dependencies = [ "msg 0.0.1", "net 0.0.1", "net_traits 0.0.1", - "png 0.1.0 (git+https://github.com/servo/rust-png)", "profile 0.0.1", "profile_traits 0.0.1", "script 0.0.1", diff --git a/python/tidy.py b/python/tidy.py index 9b09c0fd9bf..db4aecbf163 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -151,8 +151,7 @@ def check_lock(file_name, contents): packages = {} # package names to be neglected (as named by cargo) - # - `png` is used by PistonDevelopers/image-png and servo/rust-png - exceptions = ["glutin", "wayland-kbd", "png"] + exceptions = ["glutin", "wayland-kbd"] while idx < len(contents): content = contents[idx].strip() diff --git a/tests/reftest.rs b/tests/reftest.rs index d0ba3246912..bb07d521b99 100644 --- a/tests/reftest.rs +++ b/tests/reftest.rs @@ -13,11 +13,12 @@ #![feature(test)] #[macro_use] extern crate bitflags; -extern crate png; +extern crate image; extern crate test; extern crate url; extern crate util; +use image::{DynamicImage, GenericImage, ImageFormat, RgbImage}; use std::env; use std::ffi::OsStr; use std::fs::{PathExt, File, walk_dir}; @@ -334,12 +335,12 @@ fn capture(reftest: &Reftest, side: usize) -> (u32, u32, Vec) { assert!(exit_status.success()); - let image = png::load_png(&png_filename).unwrap(); - let rgba8_bytes = match image.pixels { - png::PixelsByColorType::RGBA8(pixels) => pixels, + let image = match image::open(&png_filename) { + Ok(DynamicImage::ImageRgb8(image)) => image, + Ok(image) => image.to_rgb(), _ => panic!(), }; - (image.width, image.height, rgba8_bytes) + (image.width(), image.height(), image.into_raw()) } fn servo_path() -> PathBuf { @@ -379,14 +380,9 @@ fn check_reftest(reftest: Reftest) { if pixels.iter().any(|&a| a < 255) { let output = format!("/tmp/servo-reftest-{:06}-diff.png", reftest.id); - - let mut img = png::Image { - width: left_width, - height: left_height, - pixels: png::PixelsByColorType::RGBA8(pixels), - }; - let res = png::store_png(&mut img, &output); - assert!(res.is_ok()); + let mut file = File::create(&output).unwrap(); + let img_buf = RgbImage::from_raw(left_width, left_height, pixels).expect("foo"); + DynamicImage::ImageRgb8(img_buf).save(&mut file, ImageFormat::PNG).unwrap(); match (reftest.kind, reftest.is_flaky) { (ReftestKind::Same, true) => println!("flaky test - rendering difference: {}", output),