Skip to content

Commit

Permalink
Use piston_image instead of stb_image for decoding JPEGs
Browse files Browse the repository at this point in the history
Bump image to 0.7
  • Loading branch information
kaksmet committed Mar 2, 2016
1 parent 62814f7 commit 8c07a1a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 95 deletions.
2 changes: 1 addition & 1 deletion components/compositing/Cargo.toml
Expand Up @@ -91,7 +91,7 @@ git = "https://github.com/servo/webrender"
app_units = {version = "0.2.1", features = ["plugins"]}
euclid = {version = "0.6.2", features = ["plugins"]}
gleam = "0.2"
image = "0.5.0"
image = "0.7"
log = "0.3"
num = "0.1.24"
serde = "0.6"
Expand Down
3 changes: 1 addition & 2 deletions components/net_traits/Cargo.toml
Expand Up @@ -23,10 +23,9 @@ path = "../plugins"
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
image = "0.7"
log = "0.3"
serde = "0.6"
serde_macros = "0.6"
stb_image = "0.2"
url = {version = "0.5.5", features = ["heap_size"]}
websocket = "0.15.0"
38 changes: 1 addition & 37 deletions components/net_traits/image/base.rs
Expand Up @@ -4,9 +4,7 @@

use ipc_channel::ipc::IpcSharedMemory;
use piston_image::{self, DynamicImage, GenericImage, ImageFormat};
use stb_image::image as stb_image2;
use util::opts;
use util::vec::byte_swap;

pub use msg::constellation_msg::{Image, ImageMetadata, PixelFormat};

Expand Down Expand Up @@ -49,41 +47,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
debug!("{}", msg);
None
}
Ok(ImageFormat::JPEG) => {
// For JPEG images, we use stb_image because piston_image does not yet support progressive
// JPEG.

// Can't remember why we do this. Maybe it's what cairo wants
static FORCE_DEPTH: usize = 4;

match stb_image2::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
stb_image2::LoadResult::ImageU8(mut image) => {
assert!(image.depth == 4);
// handle gif separately because the alpha-channel has to be premultiplied
if is_gif(buffer) {
byte_swap_and_premultiply(&mut image.data);
} else {
byte_swap(&mut image.data);
}
Some(Image {
width: image.width as u32,
height: image.height as u32,
format: PixelFormat::RGBA8,
bytes: IpcSharedMemory::from_bytes(&image.data[..]),
id: None,
})
}
stb_image2::LoadResult::ImageF32(_image) => {
debug!("HDR images not implemented");
None
}
stb_image2::LoadResult::Error(e) => {
debug!("stb_image failed: {}", e);
None
}
}
}
_ => {
Ok(_) => {
match piston_image::load_from_memory(buffer) {
Ok(image) => {
let mut rgba = match image {
Expand Down
1 change: 0 additions & 1 deletion components/net_traits/lib.rs
Expand Up @@ -19,7 +19,6 @@ extern crate ipc_channel;
extern crate log;
extern crate msg;
extern crate serde;
extern crate stb_image;
extern crate url;
extern crate util;
extern crate websocket;
Expand Down
2 changes: 1 addition & 1 deletion components/script/Cargo.toml
Expand Up @@ -74,7 +74,7 @@ heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
html5ever = {version = "0.5.1", features = ["heap_size", "unstable"]}
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
image = "0.7"
libc = "0.2"
log = "0.3"
num = "0.1.24"
Expand Down
47 changes: 30 additions & 17 deletions components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/servo/Cargo.toml
Expand Up @@ -18,7 +18,7 @@ doc = false
bench = false

[dev-dependencies]
image = "0.5.0"
image = "0.7"

[dev-dependencies.gfx_tests]
path = "../../tests/unit/gfx"
Expand Down
2 changes: 1 addition & 1 deletion components/webdriver_server/Cargo.toml
Expand Up @@ -26,7 +26,7 @@ git = "https://github.com/jgraham/webdriver-rust.git"
git = "https://github.com/servo/ipc-channel"

[dependencies]
image = "0.5.0"
image = "0.7"
log = "0.3"
hyper = "0.7"
rustc-serialize = "0.3.4"
Expand Down
46 changes: 29 additions & 17 deletions ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ports/cef/Cargo.toml
Expand Up @@ -13,7 +13,6 @@ euclid = {version = "0.6.2", features = ["plugins"]}
gleam = "0.2"
libc = "0.2"
log = "0.3"
stb_image = "0.2"
url = {version = "0.5.5", features = ["heap_size"]}

[dependencies.servo]
Expand Down
1 change: 0 additions & 1 deletion ports/cef/lib.rs
Expand Up @@ -40,7 +40,6 @@ extern crate msg;
extern crate util;
extern crate style;
extern crate style_traits;
extern crate stb_image;

extern crate libc;
extern crate url as std_url;
Expand Down

0 comments on commit 8c07a1a

Please sign in to comment.