aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/gfx/Cargo.toml6
-rw-r--r--components/gfx/lib.rs2
-rw-r--r--components/gfx/paint_context.rs15
-rw-r--r--components/layout/Cargo.toml3
-rw-r--r--components/layout/display_list_builder.rs18
-rw-r--r--components/layout/lib.rs1
-rw-r--r--components/net_traits/image/base.rs52
-rw-r--r--components/script/Cargo.toml3
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs12
-rw-r--r--components/script/lib.rs1
-rw-r--r--components/servo/Cargo.lock4
-rw-r--r--ports/cef/Cargo.lock4
-rw-r--r--ports/gonk/Cargo.lock4
13 files changed, 66 insertions, 59 deletions
diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml
index 5e8cc732564..d051f4baced 100644
--- a/components/gfx/Cargo.toml
+++ b/components/gfx/Cargo.toml
@@ -38,12 +38,6 @@ git = "https://github.com/servo/rust-azure"
[dependencies.layers]
git = "https://github.com/servo/rust-layers"
-[dependencies.stb_image]
-git = "https://github.com/servo/rust-stb-image"
-
-[dependencies.png]
-git = "https://github.com/servo/rust-png"
-
[dependencies.skia]
git = "https://github.com/servo/skia"
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index b42e05375be..bc9b0b94eaf 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -25,8 +25,6 @@ extern crate fnv;
extern crate euclid;
extern crate layers;
extern crate libc;
-extern crate stb_image;
-extern crate png;
#[macro_use]
extern crate profile_traits;
extern crate script_traits;
diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs
index 6e45c5354e5..cdb4b42bbdd 100644
--- a/components/gfx/paint_context.rs
+++ b/components/gfx/paint_context.rs
@@ -30,8 +30,7 @@ use euclid::side_offsets::SideOffsets2D;
use euclid::size::Size2D;
use libc::types::common::c99::uint32_t;
use msg::compositor_msg::LayerKind;
-use net_traits::image::base::Image;
-use png::PixelsByColorType;
+use net_traits::image::base::{Image, PixelFormat};
use std::default::Default;
use std::f32;
use std::mem;
@@ -134,17 +133,17 @@ impl<'a> PaintContext<'a> {
image: Arc<Image>,
image_rendering: image_rendering::T) {
let size = Size2D::new(image.width as i32, image.height as i32);
- let (pixel_width, pixels, source_format) = match image.pixels {
- PixelsByColorType::RGBA8(ref pixels) => (4, pixels, SurfaceFormat::B8G8R8A8),
- PixelsByColorType::K8(ref pixels) => (1, pixels, SurfaceFormat::A8),
- PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
- PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
+ let (pixel_width, source_format) = match image.format {
+ PixelFormat::RGBA8 => (4, SurfaceFormat::B8G8R8A8),
+ PixelFormat::K8 => (1, SurfaceFormat::A8),
+ PixelFormat::RGB8 => panic!("RGB8 color type not supported"),
+ PixelFormat::KA8 => panic!("KA8 color type not supported"),
};
let stride = image.width * pixel_width;
self.draw_target.make_current();
let draw_target_ref = &self.draw_target;
- let azure_surface = draw_target_ref.create_source_surface_from_data(pixels,
+ let azure_surface = draw_target_ref.create_source_surface_from_data(&image.bytes,
size,
stride as i32,
source_format);
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml
index e0fa25dee0f..44f86405762 100644
--- a/components/layout/Cargo.toml
+++ b/components/layout/Cargo.toml
@@ -52,9 +52,6 @@ path = "../util"
[dependencies.selectors]
git = "https://github.com/servo/rust-selectors"
-[dependencies.png]
-git = "https://github.com/servo/rust-png"
-
[dependencies.clock_ticks]
git = "https://github.com/tomaka/clock_ticks"
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 7a6f3928aca..9f613eefa56 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -36,7 +36,7 @@ use msg::compositor_msg::{ScrollPolicy, LayerId};
use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg;
use net_traits::image_cache_task::UsePlaceholder;
-use png::{self, PixelsByColorType};
+use net_traits::image::base::{Image, PixelFormat};
use std::cmp;
use std::default::Default;
use std::iter::repeat;
@@ -50,7 +50,8 @@ use style::computed_values::{border_style, image_rendering, overflow_x, position
use style::properties::ComputedValues;
use style::properties::style_structs::Border;
use style::values::RGBA;
-use style::values::computed::{Image, LinearGradient};
+use style::values::computed;
+use style::values::computed::LinearGradient;
use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
use url::Url;
@@ -108,7 +109,7 @@ pub trait FragmentDisplayListBuilding {
fn compute_background_image_size(&self,
style: &ComputedValues,
bounds: &Rect<Au>,
- image: &png::Image)
+ image: &Image)
-> Size2D<Au>;
/// Adds the display items necessary to paint the background image of this fragment to the
@@ -363,7 +364,7 @@ impl FragmentDisplayListBuilding for Fragment {
let background = style.get_background();
match background.background_image {
None => {}
- Some(Image::LinearGradient(ref gradient)) => {
+ Some(computed::Image::LinearGradient(ref gradient)) => {
self.build_display_list_for_background_linear_gradient(display_list,
level,
absolute_bounds,
@@ -371,7 +372,7 @@ impl FragmentDisplayListBuilding for Fragment {
gradient,
style)
}
- Some(Image::Url(ref image_url)) => {
+ Some(computed::Image::Url(ref image_url)) => {
self.build_display_list_for_background_image(style,
display_list,
layout_context,
@@ -386,7 +387,7 @@ impl FragmentDisplayListBuilding for Fragment {
fn compute_background_image_size(&self,
style: &ComputedValues,
bounds: &Rect<Au>,
- image: &png::Image)
+ image: &Image)
-> Size2D<Au> {
// If `image_aspect_ratio` < `bounds_aspect_ratio`, the image is tall; otherwise, it is
// wide.
@@ -1111,10 +1112,11 @@ impl FragmentDisplayListBuilding for Fragment {
&*self.style,
Cursor::DefaultCursor),
(*clip).clone()),
- image: Arc::new(png::Image {
+ image: Arc::new(Image {
width: width as u32,
height: height as u32,
- pixels: PixelsByColorType::RGBA8(canvas_data),
+ format: PixelFormat::RGBA8,
+ bytes: canvas_data,
}),
stretch_size: stacking_relative_content_box.size,
image_rendering: image_rendering::T::Auto,
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index 01a544734de..da4dd55b5f7 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -50,7 +50,6 @@ extern crate gfx_traits;
extern crate layout_traits;
extern crate libc;
extern crate msg;
-extern crate png;
extern crate script;
extern crate script_traits;
extern crate selectors;
diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs
index 8af32f826d0..c81158e416e 100644
--- a/components/net_traits/image/base.rs
+++ b/components/net_traits/image/base.rs
@@ -4,11 +4,25 @@
use png;
use stb_image::image as stb_image2;
+use std::mem;
use util::vec::byte_swap;
// FIXME: Images must not be copied every frame. Instead we should atomically
// reference count them.
-pub type Image = png::Image;
+
+pub enum PixelFormat {
+ K8, // Luminance channel only
+ KA8, // Luminance + alpha
+ RGB8, // RGB, 8 bits per channel
+ RGBA8, // RGB + alpha, 8 bits per channel
+}
+
+pub struct Image {
+ pub width: u32,
+ pub height: u32,
+ pub format: PixelFormat,
+ pub bytes: Vec<u8>,
+}
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
fn byte_swap_and_premultiply(data: &mut [u8]) {
@@ -32,14 +46,33 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
if png::is_png(buffer) {
match png::load_png_from_memory(buffer) {
Ok(mut png_image) => {
- match png_image.pixels {
- png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data),
+ let (bytes, format) = match png_image.pixels {
+ png::PixelsByColorType::K8(ref mut data) => {
+ (data, PixelFormat::K8)
+ }
+ png::PixelsByColorType::KA8(ref mut data) => {
+ (data, PixelFormat::KA8)
+ }
+ png::PixelsByColorType::RGB8(ref mut data) => {
+ byte_swap(data);
+ (data, PixelFormat::RGB8)
+ }
png::PixelsByColorType::RGBA8(ref mut data) => {
- byte_swap_and_premultiply(data)
+ byte_swap_and_premultiply(data);
+ (data, PixelFormat::RGBA8)
}
- _ => {}
- }
- Some(png_image)
+ };
+
+ let bytes = mem::replace(bytes, Vec::new());
+
+ let image = Image {
+ width: png_image.width,
+ height: png_image.height,
+ format: format,
+ bytes: bytes,
+ };
+
+ Some(image)
}
Err(_err) => None,
}
@@ -57,10 +90,11 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
} else {
byte_swap(&mut image.data);
}
- Some(png::Image {
+ Some(Image {
width: image.width as u32,
height: image.height as u32,
- pixels: png::PixelsByColorType::RGBA8(image.data)
+ format: PixelFormat::RGBA8,
+ bytes: image.data,
})
}
stb_image2::LoadResult::ImageF32(_image) => {
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index d5ab8acd9fa..8fc3d56fa9b 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -48,9 +48,6 @@ git = "https://github.com/servo/rust-selectors"
[dependencies.js]
git = "https://github.com/servo/rust-mozjs"
-[dependencies.png]
-git = "https://github.com/servo/rust-png"
-
[dependencies.url]
version = "0.2.33"
features = ["query_encoding"]
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index af787682719..4d9ea26c6b7 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -35,7 +35,7 @@ use canvas_traits::{LineCapStyle, LineJoinStyle, CompositionOrBlending};
use canvas::canvas_paint_task::CanvasPaintTask;
use net_traits::image_cache_task::{ImageCacheChan, ImageResponse};
-use png::PixelsByColorType;
+use net_traits::image::base::PixelFormat;
use num::{Float, ToPrimitive};
use std::borrow::ToOwned;
@@ -286,11 +286,11 @@ impl CanvasRenderingContext2D {
};
let image_size = Size2D::new(img.width as f64, img.height as f64);
- let image_data = match img.pixels {
- PixelsByColorType::RGBA8(ref pixels) => pixels.to_vec(),
- PixelsByColorType::K8(_) => panic!("K8 color type not supported"),
- PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"),
- PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"),
+ let image_data = match img.format {
+ PixelFormat::RGBA8 => img.bytes.to_vec(),
+ PixelFormat::K8 => panic!("K8 color type not supported"),
+ PixelFormat::RGB8 => panic!("RGB8 color type not supported"),
+ PixelFormat::KA8 => panic!("KA8 color type not supported"),
};
return Some((image_data, image_size));
diff --git a/components/script/lib.rs b/components/script/lib.rs
index c1cdc1c02f6..6b3f5ce8c8f 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -48,7 +48,6 @@ extern crate libc;
extern crate msg;
extern crate net_traits;
extern crate num;
-extern crate png;
extern crate rustc_serialize;
extern crate time;
extern crate canvas;
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 7201c574fd8..69a62b4a394 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -431,14 +431,12 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -680,7 +678,6 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script 0.0.1",
@@ -1073,7 +1070,6 @@ dependencies = [
"num 0.1.25 (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",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 986cd8ab9aa..8dbf5e06faa 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -430,14 +430,12 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -672,7 +670,6 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script 0.0.1",
@@ -1053,7 +1050,6 @@ dependencies = [
"num 0.1.25 (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",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index d9e9d2e48c9..39c6da2277c 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -409,14 +409,12 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"skia 0.0.20130412 (git+https://github.com/servo/skia)",
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
"string_cache 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -606,7 +604,6 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"plugins 0.0.1",
- "png 0.1.0 (git+https://github.com/servo/rust-png)",
"profile_traits 0.0.1",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script 0.0.1",
@@ -961,7 +958,6 @@ dependencies = [
"num 0.1.25 (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",
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",