Skip to content

Commit

Permalink
Move Image and PixelFormat to net_traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Oct 21, 2016
1 parent e3ebbd0 commit dce2872
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 32 deletions.
3 changes: 2 additions & 1 deletion components/compositing/compositor.rs
Expand Up @@ -18,9 +18,10 @@ use gleam::gl::types::{GLint, GLsizei};
use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
use ipc_channel::router::ROUTER;
use msg::constellation_msg::{Image, PixelFormat, Key, KeyModifiers, KeyState};
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId};
use msg::constellation_msg::{TraversalDirection, WindowSizeType};
use net_traits::image::base::{Image, PixelFormat};
use profile_traits::mem::{self, Reporter, ReporterRequest};
use profile_traits::time::{self, ProfilerCategory, profile};
use script_traits::{AnimationState, AnimationTickType, ConstellationControlMsg};
Expand Down
3 changes: 2 additions & 1 deletion components/compositing/compositor_thread.rs
Expand Up @@ -9,7 +9,8 @@ use compositor::CompositingReason;
use euclid::point::Point2D;
use euclid::size::Size2D;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState, PipelineId};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, PipelineId};
use net_traits::image::base::Image;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{AnimationState, ConstellationMsg, EventResult};
Expand Down
1 change: 0 additions & 1 deletion components/msg/Cargo.toml
Expand Up @@ -14,7 +14,6 @@ bitflags = "0.7"
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
ipc-channel = "0.5"
plugins = {path = "../plugins"}
serde = "0.8"
serde_derive = "0.8"
Expand Down
20 changes: 0 additions & 20 deletions components/msg/constellation_msg.rs
Expand Up @@ -5,7 +5,6 @@
//! The high-level interface from script to constellation. Using this abstract interface helps
//! reduce coupling between these two components.

use ipc_channel::ipc::IpcSharedMemory;
use std::cell::Cell;
use std::fmt;
use webrender_traits;
Expand Down Expand Up @@ -163,25 +162,6 @@ bitflags! {
}
}

#[derive(Clone, Copy, 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(Clone, 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,
#[ignore_heap_size_of = "Defined in webrender_traits"]
pub id: Option<webrender_traits::ImageKey>,
}

#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
pub enum TraversalDirection {
Forward(usize),
Expand Down
1 change: 0 additions & 1 deletion components/msg/lib.rs
Expand Up @@ -11,7 +11,6 @@
#[macro_use]
extern crate bitflags;
extern crate heapsize;
extern crate ipc_channel;
extern crate serde;
#[macro_use]
extern crate serde_derive;
Expand Down
5 changes: 5 additions & 0 deletions components/net_traits/Cargo.toml
Expand Up @@ -27,3 +27,8 @@ url = {version = "1.2", features = ["heap_size"]}
websocket = "0.17"
uuid = { version = "0.3.1", features = ["v4", "serde"] }
cookie = {version = "0.2.5", features = ["serialize-rustc"]}

[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
20 changes: 19 additions & 1 deletion components/net_traits/image/base.rs
Expand Up @@ -4,8 +4,26 @@

use ipc_channel::ipc::IpcSharedMemory;
use piston_image::{self, DynamicImage, ImageFormat};
use webrender_traits;

#[derive(Clone, Copy, 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
}

pub use msg::constellation_msg::{Image, PixelFormat};
#[derive(Clone, 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,
#[ignore_heap_size_of = "Defined in webrender_traits"]
pub id: Option<webrender_traits::ImageKey>,
}

#[derive(Clone, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)]
pub struct ImageMetadata {
Expand Down
3 changes: 1 addition & 2 deletions components/net_traits/image_cache_thread.rs
Expand Up @@ -2,9 +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::ImageMetadata;
use image::base::{Image, ImageMetadata};
use ipc_channel::ipc::{self, IpcSender};
use msg::constellation_msg::Image;
use std::sync::Arc;
use url::Url;

Expand Down
1 change: 1 addition & 0 deletions components/net_traits/lib.rs
Expand Up @@ -34,6 +34,7 @@ extern crate serde_derive;
extern crate url;
extern crate util;
extern crate uuid;
extern crate webrender_traits;
extern crate websocket;

use cookie_rs::Cookie;
Expand Down
3 changes: 2 additions & 1 deletion components/script_traits/lib.rs
Expand Up @@ -51,11 +51,12 @@ use hyper::header::Headers;
use hyper::method::Method;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void;
use msg::constellation_msg::{FrameId, FrameType, Image, Key, KeyModifiers, KeyState};
use msg::constellation_msg::{FrameId, FrameType, Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, ReferrerPolicy};
use msg::constellation_msg::{TraversalDirection, WindowSizeType};
use net_traits::{LoadOrigin, ResourceThreads};
use net_traits::bluetooth_thread::BluetoothMethodMsg;
use net_traits::image::base::Image;
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::response::HttpsState;
use profile_traits::mem;
Expand Down
3 changes: 2 additions & 1 deletion components/servo/Cargo.lock

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

1 change: 1 addition & 0 deletions components/webdriver_server/Cargo.toml
Expand Up @@ -16,6 +16,7 @@ image = "0.10"
ipc-channel = "0.5"
log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
plugins = {path = "../plugins"}
regex = "0.1.55"
rustc-serialize = "0.3.4"
Expand Down
5 changes: 3 additions & 2 deletions components/webdriver_server/lib.rs
Expand Up @@ -18,6 +18,7 @@ extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate msg;
extern crate net_traits;
extern crate regex;
extern crate rustc_serialize;
extern crate script_traits;
Expand All @@ -33,8 +34,8 @@ use hyper::method::Method::{self, Post};
use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use keys::keycodes_to_keys;
use msg::constellation_msg::{FrameId, PipelineId};
use msg::constellation_msg::{PixelFormat, TraversalDirection};
use msg::constellation_msg::{FrameId, PipelineId, TraversalDirection};
use net_traits::image::base::PixelFormat;
use regex::Captures;
use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64};
use rustc_serialize::json::{Json, ToJson};
Expand Down
3 changes: 2 additions & 1 deletion ports/cef/Cargo.lock

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

0 comments on commit dce2872

Please sign in to comment.