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

Send an IpcSharedMemory in tex_image_2d and tex_sub_image_2d #22225

Merged
merged 9 commits into from Nov 21, 2018

Move PixelFormat to the pixels crate

  • Loading branch information
nox committed Nov 20, 2018
commit 2c0acf6b9bf2c4082dfbd98763cd21de7ae56449

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

@@ -13,7 +13,7 @@ path = "lib.rs"

[features]
default = []
gl = ["gleam"]
gl = ["gleam", "pixels"]

[dependencies]
crossbeam-channel = "0.3"
@@ -28,6 +28,7 @@ keyboard-types = "0.4.3"
log = "0.4"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
pixels = {path = "../pixels", optional = true}
profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
@@ -22,7 +22,7 @@ use libc::c_void;
use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId};
use net_traits::image::base::Image;
#[cfg(feature = "gl")]
use net_traits::image::base::PixelFormat;
use pixels::PixelFormat;
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEvent};
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
@@ -4,11 +4,12 @@

use embedder_traits::resources::{self, Resource};
use immeta::load_from_buf;
use net_traits::image::base::{load_from_memory, Image, ImageMetadata, PixelFormat};
use net_traits::image::base::{load_from_memory, Image, ImageMetadata};
use net_traits::image_cache::{CanRequestImages, ImageCache, ImageResponder};
use net_traits::image_cache::{ImageOrMetadataAvailable, ImageResponse, ImageState};
use net_traits::image_cache::{PendingImageId, UsePlaceholder};
use net_traits::{FetchMetadata, FetchResponseMsg, NetworkError};
use pixels::PixelFormat;
use servo_url::ServoUrl;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::HashMap;
@@ -4,20 +4,9 @@

use ipc_channel::ipc::IpcSharedMemory;
use piston_image::{DynamicImage, ImageFormat};
use pixels::PixelFormat;
use std::fmt;

#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub enum PixelFormat {
/// Luminance channel only
K8,
/// Luminance + alpha
KA8,
/// RGB, 8 bits per channel
RGB8,
/// RGB + alpha, 8 bits per channel
BGRA8,
}

#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
pub struct Image {
pub width: u32,
@@ -12,3 +12,6 @@ path = "lib.rs"

[dependencies]
euclid = "0.19"
malloc_size_of = {path = "../malloc_size_of"}
malloc_size_of_derive = {path = "../malloc_size_of_derive"}
serde = {version = "1", features = ["derive"]}
@@ -2,9 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#[macro_use]
extern crate serde;

use euclid::{Point2D, Rect, Size2D};
use malloc_size_of_derive::MallocSizeOf;
use std::borrow::Cow;

#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub enum PixelFormat {
/// Luminance channel only
K8,
/// Luminance + alpha
KA8,
/// RGB, 8 bits per channel
RGB8,
/// RGB + alpha, 8 bits per channel
BGRA8,
}

pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
assert!(!rect.is_empty());
assert!(Rect::from_size(size).contains_rect(&rect));
@@ -34,13 +34,13 @@ use cssparser::{Parser, ParserInput, RGBA};
use dom_struct::dom_struct;
use euclid::{vec2, Point2D, Rect, Size2D, Transform2D};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::CanRequestImages;
use net_traits::image_cache::ImageCache;
use net_traits::image_cache::ImageOrMetadataAvailable;
use net_traits::image_cache::ImageResponse;
use net_traits::image_cache::ImageState;
use net_traits::image_cache::UsePlaceholder;
use pixels::PixelFormat;
use profile_traits::ipc as profiled_ipc;
use script_traits::ScriptMsg;
use servo_url::ServoUrl;
@@ -44,8 +44,8 @@ use js::rust::wrappers::Construct1;
use js::rust::HandleValue;
use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageCache;
use pixels::PixelFormat;
use profile_traits::ipc;
use script_traits::Painter;
use script_traits::{DrawAPaintImageResult, PaintWorkletError};
@@ -66,10 +66,9 @@ use js::typedarray::{
ArrayBufferView, CreateWith, Float32, Float32Array, Int32, Int32Array, Uint32Array,
};
use js::typedarray::{TypedArray, TypedArrayElementCreator};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageResponse;
use offscreen_gl_context::{GLContextAttributes, GLLimits};
use pixels;
use pixels::{self, PixelFormat};
use script_layout_interface::HTMLCanvasDataSource;
use serde::{Deserialize, Serialize};
use servo_config::prefs::PREFS;
@@ -29,6 +29,7 @@ malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
pixels = {path = "../pixels"}
profile_traits = {path = "../profile_traits"}
serde = "1.0"
servo_atoms = {path = "../atoms"}
@@ -35,10 +35,10 @@ use libc::c_void;
use msg::constellation_msg::{BrowsingContextId, HistoryStateId, PipelineId};
use msg::constellation_msg::{PipelineNamespaceId, TopLevelBrowsingContextId, TraversalDirection};
use net_traits::image::base::Image;
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageCache;
use net_traits::storage_thread::StorageType;
use net_traits::{FetchResponseMsg, ReferrerPolicy, ResourceThreads};
use pixels::PixelFormat;
use profile_traits::mem;
use profile_traits::time as profile_time;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -22,6 +22,7 @@ keyboard-types = "0.4.3"
log = "0.4"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
pixels = {path = "../pixels"}
regex = "1.0"
serde = "1"
serde_json = "1"
@@ -19,7 +19,7 @@ use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use keyboard_types::webdriver::{send_keys, Event as KeyEvent};
use msg::constellation_msg::{BrowsingContextId, TopLevelBrowsingContextId, TraversalDirection};
use net_traits::image::base::PixelFormat;
use pixels::PixelFormat;
use regex::Captures;
use script_traits::webdriver_msg::{LoadStatus, WebDriverCookieError, WebDriverFrameId};
use script_traits::webdriver_msg::{
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.