Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use piston_image instead of stb_image for decoding JPEGs #9790

Merged
merged 1 commit into from Mar 2, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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"
@@ -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"
@@ -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};

@@ -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 {
@@ -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;
@@ -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"

Some generated files are not rendered by default. Learn more.

@@ -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"
@@ -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"

Some generated files are not rendered by default. Learn more.

@@ -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]
@@ -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;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.