From 52db2faad72433a220459433bfe972e7d9055b7f Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 9 Nov 2015 15:34:51 +1000 Subject: [PATCH 01/97] Initial commit - public API and types for webrender. --- .gitignore | 2 + Cargo.toml | 14 ++ src/api.rs | 158 ++++++++++++++++++++ src/display_item.rs | 90 ++++++++++++ src/display_list.rs | 312 ++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 30 ++++ src/stacking_context.rs | 46 ++++++ src/types.rs | 263 +++++++++++++++++++++++++++++++++ 8 files changed, 915 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/api.rs create mode 100644 src/display_item.rs create mode 100644 src/display_list.rs create mode 100644 src/lib.rs create mode 100644 src/stacking_context.rs create mode 100644 src/types.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..a9d37c560c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..9487c0f508 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "webrender_traits" +version = "0.1.0" +authors = ["Glenn Watson "] + +[dependencies] +app_units = "0.1" +euclid = "0.3" +serde = "0.6" +serde_macros = "0.5" + +[target.x86_64-apple-darwin.dependencies] +core-graphics = "*" + diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000000..61f6495289 --- /dev/null +++ b/src/api.rs @@ -0,0 +1,158 @@ +use display_list::DisplayListBuilder; +use euclid::Point2D; +use stacking_context::StackingContext; +use std::cell::Cell; +use std::sync::mpsc::{self, Sender}; +use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; +use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; + +#[derive(Clone, Copy, Debug)] +pub struct IdNamespace(pub u32); + +#[derive(Clone, Copy, Debug)] +pub struct ResourceId(pub u32); + +pub enum ApiMsg { + AddRawFont(FontKey, Vec), + AddNativeFont(FontKey, NativeFontHandle), + AddImage(ImageKey, u32, u32, ImageFormat, Vec), + UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), + AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), + AddStackingContext(StackingContextId, PipelineId, Epoch, StackingContext), + CloneApi(Sender), + SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId), + SetRootPipeline(PipelineId), + Scroll(Point2D), + TranslatePointToLayerSpace(Point2D, Sender>), +} + +pub struct RenderApi { + pub tx: Sender, + pub id_namespace: IdNamespace, + pub next_id: Cell, +} + +impl RenderApi { + pub fn new(api_tx: Sender) -> RenderApi { + RenderApi { + tx: api_tx, + id_namespace: IdNamespace(0), // special case + next_id: Cell::new(ResourceId(0)), + } + } + + pub fn add_raw_font(&self, bytes: Vec) -> FontKey { + let new_id = self.next_unique_id(); + let key = FontKey::new(new_id.0, new_id.1); + let msg = ApiMsg::AddRawFont(key, bytes); + self.tx.send(msg).unwrap(); + key + } + + pub fn add_native_font(&self, native_font_handle: NativeFontHandle) -> FontKey { + let new_id = self.next_unique_id(); + let key = FontKey::new(new_id.0, new_id.1); + let msg = ApiMsg::AddNativeFont(key, native_font_handle); + self.tx.send(msg).unwrap(); + key + } + + pub fn alloc_image(&self) -> ImageKey { + let new_id = self.next_unique_id(); + ImageKey::new(new_id.0, new_id.1) + } + + pub fn add_image(&self, + width: u32, + height: u32, + format: ImageFormat, + bytes: Vec) -> ImageKey { + let new_id = self.next_unique_id(); + let key = ImageKey::new(new_id.0, new_id.1); + let msg = ApiMsg::AddImage(key, width, height, format, bytes); + self.tx.send(msg).unwrap(); + key + } + + // TODO: Support changing dimensions (and format) during image update? + pub fn update_image(&self, + key: ImageKey, + width: u32, + height: u32, + format: ImageFormat, + bytes: Vec) { + let msg = ApiMsg::UpdateImage(key, width, height, format, bytes); + self.tx.send(msg).unwrap(); + } + + pub fn add_display_list(&self, + display_list: DisplayListBuilder, + stacking_context: &mut StackingContext, + pipeline_id: PipelineId, + epoch: Epoch) -> Option { + //TODO! debug_assert!(display_list.item_count() > 0, "Avoid adding empty lists!"); + let new_id = self.next_unique_id(); + let id = DisplayListId(new_id.0, new_id.1); + stacking_context.has_stacking_contexts = stacking_context.has_stacking_contexts || + display_list.has_stacking_contexts; + let msg = ApiMsg::AddDisplayList(id, pipeline_id, epoch, display_list); + self.tx.send(msg).unwrap(); + stacking_context.display_lists.push(id); + + Some(id) + } + + pub fn add_stacking_context(&self, + stacking_context: StackingContext, + pipeline_id: PipelineId, + epoch: Epoch) -> StackingContextId { + let new_id = self.next_unique_id(); + let id = StackingContextId(new_id.0, new_id.1); + let msg = ApiMsg::AddStackingContext(id, pipeline_id, epoch, stacking_context); + self.tx.send(msg).unwrap(); + id + } + + pub fn set_root_pipeline(&self, pipeline_id: PipelineId) { + let msg = ApiMsg::SetRootPipeline(pipeline_id); + self.tx.send(msg).unwrap(); + } + + pub fn set_root_stacking_context(&self, + stacking_context_id: StackingContextId, + background_color: ColorF, + epoch: Epoch, + pipeline_id: PipelineId) { + let msg = ApiMsg::SetRootStackingContext(stacking_context_id, + background_color, + epoch, + pipeline_id); + self.tx.send(msg).unwrap(); + } + + pub fn scroll(&self, delta: Point2D) { + let msg = ApiMsg::Scroll(delta); + self.tx.send(msg).unwrap(); + } + + pub fn translate_point_to_layer_space(&self, point: &Point2D) -> Point2D { + let (tx, rx) = mpsc::channel(); + let msg = ApiMsg::TranslatePointToLayerSpace(*point, tx); + self.tx.send(msg).unwrap(); + rx.recv().unwrap() + } + + pub fn clone_api(&self) -> RenderApi { + let (tx, rx) = mpsc::channel(); + let msg = ApiMsg::CloneApi(tx); + self.tx.send(msg).unwrap(); + rx.recv().unwrap() + } + + fn next_unique_id(&self) -> (u32, u32) { + let IdNamespace(namespace) = self.id_namespace; + let ResourceId(id) = self.next_id.get(); + self.next_id.set(ResourceId(id + 1)); + (namespace, id) + } +} diff --git a/src/display_item.rs b/src/display_item.rs new file mode 100644 index 0000000000..ef6d4d13ae --- /dev/null +++ b/src/display_item.rs @@ -0,0 +1,90 @@ +use app_units::Au; +use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; +use types::{GradientStop, BorderRadius, BoxShadowClipMode}; +use euclid::{Point2D, Rect, Size2D}; + +#[derive(Debug, PartialEq)] +pub struct BorderDisplayItem { + pub left: BorderSide, + pub right: BorderSide, + pub top: BorderSide, + pub bottom: BorderSide, + pub radius: BorderRadius, +} + +impl BorderDisplayItem { + pub fn top_left_inner_radius(&self) -> Size2D { + Size2D::new((self.radius.top_left.width - self.left.width).max(0.0), + (self.radius.top_left.height - self.top.width).max(0.0)) + } + + pub fn top_right_inner_radius(&self) -> Size2D { + Size2D::new((self.radius.top_right.width - self.right.width).max(0.0), + (self.radius.top_right.height - self.top.width).max(0.0)) + } + + pub fn bottom_left_inner_radius(&self) -> Size2D { + Size2D::new((self.radius.bottom_left.width - self.left.width).max(0.0), + (self.radius.bottom_left.height - self.bottom.width).max(0.0)) + } + + pub fn bottom_right_inner_radius(&self) -> Size2D { + Size2D::new((self.radius.bottom_right.width - self.right.width).max(0.0), + (self.radius.bottom_right.height - self.bottom.width).max(0.0)) + } +} + +#[derive(Debug, PartialEq)] +pub struct BoxShadowDisplayItem { + pub box_bounds: Rect, + pub offset: Point2D, + pub color: ColorF, + pub blur_radius: f32, + pub spread_radius: f32, + pub border_radius: f32, + pub clip_mode: BoxShadowClipMode, +} + +#[derive(Debug, PartialEq)] +pub struct GradientDisplayItem { + pub start_point: Point2D, + pub end_point: Point2D, + pub stops: Vec, +} + +#[derive(Debug, PartialEq)] +pub struct ImageDisplayItem { + pub image_key: ImageKey, + pub stretch_size: Size2D, +} + +#[derive(Debug, PartialEq)] +pub struct RectangleDisplayItem { + pub color: ColorF, +} + +#[derive(Debug, PartialEq)] +pub struct TextDisplayItem { + pub glyphs: Vec, + pub font_key: FontKey, + pub size: Au, + pub color: ColorF, + pub blur_radius: Au, +} + +#[derive(Debug, PartialEq)] +pub enum SpecificDisplayItem { + Rectangle(RectangleDisplayItem), + Text(TextDisplayItem), + Image(ImageDisplayItem), + Border(BorderDisplayItem), + BoxShadow(BoxShadowDisplayItem), + Gradient(GradientDisplayItem), +} + +#[derive(Debug, PartialEq)] +pub struct DisplayItem { + pub item: SpecificDisplayItem, + pub rect: Rect, + pub clip: ClipRegion, +} diff --git a/src/display_list.rs b/src/display_list.rs new file mode 100644 index 0000000000..f6afe414dd --- /dev/null +++ b/src/display_list.rs @@ -0,0 +1,312 @@ +use app_units::Au; +use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; +use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; +use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; +use euclid::{Point2D, Rect, Size2D}; +use std::mem; +use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; +use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; +use types::{DisplayListMode, GradientStop, StackingContextId}; + +pub struct DrawListInfo { + pub items: Vec, +} + +pub struct StackingContextInfo { + pub id: StackingContextId, +} + +#[derive(Debug, Clone)] +pub struct IframeInfo { + pub id: PipelineId, + pub offset: Point2D, + pub clip: Rect, +} + +pub enum SpecificDisplayListItem { + DrawList(DrawListInfo), + StackingContext(StackingContextInfo), + Iframe(Box), +} + +pub struct DisplayListItem { + pub stacking_level: StackingLevel, + pub specific: SpecificDisplayListItem, +} + +pub struct DisplayListBuilder { + pub mode: DisplayListMode, + pub has_stacking_contexts: bool, + + pub work_background_and_borders: Vec, + pub work_block_backgrounds_and_borders: Vec, + pub work_floats: Vec, + pub work_content: Vec, + pub work_positioned_content: Vec, + pub work_outlines: Vec, + + pub items: Vec, +} + +impl DisplayListBuilder { + pub fn new() -> DisplayListBuilder { + DisplayListBuilder { + mode: DisplayListMode::Default, + has_stacking_contexts: false, + + work_background_and_borders: Vec::new(), + work_block_backgrounds_and_borders: Vec::new(), + work_floats: Vec::new(), + work_content: Vec::new(), + work_positioned_content: Vec::new(), + work_outlines: Vec::new(), + + items: Vec::new(), + } + } + + pub fn push_rect(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + color: ColorF) { + let item = RectangleDisplayItem { + color: color, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::Rectangle(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_image(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + stretch_size: Size2D, + key: ImageKey) { + let item = ImageDisplayItem { + image_key: key, + stretch_size: stretch_size, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::Image(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_text(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + glyphs: Vec, + font_key: FontKey, + color: ColorF, + size: Au, + blur_radius: Au) { + let item = TextDisplayItem { + color: color, + glyphs: glyphs, + font_key: font_key, + size: size, + blur_radius: blur_radius, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::Text(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_border(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + left: BorderSide, + top: BorderSide, + right: BorderSide, + bottom: BorderSide, + radius: BorderRadius) { + let item = BorderDisplayItem { + left: left, + top: top, + right: right, + bottom: bottom, + radius: radius, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::Border(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_box_shadow(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + box_bounds: Rect, + offset: Point2D, + color: ColorF, + blur_radius: f32, + spread_radius: f32, + border_radius: f32, + clip_mode: BoxShadowClipMode) { + let item = BoxShadowDisplayItem { + box_bounds: box_bounds, + offset: offset, + color: color, + blur_radius: blur_radius, + spread_radius: spread_radius, + border_radius: border_radius, + clip_mode: clip_mode, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::BoxShadow(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_stacking_context(&mut self, + level: StackingLevel, + stacking_context_id: StackingContextId) { + self.has_stacking_contexts = true; + self.flush_list(level); + let info = StackingContextInfo { + id: stacking_context_id, + }; + let item = DisplayListItem { + stacking_level: level, + specific: SpecificDisplayListItem::StackingContext(info), + }; + self.items.push(item); + } + + pub fn push_gradient(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + start_point: Point2D, + end_point: Point2D, + stops: Vec) { + let item = GradientDisplayItem { + start_point: start_point, + end_point: end_point, + stops: stops, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::Gradient(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + + pub fn push_iframe(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + iframe: PipelineId) { + self.flush_list(level); + let info = Box::new(IframeInfo { + id: iframe, + offset: rect.origin, + clip: clip.main, + }); + let item = DisplayListItem { + stacking_level: level, + specific: SpecificDisplayListItem::Iframe(info), + }; + self.items.push(item); + } + + fn push_item(&mut self, level: StackingLevel, item: DisplayItem) { + match level { + StackingLevel::BackgroundAndBorders => { + self.work_background_and_borders.push(item); + } + StackingLevel::BlockBackgroundAndBorders => { + self.work_block_backgrounds_and_borders.push(item); + } + StackingLevel::Floats => { + self.work_floats.push(item); + } + StackingLevel::Content => { + self.work_content.push(item); + } + StackingLevel::PositionedContent => { + self.work_positioned_content.push(item); + } + StackingLevel::Outlines => { + self.work_outlines.push(item); + } + } + } + + fn flush_list(&mut self, level: StackingLevel) { + let list = match level { + StackingLevel::BackgroundAndBorders => { + &mut self.work_background_and_borders + } + StackingLevel::BlockBackgroundAndBorders => { + &mut self.work_block_backgrounds_and_borders + } + StackingLevel::Floats => { + &mut self.work_floats + } + StackingLevel::Content => { + &mut self.work_content + } + StackingLevel::PositionedContent => { + &mut self.work_positioned_content + } + StackingLevel::Outlines => { + &mut self.work_outlines + } + }; + + let items = mem::replace(list, Vec::new()); + if items.len() > 0 { + let draw_list = DrawListInfo { + items: items, + }; + self.items.push(DisplayListItem { + stacking_level: level, + specific: SpecificDisplayListItem::DrawList(draw_list), + }); + } + } + + fn flush(&mut self) { + self.flush_list(StackingLevel::BackgroundAndBorders); + self.flush_list(StackingLevel::BlockBackgroundAndBorders); + self.flush_list(StackingLevel::Floats); + self.flush_list(StackingLevel::Content); + self.flush_list(StackingLevel::PositionedContent); + self.flush_list(StackingLevel::Outlines); + } + + pub fn finalize(&mut self) { + self.flush(); + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000000..b306464b1e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,30 @@ +#![feature(plugin)] +#![feature(custom_derive)] +#![plugin(serde_macros)] + +extern crate app_units; +extern crate euclid; +extern crate serde; + +#[cfg(target_os="macos")] +extern crate core_graphics; + +mod api; +mod display_item; +mod display_list; +mod stacking_context; +mod types; + +pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi}; +pub use display_list::{DisplayListBuilder, DisplayListItem}; +pub use display_list::{SpecificDisplayListItem, IframeInfo}; +pub use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; +pub use display_item::{BorderDisplayItem, GradientDisplayItem, RectangleDisplayItem}; +pub use stacking_context::StackingContext; +pub use types::NativeFontHandle; +pub use types::{BorderRadius, BorderSide, BorderStyle, BoxShadowClipMode}; +pub use types::{ColorF, ClipRegion, ComplexClipRegion}; +pub use types::{DisplayListId, DisplayListMode}; +pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; +pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; +pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId}; diff --git a/src/stacking_context.rs b/src/stacking_context.rs new file mode 100644 index 0000000000..0bcae6f0b3 --- /dev/null +++ b/src/stacking_context.rs @@ -0,0 +1,46 @@ +use euclid::{Matrix4, Rect}; +use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; + +pub struct StackingContext { + pub scroll_layer_id: Option, + pub scroll_policy: ScrollPolicy, + pub bounds: Rect, + pub overflow: Rect, + pub z_index: i32, + pub display_lists: Vec, + pub transform: Matrix4, + pub perspective: Matrix4, + pub establishes_3d_context: bool, + pub mix_blend_mode: MixBlendMode, + pub filters: Vec, + pub has_stacking_contexts: bool, +} + +impl StackingContext { + pub fn new(scroll_layer_id: Option, + scroll_policy: ScrollPolicy, + bounds: Rect, + overflow: Rect, + z_index: i32, + transform: &Matrix4, + perspective: &Matrix4, + establishes_3d_context: bool, + mix_blend_mode: MixBlendMode, + filters: Vec) + -> StackingContext { + StackingContext { + scroll_layer_id: scroll_layer_id, + scroll_policy: scroll_policy, + bounds: bounds, + overflow: overflow, + z_index: z_index, + display_lists: Vec::new(), + transform: transform.clone(), + perspective: perspective.clone(), + establishes_3d_context: establishes_3d_context, + mix_blend_mode: mix_blend_mode, + filters: filters, + has_stacking_contexts: false, + } + } +} diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000000..bbe885949b --- /dev/null +++ b/src/types.rs @@ -0,0 +1,263 @@ +use app_units::Au; +use euclid::{Rect, Size2D}; + +#[cfg(target_os="macos")] +use core_graphics::font::CGFont; + +// TODO: This is bogus - work out a clean way to generate scroll layer IDs that integrates well with servo... +const FIXED_SCROLL_LAYER_ID: usize = 0xffffffff; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct BorderRadius { + pub top_left: Size2D, + pub top_right: Size2D, + pub bottom_left: Size2D, + pub bottom_right: Size2D, +} + +impl BorderRadius { + pub fn zero() -> BorderRadius { + BorderRadius { + top_left: Size2D::new(0.0, 0.0), + top_right: Size2D::new(0.0, 0.0), + bottom_left: Size2D::new(0.0, 0.0), + bottom_right: Size2D::new(0.0, 0.0), + } + } + + pub fn uniform(radius: f32) -> BorderRadius { + BorderRadius { + top_left: Size2D::new(radius, radius), + top_right: Size2D::new(radius, radius), + bottom_left: Size2D::new(radius, radius), + bottom_right: Size2D::new(radius, radius), + } + } +} + +#[derive(Debug, PartialEq)] +pub struct BorderSide { + pub width: f32, + pub color: ColorF, + pub style: BorderStyle, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum BorderStyle { + None, + Solid, + Double, + Dotted, + Dashed, + Hidden, + Groove, + Ridge, + Inset, + Outset, +} + +#[derive(Debug, Copy, Clone, PartialEq)] +pub enum BoxShadowClipMode { + None, + Outset, + Inset, +} + +#[derive(Debug, Clone, PartialEq)] +pub struct ClipRegion { + pub main: Rect, + pub complex: Vec, +} + +impl ClipRegion { + pub fn new(rect: Rect, complex: Vec) -> ClipRegion { + ClipRegion { + main: rect, + complex: complex, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ComplexClipRegion { + /// The boundaries of the rectangle. + pub rect: Rect, + /// Border radii of this rectangle. + pub radii: BorderRadius, +} + +impl ComplexClipRegion { + pub fn new(rect: Rect, radii: BorderRadius) -> ComplexClipRegion { + ComplexClipRegion { + rect: rect, + radii: radii, + } + } + + pub fn from_rect(rect: &Rect) -> ComplexClipRegion { + ComplexClipRegion { + rect: *rect, + radii: BorderRadius::zero(), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ColorF { + pub r: f32, + pub g: f32, + pub b: f32, + pub a: f32, +} + +impl ColorF { + pub fn new(r: f32, g: f32, b: f32, a: f32) -> ColorF { + ColorF { + r: r, + g: g, + b: b, + a: a, + } + } + + pub fn scale_rgb(&self, scale: f32) -> ColorF { + ColorF { + r: self.r * scale, + g: self.g * scale, + b: self.b * scale, + a: self.a, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct StackingContextId(pub u32, pub u32); + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct DisplayListId(pub u32, pub u32); + +pub enum DisplayListMode { + Default, + PseudoFloat, + PseudoPositionedContent, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] +pub struct Epoch(pub u32); + +#[derive(Clone, Copy, Debug)] +pub enum FilterOp { + Blur(Au), + Brightness(f32), + Contrast(f32), + Grayscale(f32), + HueRotate(f32), + Invert(f32), + Opacity(f32), + Saturate(f32), + Sepia(f32), +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +pub struct FontKey(u32, u32); + +impl FontKey { + pub fn new(key0: u32, key1: u32) -> FontKey { + FontKey(key0, key1) + } +} + +#[derive(Debug, PartialEq)] +pub struct GlyphInstance { + pub index: u32, + pub x: f32, + pub y: f32, +} + +#[derive(Debug, PartialEq)] +pub struct GradientStop { + pub offset: f32, + pub color: ColorF, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ImageFormat { + Invalid, + A8, + RGB8, + RGBA8, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +pub struct ImageKey(u32, u32); + +impl ImageKey { + pub fn new(key0: u32, key1: u32) -> ImageKey { + ImageKey(key0, key1) + } +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum MixBlendMode { + Normal, + Multiply, + Screen, + Overlay, + Darken, + Lighten, + ColorDodge, + ColorBurn, + HardLight, + SoftLight, + Difference, + Exclusion, + Hue, + Saturation, + Color, + Luminosity, +} + +#[cfg(target_os="macos")] +pub type NativeFontHandle = CGFont; + +/// Native fonts are not used on Linux; all fonts are raw. +#[cfg(not(target_os="macos"))] +#[derive(Clone)] +pub struct NativeFontHandle; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct PipelineId(pub u32, pub u32); + +pub trait RenderNotifier : Send { + fn new_frame_ready(&mut self); +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct ScrollLayerId(pub usize); + +impl ScrollLayerId { + pub fn new(value: usize) -> ScrollLayerId { + debug_assert!(value != FIXED_SCROLL_LAYER_ID); + ScrollLayerId(value) + } + + pub fn fixed_layer() -> ScrollLayerId { + ScrollLayerId(FIXED_SCROLL_LAYER_ID) + } +} + +#[derive(Clone, PartialEq, Eq, Copy, Deserialize, Serialize, Debug)] +pub enum ScrollPolicy { + Scrollable, + Fixed, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub enum StackingLevel { + BackgroundAndBorders, + BlockBackgroundAndBorders, + Floats, + Content, + PositionedContent, + Outlines, +} From 9bf8905dfffcc970a7425b1553eaacf25f81c70a Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 16 Nov 2015 08:05:50 +1000 Subject: [PATCH 02/97] Fix iframe clip --- src/display_list.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/display_list.rs b/src/display_list.rs index f6afe414dd..617889a642 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -225,13 +225,13 @@ impl DisplayListBuilder { pub fn push_iframe(&mut self, level: StackingLevel, rect: Rect, - clip: ClipRegion, + _clip: ClipRegion, iframe: PipelineId) { self.flush_list(level); let info = Box::new(IframeInfo { id: iframe, offset: rect.origin, - clip: clip.main, + clip: rect, }); let item = DisplayListItem { stacking_level: level, From c4c468bad18c75e30f65e5562e34561cedb47352 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 16 Nov 2015 10:51:42 +1000 Subject: [PATCH 03/97] Fix font_advance reftest --- src/display_list.rs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/display_list.rs b/src/display_list.rs index 617889a642..1f61c70e22 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -112,21 +112,29 @@ impl DisplayListBuilder { color: ColorF, size: Au, blur_radius: Au) { - let item = TextDisplayItem { - color: color, - glyphs: glyphs, - font_key: font_key, - size: size, - blur_radius: blur_radius, - }; + // Sanity check - anything with glyphs bigger than this + // is probably going to consume too much memory to render + // efficiently anyway. This is specifically to work around + // the font_advance.html reftest, which creates a very large + // font as a crash test - the rendering is also ignored + // by the azure renderer. + if size < Au::from_px(4096) { + let item = TextDisplayItem { + color: color, + glyphs: glyphs, + font_key: font_key, + size: size, + blur_radius: blur_radius, + }; - let display_item = DisplayItem { - item: SpecificDisplayItem::Text(item), - rect: rect, - clip: clip, - }; + let display_item = DisplayItem { + item: SpecificDisplayItem::Text(item), + rect: rect, + clip: clip, + }; - self.push_item(level, display_item); + self.push_item(level, display_item); + } } pub fn push_border(&mut self, From a955162f8e5f9b0dccb56082c11b4b4b60d2e1d6 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 18 Nov 2015 09:37:14 +1000 Subject: [PATCH 04/97] Add image-rendering types. --- src/display_item.rs | 3 ++- src/display_list.rs | 4 +++- src/lib.rs | 2 +- src/types.rs | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/display_item.rs b/src/display_item.rs index ef6d4d13ae..1f755b61b6 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -1,6 +1,6 @@ use app_units::Au; use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; -use types::{GradientStop, BorderRadius, BoxShadowClipMode}; +use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; use euclid::{Point2D, Rect, Size2D}; #[derive(Debug, PartialEq)] @@ -56,6 +56,7 @@ pub struct GradientDisplayItem { pub struct ImageDisplayItem { pub image_key: ImageKey, pub stretch_size: Size2D, + pub image_rendering: ImageRendering, } #[derive(Debug, PartialEq)] diff --git a/src/display_list.rs b/src/display_list.rs index 1f61c70e22..d91a74e0cf 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -6,7 +6,7 @@ use euclid::{Point2D, Rect, Size2D}; use std::mem; use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; -use types::{DisplayListMode, GradientStop, StackingContextId}; +use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; pub struct DrawListInfo { pub items: Vec, @@ -88,10 +88,12 @@ impl DisplayListBuilder { rect: Rect, clip: ClipRegion, stretch_size: Size2D, + image_rendering: ImageRendering, key: ImageKey) { let item = ImageDisplayItem { image_key: key, stretch_size: stretch_size, + image_rendering: image_rendering, }; let display_item = DisplayItem { diff --git a/src/lib.rs b/src/lib.rs index b306464b1e..93b7a29de5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,7 @@ pub use stacking_context::StackingContext; pub use types::NativeFontHandle; pub use types::{BorderRadius, BorderSide, BorderStyle, BoxShadowClipMode}; pub use types::{ColorF, ClipRegion, ComplexClipRegion}; -pub use types::{DisplayListId, DisplayListMode}; +pub use types::{DisplayListId, DisplayListMode, ImageRendering}; pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId}; diff --git a/src/types.rs b/src/types.rs index bbe885949b..1d3d2d2b80 100644 --- a/src/types.rs +++ b/src/types.rs @@ -188,6 +188,13 @@ pub enum ImageFormat { RGBA8, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ImageRendering { + Auto, + CrispEdges, + Pixelated, +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] pub struct ImageKey(u32, u32); From c686da5dda246bd026f35e86ea840399d3ec9fc4 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 23 Nov 2015 13:58:58 +1000 Subject: [PATCH 05/97] Switch to using ipc-channel. --- Cargo.toml | 3 +++ src/api.rs | 24 +++++++++++++++--------- src/display_item.rs | 16 ++++++++-------- src/display_list.rs | 7 ++++++- src/lib.rs | 1 + src/stacking_context.rs | 1 + src/types.rs | 41 +++++++++++++++++++++-------------------- 7 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9487c0f508..d6f736457a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "webrender_traits" version = "0.1.0" authors = ["Glenn Watson "] +[dependencies.ipc-channel] +git = "https://github.com/pcwalton/ipc-channel" + [dependencies] app_units = "0.1" euclid = "0.3" diff --git a/src/api.rs b/src/api.rs index 61f6495289..16f0dd04ea 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,17 +1,19 @@ use display_list::DisplayListBuilder; use euclid::Point2D; +use ipc_channel::ipc::{self, IpcSender}; use stacking_context::StackingContext; use std::cell::Cell; use std::sync::mpsc::{self, Sender}; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct IdNamespace(pub u32); -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct ResourceId(pub u32); +#[derive(Serialize, Deserialize)] pub enum ApiMsg { AddRawFont(FontKey, Vec), AddNativeFont(FontKey, NativeFontHandle), @@ -19,21 +21,21 @@ pub enum ApiMsg { UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), AddStackingContext(StackingContextId, PipelineId, Epoch, StackingContext), - CloneApi(Sender), + CloneApi(IpcSender), SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId), SetRootPipeline(PipelineId), Scroll(Point2D), - TranslatePointToLayerSpace(Point2D, Sender>), + TranslatePointToLayerSpace(Point2D, IpcSender>), } pub struct RenderApi { - pub tx: Sender, + pub tx: IpcSender, pub id_namespace: IdNamespace, pub next_id: Cell, } impl RenderApi { - pub fn new(api_tx: Sender) -> RenderApi { + pub fn new(api_tx: IpcSender) -> RenderApi { RenderApi { tx: api_tx, id_namespace: IdNamespace(0), // special case @@ -136,17 +138,21 @@ impl RenderApi { } pub fn translate_point_to_layer_space(&self, point: &Point2D) -> Point2D { - let (tx, rx) = mpsc::channel(); + let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::TranslatePointToLayerSpace(*point, tx); self.tx.send(msg).unwrap(); rx.recv().unwrap() } pub fn clone_api(&self) -> RenderApi { - let (tx, rx) = mpsc::channel(); + let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::CloneApi(tx); self.tx.send(msg).unwrap(); - rx.recv().unwrap() + RenderApi { + tx: self.tx.clone(), + id_namespace: rx.recv().unwrap(), + next_id: Cell::new(ResourceId(0)), + } } fn next_unique_id(&self) -> (u32, u32) { diff --git a/src/display_item.rs b/src/display_item.rs index 1f755b61b6..6ea93a4218 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -3,7 +3,7 @@ use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; use euclid::{Point2D, Rect, Size2D}; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct BorderDisplayItem { pub left: BorderSide, pub right: BorderSide, @@ -34,7 +34,7 @@ impl BorderDisplayItem { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct BoxShadowDisplayItem { pub box_bounds: Rect, pub offset: Point2D, @@ -45,26 +45,26 @@ pub struct BoxShadowDisplayItem { pub clip_mode: BoxShadowClipMode, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GradientDisplayItem { pub start_point: Point2D, pub end_point: Point2D, pub stops: Vec, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct ImageDisplayItem { pub image_key: ImageKey, pub stretch_size: Size2D, pub image_rendering: ImageRendering, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct RectangleDisplayItem { pub color: ColorF, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct TextDisplayItem { pub glyphs: Vec, pub font_key: FontKey, @@ -73,7 +73,7 @@ pub struct TextDisplayItem { pub blur_radius: Au, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum SpecificDisplayItem { Rectangle(RectangleDisplayItem), Text(TextDisplayItem), @@ -83,7 +83,7 @@ pub enum SpecificDisplayItem { Gradient(GradientDisplayItem), } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct DisplayItem { pub item: SpecificDisplayItem, pub rect: Rect, diff --git a/src/display_list.rs b/src/display_list.rs index d91a74e0cf..e03709cc03 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -8,32 +8,37 @@ use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; +#[derive(Serialize, Deserialize)] pub struct DrawListInfo { pub items: Vec, } +#[derive(Serialize, Deserialize)] pub struct StackingContextInfo { pub id: StackingContextId, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct IframeInfo { pub id: PipelineId, pub offset: Point2D, pub clip: Rect, } +#[derive(Serialize, Deserialize)] pub enum SpecificDisplayListItem { DrawList(DrawListInfo), StackingContext(StackingContextInfo), Iframe(Box), } +#[derive(Serialize, Deserialize)] pub struct DisplayListItem { pub stacking_level: StackingLevel, pub specific: SpecificDisplayListItem, } +#[derive(Serialize, Deserialize)] pub struct DisplayListBuilder { pub mode: DisplayListMode, pub has_stacking_contexts: bool, diff --git a/src/lib.rs b/src/lib.rs index 93b7a29de5..9eb1a75ce7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ extern crate app_units; extern crate euclid; +extern crate ipc_channel; extern crate serde; #[cfg(target_os="macos")] diff --git a/src/stacking_context.rs b/src/stacking_context.rs index 0bcae6f0b3..8b210befdc 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -1,6 +1,7 @@ use euclid::{Matrix4, Rect}; use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; +#[derive(Serialize, Deserialize)] pub struct StackingContext { pub scroll_layer_id: Option, pub scroll_policy: ScrollPolicy, diff --git a/src/types.rs b/src/types.rs index 1d3d2d2b80..3a0ce155de 100644 --- a/src/types.rs +++ b/src/types.rs @@ -7,7 +7,7 @@ use core_graphics::font::CGFont; // TODO: This is bogus - work out a clean way to generate scroll layer IDs that integrates well with servo... const FIXED_SCROLL_LAYER_ID: usize = 0xffffffff; -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct BorderRadius { pub top_left: Size2D, pub top_right: Size2D, @@ -35,14 +35,14 @@ impl BorderRadius { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct BorderSide { pub width: f32, pub color: ColorF, pub style: BorderStyle, } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub enum BorderStyle { None, Solid, @@ -56,14 +56,14 @@ pub enum BorderStyle { Outset, } -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] pub enum BoxShadowClipMode { None, Outset, Inset, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ClipRegion { pub main: Rect, pub complex: Vec, @@ -78,7 +78,7 @@ impl ClipRegion { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct ComplexClipRegion { /// The boundaries of the rectangle. pub rect: Rect, @@ -102,7 +102,7 @@ impl ComplexClipRegion { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct ColorF { pub r: f32, pub g: f32, @@ -130,22 +130,23 @@ impl ColorF { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct StackingContextId(pub u32, pub u32); -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct DisplayListId(pub u32, pub u32); +#[derive(Serialize, Deserialize)] pub enum DisplayListMode { Default, PseudoFloat, PseudoPositionedContent, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] pub struct Epoch(pub u32); -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum FilterOp { Blur(Au), Brightness(f32), @@ -167,20 +168,20 @@ impl FontKey { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GlyphInstance { pub index: u32, pub x: f32, pub y: f32, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct GradientStop { pub offset: f32, pub color: ColorF, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ImageFormat { Invalid, A8, @@ -188,7 +189,7 @@ pub enum ImageFormat { RGBA8, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ImageRendering { Auto, CrispEdges, @@ -204,7 +205,7 @@ impl ImageKey { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub enum MixBlendMode { Normal, Multiply, @@ -229,17 +230,17 @@ pub type NativeFontHandle = CGFont; /// Native fonts are not used on Linux; all fonts are raw. #[cfg(not(target_os="macos"))] -#[derive(Clone)] +#[derive(Clone, Serialize, Deserialize)] pub struct NativeFontHandle; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct PipelineId(pub u32, pub u32); pub trait RenderNotifier : Send { fn new_frame_ready(&mut self); } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ScrollLayerId(pub usize); impl ScrollLayerId { @@ -259,7 +260,7 @@ pub enum ScrollPolicy { Fixed, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub enum StackingLevel { BackgroundAndBorders, BlockBackgroundAndBorders, From 9af2c0e788925d4316e4c25648b6e53d4e1cff27 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 23 Nov 2015 14:22:00 +1000 Subject: [PATCH 06/97] Fix a warning --- src/api.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index 16f0dd04ea..a838748a4b 100644 --- a/src/api.rs +++ b/src/api.rs @@ -3,7 +3,6 @@ use euclid::Point2D; use ipc_channel::ipc::{self, IpcSender}; use stacking_context::StackingContext; use std::cell::Cell; -use std::sync::mpsc::{self, Sender}; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; From 7d89e0a3996ec6f2ceeb0361ddb0fec89ef60c84 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 23 Nov 2015 16:21:21 +1000 Subject: [PATCH 07/97] Munge api so it will work with e10s/serde. --- src/api.rs | 40 +++++++++++++++++++++++----------------- src/lib.rs | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/api.rs b/src/api.rs index a838748a4b..4b7a1b82a3 100644 --- a/src/api.rs +++ b/src/api.rs @@ -27,6 +27,27 @@ pub enum ApiMsg { TranslatePointToLayerSpace(Point2D, IpcSender>), } +#[derive(Serialize, Deserialize, Clone)] +pub struct RenderApiSender(IpcSender); + +impl RenderApiSender { + pub fn new(tx: IpcSender) -> RenderApiSender { + RenderApiSender(tx) + } + + pub fn create_api(&self) -> RenderApi { + let RenderApiSender(ref tx) = *self; + let (sync_tx, sync_rx) = ipc::channel().unwrap(); + let msg = ApiMsg::CloneApi(sync_tx); + tx.send(msg).unwrap(); + RenderApi { + tx: tx.clone(), + id_namespace: sync_rx.recv().unwrap(), + next_id: Cell::new(ResourceId(0)), + } + } +} + pub struct RenderApi { pub tx: IpcSender, pub id_namespace: IdNamespace, @@ -34,12 +55,8 @@ pub struct RenderApi { } impl RenderApi { - pub fn new(api_tx: IpcSender) -> RenderApi { - RenderApi { - tx: api_tx, - id_namespace: IdNamespace(0), // special case - next_id: Cell::new(ResourceId(0)), - } + pub fn clone_sender(&self) -> RenderApiSender { + RenderApiSender::new(self.tx.clone()) } pub fn add_raw_font(&self, bytes: Vec) -> FontKey { @@ -143,17 +160,6 @@ impl RenderApi { rx.recv().unwrap() } - pub fn clone_api(&self) -> RenderApi { - let (tx, rx) = ipc::channel().unwrap(); - let msg = ApiMsg::CloneApi(tx); - self.tx.send(msg).unwrap(); - RenderApi { - tx: self.tx.clone(), - id_namespace: rx.recv().unwrap(), - next_id: Cell::new(ResourceId(0)), - } - } - fn next_unique_id(&self) -> (u32, u32) { let IdNamespace(namespace) = self.id_namespace; let ResourceId(id) = self.next_id.get(); diff --git a/src/lib.rs b/src/lib.rs index 9eb1a75ce7..8a5bb1b7cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ mod display_list; mod stacking_context; mod types; -pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi}; +pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender}; pub use display_list::{DisplayListBuilder, DisplayListItem}; pub use display_list::{SpecificDisplayListItem, IframeInfo}; pub use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; From 22daaa225236741f610360b81339e42b87fb79cb Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 24 Nov 2015 14:06:22 +1000 Subject: [PATCH 08/97] Add pipeline size change to render notifier trait. --- src/types.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types.rs b/src/types.rs index 3a0ce155de..8173ae2d53 100644 --- a/src/types.rs +++ b/src/types.rs @@ -238,6 +238,9 @@ pub struct PipelineId(pub u32, pub u32); pub trait RenderNotifier : Send { fn new_frame_ready(&mut self); + fn pipeline_size_changed(&mut self, + pipeline_id: PipelineId, + size: Option>); } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] From 4679db0f323db7881f00eed36184873ecfdd4a4d Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 25 Nov 2015 20:48:08 -0800 Subject: [PATCH 09/97] Temporary disable native fonts until fixed properly with e10s support. --- src/api.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index 4b7a1b82a3..7398f6f423 100644 --- a/src/api.rs +++ b/src/api.rs @@ -15,7 +15,7 @@ pub struct ResourceId(pub u32); #[derive(Serialize, Deserialize)] pub enum ApiMsg { AddRawFont(FontKey, Vec), - AddNativeFont(FontKey, NativeFontHandle), + //AddNativeFont(FontKey, NativeFontHandle), AddImage(ImageKey, u32, u32, ImageFormat, Vec), UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), @@ -68,11 +68,13 @@ impl RenderApi { } pub fn add_native_font(&self, native_font_handle: NativeFontHandle) -> FontKey { + panic!("TODO: Get this working again with the e10s changes!"); + /* let new_id = self.next_unique_id(); let key = FontKey::new(new_id.0, new_id.1); let msg = ApiMsg::AddNativeFont(key, native_font_handle); self.tx.send(msg).unwrap(); - key + key*/ } pub fn alloc_image(&self) -> ImageKey { From fa8a045fd68637210eaaa554abd0fd2913a3d17e Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 1 Dec 2015 10:19:58 +1000 Subject: [PATCH 10/97] Switch to servo/ipc-channel --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d6f736457a..0bc19e2620 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Glenn Watson "] [dependencies.ipc-channel] -git = "https://github.com/pcwalton/ipc-channel" +git = "https://github.com/servo/ipc-channel" [dependencies] app_units = "0.1" From 12bb1fecaa0da1bcad5b727c34e19d1d75149251 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 30 Nov 2015 17:22:48 -0800 Subject: [PATCH 11/97] Support native fonts again post-e10s. --- src/api.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/api.rs b/src/api.rs index 7398f6f423..4b7a1b82a3 100644 --- a/src/api.rs +++ b/src/api.rs @@ -15,7 +15,7 @@ pub struct ResourceId(pub u32); #[derive(Serialize, Deserialize)] pub enum ApiMsg { AddRawFont(FontKey, Vec), - //AddNativeFont(FontKey, NativeFontHandle), + AddNativeFont(FontKey, NativeFontHandle), AddImage(ImageKey, u32, u32, ImageFormat, Vec), UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), @@ -68,13 +68,11 @@ impl RenderApi { } pub fn add_native_font(&self, native_font_handle: NativeFontHandle) -> FontKey { - panic!("TODO: Get this working again with the e10s changes!"); - /* let new_id = self.next_unique_id(); let key = FontKey::new(new_id.0, new_id.1); let msg = ApiMsg::AddNativeFont(key, native_font_handle); self.tx.send(msg).unwrap(); - key*/ + key } pub fn alloc_image(&self) -> ImageKey { From f1aa08023fc7ff298d8a0fc559c0e4cf744d7f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 18 Nov 2015 12:04:07 +0100 Subject: [PATCH 12/97] Add fast WebGL support for WebRender --- Cargo.toml | 3 +++ src/api.rs | 18 +++++++++++++++++- src/display_item.rs | 7 +++++++ src/display_list.rs | 21 ++++++++++++++++++++- src/lib.rs | 2 ++ src/types.rs | 9 +++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0bc19e2620..441b8dcca5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "webrender_traits" version = "0.1.0" authors = ["Glenn Watson "] +[dependencies.offscreen_gl_context] +git = "https://github.com/ecoal95/rust-offscreen-rendering-context" + [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" diff --git a/src/api.rs b/src/api.rs index 4b7a1b82a3..69064ce752 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,10 +1,12 @@ use display_list::DisplayListBuilder; -use euclid::Point2D; +use euclid::{Point2D, Size2D}; use ipc_channel::ipc::{self, IpcSender}; use stacking_context::StackingContext; use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; +use types::{WebGLContextId, WebGLCommand}; +use offscreen_gl_context::GLContextAttributes; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct IdNamespace(pub u32); @@ -25,6 +27,8 @@ pub enum ApiMsg { SetRootPipeline(PipelineId), Scroll(Point2D), TranslatePointToLayerSpace(Point2D, IpcSender>), + RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), + WebGLCommand(WebGLContextId, WebGLCommand), } #[derive(Serialize, Deserialize, Clone)] @@ -160,6 +164,18 @@ impl RenderApi { rx.recv().unwrap() } + pub fn request_webgl_context(&self, size: &Size2D, attributes: GLContextAttributes) -> Result { + let (tx, rx) = ipc::channel().unwrap(); + let msg = ApiMsg::RequestWebGLContext(*size, attributes, tx); + self.tx.send(msg).unwrap(); + rx.recv().unwrap() + } + + pub fn send_webgl_command(&self, context_id: WebGLContextId, command: WebGLCommand) { + let msg = ApiMsg::WebGLCommand(context_id, command); + self.tx.send(msg).unwrap(); + } + fn next_unique_id(&self) -> (u32, u32) { let IdNamespace(namespace) = self.id_namespace; let ResourceId(id) = self.next_id.get(); diff --git a/src/display_item.rs b/src/display_item.rs index 6ea93a4218..f52695b05b 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -1,6 +1,7 @@ use app_units::Au; use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; +use types::{WebGLContextId}; use euclid::{Point2D, Rect, Size2D}; #[derive(Debug, PartialEq, Serialize, Deserialize)] @@ -59,6 +60,11 @@ pub struct ImageDisplayItem { pub image_rendering: ImageRendering, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +pub struct WebGLDisplayItem { + pub context_id: WebGLContextId, +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct RectangleDisplayItem { pub color: ColorF, @@ -78,6 +84,7 @@ pub enum SpecificDisplayItem { Rectangle(RectangleDisplayItem), Text(TextDisplayItem), Image(ImageDisplayItem), + WebGL(WebGLDisplayItem), Border(BorderDisplayItem), BoxShadow(BoxShadowDisplayItem), Gradient(GradientDisplayItem), diff --git a/src/display_list.rs b/src/display_list.rs index e03709cc03..17156c79c9 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -1,5 +1,5 @@ use app_units::Au; -use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; +use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisplayItem}; use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use euclid::{Point2D, Rect, Size2D}; @@ -7,6 +7,7 @@ use std::mem; use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; +use types::{WebGLContextId}; #[derive(Serialize, Deserialize)] pub struct DrawListInfo { @@ -110,6 +111,24 @@ impl DisplayListBuilder { self.push_item(level, display_item); } + pub fn push_webgl_canvas(&mut self, + level: StackingLevel, + rect: Rect, + clip: ClipRegion, + context_id: WebGLContextId) { + let item = WebGLDisplayItem { + context_id: context_id, + }; + + let display_item = DisplayItem { + item: SpecificDisplayItem::WebGL(item), + rect: rect, + clip: clip, + }; + + self.push_item(level, display_item); + } + pub fn push_text(&mut self, level: StackingLevel, rect: Rect, diff --git a/src/lib.rs b/src/lib.rs index 8a5bb1b7cc..a6a6c8489c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ extern crate app_units; extern crate euclid; extern crate ipc_channel; extern crate serde; +extern crate offscreen_gl_context; #[cfg(target_os="macos")] extern crate core_graphics; @@ -29,3 +30,4 @@ pub use types::{DisplayListId, DisplayListMode, ImageRendering}; pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId}; +pub use types::{WebGLContextId, WebGLCommand}; diff --git a/src/types.rs b/src/types.rs index 8173ae2d53..6b94633063 100644 --- a/src/types.rs +++ b/src/types.rs @@ -272,3 +272,12 @@ pub enum StackingLevel { PositionedContent, Outlines, } + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct WebGLContextId(pub usize); + +#[derive(Debug, Serialize, Deserialize)] +pub enum WebGLCommand { + Clear(u32), + ClearColor(f32, f32, f32, f32), +} From 50020b0a17f54fc404ed8a93de2d5ea666d21fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 1 Dec 2015 15:31:21 +0100 Subject: [PATCH 13/97] Use custom branch for offscreen_gl_context --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 441b8dcca5..59fd939296 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Glenn Watson "] [dependencies.offscreen_gl_context] git = "https://github.com/ecoal95/rust-offscreen-rendering-context" +branch = "webrender" [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" From 3fa520b54011be771306e48e80192fabf3bae0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 2 Dec 2015 18:18:19 +0100 Subject: [PATCH 14/97] Move all the common WebGL code to webrender_traits --- Cargo.toml | 1 + src/api.rs | 2 +- src/display_item.rs | 2 +- src/display_list.rs | 2 +- src/lib.rs | 6 +- src/types.rs | 9 -- src/webgl.rs | 339 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 348 insertions(+), 13 deletions(-) create mode 100644 src/webgl.rs diff --git a/Cargo.toml b/Cargo.toml index 59fd939296..bb7a9387bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ git = "https://github.com/servo/ipc-channel" [dependencies] app_units = "0.1" euclid = "0.3" +gleam = "*" serde = "0.6" serde_macros = "0.5" diff --git a/src/api.rs b/src/api.rs index 69064ce752..aafef50a28 100644 --- a/src/api.rs +++ b/src/api.rs @@ -5,7 +5,7 @@ use stacking_context::StackingContext; use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; -use types::{WebGLContextId, WebGLCommand}; +use webgl::{WebGLContextId, WebGLCommand}; use offscreen_gl_context::GLContextAttributes; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] diff --git a/src/display_item.rs b/src/display_item.rs index f52695b05b..5c015347bd 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -1,7 +1,7 @@ use app_units::Au; use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; -use types::{WebGLContextId}; +use webgl::{WebGLContextId}; use euclid::{Point2D, Rect, Size2D}; #[derive(Debug, PartialEq, Serialize, Deserialize)] diff --git a/src/display_list.rs b/src/display_list.rs index 17156c79c9..e172fd5c0c 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -7,7 +7,7 @@ use std::mem; use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; -use types::{WebGLContextId}; +use webgl::{WebGLContextId}; #[derive(Serialize, Deserialize)] pub struct DrawListInfo { diff --git a/src/lib.rs b/src/lib.rs index a6a6c8489c..ba3074c4eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![feature(plugin)] #![feature(custom_derive)] +#![feature(core, nonzero)] #![plugin(serde_macros)] extern crate app_units; @@ -7,6 +8,8 @@ extern crate euclid; extern crate ipc_channel; extern crate serde; extern crate offscreen_gl_context; +extern crate core; +extern crate gleam; #[cfg(target_os="macos")] extern crate core_graphics; @@ -16,6 +19,7 @@ mod display_item; mod display_list; mod stacking_context; mod types; +mod webgl; pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender}; pub use display_list::{DisplayListBuilder, DisplayListItem}; @@ -30,4 +34,4 @@ pub use types::{DisplayListId, DisplayListMode, ImageRendering}; pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId}; -pub use types::{WebGLContextId, WebGLCommand}; +pub use webgl::*; diff --git a/src/types.rs b/src/types.rs index 6b94633063..8173ae2d53 100644 --- a/src/types.rs +++ b/src/types.rs @@ -272,12 +272,3 @@ pub enum StackingLevel { PositionedContent, Outlines, } - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -pub struct WebGLContextId(pub usize); - -#[derive(Debug, Serialize, Deserialize)] -pub enum WebGLCommand { - Clear(u32), - ClearColor(f32, f32, f32, f32), -} diff --git a/src/webgl.rs b/src/webgl.rs new file mode 100644 index 0000000000..89332c1a79 --- /dev/null +++ b/src/webgl.rs @@ -0,0 +1,339 @@ +use core::nonzero::NonZero; +use ipc_channel::ipc::IpcSender; +use gleam::gl; +use offscreen_gl_context::{GLContext, GLContextAttributes, NativeGLContextMethods}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct WebGLContextId(pub usize); + +#[derive(Clone, Copy, PartialEq, Deserialize, Serialize, HeapSizeOf)] +pub enum WebGLError { + InvalidEnum, + InvalidOperation, + InvalidValue, + OutOfMemory, + ContextLost, +} + +pub type WebGLResult = Result; + +#[derive(Clone, Deserialize, Serialize)] +pub enum WebGLFramebufferBindingRequest { + Explicit(u32), + Default, +} + +#[derive(Clone, Deserialize, Serialize)] +pub enum WebGLShaderParameter { + Int(i32), + Bool(bool), + Invalid, +} + +#[derive(Clone, Deserialize, Serialize)] +pub enum WebGLCommand { + GetContextAttributes(IpcSender), + ActiveTexture(u32), + BlendColor(f32, f32, f32, f32), + BlendEquation(u32), + BlendEquationSeparate(u32, u32), + BlendFunc(u32, u32), + BlendFuncSeparate(u32, u32, u32, u32), + AttachShader(u32, u32), + BufferData(u32, Vec, u32), + Clear(u32), + ClearColor(f32, f32, f32, f32), + ClearDepth(f64), + ClearStencil(i32), + ColorMask(bool, bool, bool, bool), + CullFace(u32), + FrontFace(u32), + DepthFunc(u32), + DepthMask(bool), + DepthRange(f64, f64), + Enable(u32), + Disable(u32), + CompileShader(u32, String), + CreateBuffer(IpcSender>>), + CreateFramebuffer(IpcSender>>), + CreateRenderbuffer(IpcSender>>), + CreateTexture(IpcSender>>), + CreateProgram(IpcSender>>), + CreateShader(u32, IpcSender>>), + DeleteBuffer(u32), + DeleteFramebuffer(u32), + DeleteRenderbuffer(u32), + DeleteTexture(u32), + DeleteProgram(u32), + DeleteShader(u32), + BindBuffer(u32, u32), + BindFramebuffer(u32, WebGLFramebufferBindingRequest), + BindRenderbuffer(u32, u32), + BindTexture(u32, u32), + DrawArrays(u32, i32, i32), + EnableVertexAttribArray(u32), + GetShaderParameter(u32, u32, IpcSender), + GetAttribLocation(u32, String, IpcSender>), + GetUniformLocation(u32, String, IpcSender>), + PolygonOffset(f32, f32), + Hint(u32, u32), + LineWidth(f32), + PixelStorei(u32, i32), + LinkProgram(u32), + Uniform4fv(i32, Vec), + UseProgram(u32), + VertexAttribPointer2f(u32, i32, bool, i32, u32), + Viewport(i32, i32, i32, i32), + TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec), + TexParameteri(u32, u32, i32), + TexParameterf(u32, u32, f32), + DrawingBufferWidth(IpcSender), + DrawingBufferHeight(IpcSender), +} + +impl WebGLCommand { + /// NOTE: This method consumes the command + pub fn apply(self, ctx: &GLContext) { + match self { + WebGLCommand::GetContextAttributes(sender) => + sender.send(*ctx.borrow_attributes()).unwrap(), + WebGLCommand::ActiveTexture(target) => + gl::active_texture(target), + WebGLCommand::BlendColor(r, g, b, a) => + gl::blend_color(r, g, b, a), + WebGLCommand::BlendEquation(mode) => + gl::blend_equation(mode), + WebGLCommand::BlendEquationSeparate(mode_rgb, mode_alpha) => + gl::blend_equation_separate(mode_rgb, mode_alpha), + WebGLCommand::BlendFunc(src, dest) => + gl::blend_func(src, dest), + WebGLCommand::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha) => + gl::blend_func_separate(src_rgb, dest_rgb, src_alpha, dest_alpha), + WebGLCommand::AttachShader(program_id, shader_id) => + gl::attach_shader(program_id, shader_id), + WebGLCommand::BufferData(buffer_type, data, usage) => + gl::buffer_data(buffer_type, &data, usage), + WebGLCommand::Clear(mask) => + gl::clear(mask), + WebGLCommand::ClearColor(r, g, b, a) => + gl::clear_color(r, g, b, a), + WebGLCommand::ClearDepth(depth) => + gl::clear_depth(depth), + WebGLCommand::ClearStencil(stencil) => + gl::clear_stencil(stencil), + WebGLCommand::ColorMask(r, g, b, a) => + gl::color_mask(r, g, b, a), + WebGLCommand::CullFace(mode) => + gl::cull_face(mode), + WebGLCommand::DepthFunc(func) => + gl::depth_func(func), + WebGLCommand::DepthMask(flag) => + gl::depth_mask(flag), + WebGLCommand::DepthRange(near, far) => + gl::depth_range(near, far), + WebGLCommand::Disable(cap) => + gl::disable(cap), + WebGLCommand::Enable(cap) => + gl::enable(cap), + WebGLCommand::FrontFace(mode) => + gl::front_face(mode), + WebGLCommand::DrawArrays(mode, first, count) => + gl::draw_arrays(mode, first, count), + WebGLCommand::Hint(name, val) => + gl::hint(name, val), + WebGLCommand::LineWidth(width) => + gl::line_width(width), + WebGLCommand::PixelStorei(name, val) => + gl::pixel_store_i(name, val), + WebGLCommand::PolygonOffset(factor, units) => + gl::polygon_offset(factor, units), + WebGLCommand::EnableVertexAttribArray(attrib_id) => + gl::enable_vertex_attrib_array(attrib_id), + WebGLCommand::GetAttribLocation(program_id, name, chan) => + WebGLCommand::attrib_location(program_id, name, chan), + WebGLCommand::GetShaderParameter(shader_id, param_id, chan) => + WebGLCommand::shader_parameter(shader_id, param_id, chan), + WebGLCommand::GetUniformLocation(program_id, name, chan) => + WebGLCommand::uniform_location(program_id, name, chan), + WebGLCommand::CompileShader(shader_id, source) => + WebGLCommand::compile_shader(shader_id, source), + WebGLCommand::CreateBuffer(chan) => + WebGLCommand::create_buffer(chan), + WebGLCommand::CreateFramebuffer(chan) => + WebGLCommand::create_framebuffer(chan), + WebGLCommand::CreateRenderbuffer(chan) => + WebGLCommand::create_renderbuffer(chan), + WebGLCommand::CreateTexture(chan) => + WebGLCommand::create_texture(chan), + WebGLCommand::CreateProgram(chan) => + WebGLCommand::create_program(chan), + WebGLCommand::CreateShader(shader_type, chan) => + WebGLCommand::create_shader(shader_type, chan), + WebGLCommand::DeleteBuffer(id) => + gl::delete_buffers(&[id]), + WebGLCommand::DeleteFramebuffer(id) => + gl::delete_framebuffers(&[id]), + WebGLCommand::DeleteRenderbuffer(id) => + gl::delete_renderbuffers(&[id]), + WebGLCommand::DeleteTexture(id) => + gl::delete_textures(&[id]), + WebGLCommand::DeleteProgram(id) => + gl::delete_program(id), + WebGLCommand::DeleteShader(id) => + gl::delete_shader(id), + WebGLCommand::BindBuffer(target, id) => + gl::bind_buffer(target, id), + WebGLCommand::BindFramebuffer(target, request) => + WebGLCommand::bind_framebuffer(target, request, ctx), + WebGLCommand::BindRenderbuffer(target, id) => + gl::bind_renderbuffer(target, id), + WebGLCommand::BindTexture(target, id) => + gl::bind_texture(target, id), + WebGLCommand::LinkProgram(program_id) => + gl::link_program(program_id), + WebGLCommand::Uniform4fv(uniform_id, data) => + gl::uniform_4f(uniform_id, data[0], data[1], data[2], data[3]), + WebGLCommand::UseProgram(program_id) => + gl::use_program(program_id), + WebGLCommand::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => + gl::vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset as u32), + WebGLCommand::Viewport(x, y, width, height) => + gl::viewport(x, y, width, height), + WebGLCommand::TexImage2D(target, level, internal, width, height, format, data_type, data) => + gl::tex_image_2d(target, level, internal, width, height, /*border*/0, format, data_type, Some(&data)), + WebGLCommand::TexParameteri(target, name, value) => + gl::tex_parameter_i(target, name, value), + WebGLCommand::TexParameterf(target, name, value) => + gl::tex_parameter_f(target, name, value), + WebGLCommand::DrawingBufferWidth(sender) => + sender.send(ctx.borrow_draw_buffer().unwrap().size().width).unwrap(), + WebGLCommand::DrawingBufferHeight(sender) => + sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), + + } + } + + fn attrib_location(program_id: u32, + name: String, + chan: IpcSender> ) { + let attrib_location = gl::get_attrib_location(program_id, &name); + + let attrib_location = if attrib_location == -1 { + None + } else { + Some(attrib_location) + }; + + chan.send(attrib_location).unwrap(); + } + + fn shader_parameter(shader_id: u32, + param_id: u32, + chan: IpcSender) { + let result = match param_id { + gl::SHADER_TYPE => + WebGLShaderParameter::Int(gl::get_shader_iv(shader_id, param_id)), + gl::DELETE_STATUS | gl::COMPILE_STATUS => + WebGLShaderParameter::Bool(gl::get_shader_iv(shader_id, param_id) != 0), + _ => panic!("Unexpected shader parameter type"), + }; + + chan.send(result).unwrap(); + } + + fn uniform_location(program_id: u32, + name: String, + chan: IpcSender>) { + let location = gl::get_uniform_location(program_id, &name); + let location = if location == -1 { + None + } else { + Some(location) + }; + + chan.send(location).unwrap(); + } + + fn create_buffer(chan: IpcSender>>) { + let buffer = gl::gen_buffers(1)[0]; + let buffer = if buffer == 0 { + None + } else { + Some(unsafe { NonZero::new(buffer) }) + }; + chan.send(buffer).unwrap(); + } + + fn create_framebuffer(chan: IpcSender>>) { + let framebuffer = gl::gen_framebuffers(1)[0]; + let framebuffer = if framebuffer == 0 { + None + } else { + Some(unsafe { NonZero::new(framebuffer) }) + }; + chan.send(framebuffer).unwrap(); + } + + + fn create_renderbuffer(chan: IpcSender>>) { + let renderbuffer = gl::gen_renderbuffers(1)[0]; + let renderbuffer = if renderbuffer == 0 { + None + } else { + Some(unsafe { NonZero::new(renderbuffer) }) + }; + chan.send(renderbuffer).unwrap(); + } + + fn create_texture(chan: IpcSender>>) { + let texture = gl::gen_framebuffers(1)[0]; + let texture = if texture == 0 { + None + } else { + Some(unsafe { NonZero::new(texture) }) + }; + chan.send(texture).unwrap(); + } + + + fn create_program(chan: IpcSender>>) { + let program = gl::create_program(); + let program = if program == 0 { + None + } else { + Some(unsafe { NonZero::new(program) }) + }; + chan.send(program).unwrap(); + } + + + fn create_shader(shader_type: u32, chan: IpcSender>>) { + let shader = gl::create_shader(shader_type); + let shader = if shader == 0 { + None + } else { + Some(unsafe { NonZero::new(shader) }) + }; + chan.send(shader).unwrap(); + } + + #[inline] + fn bind_framebuffer(target: u32, + request: WebGLFramebufferBindingRequest, + ctx: &GLContext) { + let id = match request { + WebGLFramebufferBindingRequest::Explicit(id) => id, + WebGLFramebufferBindingRequest::Default => + ctx.borrow_draw_buffer().unwrap().get_framebuffer(), + }; + + gl::bind_framebuffer(target, id); + } + + + #[inline] + fn compile_shader(shader_id: u32, source: String) { + gl::shader_source(shader_id, &[source.as_bytes()]); + gl::compile_shader(shader_id); + } +} From e6f54eb8f0fa702340ff764c96495c27d398088c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 2 Dec 2015 12:27:48 -0800 Subject: [PATCH 15/97] Make `MixBlendMode` hashable. --- src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 6b94633063..f84e0aec20 100644 --- a/src/types.rs +++ b/src/types.rs @@ -205,7 +205,7 @@ impl ImageKey { } } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] pub enum MixBlendMode { Normal, Multiply, From 2e10c9b7943f406c72d5b7b2d3d1b5e3ca54d20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 3 Dec 2015 02:45:34 +0100 Subject: [PATCH 16/97] webgl: Fix texturing I discovered this while debugging the texture test (which worked without the framebuffer unbinding). PR to servo/servo incoming too. --- src/webgl.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 89332c1a79..96756eb9e7 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -209,7 +209,6 @@ impl WebGLCommand { sender.send(ctx.borrow_draw_buffer().unwrap().size().width).unwrap(), WebGLCommand::DrawingBufferHeight(sender) => sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), - } } @@ -286,7 +285,7 @@ impl WebGLCommand { } fn create_texture(chan: IpcSender>>) { - let texture = gl::gen_framebuffers(1)[0]; + let texture = gl::gen_textures(1)[0]; let texture = if texture == 0 { None } else { From fec89a4aa73d685526e5233798dd236d55113dec Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 7 Dec 2015 02:46:24 +1000 Subject: [PATCH 17/97] rustup --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb7a9387bd..26605a5c1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ git = "https://github.com/servo/ipc-channel" [dependencies] app_units = "0.1" -euclid = "0.3" +euclid = {version = "0.4", features = ["plugins"]} gleam = "*" serde = "0.6" -serde_macros = "0.5" +serde_macros = "0.6" [target.x86_64-apple-darwin.dependencies] core-graphics = "*" From 70f35071600c628d1529217c2d6705e0a3487164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 7 Dec 2015 17:54:17 +0100 Subject: [PATCH 18/97] webgl: Fix pending changes from rebase --- src/webgl.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/webgl.rs b/src/webgl.rs index 96756eb9e7..9ad42d6da6 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -40,7 +40,8 @@ pub enum WebGLCommand { BlendFunc(u32, u32), BlendFuncSeparate(u32, u32, u32, u32), AttachShader(u32, u32), - BufferData(u32, Vec, u32), + BufferData(u32, Vec, u32), + BufferSubData(u32, isize, Vec), Clear(u32), ClearColor(f32, f32, f32, f32), ClearDepth(f64), @@ -113,6 +114,8 @@ impl WebGLCommand { gl::attach_shader(program_id, shader_id), WebGLCommand::BufferData(buffer_type, data, usage) => gl::buffer_data(buffer_type, &data, usage), + WebGLCommand::BufferSubData(buffer_type, offset, data) => + gl::buffer_sub_data(buffer_type, offset, &data), WebGLCommand::Clear(mask) => gl::clear(mask), WebGLCommand::ClearColor(r, g, b, a) => @@ -210,6 +213,9 @@ impl WebGLCommand { WebGLCommand::DrawingBufferHeight(sender) => sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), } + + // FIXME: Convert to `debug_assert!` once tests are run with debug assertions + assert!(gl::get_error() == gl::NO_ERROR); } fn attrib_location(program_id: u32, From a68695ed4d80db654fef1cba7ad532319bcfa952 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 15 Dec 2015 09:00:28 +1000 Subject: [PATCH 19/97] Fix gleam dep --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 26605a5c1f..92335187c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ git = "https://github.com/servo/ipc-channel" [dependencies] app_units = "0.1" euclid = {version = "0.4", features = ["plugins"]} -gleam = "*" +gleam = "0.2" serde = "0.6" serde_macros = "0.6" From 960e48f590b44a4db0b6b5ea740e9fdf0f4e2020 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 22 Dec 2015 10:40:20 +1000 Subject: [PATCH 20/97] Update api for WR changes --- src/display_list.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/display_list.rs b/src/display_list.rs index e172fd5c0c..12b5ef6ced 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -22,8 +22,7 @@ pub struct StackingContextInfo { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct IframeInfo { pub id: PipelineId, - pub offset: Point2D, - pub clip: Rect, + pub bounds: Rect, } #[derive(Serialize, Deserialize)] @@ -264,8 +263,7 @@ impl DisplayListBuilder { self.flush_list(level); let info = Box::new(IframeInfo { id: iframe, - offset: rect.origin, - clip: rect, + bounds: rect, }); let item = DisplayListItem { stacking_level: level, From 864b212a08116b185c221cbfc1929eb048aa4f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 4 Jan 2016 12:08:35 +0100 Subject: [PATCH 21/97] webgl: Missing WebGL implementation details post-rebase --- src/webgl.rs | 223 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 203 insertions(+), 20 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 9ad42d6da6..d2fc092e6d 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -23,6 +23,15 @@ pub enum WebGLFramebufferBindingRequest { Default, } +#[derive(Clone, Deserialize, Serialize)] +pub enum WebGLParameter { + Int(i32), + Bool(bool), + String(String), + Float(f32), + Invalid, +} + #[derive(Clone, Deserialize, Serialize)] pub enum WebGLShaderParameter { Int(i32), @@ -40,6 +49,7 @@ pub enum WebGLCommand { BlendFunc(u32, u32), BlendFuncSeparate(u32, u32, u32, u32), AttachShader(u32, u32), + BindAttribLocation(u32, u32, String), BufferData(u32, Vec, u32), BufferSubData(u32, isize, Vec), Clear(u32), @@ -72,17 +82,23 @@ pub enum WebGLCommand { BindRenderbuffer(u32, u32), BindTexture(u32, u32), DrawArrays(u32, i32, i32), + DrawElements(u32, i32, u32, i64), EnableVertexAttribArray(u32), - GetShaderParameter(u32, u32, IpcSender), + GetBufferParameter(u32, u32, IpcSender>), + GetParameter(u32, IpcSender>), + GetProgramParameter(u32, u32, IpcSender>), + GetShaderParameter(u32, u32, IpcSender>), GetAttribLocation(u32, String, IpcSender>), GetUniformLocation(u32, String, IpcSender>), PolygonOffset(f32, f32), + Scissor(i32, i32, i32, i32), Hint(u32, u32), LineWidth(f32), PixelStorei(u32, i32), LinkProgram(u32), Uniform4fv(i32, Vec), UseProgram(u32), + VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), Viewport(i32, i32, i32, i32), TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec), @@ -100,6 +116,10 @@ impl WebGLCommand { sender.send(*ctx.borrow_attributes()).unwrap(), WebGLCommand::ActiveTexture(target) => gl::active_texture(target), + WebGLCommand::AttachShader(program_id, shader_id) => + gl::attach_shader(program_id, shader_id), + WebGLCommand::BindAttribLocation(program_id, index, name) => + gl::bind_attrib_location(program_id, index, &name), WebGLCommand::BlendColor(r, g, b, a) => gl::blend_color(r, g, b, a), WebGLCommand::BlendEquation(mode) => @@ -110,8 +130,6 @@ impl WebGLCommand { gl::blend_func(src, dest), WebGLCommand::BlendFuncSeparate(src_rgb, dest_rgb, src_alpha, dest_alpha) => gl::blend_func_separate(src_rgb, dest_rgb, src_alpha, dest_alpha), - WebGLCommand::AttachShader(program_id, shader_id) => - gl::attach_shader(program_id, shader_id), WebGLCommand::BufferData(buffer_type, data, usage) => gl::buffer_data(buffer_type, &data, usage), WebGLCommand::BufferSubData(buffer_type, offset, data) => @@ -142,6 +160,8 @@ impl WebGLCommand { gl::front_face(mode), WebGLCommand::DrawArrays(mode, first, count) => gl::draw_arrays(mode, first, count), + WebGLCommand::DrawElements(mode, count, type_, offset) => + gl::draw_elements(mode, count, type_, offset as u32), WebGLCommand::Hint(name, val) => gl::hint(name, val), WebGLCommand::LineWidth(width) => @@ -150,28 +170,36 @@ impl WebGLCommand { gl::pixel_store_i(name, val), WebGLCommand::PolygonOffset(factor, units) => gl::polygon_offset(factor, units), + WebGLCommand::Scissor(x, y, width, height) => + gl::scissor(x, y, width, height), WebGLCommand::EnableVertexAttribArray(attrib_id) => gl::enable_vertex_attrib_array(attrib_id), WebGLCommand::GetAttribLocation(program_id, name, chan) => - WebGLCommand::attrib_location(program_id, name, chan), + Self::attrib_location(program_id, name, chan), + WebGLCommand::GetBufferParameter(target, param_id, chan) => + Self::buffer_parameter(target, param_id, chan), + WebGLCommand::GetParameter(param_id, chan) => + Self::parameter(param_id, chan), + WebGLCommand::GetProgramParameter(program_id, param_id, chan) => + Self::program_parameter(program_id, param_id, chan), WebGLCommand::GetShaderParameter(shader_id, param_id, chan) => - WebGLCommand::shader_parameter(shader_id, param_id, chan), + Self::shader_parameter(shader_id, param_id, chan), WebGLCommand::GetUniformLocation(program_id, name, chan) => - WebGLCommand::uniform_location(program_id, name, chan), + Self::uniform_location(program_id, name, chan), WebGLCommand::CompileShader(shader_id, source) => - WebGLCommand::compile_shader(shader_id, source), + Self::compile_shader(shader_id, source), WebGLCommand::CreateBuffer(chan) => - WebGLCommand::create_buffer(chan), + Self::create_buffer(chan), WebGLCommand::CreateFramebuffer(chan) => - WebGLCommand::create_framebuffer(chan), + Self::create_framebuffer(chan), WebGLCommand::CreateRenderbuffer(chan) => - WebGLCommand::create_renderbuffer(chan), + Self::create_renderbuffer(chan), WebGLCommand::CreateTexture(chan) => - WebGLCommand::create_texture(chan), + Self::create_texture(chan), WebGLCommand::CreateProgram(chan) => - WebGLCommand::create_program(chan), + Self::create_program(chan), WebGLCommand::CreateShader(shader_type, chan) => - WebGLCommand::create_shader(shader_type, chan), + Self::create_shader(shader_type, chan), WebGLCommand::DeleteBuffer(id) => gl::delete_buffers(&[id]), WebGLCommand::DeleteFramebuffer(id) => @@ -187,7 +215,7 @@ impl WebGLCommand { WebGLCommand::BindBuffer(target, id) => gl::bind_buffer(target, id), WebGLCommand::BindFramebuffer(target, request) => - WebGLCommand::bind_framebuffer(target, request, ctx), + Self::bind_framebuffer(target, request, ctx), WebGLCommand::BindRenderbuffer(target, id) => gl::bind_renderbuffer(target, id), WebGLCommand::BindTexture(target, id) => @@ -198,6 +226,8 @@ impl WebGLCommand { gl::uniform_4f(uniform_id, data[0], data[1], data[2], data[3]), WebGLCommand::UseProgram(program_id) => gl::use_program(program_id), + WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => + gl::vertex_attrib_4f(attrib_id, x, y, z, w), WebGLCommand::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => gl::vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset as u32), WebGLCommand::Viewport(x, y, width, height) => @@ -232,15 +262,169 @@ impl WebGLCommand { chan.send(attrib_location).unwrap(); } + fn parameter(param_id: u32, + chan: IpcSender>) { + let result = match param_id { + gl::ACTIVE_TEXTURE | + gl::ALPHA_BITS | + gl::BLEND_DST_ALPHA | + gl::BLEND_DST_RGB | + gl::BLEND_EQUATION_ALPHA | + gl::BLEND_EQUATION_RGB | + gl::BLEND_SRC_ALPHA | + gl::BLEND_SRC_RGB | + gl::BLUE_BITS | + gl::CULL_FACE_MODE | + gl::DEPTH_BITS | + gl::DEPTH_FUNC | + gl::FRONT_FACE | + gl::GENERATE_MIPMAP_HINT | + gl::GREEN_BITS | + //gl::IMPLEMENTATION_COLOR_READ_FORMAT | + //gl::IMPLEMENTATION_COLOR_READ_TYPE | + gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS | + gl::MAX_CUBE_MAP_TEXTURE_SIZE | + //gl::MAX_FRAGMENT_UNIFORM_VECTORS | + gl::MAX_RENDERBUFFER_SIZE | + gl::MAX_TEXTURE_IMAGE_UNITS | + gl::MAX_TEXTURE_SIZE | + //gl::MAX_VARYING_VECTORS | + gl::MAX_VERTEX_ATTRIBS | + gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS | + //gl::MAX_VERTEX_UNIFORM_VECTORS | + gl::PACK_ALIGNMENT | + gl::RED_BITS | + gl::SAMPLE_BUFFERS | + gl::SAMPLES | + gl::STENCIL_BACK_FAIL | + gl::STENCIL_BACK_FUNC | + gl::STENCIL_BACK_PASS_DEPTH_FAIL | + gl::STENCIL_BACK_PASS_DEPTH_PASS | + gl::STENCIL_BACK_REF | + gl::STENCIL_BACK_VALUE_MASK | + gl::STENCIL_BACK_WRITEMASK | + gl::STENCIL_BITS | + gl::STENCIL_CLEAR_VALUE | + gl::STENCIL_FAIL | + gl::STENCIL_FUNC | + gl::STENCIL_PASS_DEPTH_FAIL | + gl::STENCIL_PASS_DEPTH_PASS | + gl::STENCIL_REF | + gl::STENCIL_VALUE_MASK | + gl::STENCIL_WRITEMASK | + gl::SUBPIXEL_BITS | + gl::UNPACK_ALIGNMENT => + //gl::UNPACK_COLORSPACE_CONVERSION_WEBGL => + Ok(WebGLParameter::Int(gl::get_integer_v(param_id))), + + gl::BLEND | + gl::CULL_FACE | + gl::DEPTH_TEST | + gl::DEPTH_WRITEMASK | + gl::DITHER | + gl::POLYGON_OFFSET_FILL | + gl::SAMPLE_COVERAGE_INVERT | + gl::STENCIL_TEST => + //gl::UNPACK_FLIP_Y_WEBGL | + //gl::UNPACK_PREMULTIPLY_ALPHA_WEBGL => + Ok(WebGLParameter::Bool(gl::get_boolean_v(param_id) != 0)), + + gl::DEPTH_CLEAR_VALUE | + gl::LINE_WIDTH | + gl::POLYGON_OFFSET_FACTOR | + gl::POLYGON_OFFSET_UNITS | + gl::SAMPLE_COVERAGE_VALUE => + Ok(WebGLParameter::Float(gl::get_float_v(param_id))), + + gl::VERSION => Ok(WebGLParameter::String("WebGL 1.0".to_owned())), + gl::RENDERER | + gl::VENDOR => Ok(WebGLParameter::String("Mozilla/Servo".to_owned())), + gl::SHADING_LANGUAGE_VERSION => Ok(WebGLParameter::String("WebGL GLSL ES 1.0".to_owned())), + + // TODO(zbarsky, ecoal95): Implement support for the following valid parameters + // Float32Array + gl::ALIASED_LINE_WIDTH_RANGE | + gl::ALIASED_POINT_SIZE_RANGE | + //gl::BLEND_COLOR | + gl::COLOR_CLEAR_VALUE | + gl::DEPTH_RANGE | + + // WebGLBuffer + gl::ARRAY_BUFFER_BINDING | + gl::ELEMENT_ARRAY_BUFFER_BINDING | + + // WebGLFrameBuffer + gl::FRAMEBUFFER_BINDING | + + // WebGLRenderBuffer + gl::RENDERBUFFER_BINDING | + + // WebGLProgram + gl::CURRENT_PROGRAM | + + // WebGLTexture + gl::TEXTURE_BINDING_2D | + gl::TEXTURE_BINDING_CUBE_MAP | + + // sequence + gl::COLOR_WRITEMASK | + + // Uint32Array + gl::COMPRESSED_TEXTURE_FORMATS | + + // Int32Array + gl::MAX_VIEWPORT_DIMS | + gl::SCISSOR_BOX | + gl::VIEWPORT => Err(WebGLError::InvalidEnum), + + // Invalid parameters + _ => Err(WebGLError::InvalidEnum) + }; + + chan.send(result).unwrap(); + } + + fn buffer_parameter(target: u32, + param_id: u32, + chan: IpcSender>) { + let result = match param_id { + gl::BUFFER_SIZE | + gl::BUFFER_USAGE => + Ok(WebGLParameter::Int(gl::get_buffer_parameter_iv(target, param_id))), + _ => Err(WebGLError::InvalidEnum), + }; + + chan.send(result).unwrap(); + } + + fn program_parameter(program_id: u32, + param_id: u32, + chan: IpcSender>) { + let result = match param_id { + gl::DELETE_STATUS | + gl::LINK_STATUS | + gl::VALIDATE_STATUS => + Ok(WebGLParameter::Bool(gl::get_program_iv(program_id, param_id) != 0)), + gl::ATTACHED_SHADERS | + gl::ACTIVE_ATTRIBUTES | + gl::ACTIVE_UNIFORMS => + Ok(WebGLParameter::Int(gl::get_program_iv(program_id, param_id))), + _ => Err(WebGLError::InvalidEnum), + }; + + chan.send(result).unwrap(); + } + fn shader_parameter(shader_id: u32, param_id: u32, - chan: IpcSender) { + chan: IpcSender>) { let result = match param_id { gl::SHADER_TYPE => - WebGLShaderParameter::Int(gl::get_shader_iv(shader_id, param_id)), - gl::DELETE_STATUS | gl::COMPILE_STATUS => - WebGLShaderParameter::Bool(gl::get_shader_iv(shader_id, param_id) != 0), - _ => panic!("Unexpected shader parameter type"), + Ok(WebGLParameter::Int(gl::get_shader_iv(shader_id, param_id))), + gl::DELETE_STATUS | + gl::COMPILE_STATUS => + Ok(WebGLParameter::Bool(gl::get_shader_iv(shader_id, param_id) != 0)), + _ => Err(WebGLError::InvalidEnum), }; chan.send(result).unwrap(); @@ -311,7 +495,6 @@ impl WebGLCommand { chan.send(program).unwrap(); } - fn create_shader(shader_type: u32, chan: IpcSender>>) { let shader = gl::create_shader(shader_type); let shader = if shader == 0 { From 48056c072f2fd68f9951d747201323fa2910be89 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 11 Jan 2016 10:04:07 +1000 Subject: [PATCH 22/97] warning fixes --- src/lib.rs | 2 +- src/webgl.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ba3074c4eb..65ec626c8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![feature(plugin)] #![feature(custom_derive)] -#![feature(core, nonzero)] +#![feature(nonzero)] #![plugin(serde_macros)] extern crate app_units; diff --git a/src/webgl.rs b/src/webgl.rs index d2fc092e6d..44432bc059 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -6,7 +6,7 @@ use offscreen_gl_context::{GLContext, GLContextAttributes, NativeGLContextMethod #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct WebGLContextId(pub usize); -#[derive(Clone, Copy, PartialEq, Deserialize, Serialize, HeapSizeOf)] +#[derive(Clone, Copy, PartialEq, Deserialize, Serialize)] pub enum WebGLError { InvalidEnum, InvalidOperation, From 3d7eff9542575c9d6dd72234ec53bf59fc642e53 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 8 Jan 2016 14:14:37 +1000 Subject: [PATCH 23/97] Change scroll layer id to include pipeline id. --- src/types.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/types.rs b/src/types.rs index 486590e036..af63bcfbdf 100644 --- a/src/types.rs +++ b/src/types.rs @@ -4,9 +4,6 @@ use euclid::{Rect, Size2D}; #[cfg(target_os="macos")] use core_graphics::font::CGFont; -// TODO: This is bogus - work out a clean way to generate scroll layer IDs that integrates well with servo... -const FIXED_SCROLL_LAYER_ID: usize = 0xffffffff; - #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct BorderRadius { pub top_left: Size2D, @@ -93,13 +90,6 @@ impl ComplexClipRegion { radii: radii, } } - - pub fn from_rect(rect: &Rect) -> ComplexClipRegion { - ComplexClipRegion { - rect: *rect, - radii: BorderRadius::zero(), - } - } } #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] @@ -244,16 +234,18 @@ pub trait RenderNotifier : Send { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct ScrollLayerId(pub usize); +pub enum ScrollLayerId { + Fixed, + Normal(PipelineId, usize) +} impl ScrollLayerId { - pub fn new(value: usize) -> ScrollLayerId { - debug_assert!(value != FIXED_SCROLL_LAYER_ID); - ScrollLayerId(value) + pub fn new(pipeline_id: PipelineId, index: usize) -> ScrollLayerId { + ScrollLayerId::Normal(pipeline_id, index) } pub fn fixed_layer() -> ScrollLayerId { - ScrollLayerId(FIXED_SCROLL_LAYER_ID) + ScrollLayerId::Fixed } } From 22f2bd2268d9d6841f32d186b680f5acf7ea06f4 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 15 Jan 2016 16:09:20 +1000 Subject: [PATCH 24/97] api fix --- src/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api.rs b/src/api.rs index aafef50a28..bfade0570c 100644 --- a/src/api.rs +++ b/src/api.rs @@ -25,7 +25,7 @@ pub enum ApiMsg { CloneApi(IpcSender), SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId), SetRootPipeline(PipelineId), - Scroll(Point2D), + Scroll(Point2D, Point2D), TranslatePointToLayerSpace(Point2D, IpcSender>), RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), WebGLCommand(WebGLContextId, WebGLCommand), @@ -152,8 +152,8 @@ impl RenderApi { self.tx.send(msg).unwrap(); } - pub fn scroll(&self, delta: Point2D) { - let msg = ApiMsg::Scroll(delta); + pub fn scroll(&self, delta: Point2D, cursor: Point2D) { + let msg = ApiMsg::Scroll(delta, cursor); self.tx.send(msg).unwrap(); } From 46a7cb1c2f6e22569f5f75b2135ae71bfa16c9b3 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 21 Jan 2016 13:13:22 +1000 Subject: [PATCH 25/97] Compile updates after instancing changes --- src/webgl.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 44432bc059..1ace6c11ec 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -266,20 +266,20 @@ impl WebGLCommand { chan: IpcSender>) { let result = match param_id { gl::ACTIVE_TEXTURE | - gl::ALPHA_BITS | + //gl::ALPHA_BITS | gl::BLEND_DST_ALPHA | gl::BLEND_DST_RGB | gl::BLEND_EQUATION_ALPHA | gl::BLEND_EQUATION_RGB | gl::BLEND_SRC_ALPHA | gl::BLEND_SRC_RGB | - gl::BLUE_BITS | + //gl::BLUE_BITS | gl::CULL_FACE_MODE | - gl::DEPTH_BITS | + //gl::DEPTH_BITS | gl::DEPTH_FUNC | gl::FRONT_FACE | - gl::GENERATE_MIPMAP_HINT | - gl::GREEN_BITS | + //gl::GENERATE_MIPMAP_HINT | + //gl::GREEN_BITS | //gl::IMPLEMENTATION_COLOR_READ_FORMAT | //gl::IMPLEMENTATION_COLOR_READ_TYPE | gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS | @@ -293,7 +293,7 @@ impl WebGLCommand { gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS | //gl::MAX_VERTEX_UNIFORM_VECTORS | gl::PACK_ALIGNMENT | - gl::RED_BITS | + //gl::RED_BITS | gl::SAMPLE_BUFFERS | gl::SAMPLES | gl::STENCIL_BACK_FAIL | @@ -303,7 +303,7 @@ impl WebGLCommand { gl::STENCIL_BACK_REF | gl::STENCIL_BACK_VALUE_MASK | gl::STENCIL_BACK_WRITEMASK | - gl::STENCIL_BITS | + //gl::STENCIL_BITS | gl::STENCIL_CLEAR_VALUE | gl::STENCIL_FAIL | gl::STENCIL_FUNC | @@ -344,7 +344,7 @@ impl WebGLCommand { // TODO(zbarsky, ecoal95): Implement support for the following valid parameters // Float32Array gl::ALIASED_LINE_WIDTH_RANGE | - gl::ALIASED_POINT_SIZE_RANGE | + //gl::ALIASED_POINT_SIZE_RANGE | //gl::BLEND_COLOR | gl::COLOR_CLEAR_VALUE | gl::DEPTH_RANGE | From 10d52fd52288d689f153be497b24d71fb90ecf3a Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 27 Jan 2016 15:59:57 +1000 Subject: [PATCH 26/97] Switch offscreen rendering context from webrender -> master branch. --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 92335187c4..2a87e84674 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Glenn Watson "] [dependencies.offscreen_gl_context] git = "https://github.com/ecoal95/rust-offscreen-rendering-context" -branch = "webrender" [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" From 3dc7d8bf7306c60fec6f4ba14b9b734b494ac782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 28 Jan 2016 13:59:03 +0100 Subject: [PATCH 27/97] webgl: Pending fixups --- src/webgl.rs | 91 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 1ace6c11ec..ace9e7d9af 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -2,6 +2,7 @@ use core::nonzero::NonZero; use ipc_channel::ipc::IpcSender; use gleam::gl; use offscreen_gl_context::{GLContext, GLContextAttributes, NativeGLContextMethods}; +use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct WebGLContextId(pub usize); @@ -96,7 +97,8 @@ pub enum WebGLCommand { LineWidth(f32), PixelStorei(u32, i32), LinkProgram(u32), - Uniform4fv(i32, Vec), + Uniform1f(i32, f32), + Uniform4f(i32, f32, f32, f32, f32), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), @@ -108,6 +110,82 @@ pub enum WebGLCommand { DrawingBufferHeight(IpcSender), } +impl fmt::Debug for WebGLCommand { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use WebGLCommand::*; + let name = match *self { + GetContextAttributes(..) => "GetContextAttributes", + ActiveTexture(..) => "ActiveTexture", + BlendColor(..) => "BlendColor", + BlendEquation(..) => "BlendEquation", + BlendEquationSeparate(..) => "BlendEquationSeparate", + BlendFunc(..) => "BlendFunc", + BlendFuncSeparate(..) => "BlendFuncSeparate", + AttachShader(..) => "AttachShader", + BindAttribLocation(..) => "BindAttribLocation", + BufferData(..) => "BufferData", + BufferSubData(..) => "BufferSubData", + Clear(..) => "Clear", + ClearColor(..) => "ClearColor", + ClearDepth(..) => "ClearDepth", + ClearStencil(..) => "ClearStencil", + ColorMask(..) => "ColorMask", + CullFace(..) => "CullFace", + FrontFace(..) => "FrontFace", + DepthFunc(..) => "DepthFunc", + DepthMask(..) => "DepthMask", + DepthRange(..) => "DepthRange", + Enable(..) => "Enable", + Disable(..) => "Disable", + CompileShader(..) => "CompileShader", + CreateBuffer(..) => "CreateBuffer", + CreateFramebuffer(..) => "CreateFramebuffer", + CreateRenderbuffer(..) => "CreateRenderbuffer", + CreateTexture(..) => "CreateTexture", + CreateProgram(..) => "CreateProgram", + CreateShader(..) => "CreateShader", + DeleteBuffer(..) => "DeleteBuffer", + DeleteFramebuffer(..) => "DeleteFramebuffer", + DeleteRenderbuffer(..) => "DeleteRenderBuffer", + DeleteTexture(..) => "DeleteTexture", + DeleteProgram(..) => "DeleteProgram", + DeleteShader(..) => "DeleteShader", + BindBuffer(..) => "BindBuffer", + BindFramebuffer(..) => "BindFramebuffer", + BindRenderbuffer(..) => "BindRenderbuffer", + BindTexture(..) => "BindTexture", + DrawArrays(..) => "DrawArrays", + DrawElements(..) => "DrawElements", + EnableVertexAttribArray(..) => "EnableVertexAttribArray", + GetBufferParameter(..) => "GetBufferParameter", + GetParameter(..) => "GetParameter", + GetProgramParameter(..) => "GetProgramParameter", + GetShaderParameter(..) => "GetShaderParameter", + GetAttribLocation(..) => "GetAttribLocation", + GetUniformLocation(..) => "GetUniformLocation", + PolygonOffset(..) => "PolygonOffset", + Scissor(..) => "Scissor", + Hint(..) => "Hint", + LineWidth(..) => "LineWidth", + PixelStorei(..) => "PixelStorei", + LinkProgram(..) => "LinkProgram", + Uniform4f(..) => "Uniform4f", + Uniform1f(..) => "Uniform1f", + UseProgram(..) => "UseProgram", + VertexAttrib(..) => "VertexAttrib", + VertexAttribPointer2f(..) => "VertexAttribPointer2f", + Viewport(..) => "Viewport", + TexImage2D(..) => "TexImage2D", + TexParameteri(..) => "TexParameteri", + TexParameterf(..) => "TexParameterf", + DrawingBufferWidth(..) => "DrawingBufferWidth", + DrawingBufferHeight(..) => "DrawingBufferHeight", + }; + + write!(f, "CanvasWebGLMsg::{}(..)", name) + } +} + impl WebGLCommand { /// NOTE: This method consumes the command pub fn apply(self, ctx: &GLContext) { @@ -222,8 +300,10 @@ impl WebGLCommand { gl::bind_texture(target, id), WebGLCommand::LinkProgram(program_id) => gl::link_program(program_id), - WebGLCommand::Uniform4fv(uniform_id, data) => - gl::uniform_4f(uniform_id, data[0], data[1], data[2], data[3]), + WebGLCommand::Uniform1f(uniform_id, v) => + gl::uniform_1f(uniform_id, v), + WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => + gl::uniform_4f(uniform_id, x, y, z, w), WebGLCommand::UseProgram(program_id) => gl::use_program(program_id), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => @@ -244,8 +324,9 @@ impl WebGLCommand { sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), } - // FIXME: Convert to `debug_assert!` once tests are run with debug assertions - assert!(gl::get_error() == gl::NO_ERROR); + // FIXME: Use debug_assertions once tests are run with them + let error = gl::get_error(); + assert!(error == gl::NO_ERROR, "Unexpected WebGL error: 0x{:x} ({})", error, error); } fn attrib_location(program_id: u32, From 383fb9cbd59d025b290f75323f5458b56be19454 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 29 Jan 2016 17:25:40 +1000 Subject: [PATCH 28/97] Resizing --- src/api.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api.rs b/src/api.rs index bfade0570c..5f712c8bba 100644 --- a/src/api.rs +++ b/src/api.rs @@ -23,7 +23,7 @@ pub enum ApiMsg { AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), AddStackingContext(StackingContextId, PipelineId, Epoch, StackingContext), CloneApi(IpcSender), - SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId), + SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId, Size2D), SetRootPipeline(PipelineId), Scroll(Point2D, Point2D), TranslatePointToLayerSpace(Point2D, IpcSender>), @@ -144,11 +144,13 @@ impl RenderApi { stacking_context_id: StackingContextId, background_color: ColorF, epoch: Epoch, - pipeline_id: PipelineId) { + pipeline_id: PipelineId, + viewport_size: Size2D) { let msg = ApiMsg::SetRootStackingContext(stacking_context_id, background_color, epoch, - pipeline_id); + pipeline_id, + viewport_size); self.tx.send(msg).unwrap(); } From 48a9902d59d9ef0a8f219a50f7ecf8c197cac461 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 5 Feb 2016 12:29:37 +1000 Subject: [PATCH 29/97] Update app_units --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2a87e84674..f75bd475cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/ecoal95/rust-offscreen-rendering-context" git = "https://github.com/servo/ipc-channel" [dependencies] -app_units = "0.1" +app_units = {version = "0.2", features = ["plugins"]} euclid = {version = "0.4", features = ["plugins"]} gleam = "0.2" serde = "0.6" From 2f8e25061cc186ade40156687b0978a1ed5e7286 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 5 Feb 2016 12:32:28 +1000 Subject: [PATCH 30/97] Update euclid --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f75bd475cf..87d8faa842 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ git = "https://github.com/servo/ipc-channel" [dependencies] app_units = {version = "0.2", features = ["plugins"]} -euclid = {version = "0.4", features = ["plugins"]} +euclid = {version = "0.6.1", features = ["plugins"]} gleam = "0.2" serde = "0.6" serde_macros = "0.6" From 8ccc1608590d219d1df54e49f2f1e887995b4d60 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 10 Feb 2016 10:01:58 +1000 Subject: [PATCH 31/97] Add license info --- LICENSE | 374 ++++++++++++++++++++++++++++++++++++++++ src/api.rs | 4 + src/display_item.rs | 4 + src/display_list.rs | 4 + src/lib.rs | 4 + src/stacking_context.rs | 4 + src/types.rs | 4 + src/webgl.rs | 4 + 8 files changed, 402 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..398385c9fb --- /dev/null +++ b/LICENSE @@ -0,0 +1,374 @@ + Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" +means each individual or legal entity that creates, contributes to +the creation of, or owns Covered Software. + +1.2. "Contributor Version" +means the combination of the Contributions of others (if any) used +by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" +means Covered Software of a particular Contributor. + +1.4. "Covered Software" +means Source Code Form to which the initial Contributor has attached +the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case +including portions thereof. + +1.5. "Incompatible With Secondary Licenses" +means + +(a) that the initial Contributor has attached the notice described +in Exhibit B to the Covered Software; or + +(b) that the Covered Software was made available under the terms of +version 1.1 or earlier of the License, but not also under the +terms of a Secondary License. + +1.6. "Executable Form" +means any form of the work other than Source Code Form. + +1.7. "Larger Work" +means a work that combines Covered Software with other material, in +a separate file or files, that is not Covered Software. + +1.8. "License" +means this document. + +1.9. "Licensable" +means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently, any and +all of the rights conveyed by this License. + +1.10. "Modifications" +means any of the following: + +(a) any file in Source Code Form that results from an addition to, +deletion from, or modification of the contents of Covered +Software; or + +(b) any new file in Source Code Form that contains any Covered +Software. + +1.11. "Patent Claims" of a Contributor +means any patent claim(s), including without limitation, method, +process, and apparatus claims, in any patent Licensable by such +Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having +made, import, or transfer of either its Contributions or its +Contributor Version. + +1.12. "Secondary License" +means either the GNU General Public License, Version 2.0, the GNU +Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those +licenses. + +1.13. "Source Code Form" +means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") +means an individual or a legal entity exercising rights under this +License. For legal entities, "You" includes any entity that +controls, is controlled by, or is under common control with You. For +purposes of this definition, "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than +fifty percent (50%) of the outstanding shares or beneficial +ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, +modify, display, perform, distribute, and otherwise exploit its +Contributions, either on an unmodified basis, with Modifications, or +as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer +for sale, have made, import, and otherwise transfer either its +Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; +or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its +Contributions with other software (except as part of its Contributor +Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of +its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code +Form, as described in Section 3.1, and You must inform recipients of +the Executable Form how they can obtain a copy of such Source Code +Form by reasonable means in a timely manner, at a charge no more +than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this +License, or sublicense it under different terms, provided that the +license for the Executable Form does not attempt to limit or alter +the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + +This Source Code Form is subject to the terms of the Mozilla Public +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/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + +This Source Code Form is "Incompatible With Secondary Licenses", as +defined by the Mozilla Public License, v. 2.0. + diff --git a/src/api.rs b/src/api.rs index 5f712c8bba..b9e9b738ec 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 display_list::DisplayListBuilder; use euclid::{Point2D, Size2D}; use ipc_channel::ipc::{self, IpcSender}; diff --git a/src/display_item.rs b/src/display_item.rs index 5c015347bd..2b4850fd8a 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 app_units::Au; use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; diff --git a/src/display_list.rs b/src/display_list.rs index 12b5ef6ced..c3e2465d52 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 app_units::Au; use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisplayItem}; use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; diff --git a/src/lib.rs b/src/lib.rs index 65ec626c8b..b9475cdbc1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + #![feature(plugin)] #![feature(custom_derive)] #![feature(nonzero)] diff --git a/src/stacking_context.rs b/src/stacking_context.rs index 8b210befdc..dd4f89a3ac 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 euclid::{Matrix4, Rect}; use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; diff --git a/src/types.rs b/src/types.rs index af63bcfbdf..de2ae55819 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 app_units::Au; use euclid::{Rect, Size2D}; diff --git a/src/webgl.rs b/src/webgl.rs index ace9e7d9af..1821152604 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -1,3 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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 core::nonzero::NonZero; use ipc_channel::ipc::IpcSender; use gleam::gl; From 11cdfa56fa7bf0f2ac8cbad8ba85e32823187a7c Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 17 Feb 2016 14:29:51 +1000 Subject: [PATCH 32/97] Update euclid/app_units --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 87d8faa842..6145fe32e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ git = "https://github.com/ecoal95/rust-offscreen-rendering-context" git = "https://github.com/servo/ipc-channel" [dependencies] -app_units = {version = "0.2", features = ["plugins"]} -euclid = {version = "0.6.1", features = ["plugins"]} +app_units = {version = "0.2.1", features = ["plugins"]} +euclid = {version = "0.6.2", features = ["plugins"]} gleam = "0.2" serde = "0.6" serde_macros = "0.6" From a0096f6ad926c1a91282a6b9fb3d406acd0ab33c Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 23 Feb 2016 20:15:35 -0500 Subject: [PATCH 33/97] Setup continuous integration with Travis CI. --- .travis.yml | 11 +++++++++++ Cargo.toml | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..46b81f4f91 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: rust +rust: nightly +notifications: + webhooks: http://build.servo.org:54856/travis +addons: + apt: + packages: + - libgles2-mesa-dev +os: + - linux + - osx diff --git a/Cargo.toml b/Cargo.toml index 6145fe32e1..2888895991 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,8 @@ git = "https://github.com/servo/ipc-channel" app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} gleam = "0.2" -serde = "0.6" +serde = {version = "0.6", features = ["nightly"]} serde_macros = "0.6" [target.x86_64-apple-darwin.dependencies] core-graphics = "*" - From 617142ac3c5a7fa0e5f314eb509058418410edd5 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 23 Feb 2016 21:01:57 -0500 Subject: [PATCH 34/97] Lock 'core-graphics' version. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2888895991..080e7c1e0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,4 @@ serde = {version = "0.6", features = ["nightly"]} serde_macros = "0.6" [target.x86_64-apple-darwin.dependencies] -core-graphics = "*" +core-graphics = "0.2" From a25558a2607d0e2c00fed7760e12bc82d93da778 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Sat, 27 Feb 2016 08:44:57 +1000 Subject: [PATCH 35/97] Support for fixed layer per iframe --- src/lib.rs | 2 +- src/types.rs | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b9475cdbc1..5b6faba95a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,5 +37,5 @@ pub use types::{ColorF, ClipRegion, ComplexClipRegion}; pub use types::{DisplayListId, DisplayListMode, ImageRendering}; pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; -pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId}; +pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId, ScrollLayerInfo}; pub use webgl::*; diff --git a/src/types.rs b/src/types.rs index de2ae55819..010d62a3d1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -238,18 +238,30 @@ pub trait RenderNotifier : Send { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum ScrollLayerId { +pub enum ScrollLayerInfo { Fixed, - Normal(PipelineId, usize) + Scrollable(usize) +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct ScrollLayerId { + pub pipeline_id: PipelineId, + pub info: ScrollLayerInfo, } impl ScrollLayerId { pub fn new(pipeline_id: PipelineId, index: usize) -> ScrollLayerId { - ScrollLayerId::Normal(pipeline_id, index) + ScrollLayerId { + pipeline_id: pipeline_id, + info: ScrollLayerInfo::Scrollable(index), + } } - pub fn fixed_layer() -> ScrollLayerId { - ScrollLayerId::Fixed + pub fn create_fixed(pipeline_id: PipelineId) -> ScrollLayerId { + ScrollLayerId { + pipeline_id: pipeline_id, + info: ScrollLayerInfo::Fixed, + } } } From 8120a670cc4afe124598668594ae60add8e87189 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 3 Mar 2016 12:56:44 -0800 Subject: [PATCH 36/97] Flatten the WebRender API to allow us to use shared memory to transfer display lists. Improves performance significantly. --- src/api.rs | 19 ++- src/display_item.rs | 27 ++--- src/display_list.rs | 250 +++++++++++++++++++++++++++++++++++----- src/lib.rs | 5 +- src/stacking_context.rs | 8 +- src/types.rs | 22 ++-- 6 files changed, 269 insertions(+), 62 deletions(-) diff --git a/src/api.rs b/src/api.rs index b9e9b738ec..f8ce0c77a4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -2,7 +2,7 @@ * 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 display_list::DisplayListBuilder; +use display_list::{AuxiliaryLists, BuiltDisplayList}; use euclid::{Point2D, Size2D}; use ipc_channel::ipc::{self, IpcSender}; use stacking_context::StackingContext; @@ -24,10 +24,15 @@ pub enum ApiMsg { AddNativeFont(FontKey, NativeFontHandle), AddImage(ImageKey, u32, u32, ImageFormat, Vec), UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), - AddDisplayList(DisplayListId, PipelineId, Epoch, DisplayListBuilder), + AddDisplayList(DisplayListId, PipelineId, Epoch, BuiltDisplayList), AddStackingContext(StackingContextId, PipelineId, Epoch, StackingContext), CloneApi(IpcSender), - SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId, Size2D), + SetRootStackingContext(StackingContextId, + ColorF, + Epoch, + PipelineId, + Size2D, + AuxiliaryLists), SetRootPipeline(PipelineId), Scroll(Point2D, Point2D), TranslatePointToLayerSpace(Point2D, IpcSender>), @@ -112,7 +117,7 @@ impl RenderApi { } pub fn add_display_list(&self, - display_list: DisplayListBuilder, + display_list: BuiltDisplayList, stacking_context: &mut StackingContext, pipeline_id: PipelineId, epoch: Epoch) -> Option { @@ -149,12 +154,14 @@ impl RenderApi { background_color: ColorF, epoch: Epoch, pipeline_id: PipelineId, - viewport_size: Size2D) { + viewport_size: Size2D, + auxiliary_lists: AuxiliaryLists) { let msg = ApiMsg::SetRootStackingContext(stacking_context_id, background_color, epoch, pipeline_id, - viewport_size); + viewport_size, + auxiliary_lists); self.tx.send(msg).unwrap(); } diff --git a/src/display_item.rs b/src/display_item.rs index 2b4850fd8a..388869daa0 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -3,12 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use types::{ClipRegion, ColorF, GlyphInstance, FontKey, ImageKey, BorderSide}; -use types::{GradientStop, BorderRadius, BoxShadowClipMode, ImageRendering}; +use display_list::ItemRange; +use types::{ClipRegion, ColorF, FontKey, ImageKey, BorderSide}; +use types::{BorderRadius, BoxShadowClipMode, ImageRendering}; use webgl::{WebGLContextId}; use euclid::{Point2D, Rect, Size2D}; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct BorderDisplayItem { pub left: BorderSide, pub right: BorderSide, @@ -39,7 +40,7 @@ impl BorderDisplayItem { } } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct BoxShadowDisplayItem { pub box_bounds: Rect, pub offset: Point2D, @@ -50,40 +51,40 @@ pub struct BoxShadowDisplayItem { pub clip_mode: BoxShadowClipMode, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GradientDisplayItem { pub start_point: Point2D, pub end_point: Point2D, - pub stops: Vec, + pub stops: ItemRange, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ImageDisplayItem { pub image_key: ImageKey, pub stretch_size: Size2D, pub image_rendering: ImageRendering, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct WebGLDisplayItem { pub context_id: WebGLContextId, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct RectangleDisplayItem { pub color: ColorF, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct TextDisplayItem { - pub glyphs: Vec, + pub glyphs: ItemRange, pub font_key: FontKey, pub size: Au, pub color: ColorF, pub blur_radius: Au, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum SpecificDisplayItem { Rectangle(RectangleDisplayItem), Text(TextDisplayItem), @@ -94,7 +95,7 @@ pub enum SpecificDisplayItem { Gradient(GradientDisplayItem), } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct DisplayItem { pub item: SpecificDisplayItem, pub rect: Rect, diff --git a/src/display_list.rs b/src/display_list.rs index c3e2465d52..fd3b63fbc4 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -7,42 +7,66 @@ use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisp use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use euclid::{Point2D, Rect, Size2D}; +use ipc_channel::ipc::IpcSharedMemory; use std::mem; -use types::{ClipRegion, ColorF, FontKey, ImageKey, PipelineId, StackingLevel}; -use types::{BorderRadius, BorderSide, BoxShadowClipMode, GlyphInstance}; +use std::slice; +use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId, StackingLevel}; +use types::{BorderRadius, BorderSide, BoxShadowClipMode, FilterOp, GlyphInstance}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; use webgl::{WebGLContextId}; -#[derive(Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub struct DrawListInfo { - pub items: Vec, + pub items: ItemRange, } -#[derive(Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub struct StackingContextInfo { pub id: StackingContextId, } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] pub struct IframeInfo { pub id: PipelineId, pub bounds: Rect, } -#[derive(Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub enum SpecificDisplayListItem { DrawList(DrawListInfo), StackingContext(StackingContextInfo), - Iframe(Box), + Iframe(IframeInfo), } -#[derive(Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub struct DisplayListItem { pub stacking_level: StackingLevel, pub specific: SpecificDisplayListItem, } -#[derive(Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] +pub struct BuiltDisplayList { + pub mode: DisplayListMode, + pub has_stacking_contexts: bool, + + display_list_items: IpcSharedMemory, + display_items: IpcSharedMemory, +} + +impl BuiltDisplayList { + pub fn display_list_items<'a>(&'a self) -> &'a [DisplayListItem] { + unsafe { + convert_blob_to_pod(&self.display_list_items[..]) + } + } + + pub fn display_items<'a>(&'a self, range: &ItemRange) -> &'a [DisplayItem] { + unsafe { + range.get(convert_blob_to_pod(&self.display_items[..])) + } + } +} + pub struct DisplayListBuilder { pub mode: DisplayListMode, pub has_stacking_contexts: bool, @@ -54,7 +78,8 @@ pub struct DisplayListBuilder { pub work_positioned_content: Vec, pub work_outlines: Vec, - pub items: Vec, + pub display_list_items: Vec, + pub display_items: Vec, } impl DisplayListBuilder { @@ -70,7 +95,8 @@ impl DisplayListBuilder { work_positioned_content: Vec::new(), work_outlines: Vec::new(), - items: Vec::new(), + display_list_items: Vec::new(), + display_items: Vec::new(), } } @@ -140,7 +166,8 @@ impl DisplayListBuilder { font_key: FontKey, color: ColorF, size: Au, - blur_radius: Au) { + blur_radius: Au, + auxiliary_lists_builder: &mut AuxiliaryListsBuilder) { // Sanity check - anything with glyphs bigger than this // is probably going to consume too much memory to render // efficiently anyway. This is specifically to work around @@ -150,7 +177,7 @@ impl DisplayListBuilder { if size < Au::from_px(4096) { let item = TextDisplayItem { color: color, - glyphs: glyphs, + glyphs: auxiliary_lists_builder.add_glyph_instances(&glyphs), font_key: font_key, size: size, blur_radius: blur_radius, @@ -234,7 +261,7 @@ impl DisplayListBuilder { stacking_level: level, specific: SpecificDisplayListItem::StackingContext(info), }; - self.items.push(item); + self.display_list_items.push(item); } pub fn push_gradient(&mut self, @@ -243,11 +270,12 @@ impl DisplayListBuilder { clip: ClipRegion, start_point: Point2D, end_point: Point2D, - stops: Vec) { + stops: Vec, + auxiliary_lists_builder: &mut AuxiliaryListsBuilder) { let item = GradientDisplayItem { start_point: start_point, end_point: end_point, - stops: stops, + stops: auxiliary_lists_builder.add_gradient_stops(&stops), }; let display_item = DisplayItem { @@ -265,15 +293,15 @@ impl DisplayListBuilder { _clip: ClipRegion, iframe: PipelineId) { self.flush_list(level); - let info = Box::new(IframeInfo { + let info = IframeInfo { id: iframe, bounds: rect, - }); + }; let item = DisplayListItem { stacking_level: level, specific: SpecificDisplayListItem::Iframe(info), }; - self.items.push(item); + self.display_list_items.push(item); } fn push_item(&mut self, level: StackingLevel, item: DisplayItem) { @@ -322,15 +350,17 @@ impl DisplayListBuilder { }; let items = mem::replace(list, Vec::new()); - if items.len() > 0 { - let draw_list = DrawListInfo { - items: items, - }; - self.items.push(DisplayListItem { - stacking_level: level, - specific: SpecificDisplayListItem::DrawList(draw_list), - }); + if items.is_empty() { + return } + + let draw_list = DrawListInfo { + items: ItemRange::new(&mut self.display_items, &items), + }; + self.display_list_items.push(DisplayListItem { + stacking_level: level, + specific: SpecificDisplayListItem::DrawList(draw_list), + }); } fn flush(&mut self) { @@ -342,7 +372,169 @@ impl DisplayListBuilder { self.flush_list(StackingLevel::Outlines); } - pub fn finalize(&mut self) { + pub fn finalize(mut self) -> BuiltDisplayList { self.flush(); + + unsafe { + BuiltDisplayList { + mode: self.mode, + has_stacking_contexts: self.has_stacking_contexts, + display_list_items: + IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.display_list_items)), + display_items: + IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.display_items)), + } + } } + + pub fn display_items<'a>(&'a self, range: &ItemRange) -> &'a [DisplayItem] { + range.get(&self.display_items) + } + + pub fn display_items_mut<'a>(&'a mut self, range: &ItemRange) -> &'a mut [DisplayItem] { + range.get_mut(&mut self.display_items) + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct ItemRange { + pub start: usize, + pub length: usize, } + +impl ItemRange { + pub fn new(backing_list: &mut Vec, items: &[T]) -> ItemRange where T: Copy + Clone { + let start = backing_list.len(); + backing_list.extend_from_slice(items); + ItemRange { + start: start, + length: items.len(), + } + } + + pub fn empty() -> ItemRange { + ItemRange { + start: 0, + length: 0, + } + } + + pub fn get<'a, T>(&self, backing_list: &'a [T]) -> &'a [T] { + &backing_list[self.start..(self.start + self.length)] + } + + pub fn get_mut<'a, T>(&self, backing_list: &'a mut [T]) -> &'a mut [T] { + &mut backing_list[self.start..(self.start + self.length)] + } +} + +#[derive(Clone)] +pub struct AuxiliaryListsBuilder { + gradient_stops: Vec, + complex_clip_regions: Vec, + filters: Vec, + glyph_instances: Vec, +} + +impl AuxiliaryListsBuilder { + pub fn new() -> AuxiliaryListsBuilder { + AuxiliaryListsBuilder { + gradient_stops: Vec::new(), + complex_clip_regions: Vec::new(), + filters: Vec::new(), + glyph_instances: Vec::new(), + } + } + + pub fn add_gradient_stops(&mut self, gradient_stops: &[GradientStop]) -> ItemRange { + ItemRange::new(&mut self.gradient_stops, gradient_stops) + } + + pub fn gradient_stops(&self, gradient_stops_range: &ItemRange) -> &[GradientStop] { + gradient_stops_range.get(&self.gradient_stops[..]) + } + + pub fn add_complex_clip_regions(&mut self, complex_clip_regions: &[ComplexClipRegion]) + -> ItemRange { + ItemRange::new(&mut self.complex_clip_regions, complex_clip_regions) + } + + pub fn complex_clip_regions(&self, complex_clip_regions_range: &ItemRange) + -> &[ComplexClipRegion] { + complex_clip_regions_range.get(&self.complex_clip_regions[..]) + } + + pub fn add_filters(&mut self, filters: &[FilterOp]) -> ItemRange { + ItemRange::new(&mut self.filters, filters) + } + + pub fn filters(&self, filters_range: &ItemRange) -> &[FilterOp] { + filters_range.get(&self.filters[..]) + } + + pub fn add_glyph_instances(&mut self, glyph_instances: &[GlyphInstance]) -> ItemRange { + ItemRange::new(&mut self.glyph_instances, glyph_instances) + } + + pub fn glyph_instances(&self, glyph_instances_range: &ItemRange) -> &[GlyphInstance] { + glyph_instances_range.get(&self.glyph_instances[..]) + } + + pub fn finalize(self) -> AuxiliaryLists { + unsafe { + AuxiliaryLists { + gradient_stops: + IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.gradient_stops)), + complex_clip_regions: + IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.complex_clip_regions)), + filters: IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.filters)), + glyph_instances: + IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.glyph_instances)), + } + } + } +} + +#[derive(Clone, Serialize, Deserialize)] +pub struct AuxiliaryLists { + gradient_stops: IpcSharedMemory, + complex_clip_regions: IpcSharedMemory, + filters: IpcSharedMemory, + glyph_instances: IpcSharedMemory, +} + +impl AuxiliaryLists { + pub fn gradient_stops(&self, gradient_stops_range: &ItemRange) -> &[GradientStop] { + unsafe { + gradient_stops_range.get(convert_blob_to_pod(&self.gradient_stops[..])) + } + } + + pub fn complex_clip_regions(&self, complex_clip_regions_range: &ItemRange) + -> &[ComplexClipRegion] { + unsafe { + complex_clip_regions_range.get(convert_blob_to_pod(&self.complex_clip_regions[..])) + } + } + + pub fn filters(&self, filters_range: &ItemRange) -> &[FilterOp] { + unsafe { + filters_range.get(convert_blob_to_pod(&self.filters[..])) + } + } + + pub fn glyph_instances(&self, glyph_instances_range: &ItemRange) -> &[GlyphInstance] { + unsafe { + glyph_instances_range.get(convert_blob_to_pod(&self.glyph_instances[..])) + } + } +} + +unsafe fn convert_pod_to_blob(data: &[T]) -> &[u8] where T: Copy + 'static { + slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * mem::size_of::()) +} + +unsafe fn convert_blob_to_pod(blob: &[u8]) -> &[T] where T: Copy + 'static { + slice::from_raw_parts(blob.as_ptr() as *const T, blob.len() / mem::size_of::()) +} + diff --git a/src/lib.rs b/src/lib.rs index 5b6faba95a..55560cb839 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,8 +26,9 @@ mod types; mod webgl; pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender}; -pub use display_list::{DisplayListBuilder, DisplayListItem}; -pub use display_list::{SpecificDisplayListItem, IframeInfo}; +pub use display_list::{AuxiliaryLists, AuxiliaryListsBuilder, BuiltDisplayList}; +pub use display_list::{DisplayListBuilder, DisplayListItem, IframeInfo, ItemRange}; +pub use display_list::{SpecificDisplayListItem}; pub use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; pub use display_item::{BorderDisplayItem, GradientDisplayItem, RectangleDisplayItem}; pub use stacking_context::StackingContext; diff --git a/src/stacking_context.rs b/src/stacking_context.rs index dd4f89a3ac..294b7ec800 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -2,6 +2,7 @@ * 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 display_list::{AuxiliaryListsBuilder, ItemRange}; use euclid::{Matrix4, Rect}; use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; @@ -17,7 +18,7 @@ pub struct StackingContext { pub perspective: Matrix4, pub establishes_3d_context: bool, pub mix_blend_mode: MixBlendMode, - pub filters: Vec, + pub filters: ItemRange, pub has_stacking_contexts: bool, } @@ -31,7 +32,8 @@ impl StackingContext { perspective: &Matrix4, establishes_3d_context: bool, mix_blend_mode: MixBlendMode, - filters: Vec) + filters: Vec, + auxiliary_lists_builder: &mut AuxiliaryListsBuilder) -> StackingContext { StackingContext { scroll_layer_id: scroll_layer_id, @@ -44,7 +46,7 @@ impl StackingContext { perspective: perspective.clone(), establishes_3d_context: establishes_3d_context, mix_blend_mode: mix_blend_mode, - filters: filters, + filters: auxiliary_lists_builder.add_filters(&filters), has_stacking_contexts: false, } } diff --git a/src/types.rs b/src/types.rs index 010d62a3d1..bb7da1a34c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; +use display_list::{AuxiliaryListsBuilder, ItemRange}; use euclid::{Rect, Size2D}; #[cfg(target_os="macos")] @@ -36,7 +37,7 @@ impl BorderRadius { } } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct BorderSide { pub width: f32, pub color: ColorF, @@ -64,17 +65,20 @@ pub enum BoxShadowClipMode { Inset, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ClipRegion { pub main: Rect, - pub complex: Vec, + pub complex: ItemRange, } impl ClipRegion { - pub fn new(rect: Rect, complex: Vec) -> ClipRegion { + pub fn new(rect: &Rect, + complex: Vec, + auxiliary_lists_builder: &mut AuxiliaryListsBuilder) + -> ClipRegion { ClipRegion { - main: rect, - complex: complex, + main: *rect, + complex: auxiliary_lists_builder.add_complex_clip_regions(&complex), } } } @@ -130,7 +134,7 @@ pub struct StackingContextId(pub u32, pub u32); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct DisplayListId(pub u32, pub u32); -#[derive(Serialize, Deserialize)] +#[derive(Copy, Clone, Serialize, Deserialize)] pub enum DisplayListMode { Default, PseudoFloat, @@ -162,14 +166,14 @@ impl FontKey { } } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GlyphInstance { pub index: u32, pub x: f32, pub y: f32, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GradientStop { pub offset: f32, pub color: ColorF, From 8d9816e3205b50fd7ef8ee7d6b9ee548b145a154 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 3 Mar 2016 13:47:28 -0800 Subject: [PATCH 37/97] Add lockfile --- Cargo.lock | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..211303a4ed --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,347 @@ +[root] +name = "webrender_traits" +version = "0.1.0" +dependencies = [ + "app_units 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", + "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aho-corasick" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "app_units" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize_plugin 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aster" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bincode" +version = "0.4.0" +source = "git+https://github.com/TyOverby/bincode#8f4323c55c3c277f48171ff3e72bcb4531848757" +dependencies = [ + "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cgl" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-graphics" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "euclid" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize_plugin 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gl_generator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "xml-rs 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gleam" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heapsize" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heapsize_plugin" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ipc-channel" +version = "0.2.0" +source = "git+https://github.com/servo/ipc-channel#2b5d7535100125662652ab55168b7d2ca15960dd" +dependencies = [ + "bincode 0.4.0 (git+https://github.com/TyOverby/bincode)", + "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "khronos_api" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "offscreen_gl_context" +version = "0.1.0" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#9c123fa51268927420c395a83b458348b39ad90a" +dependencies = [ + "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pkg-config" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quasi_codegen" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quasi_macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "0.1.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc-serialize" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_codegen" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quasi_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_macros" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "utf8-ranges" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "uuid" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "x11" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "xml-rs" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + From 95a18927733f23cdec49b624c10079e1acf89daa Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 2 Mar 2016 16:16:24 -0800 Subject: [PATCH 38/97] Introduce support for overscroll bounce animations. --- src/api.rs | 24 +++++++++++++++++++++--- src/lib.rs | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/api.rs b/src/api.rs index f8ce0c77a4..1be4090318 100644 --- a/src/api.rs +++ b/src/api.rs @@ -18,6 +18,17 @@ pub struct IdNamespace(pub u32); #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct ResourceId(pub u32); +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +pub enum ScrollEventPhase { + /// The user started scrolling. + Start, + /// The user performed a scroll. The Boolean flag indicates whether the user's fingers are + /// down, if a touchpad is in use. (If false, the event is a touchpad fling.) + Move(bool), + /// The user ended scrolling. + End, +} + #[derive(Serialize, Deserialize)] pub enum ApiMsg { AddRawFont(FontKey, Vec), @@ -34,7 +45,8 @@ pub enum ApiMsg { Size2D, AuxiliaryLists), SetRootPipeline(PipelineId), - Scroll(Point2D, Point2D), + Scroll(Point2D, Point2D, ScrollEventPhase), + TickScrollingBounce, TranslatePointToLayerSpace(Point2D, IpcSender>), RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), WebGLCommand(WebGLContextId, WebGLCommand), @@ -165,8 +177,13 @@ impl RenderApi { self.tx.send(msg).unwrap(); } - pub fn scroll(&self, delta: Point2D, cursor: Point2D) { - let msg = ApiMsg::Scroll(delta, cursor); + pub fn scroll(&self, delta: Point2D, cursor: Point2D, phase: ScrollEventPhase) { + let msg = ApiMsg::Scroll(delta, cursor, phase); + self.tx.send(msg).unwrap(); + } + + pub fn tick_scrolling_bounce_animations(&self) { + let msg = ApiMsg::TickScrollingBounce; self.tx.send(msg).unwrap(); } @@ -196,3 +213,4 @@ impl RenderApi { (namespace, id) } } + diff --git a/src/lib.rs b/src/lib.rs index 55560cb839..df75a3f88a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ mod stacking_context; mod types; mod webgl; -pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender}; +pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender, ScrollEventPhase}; pub use display_list::{AuxiliaryLists, AuxiliaryListsBuilder, BuiltDisplayList}; pub use display_list::{DisplayListBuilder, DisplayListItem, IframeInfo, ItemRange}; pub use display_list::{SpecificDisplayListItem}; From 5524a79fe11a62eab7beaf920b217bf362e9d5bb Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 9 Mar 2016 03:36:14 +0100 Subject: [PATCH 39/97] Allow both serde 0.6 and 0.7 and remove Cargo.lock file --- Cargo.lock | 347 ----------------------------------------------------- Cargo.toml | 6 +- 2 files changed, 3 insertions(+), 350 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 211303a4ed..0000000000 --- a/Cargo.lock +++ /dev/null @@ -1,347 +0,0 @@ -[root] -name = "webrender_traits" -version = "0.1.0" -dependencies = [ - "app_units 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", - "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aho-corasick" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "app_units" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aster" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bincode" -version = "0.4.0" -source = "git+https://github.com/TyOverby/bincode#8f4323c55c3c277f48171ff3e72bcb4531848757" -dependencies = [ - "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cgl" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-graphics" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "euclid" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize_plugin 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gl_generator" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "xml-rs 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gleam" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "heapsize" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "heapsize_plugin" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ipc-channel" -version = "0.2.0" -source = "git+https://github.com/servo/ipc-channel#2b5d7535100125662652ab55168b7d2ca15960dd" -dependencies = [ - "bincode 0.4.0 (git+https://github.com/TyOverby/bincode)", - "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "khronos_api" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "offscreen_gl_context" -version = "0.1.0" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#9c123fa51268927420c395a83b458348b39ad90a" -dependencies = [ - "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_macros 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pkg-config" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quasi_codegen" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quasi_macros" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.3.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "0.1.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc-serialize" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "0.6.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_codegen" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quasi_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_macros" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "uuid" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "x11" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "xml-rs" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - diff --git a/Cargo.toml b/Cargo.toml index 080e7c1e0c..24ab13065f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ git = "https://github.com/servo/ipc-channel" app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} gleam = "0.2" -serde = {version = "0.6", features = ["nightly"]} -serde_macros = "0.6" +serde = {version = ">=0.6, <0.8", features = ["nightly"]} +serde_macros = ">=0.6, <0.8" [target.x86_64-apple-darwin.dependencies] -core-graphics = "0.2" +core-graphics = ">=0.2, <0.4" From 237f68fb05fadcf06166edb5c03fcf063ebec44e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 10 Mar 2016 23:17:55 +0100 Subject: [PATCH 40/97] Ignore failure on nightly, but not on Servo's nightly --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 46b81f4f91..8c03d1d7a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,10 @@ language: rust -rust: nightly +rust: + - nightly + - nightly-2016-03-07 # Should be kept in sync with Servo. +matrix: + allow_failures: + - rust: nightly notifications: webhooks: http://build.servo.org:54856/travis addons: From c82b99dd725b07cbec34b518cf0d2d44090f9f93 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 9 Mar 2016 16:29:53 -0800 Subject: [PATCH 41/97] Flatten display list transfer into a separately-transferred byte array, and consolidate the multitude of display list messages into one. Along with the corresponding patches to other Servo repositories, this improves display list building performance on small display lists by about 3x. --- src/api.rs | 143 +++++++++++++++++++++++++++----------------- src/display_list.rs | 130 +++++++++++++++++++++++++++++++--------- 2 files changed, 189 insertions(+), 84 deletions(-) diff --git a/src/api.rs b/src/api.rs index 1be4090318..a0e2e4e444 100644 --- a/src/api.rs +++ b/src/api.rs @@ -2,9 +2,10 @@ * 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 display_list::{AuxiliaryLists, BuiltDisplayList}; +use display_list::{AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList}; +use display_list::{BuiltDisplayListDescriptor}; use euclid::{Point2D, Size2D}; -use ipc_channel::ipc::{self, IpcSender}; +use ipc_channel::ipc::{self, IpcBytesSender, IpcSender}; use stacking_context::StackingContext; use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; @@ -35,15 +36,23 @@ pub enum ApiMsg { AddNativeFont(FontKey, NativeFontHandle), AddImage(ImageKey, u32, u32, ImageFormat, Vec), UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), - AddDisplayList(DisplayListId, PipelineId, Epoch, BuiltDisplayList), - AddStackingContext(StackingContextId, PipelineId, Epoch, StackingContext), CloneApi(IpcSender), + /// Supplies a new frame to WebRender. + /// + /// The first `StackingContextId` describes the root stacking context. The actual stacking + /// contexts are supplied as the sixth parameter, while the display lists that make up those + /// stacking contexts are supplied as the seventh parameter. + /// + /// After receiving this message, WebRender will read the display lists, followed by the + /// auxiliary lists, from the payload channel. SetRootStackingContext(StackingContextId, ColorF, Epoch, PipelineId, Size2D, - AuxiliaryLists), + Vec<(StackingContextId, StackingContext)>, + Vec<(DisplayListId, BuiltDisplayListDescriptor)>, + AuxiliaryListsDescriptor), SetRootPipeline(PipelineId), Scroll(Point2D, Point2D, ScrollEventPhase), TickScrollingBounce, @@ -53,20 +62,30 @@ pub enum ApiMsg { } #[derive(Serialize, Deserialize, Clone)] -pub struct RenderApiSender(IpcSender); +pub struct RenderApiSender { + api_sender: IpcSender, + payload_sender: IpcBytesSender, +} impl RenderApiSender { - pub fn new(tx: IpcSender) -> RenderApiSender { - RenderApiSender(tx) + pub fn new(api_sender: IpcSender, payload_sender: IpcBytesSender) -> RenderApiSender { + RenderApiSender { + api_sender: api_sender, + payload_sender: payload_sender, + } } pub fn create_api(&self) -> RenderApi { - let RenderApiSender(ref tx) = *self; + let RenderApiSender { + ref api_sender, + ref payload_sender + } = *self; let (sync_tx, sync_rx) = ipc::channel().unwrap(); let msg = ApiMsg::CloneApi(sync_tx); - tx.send(msg).unwrap(); + api_sender.send(msg).unwrap(); RenderApi { - tx: tx.clone(), + api_sender: api_sender.clone(), + payload_sender: payload_sender.clone(), id_namespace: sync_rx.recv().unwrap(), next_id: Cell::new(ResourceId(0)), } @@ -74,21 +93,22 @@ impl RenderApiSender { } pub struct RenderApi { - pub tx: IpcSender, + pub api_sender: IpcSender, + pub payload_sender: IpcBytesSender, pub id_namespace: IdNamespace, pub next_id: Cell, } impl RenderApi { pub fn clone_sender(&self) -> RenderApiSender { - RenderApiSender::new(self.tx.clone()) + RenderApiSender::new(self.api_sender.clone(), self.payload_sender.clone()) } pub fn add_raw_font(&self, bytes: Vec) -> FontKey { let new_id = self.next_unique_id(); let key = FontKey::new(new_id.0, new_id.1); let msg = ApiMsg::AddRawFont(key, bytes); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); key } @@ -96,7 +116,7 @@ impl RenderApi { let new_id = self.next_unique_id(); let key = FontKey::new(new_id.0, new_id.1); let msg = ApiMsg::AddNativeFont(key, native_font_handle); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); key } @@ -113,7 +133,7 @@ impl RenderApi { let new_id = self.next_unique_id(); let key = ImageKey::new(new_id.0, new_id.1); let msg = ApiMsg::AddImage(key, width, height, format, bytes); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); key } @@ -125,87 +145,98 @@ impl RenderApi { format: ImageFormat, bytes: Vec) { let msg = ApiMsg::UpdateImage(key, width, height, format, bytes); - self.tx.send(msg).unwrap(); - } - - pub fn add_display_list(&self, - display_list: BuiltDisplayList, - stacking_context: &mut StackingContext, - pipeline_id: PipelineId, - epoch: Epoch) -> Option { - //TODO! debug_assert!(display_list.item_count() > 0, "Avoid adding empty lists!"); - let new_id = self.next_unique_id(); - let id = DisplayListId(new_id.0, new_id.1); - stacking_context.has_stacking_contexts = stacking_context.has_stacking_contexts || - display_list.has_stacking_contexts; - let msg = ApiMsg::AddDisplayList(id, pipeline_id, epoch, display_list); - self.tx.send(msg).unwrap(); - stacking_context.display_lists.push(id); - - Some(id) - } - - pub fn add_stacking_context(&self, - stacking_context: StackingContext, - pipeline_id: PipelineId, - epoch: Epoch) -> StackingContextId { - let new_id = self.next_unique_id(); - let id = StackingContextId(new_id.0, new_id.1); - let msg = ApiMsg::AddStackingContext(id, pipeline_id, epoch, stacking_context); - self.tx.send(msg).unwrap(); - id + self.api_sender.send(msg).unwrap(); } pub fn set_root_pipeline(&self, pipeline_id: PipelineId) { let msg = ApiMsg::SetRootPipeline(pipeline_id); - self.tx.send(msg).unwrap(); - } - + self.api_sender.send(msg).unwrap(); + } + + /// Supplies a new frame to WebRender. + /// + /// Arguments: + /// * `stacking_context_id`: The ID of the root stacking context. + /// * `background_color`: The background color of this pipeline. + /// * `epoch`: A monotonically increasing timestamp. + /// * `pipeline_id`: The ID of the pipeline that is supplying this display list. + /// * `viewport_size`: The size of the viewport for this frame. + /// * `stacking_contexts`: Stacking contexts used in this frame. + /// * `display_lists`: Display lists used in this frame. + /// * `auxiliary_lists`: Various items that the display lists and stacking contexts reference. pub fn set_root_stacking_context(&self, stacking_context_id: StackingContextId, background_color: ColorF, epoch: Epoch, pipeline_id: PipelineId, viewport_size: Size2D, + stacking_contexts: Vec<(StackingContextId, StackingContext)>, + display_lists: Vec<(DisplayListId, BuiltDisplayList)>, auxiliary_lists: AuxiliaryLists) { + let display_list_descriptors = display_lists.iter().map(|&(display_list_id, + ref built_display_list)| { + (display_list_id, (*built_display_list.descriptor()).clone()) + }).collect(); let msg = ApiMsg::SetRootStackingContext(stacking_context_id, background_color, epoch, pipeline_id, viewport_size, - auxiliary_lists); - self.tx.send(msg).unwrap(); + stacking_contexts, + display_list_descriptors, + *auxiliary_lists.descriptor()); + self.api_sender.send(msg).unwrap(); + + for &(_, ref built_display_list) in &display_lists { + self.payload_sender.send(built_display_list.data()).unwrap(); + } + + self.payload_sender.send(auxiliary_lists.data()).unwrap(); } pub fn scroll(&self, delta: Point2D, cursor: Point2D, phase: ScrollEventPhase) { let msg = ApiMsg::Scroll(delta, cursor, phase); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); } pub fn tick_scrolling_bounce_animations(&self) { let msg = ApiMsg::TickScrollingBounce; - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); } pub fn translate_point_to_layer_space(&self, point: &Point2D) -> Point2D { let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::TranslatePointToLayerSpace(*point, tx); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); rx.recv().unwrap() } - pub fn request_webgl_context(&self, size: &Size2D, attributes: GLContextAttributes) -> Result { + pub fn request_webgl_context(&self, size: &Size2D, attributes: GLContextAttributes) + -> Result { let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::RequestWebGLContext(*size, attributes, tx); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); rx.recv().unwrap() } pub fn send_webgl_command(&self, context_id: WebGLContextId, command: WebGLCommand) { let msg = ApiMsg::WebGLCommand(context_id, command); - self.tx.send(msg).unwrap(); + self.api_sender.send(msg).unwrap(); + } + + #[inline] + pub fn next_stacking_context_id(&self) -> StackingContextId { + let new_id = self.next_unique_id(); + StackingContextId(new_id.0, new_id.1) + } + + #[inline] + pub fn next_display_list_id(&self) -> DisplayListId { + let new_id = self.next_unique_id(); + DisplayListId(new_id.0, new_id.1) } + #[inline] fn next_unique_id(&self) -> (u32, u32) { let IdNamespace(namespace) = self.id_namespace; let ResourceId(id) = self.next_id.get(); diff --git a/src/display_list.rs b/src/display_list.rs index fd3b63fbc4..0ad326d918 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -7,7 +7,6 @@ use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisp use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use euclid::{Point2D, Rect, Size2D}; -use ipc_channel::ipc::IpcSharedMemory; use std::mem; use std::slice; use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId, StackingLevel}; @@ -44,25 +43,51 @@ pub struct DisplayListItem { pub specific: SpecificDisplayListItem, } -#[derive(Clone, Serialize, Deserialize)] -pub struct BuiltDisplayList { +/// Describes the memory layout of a display list. +/// +/// A display list consists of some number of display list items, followed by a number of display +/// items. +#[derive(Copy, Clone, Serialize, Deserialize)] +pub struct BuiltDisplayListDescriptor { pub mode: DisplayListMode, pub has_stacking_contexts: bool, - display_list_items: IpcSharedMemory, - display_items: IpcSharedMemory, + /// The size in bytes of the display items in this display list. + display_list_items_size: usize, +} + +/// A display list. +#[derive(Clone, Serialize, Deserialize)] +pub struct BuiltDisplayList { + data: Vec, + descriptor: BuiltDisplayListDescriptor, } impl BuiltDisplayList { + pub fn from_data(data: Vec, descriptor: BuiltDisplayListDescriptor) -> BuiltDisplayList { + BuiltDisplayList { + data: data, + descriptor: descriptor, + } + } + + pub fn data(&self) -> &[u8] { + &self.data[..] + } + + pub fn descriptor(&self) -> &BuiltDisplayListDescriptor { + &self.descriptor + } + pub fn display_list_items<'a>(&'a self) -> &'a [DisplayListItem] { unsafe { - convert_blob_to_pod(&self.display_list_items[..]) + convert_blob_to_pod(&self.data[0..self.descriptor.display_list_items_size]) } } pub fn display_items<'a>(&'a self, range: &ItemRange) -> &'a [DisplayItem] { unsafe { - range.get(convert_blob_to_pod(&self.display_items[..])) + range.get(convert_blob_to_pod(&self.data[self.descriptor.display_list_items_size..])) } } } @@ -376,13 +401,16 @@ impl DisplayListBuilder { self.flush(); unsafe { + let mut blob = convert_pod_to_blob(&self.display_list_items).to_vec(); + let display_list_items_size = blob.len(); + blob.extend_from_slice(convert_pod_to_blob(&self.display_items)); BuiltDisplayList { - mode: self.mode, - has_stacking_contexts: self.has_stacking_contexts, - display_list_items: - IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.display_list_items)), - display_items: - IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.display_items)), + descriptor: BuiltDisplayListDescriptor { + mode: self.mode, + has_stacking_contexts: self.has_stacking_contexts, + display_list_items_size: display_list_items_size, + }, + data: blob, } } } @@ -482,50 +510,96 @@ impl AuxiliaryListsBuilder { pub fn finalize(self) -> AuxiliaryLists { unsafe { + let mut blob = convert_pod_to_blob(&self.gradient_stops).to_vec(); + let gradient_stops_size = blob.len(); + blob.extend_from_slice(convert_pod_to_blob(&self.complex_clip_regions)); + let complex_clip_regions_size = blob.len() - gradient_stops_size; + blob.extend_from_slice(convert_pod_to_blob(&self.filters)); + let filters_size = blob.len() - (complex_clip_regions_size + gradient_stops_size); + blob.extend_from_slice(convert_pod_to_blob(&self.glyph_instances)); + AuxiliaryLists { - gradient_stops: - IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.gradient_stops)), - complex_clip_regions: - IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.complex_clip_regions)), - filters: IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.filters)), - glyph_instances: - IpcSharedMemory::from_bytes(convert_pod_to_blob(&self.glyph_instances)), + data: blob, + descriptor: AuxiliaryListsDescriptor { + gradient_stops_size: gradient_stops_size, + complex_clip_regions_size: complex_clip_regions_size, + filters_size: filters_size, + }, } } } } +/// Describes the memory layout of the auxiliary lists. +/// +/// Auxiliary lists consist of some number of gradient stops, complex clip regions, filters, and +/// glyph instances, in that order. +#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +pub struct AuxiliaryListsDescriptor { + gradient_stops_size: usize, + complex_clip_regions_size: usize, + filters_size: usize, +} + #[derive(Clone, Serialize, Deserialize)] pub struct AuxiliaryLists { - gradient_stops: IpcSharedMemory, - complex_clip_regions: IpcSharedMemory, - filters: IpcSharedMemory, - glyph_instances: IpcSharedMemory, + /// The concatenation of: gradient stops, complex clip regions, filters, and glyph instances, + /// in that order. + data: Vec, + descriptor: AuxiliaryListsDescriptor, } impl AuxiliaryLists { + /// Creates a new `AuxiliaryLists` instance from a descriptor and data received over a channel. + pub fn from_data(data: Vec, descriptor: AuxiliaryListsDescriptor) -> AuxiliaryLists { + AuxiliaryLists { + data: data, + descriptor: descriptor, + } + } + + pub fn data(&self) -> &[u8] { + &self.data[..] + } + + pub fn descriptor(&self) -> &AuxiliaryListsDescriptor { + &self.descriptor + } + + /// Returns the gradient stops described by `gradient_stops_range`. pub fn gradient_stops(&self, gradient_stops_range: &ItemRange) -> &[GradientStop] { unsafe { - gradient_stops_range.get(convert_blob_to_pod(&self.gradient_stops[..])) + let end = self.descriptor.gradient_stops_size; + gradient_stops_range.get(convert_blob_to_pod(&self.data[0..end])) } } + /// Returns the complex clipping regions described by `complex_clip_regions_range`. pub fn complex_clip_regions(&self, complex_clip_regions_range: &ItemRange) -> &[ComplexClipRegion] { + let start = self.descriptor.gradient_stops_size; + let end = start + self.descriptor.complex_clip_regions_size; unsafe { - complex_clip_regions_range.get(convert_blob_to_pod(&self.complex_clip_regions[..])) + complex_clip_regions_range.get(convert_blob_to_pod(&self.data[start..end])) } } + /// Returns the filters described by `filters_range`. pub fn filters(&self, filters_range: &ItemRange) -> &[FilterOp] { + let start = self.descriptor.gradient_stops_size + + self.descriptor.complex_clip_regions_size; + let end = start + self.descriptor.filters_size; unsafe { - filters_range.get(convert_blob_to_pod(&self.filters[..])) + filters_range.get(convert_blob_to_pod(&self.data[start..end])) } } + /// Returns the glyph instances described by `glyph_instances_range`. pub fn glyph_instances(&self, glyph_instances_range: &ItemRange) -> &[GlyphInstance] { + let start = self.descriptor.gradient_stops_size + + self.descriptor.complex_clip_regions_size + self.descriptor.filters_size; unsafe { - glyph_instances_range.get(convert_blob_to_pod(&self.glyph_instances[..])) + glyph_instances_range.get(convert_blob_to_pod(&self.data[start..])) } } } From ec34dbf37d18d6121655142fd56c007092d6837d Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 20 Mar 2016 22:03:55 -0400 Subject: [PATCH 42/97] Update rust nightly to keep in sync with Servo. Rustup happened in servo/servo#10076 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8c03d1d7a6..47723480fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-03-07 # Should be kept in sync with Servo. + - nightly-2016-03-18 # Should be kept in sync with Servo. matrix: allow_failures: - rust: nightly From 5cbd204c1e5adfc8c4b2dd2ed195e9f9e1f1d2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 23 Mar 2016 17:07:24 +0100 Subject: [PATCH 43/97] webgl: Use offscreen_gl_context from crates.io Due to my username change --- Cargo.toml | 4 +--- src/webgl.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 24ab13065f..5f5aed33f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,13 +3,11 @@ name = "webrender_traits" version = "0.1.0" authors = ["Glenn Watson "] -[dependencies.offscreen_gl_context] -git = "https://github.com/ecoal95/rust-offscreen-rendering-context" - [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" [dependencies] +offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} gleam = "0.2" diff --git a/src/webgl.rs b/src/webgl.rs index 1821152604..aae6ec9613 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -426,7 +426,7 @@ impl WebGLCommand { gl::VENDOR => Ok(WebGLParameter::String("Mozilla/Servo".to_owned())), gl::SHADING_LANGUAGE_VERSION => Ok(WebGLParameter::String("WebGL GLSL ES 1.0".to_owned())), - // TODO(zbarsky, ecoal95): Implement support for the following valid parameters + // TODO(zbarsky, emilio): Implement support for the following valid parameters // Float32Array gl::ALIASED_LINE_WIDTH_RANGE | //gl::ALIASED_POINT_SIZE_RANGE | From 41ab4362d2cc7d84896f9a1ebb85b9f3526bb76c Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Sat, 26 Mar 2016 17:26:41 -0600 Subject: [PATCH 44/97] Added finish variant to WebGLCommand --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 1821152604..a344145bfe 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -112,6 +112,7 @@ pub enum WebGLCommand { TexParameterf(u32, u32, f32), DrawingBufferWidth(IpcSender), DrawingBufferHeight(IpcSender), + Finish(IpcSender<()>), } impl fmt::Debug for WebGLCommand { @@ -184,6 +185,7 @@ impl fmt::Debug for WebGLCommand { TexParameterf(..) => "TexParameterf", DrawingBufferWidth(..) => "DrawingBufferWidth", DrawingBufferHeight(..) => "DrawingBufferHeight", + Finish(..) => "Finish", }; write!(f, "CanvasWebGLMsg::{}(..)", name) @@ -326,6 +328,8 @@ impl WebGLCommand { sender.send(ctx.borrow_draw_buffer().unwrap().size().width).unwrap(), WebGLCommand::DrawingBufferHeight(sender) => sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), + WebGLCommand::Finish(sender) => + { gl::finish(); sender.send(()).unwrap(); }, } // FIXME: Use debug_assertions once tests are run with them From 665ee19d01e4560163008d997121c059ee00e6ba Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Sat, 26 Mar 2016 18:14:27 -0600 Subject: [PATCH 45/97] Added flush variant --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 43815733ec..b24b6f031c 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -113,6 +113,7 @@ pub enum WebGLCommand { DrawingBufferWidth(IpcSender), DrawingBufferHeight(IpcSender), Finish(IpcSender<()>), + Flush, } impl fmt::Debug for WebGLCommand { @@ -186,6 +187,7 @@ impl fmt::Debug for WebGLCommand { DrawingBufferWidth(..) => "DrawingBufferWidth", DrawingBufferHeight(..) => "DrawingBufferHeight", Finish(..) => "Finish", + Flush => "Flush", }; write!(f, "CanvasWebGLMsg::{}(..)", name) @@ -330,6 +332,8 @@ impl WebGLCommand { sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), WebGLCommand::Finish(sender) => { gl::finish(); sender.send(()).unwrap(); }, + WebGLCommand::Flush => + gl::flush(), } // FIXME: Use debug_assertions once tests are run with them From a7b673250177e43f5f6c11c6558c6b80766b4c4f Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Sat, 26 Mar 2016 19:31:37 -0600 Subject: [PATCH 46/97] Added detach shader variant Moved Finish branch of apply() to function --- src/webgl.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/webgl.rs b/src/webgl.rs index b24b6f031c..7de9a9c5da 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -54,6 +54,7 @@ pub enum WebGLCommand { BlendFunc(u32, u32), BlendFuncSeparate(u32, u32, u32, u32), AttachShader(u32, u32), + DetachShader(u32, u32), BindAttribLocation(u32, u32, String), BufferData(u32, Vec, u32), BufferSubData(u32, isize, Vec), @@ -128,6 +129,7 @@ impl fmt::Debug for WebGLCommand { BlendFunc(..) => "BlendFunc", BlendFuncSeparate(..) => "BlendFuncSeparate", AttachShader(..) => "AttachShader", + DetachShader(..) => "DetachShader", BindAttribLocation(..) => "BindAttribLocation", BufferData(..) => "BufferData", BufferSubData(..) => "BufferSubData", @@ -204,6 +206,8 @@ impl WebGLCommand { gl::active_texture(target), WebGLCommand::AttachShader(program_id, shader_id) => gl::attach_shader(program_id, shader_id), + WebGLCommand::DetachShader(program_id, shader_id) => + gl::detach_shader(program_id, shader_id), WebGLCommand::BindAttribLocation(program_id, index, name) => gl::bind_attrib_location(program_id, index, &name), WebGLCommand::BlendColor(r, g, b, a) => @@ -331,7 +335,7 @@ impl WebGLCommand { WebGLCommand::DrawingBufferHeight(sender) => sender.send(ctx.borrow_draw_buffer().unwrap().size().height).unwrap(), WebGLCommand::Finish(sender) => - { gl::finish(); sender.send(()).unwrap(); }, + Self::finish(sender), WebGLCommand::Flush => gl::flush(), } @@ -477,6 +481,11 @@ impl WebGLCommand { chan.send(result).unwrap(); } + fn finish(chan: IpcSender<()>) { + gl::finish(); + chan.send(()).unwrap(); + } + fn buffer_parameter(target: u32, param_id: u32, chan: IpcSender>) { From 3d7f6d7ddd9aae7e376e8dd415498105413bab88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 27 Mar 2016 14:34:03 +0200 Subject: [PATCH 47/97] webgl: Derive Debug on most types This will allow us creating more useful error messages. --- src/webgl.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 7de9a9c5da..a58886cc36 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -11,7 +11,7 @@ use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct WebGLContextId(pub usize); -#[derive(Clone, Copy, PartialEq, Deserialize, Serialize)] +#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] pub enum WebGLError { InvalidEnum, InvalidOperation, @@ -22,13 +22,13 @@ pub enum WebGLError { pub type WebGLResult = Result; -#[derive(Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub enum WebGLFramebufferBindingRequest { Explicit(u32), Default, } -#[derive(Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub enum WebGLParameter { Int(i32), Bool(bool), @@ -37,7 +37,7 @@ pub enum WebGLParameter { Invalid, } -#[derive(Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub enum WebGLShaderParameter { Int(i32), Bool(bool), From 2ce5129807be2134fdef1a333274e3bf76ba5d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 27 Mar 2016 15:31:48 +0200 Subject: [PATCH 48/97] webgl: Make the RequestWebGLContext return the GLLimits structure --- src/api.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api.rs b/src/api.rs index a0e2e4e444..40d8d5db59 100644 --- a/src/api.rs +++ b/src/api.rs @@ -11,7 +11,7 @@ use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; use webgl::{WebGLContextId, WebGLCommand}; -use offscreen_gl_context::GLContextAttributes; +use offscreen_gl_context::{GLContextAttributes, GLLimits}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct IdNamespace(pub u32); @@ -57,7 +57,7 @@ pub enum ApiMsg { Scroll(Point2D, Point2D, ScrollEventPhase), TickScrollingBounce, TranslatePointToLayerSpace(Point2D, IpcSender>), - RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), + RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), WebGLCommand(WebGLContextId, WebGLCommand), } @@ -212,7 +212,7 @@ impl RenderApi { } pub fn request_webgl_context(&self, size: &Size2D, attributes: GLContextAttributes) - -> Result { + -> Result<(WebGLContextId, GLLimits), String> { let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::RequestWebGLContext(*size, attributes, tx); self.api_sender.send(msg).unwrap(); From dac5f7df080f8b2da693893e404f4b28f65ebb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 27 Mar 2016 15:32:21 +0200 Subject: [PATCH 49/97] webgl: Remove unneeded scalar cast --- src/webgl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webgl.rs b/src/webgl.rs index a58886cc36..762983c8f0 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -321,7 +321,7 @@ impl WebGLCommand { WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => gl::vertex_attrib_4f(attrib_id, x, y, z, w), WebGLCommand::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => - gl::vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset as u32), + gl::vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset), WebGLCommand::Viewport(x, y, width, height) => gl::viewport(x, y, width, height), WebGLCommand::TexImage2D(target, level, internal, width, height, format, data_type, data) => From c97e5ca8eb92fb3434a6a4940c6c4cb58a2376fd Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Tue, 29 Mar 2016 09:28:21 -0600 Subject: [PATCH 50/97] Added generate mipmap variant --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 7de9a9c5da..3f9619da4d 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -115,6 +115,7 @@ pub enum WebGLCommand { DrawingBufferHeight(IpcSender), Finish(IpcSender<()>), Flush, + GenerateMipmap(u32), } impl fmt::Debug for WebGLCommand { @@ -190,6 +191,7 @@ impl fmt::Debug for WebGLCommand { DrawingBufferHeight(..) => "DrawingBufferHeight", Finish(..) => "Finish", Flush => "Flush", + GenerateMipmap(..) => "GenerateMipmap", }; write!(f, "CanvasWebGLMsg::{}(..)", name) @@ -338,6 +340,8 @@ impl WebGLCommand { Self::finish(sender), WebGLCommand::Flush => gl::flush(), + WebGLCommand::GenerateMipmap(target) => + gl::generate_mipmap(target), } // FIXME: Use debug_assertions once tests are run with them From 769501052800c937518db6d97db5e68bc597ded9 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 30 Mar 2016 17:44:22 -0700 Subject: [PATCH 51/97] Communicate iframe clipping regions to WebRender. Partially addresses servo/servo#9983. --- src/display_list.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/display_list.rs b/src/display_list.rs index 0ad326d918..ee428778de 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -28,6 +28,7 @@ pub struct StackingContextInfo { pub struct IframeInfo { pub id: PipelineId, pub bounds: Rect, + pub clip: ClipRegion, } #[derive(Copy, Clone, Serialize, Deserialize)] @@ -315,12 +316,13 @@ impl DisplayListBuilder { pub fn push_iframe(&mut self, level: StackingLevel, rect: Rect, - _clip: ClipRegion, + clip: ClipRegion, iframe: PipelineId) { self.flush_list(level); let info = IframeInfo { id: iframe, bounds: rect, + clip: clip, }; let item = DisplayListItem { stacking_level: level, From c8ca5e2eaea38928832eb665b829fa60663a62fc Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Thu, 31 Mar 2016 17:48:46 -0600 Subject: [PATCH 52/97] Add Uniform1i variant --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index c981ab6dd0..997a5a4c15 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -103,6 +103,7 @@ pub enum WebGLCommand { PixelStorei(u32, i32), LinkProgram(u32), Uniform1f(i32, f32), + Uniform1i(i32, i32), Uniform4f(i32, f32, f32, f32, f32), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), @@ -180,6 +181,7 @@ impl fmt::Debug for WebGLCommand { LinkProgram(..) => "LinkProgram", Uniform4f(..) => "Uniform4f", Uniform1f(..) => "Uniform1f", + Uniform1i(..) => "Uniform1i", UseProgram(..) => "UseProgram", VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", @@ -316,6 +318,8 @@ impl WebGLCommand { gl::link_program(program_id), WebGLCommand::Uniform1f(uniform_id, v) => gl::uniform_1f(uniform_id, v), + WebGLCommand::Uniform1i(uniform_id, v) => + gl::uniform_1i(uniform_id, v), WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => gl::uniform_4f(uniform_id, x, y, z, w), WebGLCommand::UseProgram(program_id) => From 5aa77605400be9e7e3f1b2228b01feb4246ef014 Mon Sep 17 00:00:00 2001 From: Ar13mis Date: Fri, 1 Apr 2016 17:00:15 -0600 Subject: [PATCH 53/97] Added Uniform2f variant --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 997a5a4c15..ecf17b673c 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -104,6 +104,7 @@ pub enum WebGLCommand { LinkProgram(u32), Uniform1f(i32, f32), Uniform1i(i32, i32), + Uniform2f(i32, f32, f32), Uniform4f(i32, f32, f32, f32, f32), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), @@ -182,6 +183,7 @@ impl fmt::Debug for WebGLCommand { Uniform4f(..) => "Uniform4f", Uniform1f(..) => "Uniform1f", Uniform1i(..) => "Uniform1i", + Uniform2f(..) => "Uniform2f", UseProgram(..) => "UseProgram", VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", @@ -320,6 +322,8 @@ impl WebGLCommand { gl::uniform_1f(uniform_id, v), WebGLCommand::Uniform1i(uniform_id, v) => gl::uniform_1i(uniform_id, v), + WebGLCommand::Uniform2f(uniform_id, x, y) => + gl::uniform_2f(uniform_id, x, y), WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => gl::uniform_4f(uniform_id, x, y, z, w), WebGLCommand::UseProgram(program_id) => From 1a7b8e8854d9aade2dc7371b1c2da0b82052dc14 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 1 Apr 2016 16:37:03 -0700 Subject: [PATCH 54/97] Brand each payload message with the stacking context ID and epoch to avoid races. Addresses servo/servo#10256. --- Cargo.toml | 1 + src/api.rs | 10 ++++++++-- src/display_list.rs | 23 ++++++++++++++++++++++- src/lib.rs | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5f5aed33f3..c0417b8b70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ euclid = {version = "0.6.2", features = ["plugins"]} gleam = "0.2" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" +byteorder = "0.5" [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" diff --git a/src/api.rs b/src/api.rs index 40d8d5db59..7dac93fa36 100644 --- a/src/api.rs +++ b/src/api.rs @@ -2,6 +2,7 @@ * 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 byteorder::{LittleEndian, WriteBytesExt}; use display_list::{AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList}; use display_list::{BuiltDisplayListDescriptor}; use euclid::{Point2D, Size2D}; @@ -187,11 +188,16 @@ impl RenderApi { *auxiliary_lists.descriptor()); self.api_sender.send(msg).unwrap(); + let mut payload = vec![]; + payload.write_u32::(stacking_context_id.0).unwrap(); + payload.write_u32::(epoch.0).unwrap(); + for &(_, ref built_display_list) in &display_lists { - self.payload_sender.send(built_display_list.data()).unwrap(); + payload.extend_from_slice(built_display_list.data()); } + payload.extend_from_slice(auxiliary_lists.data()); - self.payload_sender.send(auxiliary_lists.data()).unwrap(); + self.payload_sender.send(&payload[..]).unwrap(); } pub fn scroll(&self, delta: Point2D, cursor: Point2D, phase: ScrollEventPhase) { diff --git a/src/display_list.rs b/src/display_list.rs index 0ad326d918..34f27b02f3 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -52,8 +52,16 @@ pub struct BuiltDisplayListDescriptor { pub mode: DisplayListMode, pub has_stacking_contexts: bool, - /// The size in bytes of the display items in this display list. + /// The size in bytes of the display list items in this display list. display_list_items_size: usize, + /// The size in bytes of the display items in this display list. + display_items_size: usize, +} + +impl BuiltDisplayListDescriptor { + pub fn size(&self) -> usize { + self.display_list_items_size + self.display_items_size + } } /// A display list. @@ -404,11 +412,13 @@ impl DisplayListBuilder { let mut blob = convert_pod_to_blob(&self.display_list_items).to_vec(); let display_list_items_size = blob.len(); blob.extend_from_slice(convert_pod_to_blob(&self.display_items)); + let display_items_size = blob.len() - display_list_items_size; BuiltDisplayList { descriptor: BuiltDisplayListDescriptor { mode: self.mode, has_stacking_contexts: self.has_stacking_contexts, display_list_items_size: display_list_items_size, + display_items_size: display_items_size, }, data: blob, } @@ -517,6 +527,8 @@ impl AuxiliaryListsBuilder { blob.extend_from_slice(convert_pod_to_blob(&self.filters)); let filters_size = blob.len() - (complex_clip_regions_size + gradient_stops_size); blob.extend_from_slice(convert_pod_to_blob(&self.glyph_instances)); + let glyph_instances_size = blob.len() - + (complex_clip_regions_size + gradient_stops_size + filters_size); AuxiliaryLists { data: blob, @@ -524,6 +536,7 @@ impl AuxiliaryListsBuilder { gradient_stops_size: gradient_stops_size, complex_clip_regions_size: complex_clip_regions_size, filters_size: filters_size, + glyph_instances_size: glyph_instances_size, }, } } @@ -539,6 +552,14 @@ pub struct AuxiliaryListsDescriptor { gradient_stops_size: usize, complex_clip_regions_size: usize, filters_size: usize, + glyph_instances_size: usize, +} + +impl AuxiliaryListsDescriptor { + pub fn size(&self) -> usize { + self.gradient_stops_size + self.complex_clip_regions_size + self.filters_size + + self.glyph_instances_size + } } #[derive(Clone, Serialize, Deserialize)] diff --git a/src/lib.rs b/src/lib.rs index df75a3f88a..42570936dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ #![plugin(serde_macros)] extern crate app_units; +extern crate byteorder; extern crate euclid; extern crate ipc_channel; extern crate serde; From b609c2e360a9765f78c2689d22c740cb515f7ae6 Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Sat, 2 Apr 2016 20:32:22 +0200 Subject: [PATCH 55/97] Added Uniform4i --- src/webgl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index ecf17b673c..456a4217eb 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -106,6 +106,7 @@ pub enum WebGLCommand { Uniform1i(i32, i32), Uniform2f(i32, f32, f32), Uniform4f(i32, f32, f32, f32, f32), + Uniform4i(i32, i32, i32, i32, i32), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), @@ -181,6 +182,7 @@ impl fmt::Debug for WebGLCommand { PixelStorei(..) => "PixelStorei", LinkProgram(..) => "LinkProgram", Uniform4f(..) => "Uniform4f", + Uniform4i(..) => "Uniform4i", Uniform1f(..) => "Uniform1f", Uniform1i(..) => "Uniform1i", Uniform2f(..) => "Uniform2f", @@ -326,6 +328,8 @@ impl WebGLCommand { gl::uniform_2f(uniform_id, x, y), WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => gl::uniform_4f(uniform_id, x, y, z, w), + WebGLCommand::Uniform4i(uniform_id, x, y, z, w) => + gl::uniform_4i(uniform_id, x, y, z, w), WebGLCommand::UseProgram(program_id) => gl::use_program(program_id), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => From 618b074d16ead57cd3c7e73a1157a5aee44e7cc5 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 2 Apr 2016 20:08:53 -0700 Subject: [PATCH 56/97] Add getActiveAttrib --- src/webgl.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 456a4217eb..e9e78176a3 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -94,6 +94,7 @@ pub enum WebGLCommand { GetParameter(u32, IpcSender>), GetProgramParameter(u32, u32, IpcSender>), GetShaderParameter(u32, u32, IpcSender>), + GetActiveAttrib(u32, u32, IpcSender>), GetAttribLocation(u32, String, IpcSender>), GetUniformLocation(u32, String, IpcSender>), PolygonOffset(f32, f32), @@ -173,6 +174,7 @@ impl fmt::Debug for WebGLCommand { GetParameter(..) => "GetParameter", GetProgramParameter(..) => "GetProgramParameter", GetShaderParameter(..) => "GetShaderParameter", + GetActiveAttrib(..) => "GetActiveAttrib", GetAttribLocation(..) => "GetAttribLocation", GetUniformLocation(..) => "GetUniformLocation", PolygonOffset(..) => "PolygonOffset", @@ -272,6 +274,8 @@ impl WebGLCommand { gl::scissor(x, y, width, height), WebGLCommand::EnableVertexAttribArray(attrib_id) => gl::enable_vertex_attrib_array(attrib_id), + WebGLCommand::GetActiveAttrib(program_id, index, chan) => + Self::active_attrib(program_id, index, chan), WebGLCommand::GetAttribLocation(program_id, name, chan) => Self::attrib_location(program_id, name, chan), WebGLCommand::GetBufferParameter(target, param_id, chan) => @@ -361,6 +365,18 @@ impl WebGLCommand { assert!(error == gl::NO_ERROR, "Unexpected WebGL error: 0x{:x} ({})", error, error); } + fn active_attrib(program_id: u32, + index: u32, + chan: IpcSender>) { + let result = if index >= gl::get_program_iv(program_id, gl::ACTIVE_ATTRIBUTES) as u32 { + Err(WebGLError::InvalidValue) + } else { + Ok(gl::get_active_attrib(program_id, index)) + }; + chan.send(result).unwrap(); + } + + fn attrib_location(program_id: u32, name: String, chan: IpcSender> ) { From 1b368405a31e4c039488bc45997d11e92a3c2862 Mon Sep 17 00:00:00 2001 From: Saurav Sachidanand Date: Tue, 5 Apr 2016 22:58:38 +0530 Subject: [PATCH 57/97] Add GetActiveUniform --- src/webgl.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index e9e78176a3..54aab7f45c 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -95,6 +95,7 @@ pub enum WebGLCommand { GetProgramParameter(u32, u32, IpcSender>), GetShaderParameter(u32, u32, IpcSender>), GetActiveAttrib(u32, u32, IpcSender>), + GetActiveUniform(u32, u32, IpcSender>), GetAttribLocation(u32, String, IpcSender>), GetUniformLocation(u32, String, IpcSender>), PolygonOffset(f32, f32), @@ -175,6 +176,7 @@ impl fmt::Debug for WebGLCommand { GetProgramParameter(..) => "GetProgramParameter", GetShaderParameter(..) => "GetShaderParameter", GetActiveAttrib(..) => "GetActiveAttrib", + GetActiveUniform(..) => "GetActiveUniform", GetAttribLocation(..) => "GetAttribLocation", GetUniformLocation(..) => "GetUniformLocation", PolygonOffset(..) => "PolygonOffset", @@ -276,6 +278,8 @@ impl WebGLCommand { gl::enable_vertex_attrib_array(attrib_id), WebGLCommand::GetActiveAttrib(program_id, index, chan) => Self::active_attrib(program_id, index, chan), + WebGLCommand::GetActiveUniform(program_id, index, chan) => + Self::active_uniform(program_id, index, chan), WebGLCommand::GetAttribLocation(program_id, name, chan) => Self::attrib_location(program_id, name, chan), WebGLCommand::GetBufferParameter(target, param_id, chan) => @@ -376,6 +380,16 @@ impl WebGLCommand { chan.send(result).unwrap(); } + fn active_uniform(program_id: u32, + index: u32, + chan: IpcSender>) { + let result = if index >= gl::get_program_iv(program_id, gl::ACTIVE_UNIFORMS) as u32 { + Err(WebGLError::InvalidValue) + } else { + Ok(gl::get_active_uniform(program_id, index)) + }; + chan.send(result).unwrap(); + } fn attrib_location(program_id: u32, name: String, From aea129570598718394e598be8b396283e480246f Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Wed, 6 Apr 2016 12:44:18 +0200 Subject: [PATCH 58/97] Added remaining uniforms --- src/webgl.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index 54aab7f45c..666da71892 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -107,6 +107,9 @@ pub enum WebGLCommand { Uniform1f(i32, f32), Uniform1i(i32, i32), Uniform2f(i32, f32, f32), + Uniform2i(i32, i32, i32), + Uniform3f(i32, f32, f32, f32), + Uniform3i(i32, i32, i32, i32), Uniform4f(i32, f32, f32, f32, f32), Uniform4i(i32, i32, i32, i32, i32), UseProgram(u32), @@ -185,11 +188,14 @@ impl fmt::Debug for WebGLCommand { LineWidth(..) => "LineWidth", PixelStorei(..) => "PixelStorei", LinkProgram(..) => "LinkProgram", - Uniform4f(..) => "Uniform4f", - Uniform4i(..) => "Uniform4i", Uniform1f(..) => "Uniform1f", Uniform1i(..) => "Uniform1i", Uniform2f(..) => "Uniform2f", + Uniform2i(..) => "Uniform2i", + Uniform3f(..) => "Uniform3f", + Uniform3i(..) => "Uniform3i", + Uniform4f(..) => "Uniform4f", + Uniform4i(..) => "Uniform4i", UseProgram(..) => "UseProgram", VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", @@ -334,6 +340,12 @@ impl WebGLCommand { gl::uniform_1i(uniform_id, v), WebGLCommand::Uniform2f(uniform_id, x, y) => gl::uniform_2f(uniform_id, x, y), + WebGLCommand::Uniform2i(uniform_id, x, y) => + gl::uniform_2i(uniform_id, x, y), + WebGLCommand::Uniform3f(uniform_id, x, y, z) => + gl::uniform_3f(uniform_id, x, y, z), + WebGLCommand::Uniform3i(uniform_id, x, y, z) => + gl::uniform_3i(uniform_id, x, y, z), WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => gl::uniform_4f(uniform_id, x, y, z, w), WebGLCommand::Uniform4i(uniform_id, x, y, z, w) => From a235763211329a9bf4a033a840acc25712de7518 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 6 Apr 2016 14:45:43 -0400 Subject: [PATCH 59/97] Update nightly Rust version to keep in sync with Servo. https://github.com/servo/servo/pull/10173/ --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47723480fc..e2cc6ded5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-03-18 # Should be kept in sync with Servo. + - nightly-2016-04-06 # Should be kept in sync with Servo. matrix: allow_failures: - rust: nightly From 6b070ac04342d61fb7cc60c681f0f2156e2a7756 Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Fri, 8 Apr 2016 00:48:31 +0200 Subject: [PATCH 60/97] Added uniform vector functions --- src/webgl.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 666da71892..e8b1b48678 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -105,13 +105,21 @@ pub enum WebGLCommand { PixelStorei(u32, i32), LinkProgram(u32), Uniform1f(i32, f32), + Uniform1fv(i32, Vec), Uniform1i(i32, i32), + Uniform1iv(i32, Vec), Uniform2f(i32, f32, f32), + Uniform2fv(i32, Vec), Uniform2i(i32, i32, i32), + Uniform2iv(i32, Vec), Uniform3f(i32, f32, f32, f32), + Uniform3fv(i32, Vec), Uniform3i(i32, i32, i32, i32), + Uniform3iv(i32, Vec), Uniform4f(i32, f32, f32, f32, f32), + Uniform4fv(i32, Vec), Uniform4i(i32, i32, i32, i32, i32), + Uniform4iv(i32, Vec), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), @@ -189,13 +197,21 @@ impl fmt::Debug for WebGLCommand { PixelStorei(..) => "PixelStorei", LinkProgram(..) => "LinkProgram", Uniform1f(..) => "Uniform1f", + Uniform1fv(..) => "Uniform1fv", Uniform1i(..) => "Uniform1i", + Uniform1iv(..) => "Uniform1iv", Uniform2f(..) => "Uniform2f", + Uniform2fv(..) => "Uniform2fv", Uniform2i(..) => "Uniform2i", + Uniform2iv(..) => "Uniform2iv", Uniform3f(..) => "Uniform3f", + Uniform3fv(..) => "Uniform3fv", Uniform3i(..) => "Uniform3i", + Uniform3iv(..) => "Uniform3iv", Uniform4f(..) => "Uniform4f", + Uniform4fv(..) => "Uniform4fv", Uniform4i(..) => "Uniform4i", + Uniform4iv(..) => "Uniform4iv", UseProgram(..) => "UseProgram", VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", @@ -336,20 +352,36 @@ impl WebGLCommand { gl::link_program(program_id), WebGLCommand::Uniform1f(uniform_id, v) => gl::uniform_1f(uniform_id, v), + WebGLCommand::Uniform1fv(uniform_id, v) => + gl::uniform_1fv(uniform_id, &v), WebGLCommand::Uniform1i(uniform_id, v) => gl::uniform_1i(uniform_id, v), + WebGLCommand::Uniform1iv(uniform_id, v) => + gl::uniform_1iv(uniform_id, &v), WebGLCommand::Uniform2f(uniform_id, x, y) => gl::uniform_2f(uniform_id, x, y), + WebGLCommand::Uniform2fv(uniform_id, v) => + gl::uniform_2fv(uniform_id, &v), WebGLCommand::Uniform2i(uniform_id, x, y) => gl::uniform_2i(uniform_id, x, y), + WebGLCommand::Uniform2iv(uniform_id, v) => + gl::uniform_2iv(uniform_id, &v), WebGLCommand::Uniform3f(uniform_id, x, y, z) => gl::uniform_3f(uniform_id, x, y, z), + WebGLCommand::Uniform3fv(uniform_id, v) => + gl::uniform_3fv(uniform_id, &v), WebGLCommand::Uniform3i(uniform_id, x, y, z) => gl::uniform_3i(uniform_id, x, y, z), + WebGLCommand::Uniform3iv(uniform_id, v) => + gl::uniform_3iv(uniform_id, &v), WebGLCommand::Uniform4f(uniform_id, x, y, z, w) => gl::uniform_4f(uniform_id, x, y, z, w), + WebGLCommand::Uniform4fv(uniform_id, v) => + gl::uniform_4fv(uniform_id, &v), WebGLCommand::Uniform4i(uniform_id, x, y, z, w) => gl::uniform_4i(uniform_id, x, y, z, w), + WebGLCommand::Uniform4iv(uniform_id, v) => + gl::uniform_4iv(uniform_id, &v), WebGLCommand::UseProgram(program_id) => gl::use_program(program_id), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => From c3858476f3eb0abf4d643349508fed656894da06 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Thu, 14 Apr 2016 14:46:07 -0700 Subject: [PATCH 61/97] Remove the concept of StackingLevels Servo now sorts the display list before passing it to WebRender, so we don't need to have the concept of StackingLevels. Instead we can just keep a list of items and StackingContexts. --- src/display_list.rs | 109 +++++++------------------------------------- src/lib.rs | 2 +- src/types.rs | 10 ---- 3 files changed, 18 insertions(+), 103 deletions(-) diff --git a/src/display_list.rs b/src/display_list.rs index 660d2d4b7b..3ee002f3b6 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -9,7 +9,7 @@ use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use euclid::{Point2D, Rect, Size2D}; use std::mem; use std::slice; -use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId, StackingLevel}; +use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, FilterOp, GlyphInstance}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; use webgl::{WebGLContextId}; @@ -40,7 +40,6 @@ pub enum SpecificDisplayListItem { #[derive(Copy, Clone, Serialize, Deserialize)] pub struct DisplayListItem { - pub stacking_level: StackingLevel, pub specific: SpecificDisplayListItem, } @@ -105,12 +104,7 @@ pub struct DisplayListBuilder { pub mode: DisplayListMode, pub has_stacking_contexts: bool, - pub work_background_and_borders: Vec, - pub work_block_backgrounds_and_borders: Vec, - pub work_floats: Vec, - pub work_content: Vec, - pub work_positioned_content: Vec, - pub work_outlines: Vec, + pub work_list: Vec, pub display_list_items: Vec, pub display_items: Vec, @@ -121,21 +115,13 @@ impl DisplayListBuilder { DisplayListBuilder { mode: DisplayListMode::Default, has_stacking_contexts: false, - - work_background_and_borders: Vec::new(), - work_block_backgrounds_and_borders: Vec::new(), - work_floats: Vec::new(), - work_content: Vec::new(), - work_positioned_content: Vec::new(), - work_outlines: Vec::new(), - + work_list: Vec::new(), display_list_items: Vec::new(), display_items: Vec::new(), } } pub fn push_rect(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, color: ColorF) { @@ -149,11 +135,10 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } pub fn push_image(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, stretch_size: Size2D, @@ -171,11 +156,10 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } pub fn push_webgl_canvas(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, context_id: WebGLContextId) { @@ -189,11 +173,10 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } pub fn push_text(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, glyphs: Vec, @@ -223,12 +206,11 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } } pub fn push_border(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, left: BorderSide, @@ -250,11 +232,10 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } pub fn push_box_shadow(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, box_bounds: Rect, @@ -280,26 +261,22 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } - pub fn push_stacking_context(&mut self, - level: StackingLevel, - stacking_context_id: StackingContextId) { + pub fn push_stacking_context(&mut self, stacking_context_id: StackingContextId) { self.has_stacking_contexts = true; - self.flush_list(level); + self.flush(); let info = StackingContextInfo { id: stacking_context_id, }; let item = DisplayListItem { - stacking_level: level, specific: SpecificDisplayListItem::StackingContext(info), }; self.display_list_items.push(item); } pub fn push_gradient(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, start_point: Point2D, @@ -318,73 +295,31 @@ impl DisplayListBuilder { clip: clip, }; - self.push_item(level, display_item); + self.push_item(display_item); } pub fn push_iframe(&mut self, - level: StackingLevel, rect: Rect, clip: ClipRegion, iframe: PipelineId) { - self.flush_list(level); + self.flush(); let info = IframeInfo { id: iframe, bounds: rect, clip: clip, }; let item = DisplayListItem { - stacking_level: level, specific: SpecificDisplayListItem::Iframe(info), }; self.display_list_items.push(item); } - fn push_item(&mut self, level: StackingLevel, item: DisplayItem) { - match level { - StackingLevel::BackgroundAndBorders => { - self.work_background_and_borders.push(item); - } - StackingLevel::BlockBackgroundAndBorders => { - self.work_block_backgrounds_and_borders.push(item); - } - StackingLevel::Floats => { - self.work_floats.push(item); - } - StackingLevel::Content => { - self.work_content.push(item); - } - StackingLevel::PositionedContent => { - self.work_positioned_content.push(item); - } - StackingLevel::Outlines => { - self.work_outlines.push(item); - } - } + fn push_item(&mut self, item: DisplayItem) { + self.work_list.push(item); } - fn flush_list(&mut self, level: StackingLevel) { - let list = match level { - StackingLevel::BackgroundAndBorders => { - &mut self.work_background_and_borders - } - StackingLevel::BlockBackgroundAndBorders => { - &mut self.work_block_backgrounds_and_borders - } - StackingLevel::Floats => { - &mut self.work_floats - } - StackingLevel::Content => { - &mut self.work_content - } - StackingLevel::PositionedContent => { - &mut self.work_positioned_content - } - StackingLevel::Outlines => { - &mut self.work_outlines - } - }; - - let items = mem::replace(list, Vec::new()); + fn flush(&mut self) { + let items = mem::replace(&mut self.work_list, Vec::new()); if items.is_empty() { return } @@ -393,20 +328,10 @@ impl DisplayListBuilder { items: ItemRange::new(&mut self.display_items, &items), }; self.display_list_items.push(DisplayListItem { - stacking_level: level, specific: SpecificDisplayListItem::DrawList(draw_list), }); } - fn flush(&mut self) { - self.flush_list(StackingLevel::BackgroundAndBorders); - self.flush_list(StackingLevel::BlockBackgroundAndBorders); - self.flush_list(StackingLevel::Floats); - self.flush_list(StackingLevel::Content); - self.flush_list(StackingLevel::PositionedContent); - self.flush_list(StackingLevel::Outlines); - } - pub fn finalize(mut self) -> BuiltDisplayList { self.flush(); diff --git a/src/lib.rs b/src/lib.rs index 42570936dd..8fed427f5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,5 +39,5 @@ pub use types::{ColorF, ClipRegion, ComplexClipRegion}; pub use types::{DisplayListId, DisplayListMode, ImageRendering}; pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; -pub use types::{ScrollLayerId, ScrollPolicy, StackingLevel, StackingContextId, ScrollLayerInfo}; +pub use types::{ScrollLayerId, ScrollPolicy, StackingContextId, ScrollLayerInfo}; pub use webgl::*; diff --git a/src/types.rs b/src/types.rs index bb7da1a34c..52282ec41b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -274,13 +274,3 @@ pub enum ScrollPolicy { Scrollable, Fixed, } - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -pub enum StackingLevel { - BackgroundAndBorders, - BlockBackgroundAndBorders, - Floats, - Content, - PositionedContent, - Outlines, -} From 5297c268452886f382a5e1d8da8aa34741679be0 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Fri, 15 Apr 2016 11:03:10 -0700 Subject: [PATCH 62/97] Update Rust version in travis configuration Servo's rust version has changed, so we must pin travis to the new version. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e2cc6ded5f..8957738573 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-04-06 # Should be kept in sync with Servo. + - nightly-2016-04-11 # Should be kept in sync with Servo. matrix: allow_failures: - rust: nightly From 6c60068c6ac3a04f2963f389f092a5c10b254671 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Sat, 16 Apr 2016 23:19:35 -0400 Subject: [PATCH 63/97] Add stencil WebGL commands --- src/webgl.rs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/webgl.rs b/src/webgl.rs index e8b1b48678..ad262cfcff 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -100,6 +100,12 @@ pub enum WebGLCommand { GetUniformLocation(u32, String, IpcSender>), PolygonOffset(f32, f32), Scissor(i32, i32, i32, i32), + StencilFunc(u32, i32, u32), + StencilFuncSeparate(u32, u32, i32, u32), + StencilMask(u32), + StencilMaskSeparate(u32, u32), + StencilOp(u32, u32, u32), + StencilOpSeparate(u32, u32, u32, u32), Hint(u32, u32), LineWidth(f32), PixelStorei(u32, i32), @@ -192,6 +198,12 @@ impl fmt::Debug for WebGLCommand { GetUniformLocation(..) => "GetUniformLocation", PolygonOffset(..) => "PolygonOffset", Scissor(..) => "Scissor", + StencilFunc(..) => "StencilFunc", + StencilFuncSeparate(..) => "StencilFuncSeparate", + StencilMask(..) => "StencilMask", + StencilMaskSeparate(..) => "StencilMaskSeparate", + StencilOp(..) => "StencilOp", + StencilOpSeparate(..) => "StencilOpSeparate", Hint(..) => "Hint", LineWidth(..) => "LineWidth", PixelStorei(..) => "PixelStorei", @@ -286,6 +298,8 @@ impl WebGLCommand { gl::draw_arrays(mode, first, count), WebGLCommand::DrawElements(mode, count, type_, offset) => gl::draw_elements(mode, count, type_, offset as u32), + WebGLCommand::EnableVertexAttribArray(attrib_id) => + gl::enable_vertex_attrib_array(attrib_id), WebGLCommand::Hint(name, val) => gl::hint(name, val), WebGLCommand::LineWidth(width) => @@ -296,8 +310,18 @@ impl WebGLCommand { gl::polygon_offset(factor, units), WebGLCommand::Scissor(x, y, width, height) => gl::scissor(x, y, width, height), - WebGLCommand::EnableVertexAttribArray(attrib_id) => - gl::enable_vertex_attrib_array(attrib_id), + WebGLCommand::StencilFunc(func, ref_, mask) => + gl::stencil_func(func, ref_, mask), + WebGLCommand::StencilFuncSeparate(face, func, ref_, mask) => + gl::stencil_func_separate(face, func, ref_, mask), + WebGLCommand::StencilMask(mask) => + gl::stencil_mask(mask), + WebGLCommand::StencilMaskSeparate(face, mask) => + gl::stencil_mask_separate(face, mask), + WebGLCommand::StencilOp(fail, zfail, zpass) => + gl::stencil_op(fail, zfail, zpass), + WebGLCommand::StencilOpSeparate(face, fail, zfail, zpass) => + gl::stencil_op_separate(face, fail, zfail, zpass), WebGLCommand::GetActiveAttrib(program_id, index, chan) => Self::active_attrib(program_id, index, chan), WebGLCommand::GetActiveUniform(program_id, index, chan) => @@ -425,8 +449,8 @@ impl WebGLCommand { } fn active_uniform(program_id: u32, - index: u32, - chan: IpcSender>) { + index: u32, + chan: IpcSender>) { let result = if index >= gl::get_program_iv(program_id, gl::ACTIVE_UNIFORMS) as u32 { Err(WebGLError::InvalidValue) } else { From ab8417389dbb369bc7f142e2c4a109af34119082 Mon Sep 17 00:00:00 2001 From: edunham Date: Tue, 19 Apr 2016 09:15:20 -0700 Subject: [PATCH 64/97] Tidy-check install servo-tidy from pip, probably same code as https://github.com/servo/servo/tree/master/python/tidy, and run it --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8957738573..f3b5b7312f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,14 @@ language: rust rust: - nightly - nightly-2016-04-11 # Should be kept in sync with Servo. + matrix: allow_failures: - rust: nightly + notifications: webhooks: http://build.servo.org:54856/travis + addons: apt: packages: @@ -14,3 +17,11 @@ addons: os: - linux - osx + +before_script: + - export PATH=$HOME/.local/bin:/Users/travis/Library/Python/2.7/bin:$PATH + - pip install servo_tidy --user `whoami` + +script: + - servo-tidy + From 8b7c42d12dc7b07df109b5a3ae90201e8417ad33 Mon Sep 17 00:00:00 2001 From: edunham Date: Tue, 19 Apr 2016 09:23:06 -0700 Subject: [PATCH 65/97] style fixups suggested by tidy --- src/api.rs | 2 +- src/display_item.rs | 4 ++-- src/display_list.rs | 4 ++-- src/lib.rs | 9 ++++----- src/types.rs | 7 +++---- src/webgl.rs | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/api.rs b/src/api.rs index 7dac93fa36..a286619c62 100644 --- a/src/api.rs +++ b/src/api.rs @@ -7,12 +7,12 @@ use display_list::{AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList}; use display_list::{BuiltDisplayListDescriptor}; use euclid::{Point2D, Size2D}; use ipc_channel::ipc::{self, IpcBytesSender, IpcSender}; +use offscreen_gl_context::{GLContextAttributes, GLLimits}; use stacking_context::StackingContext; use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; use webgl::{WebGLContextId, WebGLCommand}; -use offscreen_gl_context::{GLContextAttributes, GLLimits}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct IdNamespace(pub u32); diff --git a/src/display_item.rs b/src/display_item.rs index 388869daa0..b32d8bcae0 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -4,10 +4,10 @@ use app_units::Au; use display_list::ItemRange; -use types::{ClipRegion, ColorF, FontKey, ImageKey, BorderSide}; +use euclid::{Point2D, Rect, Size2D}; use types::{BorderRadius, BoxShadowClipMode, ImageRendering}; +use types::{ClipRegion, ColorF, FontKey, ImageKey, BorderSide}; use webgl::{WebGLContextId}; -use euclid::{Point2D, Rect, Size2D}; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct BorderDisplayItem { diff --git a/src/display_list.rs b/src/display_list.rs index 3ee002f3b6..b8275ea285 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -3,14 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; +use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisplayItem}; use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; -use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; use euclid::{Point2D, Rect, Size2D}; use std::mem; use std::slice; -use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId}; use types::{BorderRadius, BorderSide, BoxShadowClipMode, FilterOp, GlyphInstance}; +use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId}; use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; use webgl::{WebGLContextId}; diff --git a/src/lib.rs b/src/lib.rs index 8fed427f5d..5aa6fc662b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,15 +9,14 @@ extern crate app_units; extern crate byteorder; +extern crate core; extern crate euclid; +extern crate gleam; extern crate ipc_channel; -extern crate serde; extern crate offscreen_gl_context; -extern crate core; -extern crate gleam; +extern crate serde; -#[cfg(target_os="macos")] -extern crate core_graphics; +#[cfg(target_os = "macos")] extern crate core_graphics; mod api; mod display_item; diff --git a/src/types.rs b/src/types.rs index 52282ec41b..5e47bd8f58 100644 --- a/src/types.rs +++ b/src/types.rs @@ -6,8 +6,7 @@ use app_units::Au; use display_list::{AuxiliaryListsBuilder, ItemRange}; use euclid::{Rect, Size2D}; -#[cfg(target_os="macos")] -use core_graphics::font::CGFont; +#[cfg(target_os = "macos")] use core_graphics::font::CGFont; #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct BorderRadius { @@ -223,11 +222,11 @@ pub enum MixBlendMode { Luminosity, } -#[cfg(target_os="macos")] +#[cfg(target_os = "macos")] pub type NativeFontHandle = CGFont; /// Native fonts are not used on Linux; all fonts are raw. -#[cfg(not(target_os="macos"))] +#[cfg(not(target_os = "macos"))] #[derive(Clone, Serialize, Deserialize)] pub struct NativeFontHandle; diff --git a/src/webgl.rs b/src/webgl.rs index ad262cfcff..ebf6c7e84b 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use core::nonzero::NonZero; -use ipc_channel::ipc::IpcSender; use gleam::gl; +use ipc_channel::ipc::IpcSender; use offscreen_gl_context::{GLContext, GLContextAttributes, NativeGLContextMethods}; use std::fmt; From 04205177eb5e8cdd6e2b42913aa3a80a1b727bef Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Thu, 21 Apr 2016 00:07:37 -0700 Subject: [PATCH 66/97] Implement GetVertexAttrib --- src/webgl.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index ebf6c7e84b..5b9dde4f2f 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -34,6 +34,7 @@ pub enum WebGLParameter { Bool(bool), String(String), Float(f32), + FloatArray(Vec), Invalid, } @@ -98,6 +99,7 @@ pub enum WebGLCommand { GetActiveUniform(u32, u32, IpcSender>), GetAttribLocation(u32, String, IpcSender>), GetUniformLocation(u32, String, IpcSender>), + GetVertexAttrib(u32, u32, IpcSender>), PolygonOffset(f32, f32), Scissor(i32, i32, i32, i32), StencilFunc(u32, i32, u32), @@ -196,6 +198,7 @@ impl fmt::Debug for WebGLCommand { GetActiveUniform(..) => "GetActiveUniform", GetAttribLocation(..) => "GetAttribLocation", GetUniformLocation(..) => "GetUniformLocation", + GetVertexAttrib(..) => "GetVertexAttrib", PolygonOffset(..) => "PolygonOffset", Scissor(..) => "Scissor", StencilFunc(..) => "StencilFunc", @@ -328,6 +331,8 @@ impl WebGLCommand { Self::active_uniform(program_id, index, chan), WebGLCommand::GetAttribLocation(program_id, name, chan) => Self::attrib_location(program_id, name, chan), + WebGLCommand::GetVertexAttrib(index, pname, chan) => + Self::vertex_attrib(index, pname, chan), WebGLCommand::GetBufferParameter(target, param_id, chan) => Self::buffer_parameter(target, param_id, chan), WebGLCommand::GetParameter(param_id, chan) => @@ -600,6 +605,30 @@ impl WebGLCommand { chan.send(()).unwrap(); } + fn vertex_attrib(index: u32, + pname: u32, + chan: IpcSender>) { + let result = if index >= gl::get_integer_v(gl::MAX_VERTEX_ATTRIBS) as u32 { + Err(WebGLError::InvalidValue) + } else { + match pname { + gl::VERTEX_ATTRIB_ARRAY_ENABLED | + gl::VERTEX_ATTRIB_ARRAY_NORMALIZED => + Ok(WebGLParameter::Bool(gl::get_vertex_attrib_iv(index, pname) != 0)), + gl::VERTEX_ATTRIB_ARRAY_SIZE | + gl::VERTEX_ATTRIB_ARRAY_STRIDE | + gl::VERTEX_ATTRIB_ARRAY_TYPE => + Ok(WebGLParameter::Int(gl::get_vertex_attrib_iv(index, pname))), + gl::CURRENT_VERTEX_ATTRIB => + Ok(WebGLParameter::FloatArray(gl::get_vertex_attrib_fv(index, pname))), + // gl::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING should return WebGLBuffer + _ => Err(WebGLError::InvalidEnum), + } + }; + + chan.send(result).unwrap(); + } + fn buffer_parameter(target: u32, param_id: u32, chan: IpcSender>) { From 4dff97ebb05d77ec7b1442555d4ef514068fa2cc Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 16 Apr 2016 13:07:49 -0700 Subject: [PATCH 67/97] Implement ReadPixels --- src/webgl.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 5b9dde4f2f..655e79e4df 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -101,6 +101,7 @@ pub enum WebGLCommand { GetUniformLocation(u32, String, IpcSender>), GetVertexAttrib(u32, u32, IpcSender>), PolygonOffset(f32, f32), + ReadPixels(i32, i32, i32, i32, u32, u32, IpcSender>), Scissor(i32, i32, i32, i32), StencilFunc(u32, i32, u32), StencilFuncSeparate(u32, u32, i32, u32), @@ -200,6 +201,7 @@ impl fmt::Debug for WebGLCommand { GetUniformLocation(..) => "GetUniformLocation", GetVertexAttrib(..) => "GetVertexAttrib", PolygonOffset(..) => "PolygonOffset", + ReadPixels(..) => "ReadPixels", Scissor(..) => "Scissor", StencilFunc(..) => "StencilFunc", StencilFuncSeparate(..) => "StencilFuncSeparate", @@ -311,6 +313,8 @@ impl WebGLCommand { gl::pixel_store_i(name, val), WebGLCommand::PolygonOffset(factor, units) => gl::polygon_offset(factor, units), + WebGLCommand::ReadPixels(x, y, width, height, format, pixel_type, chan) => + Self::read_pixels(x, y, width, height, format, pixel_type, chan), WebGLCommand::Scissor(x, y, width, height) => gl::scissor(x, y, width, height), WebGLCommand::StencilFunc(func, ref_, mask) => @@ -442,6 +446,12 @@ impl WebGLCommand { assert!(error == gl::NO_ERROR, "Unexpected WebGL error: 0x{:x} ({})", error, error); } + fn read_pixels(x: i32, y: i32, width: i32, height: i32, format: u32, pixel_type: u32, + chan: IpcSender>) { + let result = gl::read_pixels(x, y, width, height, format, pixel_type); + chan.send(result).unwrap() + } + fn active_attrib(program_id: u32, index: u32, chan: IpcSender>) { From f3f7b15f8d9cb448565b0aa7ad06bd43a420bc8d Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 25 Apr 2016 11:24:09 -0700 Subject: [PATCH 68/97] Bump gleam dependency Because of #43 and servo/gleam#79 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c0417b8b70..2fadf38322 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/servo/ipc-channel" offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2" +gleam = "0.2.16" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" byteorder = "0.5" From 67bcaeebf19bc6aab83bef817b8a24ea02cefaa5 Mon Sep 17 00:00:00 2001 From: Daniel Robertson Date: Thu, 28 Apr 2016 14:57:48 -0400 Subject: [PATCH 69/97] Implement copyTex* and texSubImage2D --- src/webgl.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/webgl.rs b/src/webgl.rs index 655e79e4df..808afac347 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -72,6 +72,8 @@ pub enum WebGLCommand { Enable(u32), Disable(u32), CompileShader(u32, String), + CopyTexImage2D(u32, i32, u32, i32, i32, i32, i32, i32), + CopyTexSubImage2D(u32, i32, i32, i32, i32, i32, i32, i32), CreateBuffer(IpcSender>>), CreateFramebuffer(IpcSender>>), CreateRenderbuffer(IpcSender>>), @@ -136,6 +138,7 @@ pub enum WebGLCommand { TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec), TexParameteri(u32, u32, i32), TexParameterf(u32, u32, f32), + TexSubImage2D(u32, i32, i32, i32, i32, i32, u32, u32, Vec), DrawingBufferWidth(IpcSender), DrawingBufferHeight(IpcSender), Finish(IpcSender<()>), @@ -164,6 +167,8 @@ impl fmt::Debug for WebGLCommand { ClearDepth(..) => "ClearDepth", ClearStencil(..) => "ClearStencil", ColorMask(..) => "ColorMask", + CopyTexImage2D(..) => "CopyTexImage2D", + CopyTexSubImage2D(..) => "CopyTexSubImage2D", CullFace(..) => "CullFace", FrontFace(..) => "FrontFace", DepthFunc(..) => "DepthFunc", @@ -236,6 +241,7 @@ impl fmt::Debug for WebGLCommand { TexImage2D(..) => "TexImage2D", TexParameteri(..) => "TexParameteri", TexParameterf(..) => "TexParameterf", + TexSubImage2D(..) => "TexSubImage2D", DrawingBufferWidth(..) => "DrawingBufferWidth", DrawingBufferHeight(..) => "DrawingBufferHeight", Finish(..) => "Finish", @@ -285,6 +291,10 @@ impl WebGLCommand { gl::clear_stencil(stencil), WebGLCommand::ColorMask(r, g, b, a) => gl::color_mask(r, g, b, a), + WebGLCommand::CopyTexImage2D(target, level, internal_format, x, y, width, height, border) => + gl::copy_tex_image_2d(target, level, internal_format, x, y, width, height, border), + WebGLCommand::CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height) => + gl::copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height), WebGLCommand::CullFace(mode) => gl::cull_face(mode), WebGLCommand::DepthFunc(func) => @@ -429,6 +439,8 @@ impl WebGLCommand { gl::tex_parameter_i(target, name, value), WebGLCommand::TexParameterf(target, name, value) => gl::tex_parameter_f(target, name, value), + WebGLCommand::TexSubImage2D(target, level, xoffset, yoffset, x, y, width, height, data) => + gl::tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height, &data), WebGLCommand::DrawingBufferWidth(sender) => sender.send(ctx.borrow_draw_buffer().unwrap().size().width).unwrap(), WebGLCommand::DrawingBufferHeight(sender) => From 5f013961bf18edb715e28749c0ddf671642d254b Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 3 May 2016 18:31:51 -0700 Subject: [PATCH 70/97] Implement the infrastructure necessary to send back the corresponding pipeline ID when translating a point to layer space. Fixes events in browser.html. --- src/api.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index a286619c62..60193764a1 100644 --- a/src/api.rs +++ b/src/api.rs @@ -57,7 +57,7 @@ pub enum ApiMsg { SetRootPipeline(PipelineId), Scroll(Point2D, Point2D, ScrollEventPhase), TickScrollingBounce, - TranslatePointToLayerSpace(Point2D, IpcSender>), + TranslatePointToLayerSpace(Point2D, IpcSender<(Point2D, PipelineId)>), RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), WebGLCommand(WebGLContextId, WebGLCommand), } @@ -210,7 +210,8 @@ impl RenderApi { self.api_sender.send(msg).unwrap(); } - pub fn translate_point_to_layer_space(&self, point: &Point2D) -> Point2D { + pub fn translate_point_to_layer_space(&self, point: &Point2D) + -> (Point2D, PipelineId) { let (tx, rx) = ipc::channel().unwrap(); let msg = ApiMsg::TranslatePointToLayerSpace(*point, tx); self.api_sender.send(msg).unwrap(); From f4c382bb88ff39c0a7ceac0139be15922466123f Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Wed, 4 May 2016 11:13:22 +0200 Subject: [PATCH 71/97] Added missing uniform matrix methods --- Cargo.toml | 2 +- src/webgl.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2fadf38322..5165959127 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/servo/ipc-channel" offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2.16" +gleam = "0.2.17" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" byteorder = "0.5" diff --git a/src/webgl.rs b/src/webgl.rs index 808afac347..2c0896ae07 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -131,6 +131,9 @@ pub enum WebGLCommand { Uniform4fv(i32, Vec), Uniform4i(i32, i32, i32, i32, i32), Uniform4iv(i32, Vec), + UniformMatrix2fv(i32, bool, Vec), + UniformMatrix3fv(i32, bool, Vec), + UniformMatrix4fv(i32, bool, Vec), UseProgram(u32), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), @@ -234,6 +237,9 @@ impl fmt::Debug for WebGLCommand { Uniform4fv(..) => "Uniform4fv", Uniform4i(..) => "Uniform4i", Uniform4iv(..) => "Uniform4iv", + UniformMatrix2fv(..) => "UniformMatrix2fv", + UniformMatrix3fv(..) => "UniformMatrix3fv", + UniformMatrix4fv(..) => "UniformMatrix4fv", UseProgram(..) => "UseProgram", VertexAttrib(..) => "VertexAttrib", VertexAttribPointer2f(..) => "VertexAttribPointer2f", @@ -425,6 +431,12 @@ impl WebGLCommand { gl::uniform_4i(uniform_id, x, y, z, w), WebGLCommand::Uniform4iv(uniform_id, v) => gl::uniform_4iv(uniform_id, &v), + WebGLCommand::UniformMatrix2fv(uniform_id, transpose, v) => + gl::uniform_matrix_2fv(uniform_id, transpose, &v), + WebGLCommand::UniformMatrix3fv(uniform_id, transpose, v) => + gl::uniform_matrix_3fv(uniform_id, transpose, &v), + WebGLCommand::UniformMatrix4fv(uniform_id, transpose, v) => + gl::uniform_matrix_4fv(uniform_id, transpose, &v), WebGLCommand::UseProgram(program_id) => gl::use_program(program_id), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => From ce1602086e7710e2c8df29740c9102179d63edd2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 6 May 2016 01:35:34 -0400 Subject: [PATCH 72/97] add is_shader and is_texture commands --- Cargo.toml | 2 +- src/webgl.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5165959127..81c058059a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/servo/ipc-channel" offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2.17" +gleam = "0.2.18" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" byteorder = "0.5" diff --git a/src/webgl.rs b/src/webgl.rs index 2c0896ae07..5dfc5179ea 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -112,6 +112,8 @@ pub enum WebGLCommand { StencilOp(u32, u32, u32), StencilOpSeparate(u32, u32, u32, u32), Hint(u32, u32), + IsShader(u32), + IsTexture(u32), LineWidth(f32), PixelStorei(u32, i32), LinkProgram(u32), @@ -218,6 +220,8 @@ impl fmt::Debug for WebGLCommand { StencilOp(..) => "StencilOp", StencilOpSeparate(..) => "StencilOpSeparate", Hint(..) => "Hint", + IsShader(..) => "IsShader", + IsTexture(..) => "IsTexture", LineWidth(..) => "LineWidth", PixelStorei(..) => "PixelStorei", LinkProgram(..) => "LinkProgram", @@ -323,6 +327,10 @@ impl WebGLCommand { gl::enable_vertex_attrib_array(attrib_id), WebGLCommand::Hint(name, val) => gl::hint(name, val), + WebGLCommand::IsShader(shader) => + gl::is_shader(shader), + WebGLCommand::IsTexture(texture) => + gl::is_texture(texture), WebGLCommand::LineWidth(width) => gl::line_width(width), WebGLCommand::PixelStorei(name, val) => From b833f4d6d6fc57464bf4f7fa85d7b1bca0afd3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 7 May 2016 13:13:29 +0200 Subject: [PATCH 73/97] Revert "Auto merge of #49 - DDEFISHER:master, r=metajack" This reverts commit 3a78976c4f637206cf59bb22995cba33b1188810, reversing changes made to 7a51247cb5333d7a4560e00fe4518db328a550da. This is done because it broke the build and wasn't caught by CI. --- Cargo.toml | 2 +- src/webgl.rs | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 81c058059a..5165959127 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/servo/ipc-channel" offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2.18" +gleam = "0.2.17" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" byteorder = "0.5" diff --git a/src/webgl.rs b/src/webgl.rs index 5dfc5179ea..2c0896ae07 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -112,8 +112,6 @@ pub enum WebGLCommand { StencilOp(u32, u32, u32), StencilOpSeparate(u32, u32, u32, u32), Hint(u32, u32), - IsShader(u32), - IsTexture(u32), LineWidth(f32), PixelStorei(u32, i32), LinkProgram(u32), @@ -220,8 +218,6 @@ impl fmt::Debug for WebGLCommand { StencilOp(..) => "StencilOp", StencilOpSeparate(..) => "StencilOpSeparate", Hint(..) => "Hint", - IsShader(..) => "IsShader", - IsTexture(..) => "IsTexture", LineWidth(..) => "LineWidth", PixelStorei(..) => "PixelStorei", LinkProgram(..) => "LinkProgram", @@ -327,10 +323,6 @@ impl WebGLCommand { gl::enable_vertex_attrib_array(attrib_id), WebGLCommand::Hint(name, val) => gl::hint(name, val), - WebGLCommand::IsShader(shader) => - gl::is_shader(shader), - WebGLCommand::IsTexture(texture) => - gl::is_texture(texture), WebGLCommand::LineWidth(width) => gl::line_width(width), WebGLCommand::PixelStorei(name, val) => From f813896a872b2bdf4d1a4d165419154c5a48304c Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Sat, 7 May 2016 07:43:40 +0200 Subject: [PATCH 74/97] Added build back to travis (fixes #51) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3b5b7312f..21d53792ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-04-11 # Should be kept in sync with Servo. + - nightly-2016-04-29 # Should be kept in sync with Servo. matrix: allow_failures: @@ -24,4 +24,4 @@ before_script: script: - servo-tidy - + - cargo build --verbose From b2dda0968c0255a97cb20e06ec3ddac47d98f26f Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Thu, 19 May 2016 22:44:49 -0700 Subject: [PATCH 75/97] Implement SampleCoverage --- .travis.yml | 2 +- Cargo.toml | 2 +- src/webgl.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21d53792ff..0b531e30f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-04-29 # Should be kept in sync with Servo. + - nightly-2016-05-17 # Should be kept in sync with Servo. matrix: allow_failures: diff --git a/Cargo.toml b/Cargo.toml index 5165959127..519169d290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ git = "https://github.com/servo/ipc-channel" offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} app_units = {version = "0.2.1", features = ["plugins"]} euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2.17" +gleam = "0.2.19" serde = {version = ">=0.6, <0.8", features = ["nightly"]} serde_macros = ">=0.6, <0.8" byteorder = "0.5" diff --git a/src/webgl.rs b/src/webgl.rs index 2c0896ae07..e67f864ac6 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -104,6 +104,7 @@ pub enum WebGLCommand { GetVertexAttrib(u32, u32, IpcSender>), PolygonOffset(f32, f32), ReadPixels(i32, i32, i32, i32, u32, u32, IpcSender>), + SampleCoverage(f32, bool), Scissor(i32, i32, i32, i32), StencilFunc(u32, i32, u32), StencilFuncSeparate(u32, u32, i32, u32), @@ -210,6 +211,7 @@ impl fmt::Debug for WebGLCommand { GetVertexAttrib(..) => "GetVertexAttrib", PolygonOffset(..) => "PolygonOffset", ReadPixels(..) => "ReadPixels", + SampleCoverage(..) => "SampleCoverage", Scissor(..) => "Scissor", StencilFunc(..) => "StencilFunc", StencilFuncSeparate(..) => "StencilFuncSeparate", @@ -331,6 +333,8 @@ impl WebGLCommand { gl::polygon_offset(factor, units), WebGLCommand::ReadPixels(x, y, width, height, format, pixel_type, chan) => Self::read_pixels(x, y, width, height, format, pixel_type, chan), + WebGLCommand::SampleCoverage(value, invert) => + gl::sample_coverage(value, invert), WebGLCommand::Scissor(x, y, width, height) => gl::scissor(x, y, width, height), WebGLCommand::StencilFunc(func, ref_, mask) => From 6489d42c9a6cf28ec5aaa1cf81863d80eace8fa9 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 24 May 2016 18:28:22 -0700 Subject: [PATCH 76/97] Add functionality to enable Servo to fetch scroll positions for all stacking contexts. Partially addresses servo/servo#11108. --- src/api.rs | 10 +++++++++- src/lib.rs | 5 +++-- src/stacking_context.rs | 6 +++++- src/types.rs | 24 +++++++++++++++++++++--- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/api.rs b/src/api.rs index 60193764a1..928f18a044 100644 --- a/src/api.rs +++ b/src/api.rs @@ -11,7 +11,7 @@ use offscreen_gl_context::{GLContextAttributes, GLLimits}; use stacking_context::StackingContext; use std::cell::Cell; use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; -use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId}; +use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId, ScrollLayerState}; use webgl::{WebGLContextId, WebGLCommand}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] @@ -58,6 +58,7 @@ pub enum ApiMsg { Scroll(Point2D, Point2D, ScrollEventPhase), TickScrollingBounce, TranslatePointToLayerSpace(Point2D, IpcSender<(Point2D, PipelineId)>), + GetScrollLayerState(IpcSender>), RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), WebGLCommand(WebGLContextId, WebGLCommand), } @@ -218,6 +219,13 @@ impl RenderApi { rx.recv().unwrap() } + pub fn get_scroll_layer_state(&self) -> Vec { + let (tx, rx) = ipc::channel().unwrap(); + let msg = ApiMsg::GetScrollLayerState(tx); + self.api_sender.send(msg).unwrap(); + rx.recv().unwrap() + } + pub fn request_webgl_context(&self, size: &Size2D, attributes: GLContextAttributes) -> Result<(WebGLContextId, GLLimits), String> { let (tx, rx) = ipc::channel().unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 5aa6fc662b..069c302ba7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,7 +36,8 @@ pub use types::NativeFontHandle; pub use types::{BorderRadius, BorderSide, BorderStyle, BoxShadowClipMode}; pub use types::{ColorF, ClipRegion, ComplexClipRegion}; pub use types::{DisplayListId, DisplayListMode, ImageRendering}; -pub use types::{Epoch, FilterOp, FontKey, GlyphInstance, GradientStop}; +pub use types::{Epoch, FilterOp, FontKey, FragmentType, GlyphInstance, GradientStop}; pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; -pub use types::{ScrollLayerId, ScrollPolicy, StackingContextId, ScrollLayerInfo}; +pub use types::{ScrollLayerId, ScrollPolicy, ServoStackingContextId, StackingContextId}; +pub use types::{ScrollLayerInfo, ScrollLayerState}; pub use webgl::*; diff --git a/src/stacking_context.rs b/src/stacking_context.rs index 294b7ec800..73f00fb2e0 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -5,9 +5,11 @@ use display_list::{AuxiliaryListsBuilder, ItemRange}; use euclid::{Matrix4, Rect}; use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; +use types::{ServoStackingContextId}; #[derive(Serialize, Deserialize)] pub struct StackingContext { + pub servo_id: ServoStackingContextId, pub scroll_layer_id: Option, pub scroll_policy: ScrollPolicy, pub bounds: Rect, @@ -23,7 +25,8 @@ pub struct StackingContext { } impl StackingContext { - pub fn new(scroll_layer_id: Option, + pub fn new(servo_id: ServoStackingContextId, + scroll_layer_id: Option, scroll_policy: ScrollPolicy, bounds: Rect, overflow: Rect, @@ -36,6 +39,7 @@ impl StackingContext { auxiliary_lists_builder: &mut AuxiliaryListsBuilder) -> StackingContext { StackingContext { + servo_id: servo_id, scroll_layer_id: scroll_layer_id, scroll_policy: scroll_policy, bounds: bounds, diff --git a/src/types.rs b/src/types.rs index 5e47bd8f58..2318017824 100644 --- a/src/types.rs +++ b/src/types.rs @@ -4,7 +4,7 @@ use app_units::Au; use display_list::{AuxiliaryListsBuilder, ItemRange}; -use euclid::{Rect, Size2D}; +use euclid::{Point2D, Rect, Size2D}; #[cfg(target_os = "macos")] use core_graphics::font::CGFont; @@ -131,15 +131,25 @@ impl ColorF { pub struct StackingContextId(pub u32, pub u32); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct DisplayListId(pub u32, pub u32); +pub struct ServoStackingContextId(pub FragmentType, pub usize); + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum FragmentType { + FragmentBody, + BeforePseudoContent, + AfterPseudoContent, +} -#[derive(Copy, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum DisplayListMode { Default, PseudoFloat, PseudoPositionedContent, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct DisplayListId(pub u32, pub u32); + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] pub struct Epoch(pub u32); @@ -273,3 +283,11 @@ pub enum ScrollPolicy { Scrollable, Fixed, } + +#[derive(Serialize, Deserialize, Clone)] +pub struct ScrollLayerState { + pub pipeline_id: PipelineId, + pub stacking_context_id: ServoStackingContextId, + pub scroll_offset: Point2D, +} + From 3420195a0a03b98d8e1e4a1eaf446bf98da257b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 15 Jun 2016 14:19:51 +0200 Subject: [PATCH 77/97] api: Add an api method to deallocate images. Allows taking rid of some always-growing memory consumption. --- src/api.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api.rs b/src/api.rs index 928f18a044..3bed374cae 100644 --- a/src/api.rs +++ b/src/api.rs @@ -35,8 +35,12 @@ pub enum ScrollEventPhase { pub enum ApiMsg { AddRawFont(FontKey, Vec), AddNativeFont(FontKey, NativeFontHandle), + /// Adds an image from the resource cache. AddImage(ImageKey, u32, u32, ImageFormat, Vec), + /// Updates the the resource cache with the new image data. UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), + /// Drops an image from the resource cache. + DeleteImage(ImageKey), CloneApi(IpcSender), /// Supplies a new frame to WebRender. /// @@ -150,6 +154,11 @@ impl RenderApi { self.api_sender.send(msg).unwrap(); } + pub fn delete_image(&self, key: ImageKey) { + let msg = ApiMsg::DeleteImage(key); + self.api_sender.send(msg).unwrap(); + } + pub fn set_root_pipeline(&self, pipeline_id: PipelineId) { let msg = ApiMsg::SetRootPipeline(pipeline_id); self.api_sender.send(msg).unwrap(); From 4e7a095d0b26fcf06323048be59a102377370e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 16 Jun 2016 11:44:41 +0200 Subject: [PATCH 78/97] Rustup --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b531e30f1..36d89bb81c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-05-17 # Should be kept in sync with Servo. + - nightly-2016-06-14 # Should be kept in sync with Servo. matrix: allow_failures: From 8f8e93c66f6a3ed10d7cf32bc4a41fbf5909df86 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 21 Jun 2016 17:11:28 +0200 Subject: [PATCH 79/97] Use serde_codegen instead of serde_macros We take this opportunity to bump to 0.2.0 and bump all serde-related dependencies (app_units, euclid, offscreen_gl_context). --- Cargo.toml | 17 +- build.rs | 18 ++ src/api.rs | 73 +----- src/display_item.rs | 140 ++++++----- src/display_list.rs | 93 +------ src/lib.rs | 24 +- src/stacking_context.rs | 23 +- src/types.rs | 543 ++++++++++++++++++++++++++++++---------- src/webgl.rs | 146 +---------- 9 files changed, 544 insertions(+), 533 deletions(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 519169d290..3adff18c1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,22 @@ [package] name = "webrender_traits" -version = "0.1.0" +version = "0.2.0" authors = ["Glenn Watson "] +build = "build.rs" [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" [dependencies] -offscreen_gl_context = {version = "0.1.1", features = ["serde_serialization"]} -app_units = {version = "0.2.1", features = ["plugins"]} -euclid = {version = "0.6.2", features = ["plugins"]} -gleam = "0.2.19" -serde = {version = ">=0.6, <0.8", features = ["nightly"]} -serde_macros = ">=0.6, <0.8" +app_units = "0.2.5" byteorder = "0.5" +euclid = "0.7.1" +gleam = "0.2.19" +offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} +serde = {version = "0.7.11", features = ["nightly"]} [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" + +[build-dependencies] +serde_codegen = "0.7.11" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000000..d61b453f34 --- /dev/null +++ b/build.rs @@ -0,0 +1,18 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +extern crate serde_codegen; + +use std::env; +use std::path::Path; + +pub fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + + let src = Path::new("src/types.rs"); + let dst = Path::new(&out_dir).join("types.rs"); + + serde_codegen::expand(&src, &dst).unwrap(); + println!("cargo:rerun-if-changed=src/types.rs"); +} diff --git a/src/api.rs b/src/api.rs index 3bed374cae..e97fcab7e4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -3,78 +3,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use byteorder::{LittleEndian, WriteBytesExt}; -use display_list::{AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList}; -use display_list::{BuiltDisplayListDescriptor}; use euclid::{Point2D, Size2D}; use ipc_channel::ipc::{self, IpcBytesSender, IpcSender}; use offscreen_gl_context::{GLContextAttributes, GLLimits}; -use stacking_context::StackingContext; use std::cell::Cell; -use types::{ColorF, DisplayListId, Epoch, FontKey, StackingContextId}; -use types::{ImageKey, ImageFormat, NativeFontHandle, PipelineId, ScrollLayerState}; -use webgl::{WebGLContextId, WebGLCommand}; - -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] -pub struct IdNamespace(pub u32); - -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] -pub struct ResourceId(pub u32); - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] -pub enum ScrollEventPhase { - /// The user started scrolling. - Start, - /// The user performed a scroll. The Boolean flag indicates whether the user's fingers are - /// down, if a touchpad is in use. (If false, the event is a touchpad fling.) - Move(bool), - /// The user ended scrolling. - End, -} - -#[derive(Serialize, Deserialize)] -pub enum ApiMsg { - AddRawFont(FontKey, Vec), - AddNativeFont(FontKey, NativeFontHandle), - /// Adds an image from the resource cache. - AddImage(ImageKey, u32, u32, ImageFormat, Vec), - /// Updates the the resource cache with the new image data. - UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), - /// Drops an image from the resource cache. - DeleteImage(ImageKey), - CloneApi(IpcSender), - /// Supplies a new frame to WebRender. - /// - /// The first `StackingContextId` describes the root stacking context. The actual stacking - /// contexts are supplied as the sixth parameter, while the display lists that make up those - /// stacking contexts are supplied as the seventh parameter. - /// - /// After receiving this message, WebRender will read the display lists, followed by the - /// auxiliary lists, from the payload channel. - SetRootStackingContext(StackingContextId, - ColorF, - Epoch, - PipelineId, - Size2D, - Vec<(StackingContextId, StackingContext)>, - Vec<(DisplayListId, BuiltDisplayListDescriptor)>, - AuxiliaryListsDescriptor), - SetRootPipeline(PipelineId), - Scroll(Point2D, Point2D, ScrollEventPhase), - TickScrollingBounce, - TranslatePointToLayerSpace(Point2D, IpcSender<(Point2D, PipelineId)>), - GetScrollLayerState(IpcSender>), - RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), - WebGLCommand(WebGLContextId, WebGLCommand), -} - -#[derive(Serialize, Deserialize, Clone)] -pub struct RenderApiSender { - api_sender: IpcSender, - payload_sender: IpcBytesSender, -} +use {ApiMsg, AuxiliaryLists, BuiltDisplayList, ColorF, DisplayListId, Epoch}; +use {FontKey, IdNamespace, ImageFormat, ImageKey, NativeFontHandle, PipelineId}; +use {RenderApiSender, ResourceId, ScrollEventPhase, ScrollLayerState}; +use {StackingContext, StackingContextId, WebGLContextId, WebGLCommand}; impl RenderApiSender { - pub fn new(api_sender: IpcSender, payload_sender: IpcBytesSender) -> RenderApiSender { + pub fn new(api_sender: IpcSender, + payload_sender: IpcBytesSender) + -> RenderApiSender { RenderApiSender { api_sender: api_sender, payload_sender: payload_sender, diff --git a/src/display_item.rs b/src/display_item.rs index b32d8bcae0..1a0e418fd7 100644 --- a/src/display_item.rs +++ b/src/display_item.rs @@ -2,21 +2,10 @@ * 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 app_units::Au; -use display_list::ItemRange; -use euclid::{Point2D, Rect, Size2D}; -use types::{BorderRadius, BoxShadowClipMode, ImageRendering}; -use types::{ClipRegion, ColorF, FontKey, ImageKey, BorderSide}; -use webgl::{WebGLContextId}; - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct BorderDisplayItem { - pub left: BorderSide, - pub right: BorderSide, - pub top: BorderSide, - pub bottom: BorderSide, - pub radius: BorderRadius, -} +use display_list::AuxiliaryListsBuilder; +use euclid::{Rect, Size2D}; +use {BorderRadius, BorderDisplayItem, ClipRegion, ColorF, ComplexClipRegion}; +use {FontKey, ImageKey, PipelineId, ScrollLayerId, ScrollLayerInfo}; impl BorderDisplayItem { pub fn top_left_inner_radius(&self) -> Size2D { @@ -40,64 +29,91 @@ impl BorderDisplayItem { } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct BoxShadowDisplayItem { - pub box_bounds: Rect, - pub offset: Point2D, - pub color: ColorF, - pub blur_radius: f32, - pub spread_radius: f32, - pub border_radius: f32, - pub clip_mode: BoxShadowClipMode, -} +impl BorderRadius { + pub fn zero() -> BorderRadius { + BorderRadius { + top_left: Size2D::new(0.0, 0.0), + top_right: Size2D::new(0.0, 0.0), + bottom_left: Size2D::new(0.0, 0.0), + bottom_right: Size2D::new(0.0, 0.0), + } + } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct GradientDisplayItem { - pub start_point: Point2D, - pub end_point: Point2D, - pub stops: ItemRange, + pub fn uniform(radius: f32) -> BorderRadius { + BorderRadius { + top_left: Size2D::new(radius, radius), + top_right: Size2D::new(radius, radius), + bottom_left: Size2D::new(radius, radius), + bottom_right: Size2D::new(radius, radius), + } + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct ImageDisplayItem { - pub image_key: ImageKey, - pub stretch_size: Size2D, - pub image_rendering: ImageRendering, +impl ClipRegion { + pub fn new(rect: &Rect, + complex: Vec, + auxiliary_lists_builder: &mut AuxiliaryListsBuilder) + -> ClipRegion { + ClipRegion { + main: *rect, + complex: auxiliary_lists_builder.add_complex_clip_regions(&complex), + } + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct WebGLDisplayItem { - pub context_id: WebGLContextId, +impl ColorF { + pub fn new(r: f32, g: f32, b: f32, a: f32) -> ColorF { + ColorF { + r: r, + g: g, + b: b, + a: a, + } + } + + pub fn scale_rgb(&self, scale: f32) -> ColorF { + ColorF { + r: self.r * scale, + g: self.g * scale, + b: self.b * scale, + a: self.a, + } + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct RectangleDisplayItem { - pub color: ColorF, +impl ComplexClipRegion { + pub fn new(rect: Rect, radii: BorderRadius) -> ComplexClipRegion { + ComplexClipRegion { + rect: rect, + radii: radii, + } + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct TextDisplayItem { - pub glyphs: ItemRange, - pub font_key: FontKey, - pub size: Au, - pub color: ColorF, - pub blur_radius: Au, +impl FontKey { + pub fn new(key0: u32, key1: u32) -> FontKey { + FontKey(key0, key1) + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum SpecificDisplayItem { - Rectangle(RectangleDisplayItem), - Text(TextDisplayItem), - Image(ImageDisplayItem), - WebGL(WebGLDisplayItem), - Border(BorderDisplayItem), - BoxShadow(BoxShadowDisplayItem), - Gradient(GradientDisplayItem), +impl ImageKey { + pub fn new(key0: u32, key1: u32) -> ImageKey { + ImageKey(key0, key1) + } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct DisplayItem { - pub item: SpecificDisplayItem, - pub rect: Rect, - pub clip: ClipRegion, +impl ScrollLayerId { + pub fn new(pipeline_id: PipelineId, index: usize) -> ScrollLayerId { + ScrollLayerId { + pipeline_id: pipeline_id, + info: ScrollLayerInfo::Scrollable(index), + } + } + + pub fn create_fixed(pipeline_id: PipelineId) -> ScrollLayerId { + ScrollLayerId { + pipeline_id: pipeline_id, + info: ScrollLayerInfo::Fixed, + } + } } diff --git a/src/display_list.rs b/src/display_list.rs index b8275ea285..eb7c7ee71f 100644 --- a/src/display_list.rs +++ b/src/display_list.rs @@ -3,60 +3,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use display_item::{BorderDisplayItem, BoxShadowDisplayItem}; -use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem, WebGLDisplayItem}; -use display_item::{RectangleDisplayItem, TextDisplayItem, GradientDisplayItem}; use euclid::{Point2D, Rect, Size2D}; use std::mem; use std::slice; -use types::{BorderRadius, BorderSide, BoxShadowClipMode, FilterOp, GlyphInstance}; -use types::{ClipRegion, ColorF, ComplexClipRegion, FontKey, ImageKey, PipelineId}; -use types::{DisplayListMode, GradientStop, StackingContextId, ImageRendering}; -use webgl::{WebGLContextId}; - -#[derive(Copy, Clone, Serialize, Deserialize)] -pub struct DrawListInfo { - pub items: ItemRange, -} - -#[derive(Copy, Clone, Serialize, Deserialize)] -pub struct StackingContextInfo { - pub id: StackingContextId, -} - -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] -pub struct IframeInfo { - pub id: PipelineId, - pub bounds: Rect, - pub clip: ClipRegion, -} - -#[derive(Copy, Clone, Serialize, Deserialize)] -pub enum SpecificDisplayListItem { - DrawList(DrawListInfo), - StackingContext(StackingContextInfo), - Iframe(IframeInfo), -} - -#[derive(Copy, Clone, Serialize, Deserialize)] -pub struct DisplayListItem { - pub specific: SpecificDisplayListItem, -} - -/// Describes the memory layout of a display list. -/// -/// A display list consists of some number of display list items, followed by a number of display -/// items. -#[derive(Copy, Clone, Serialize, Deserialize)] -pub struct BuiltDisplayListDescriptor { - pub mode: DisplayListMode, - pub has_stacking_contexts: bool, - - /// The size in bytes of the display list items in this display list. - display_list_items_size: usize, - /// The size in bytes of the display items in this display list. - display_items_size: usize, -} +use {AuxiliaryLists, AuxiliaryListsDescriptor, BorderDisplayItem, BorderRadius}; +use {BorderSide, BoxShadowClipMode, BoxShadowDisplayItem, BuiltDisplayList}; +use {BuiltDisplayListDescriptor, ClipRegion, ComplexClipRegion, ColorF}; +use {DisplayItem, DisplayListItem, DisplayListMode, DrawListInfo, FilterOp}; +use {FontKey, GlyphInstance, GradientDisplayItem, GradientStop, IframeInfo}; +use {ImageDisplayItem, ImageKey, ImageRendering, ItemRange, PipelineId}; +use {RectangleDisplayItem, SpecificDisplayItem, SpecificDisplayListItem}; +use {StackingContextId, StackingContextInfo, TextDisplayItem}; +use {WebGLContextId, WebGLDisplayItem}; impl BuiltDisplayListDescriptor { pub fn size(&self) -> usize { @@ -64,13 +22,6 @@ impl BuiltDisplayListDescriptor { } } -/// A display list. -#[derive(Clone, Serialize, Deserialize)] -pub struct BuiltDisplayList { - data: Vec, - descriptor: BuiltDisplayListDescriptor, -} - impl BuiltDisplayList { pub fn from_data(data: Vec, descriptor: BuiltDisplayListDescriptor) -> BuiltDisplayList { BuiltDisplayList { @@ -361,12 +312,6 @@ impl DisplayListBuilder { } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct ItemRange { - pub start: usize, - pub length: usize, -} - impl ItemRange { pub fn new(backing_list: &mut Vec, items: &[T]) -> ItemRange where T: Copy + Clone { let start = backing_list.len(); @@ -470,18 +415,6 @@ impl AuxiliaryListsBuilder { } } -/// Describes the memory layout of the auxiliary lists. -/// -/// Auxiliary lists consist of some number of gradient stops, complex clip regions, filters, and -/// glyph instances, in that order. -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] -pub struct AuxiliaryListsDescriptor { - gradient_stops_size: usize, - complex_clip_regions_size: usize, - filters_size: usize, - glyph_instances_size: usize, -} - impl AuxiliaryListsDescriptor { pub fn size(&self) -> usize { self.gradient_stops_size + self.complex_clip_regions_size + self.filters_size + @@ -489,14 +422,6 @@ impl AuxiliaryListsDescriptor { } } -#[derive(Clone, Serialize, Deserialize)] -pub struct AuxiliaryLists { - /// The concatenation of: gradient stops, complex clip regions, filters, and glyph instances, - /// in that order. - data: Vec, - descriptor: AuxiliaryListsDescriptor, -} - impl AuxiliaryLists { /// Creates a new `AuxiliaryLists` instance from a descriptor and data received over a channel. pub fn from_data(data: Vec, descriptor: AuxiliaryListsDescriptor) -> AuxiliaryLists { diff --git a/src/lib.rs b/src/lib.rs index 069c302ba7..e7c456a75e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,10 +2,7 @@ * 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/. */ -#![feature(plugin)] -#![feature(custom_derive)] #![feature(nonzero)] -#![plugin(serde_macros)] extern crate app_units; extern crate byteorder; @@ -18,26 +15,13 @@ extern crate serde; #[cfg(target_os = "macos")] extern crate core_graphics; +include!(concat!(env!("OUT_DIR"), "/types.rs")); + mod api; mod display_item; mod display_list; mod stacking_context; -mod types; mod webgl; -pub use api::{ApiMsg, IdNamespace, ResourceId, RenderApi, RenderApiSender, ScrollEventPhase}; -pub use display_list::{AuxiliaryLists, AuxiliaryListsBuilder, BuiltDisplayList}; -pub use display_list::{DisplayListBuilder, DisplayListItem, IframeInfo, ItemRange}; -pub use display_list::{SpecificDisplayListItem}; -pub use display_item::{DisplayItem, SpecificDisplayItem, ImageDisplayItem}; -pub use display_item::{BorderDisplayItem, GradientDisplayItem, RectangleDisplayItem}; -pub use stacking_context::StackingContext; -pub use types::NativeFontHandle; -pub use types::{BorderRadius, BorderSide, BorderStyle, BoxShadowClipMode}; -pub use types::{ColorF, ClipRegion, ComplexClipRegion}; -pub use types::{DisplayListId, DisplayListMode, ImageRendering}; -pub use types::{Epoch, FilterOp, FontKey, FragmentType, GlyphInstance, GradientStop}; -pub use types::{ImageFormat, ImageKey, MixBlendMode, PipelineId, RenderNotifier}; -pub use types::{ScrollLayerId, ScrollPolicy, ServoStackingContextId, StackingContextId}; -pub use types::{ScrollLayerInfo, ScrollLayerState}; -pub use webgl::*; +pub use api::RenderApi; +pub use display_list::{AuxiliaryListsBuilder, DisplayListBuilder}; diff --git a/src/stacking_context.rs b/src/stacking_context.rs index 73f00fb2e0..14a54f0d91 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -2,27 +2,10 @@ * 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 display_list::{AuxiliaryListsBuilder, ItemRange}; +use display_list::AuxiliaryListsBuilder; use euclid::{Matrix4, Rect}; -use types::{DisplayListId, FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; -use types::{ServoStackingContextId}; - -#[derive(Serialize, Deserialize)] -pub struct StackingContext { - pub servo_id: ServoStackingContextId, - pub scroll_layer_id: Option, - pub scroll_policy: ScrollPolicy, - pub bounds: Rect, - pub overflow: Rect, - pub z_index: i32, - pub display_lists: Vec, - pub transform: Matrix4, - pub perspective: Matrix4, - pub establishes_3d_context: bool, - pub mix_blend_mode: MixBlendMode, - pub filters: ItemRange, - pub has_stacking_contexts: bool, -} +use {FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; +use {ServoStackingContextId, StackingContext}; impl StackingContext { pub fn new(servo_id: ServoStackingContextId, diff --git a/src/types.rs b/src/types.rs index 2318017824..398c2d506f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,13 +2,83 @@ * 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/. */ +// Every serialisable type is defined in this file to only codegen one file +// for the serde implementations. + use app_units::Au; -use display_list::{AuxiliaryListsBuilder, ItemRange}; -use euclid::{Point2D, Rect, Size2D}; +use core::nonzero::NonZero; +use euclid::{Matrix4, Point2D, Rect, Size2D}; +use ipc_channel::ipc::{IpcBytesSender, IpcSender}; +use offscreen_gl_context::{GLContextAttributes, GLLimits}; #[cfg(target_os = "macos")] use core_graphics::font::CGFont; -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Deserialize, Serialize)] +pub enum ApiMsg { + AddRawFont(FontKey, Vec), + AddNativeFont(FontKey, NativeFontHandle), + /// Adds an image from the resource cache. + AddImage(ImageKey, u32, u32, ImageFormat, Vec), + /// Updates the the resource cache with the new image data. + UpdateImage(ImageKey, u32, u32, ImageFormat, Vec), + /// Drops an image from the resource cache. + DeleteImage(ImageKey), + CloneApi(IpcSender), + /// Supplies a new frame to WebRender. + /// + /// The first `StackingContextId` describes the root stacking context. The actual stacking + /// contexts are supplied as the sixth parameter, while the display lists that make up those + /// stacking contexts are supplied as the seventh parameter. + /// + /// After receiving this message, WebRender will read the display lists, followed by the + /// auxiliary lists, from the payload channel. + SetRootStackingContext(StackingContextId, + ColorF, + Epoch, + PipelineId, + Size2D, + Vec<(StackingContextId, StackingContext)>, + Vec<(DisplayListId, BuiltDisplayListDescriptor)>, + AuxiliaryListsDescriptor), + SetRootPipeline(PipelineId), + Scroll(Point2D, Point2D, ScrollEventPhase), + TickScrollingBounce, + TranslatePointToLayerSpace(Point2D, IpcSender<(Point2D, PipelineId)>), + GetScrollLayerState(IpcSender>), + RequestWebGLContext(Size2D, GLContextAttributes, IpcSender>), + WebGLCommand(WebGLContextId, WebGLCommand), +} + +#[derive(Clone, Deserialize, Serialize)] +pub struct AuxiliaryLists { + /// The concatenation of: gradient stops, complex clip regions, filters, and glyph instances, + /// in that order. + data: Vec, + descriptor: AuxiliaryListsDescriptor, +} + +/// Describes the memory layout of the auxiliary lists. +/// +/// Auxiliary lists consist of some number of gradient stops, complex clip regions, filters, and +/// glyph instances, in that order. +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct AuxiliaryListsDescriptor { + gradient_stops_size: usize, + complex_clip_regions_size: usize, + filters_size: usize, + glyph_instances_size: usize, +} + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct BorderDisplayItem { + pub left: BorderSide, + pub right: BorderSide, + pub top: BorderSide, + pub bottom: BorderSide, + pub radius: BorderRadius, +} + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct BorderRadius { pub top_left: Size2D, pub top_right: Size2D, @@ -16,34 +86,14 @@ pub struct BorderRadius { pub bottom_right: Size2D, } -impl BorderRadius { - pub fn zero() -> BorderRadius { - BorderRadius { - top_left: Size2D::new(0.0, 0.0), - top_right: Size2D::new(0.0, 0.0), - bottom_left: Size2D::new(0.0, 0.0), - bottom_right: Size2D::new(0.0, 0.0), - } - } - - pub fn uniform(radius: f32) -> BorderRadius { - BorderRadius { - top_left: Size2D::new(radius, radius), - top_right: Size2D::new(radius, radius), - bottom_left: Size2D::new(radius, radius), - bottom_right: Size2D::new(radius, radius), - } - } -} - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct BorderSide { pub width: f32, pub color: ColorF, pub style: BorderStyle, } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub enum BorderStyle { None, Solid, @@ -57,49 +107,47 @@ pub enum BorderStyle { Outset, } -#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub enum BoxShadowClipMode { None, Outset, Inset, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct ClipRegion { - pub main: Rect, - pub complex: ItemRange, +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct BoxShadowDisplayItem { + pub box_bounds: Rect, + pub offset: Point2D, + pub color: ColorF, + pub blur_radius: f32, + pub spread_radius: f32, + pub border_radius: f32, + pub clip_mode: BoxShadowClipMode, } -impl ClipRegion { - pub fn new(rect: &Rect, - complex: Vec, - auxiliary_lists_builder: &mut AuxiliaryListsBuilder) - -> ClipRegion { - ClipRegion { - main: *rect, - complex: auxiliary_lists_builder.add_complex_clip_regions(&complex), - } - } +/// A display list. +#[derive(Clone, Deserialize, Serialize)] +pub struct BuiltDisplayList { + data: Vec, + descriptor: BuiltDisplayListDescriptor, } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] -pub struct ComplexClipRegion { - /// The boundaries of the rectangle. - pub rect: Rect, - /// Border radii of this rectangle. - pub radii: BorderRadius, +/// Describes the memory layout of a display list. +/// +/// A display list consists of some number of display list items, followed by a number of display +/// items. +#[derive(Copy, Clone, Deserialize, Serialize)] +pub struct BuiltDisplayListDescriptor { + pub mode: DisplayListMode, + pub has_stacking_contexts: bool, + + /// The size in bytes of the display list items in this display list. + display_list_items_size: usize, + /// The size in bytes of the display items in this display list. + display_items_size: usize, } -impl ComplexClipRegion { - pub fn new(rect: Rect, radii: BorderRadius) -> ComplexClipRegion { - ComplexClipRegion { - rect: rect, - radii: radii, - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct ColorF { pub r: f32, pub g: f32, @@ -107,53 +155,51 @@ pub struct ColorF { pub a: f32, } -impl ColorF { - pub fn new(r: f32, g: f32, b: f32, a: f32) -> ColorF { - ColorF { - r: r, - g: g, - b: b, - a: a, - } - } +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct ClipRegion { + pub main: Rect, + pub complex: ItemRange, +} - pub fn scale_rgb(&self, scale: f32) -> ColorF { - ColorF { - r: self.r * scale, - g: self.g * scale, - b: self.b * scale, - a: self.a, - } - } +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct ComplexClipRegion { + /// The boundaries of the rectangle. + pub rect: Rect, + /// Border radii of this rectangle. + pub radii: BorderRadius, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct StackingContextId(pub u32, pub u32); +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct DisplayItem { + pub item: SpecificDisplayItem, + pub rect: Rect, + pub clip: ClipRegion, +} -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct ServoStackingContextId(pub FragmentType, pub usize); +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct DisplayListId(pub u32, pub u32); -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum FragmentType { - FragmentBody, - BeforePseudoContent, - AfterPseudoContent, +#[derive(Clone, Copy, Deserialize, Serialize)] +pub struct DisplayListItem { + pub specific: SpecificDisplayListItem, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum DisplayListMode { Default, PseudoFloat, PseudoPositionedContent, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct DisplayListId(pub u32, pub u32); +#[derive(Clone, Copy, Deserialize, Serialize)] +pub struct DrawListInfo { + pub items: ItemRange, +} -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct Epoch(pub u32); -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub enum FilterOp { Blur(Au), Brightness(f32), @@ -166,29 +212,54 @@ pub enum FilterOp { Sepia(f32), } -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct FontKey(u32, u32); -impl FontKey { - pub fn new(key0: u32, key1: u32) -> FontKey { - FontKey(key0, key1) - } +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub enum FragmentType { + FragmentBody, + BeforePseudoContent, + AfterPseudoContent, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct GlyphInstance { pub index: u32, pub x: f32, pub y: f32, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct GradientDisplayItem { + pub start_point: Point2D, + pub end_point: Point2D, + pub stops: ItemRange, +} + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct GradientStop { pub offset: f32, pub color: ColorF, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct IdNamespace(pub u32); + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct IframeInfo { + pub id: PipelineId, + pub bounds: Rect, + pub clip: ClipRegion, +} + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct ImageDisplayItem { + pub image_key: ImageKey, + pub stretch_size: Size2D, + pub image_rendering: ImageRendering, +} + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum ImageFormat { Invalid, A8, @@ -196,23 +267,23 @@ pub enum ImageFormat { RGBA8, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ImageKey(u32, u32); + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum ImageRendering { Auto, CrispEdges, Pixelated, } -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] -pub struct ImageKey(u32, u32); - -impl ImageKey { - pub fn new(key0: u32, key1: u32) -> ImageKey { - ImageKey(key0, key1) - } +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct ItemRange { + pub start: usize, + pub length: usize, } -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum MixBlendMode { Normal, Multiply, @@ -237,57 +308,267 @@ pub type NativeFontHandle = CGFont; /// Native fonts are not used on Linux; all fonts are raw. #[cfg(not(target_os = "macos"))] -#[derive(Clone, Serialize, Deserialize)] +#[cfg_attr(not(target_os = "macos"), derive(Clone, Serialize, Deserialize))] pub struct NativeFontHandle; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct PipelineId(pub u32, pub u32); -pub trait RenderNotifier : Send { +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct RectangleDisplayItem { + pub color: ColorF, +} + +#[derive(Clone, Deserialize, Serialize)] +pub struct RenderApiSender { + api_sender: IpcSender, + payload_sender: IpcBytesSender, +} + +pub trait RenderNotifier: Send { fn new_frame_ready(&mut self); fn pipeline_size_changed(&mut self, pipeline_id: PipelineId, size: Option>); } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub enum ScrollLayerInfo { - Fixed, - Scrollable(usize) +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct ResourceId(pub u32); + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub enum ScrollEventPhase { + /// The user started scrolling. + Start, + /// The user performed a scroll. The Boolean flag indicates whether the user's fingers are + /// down, if a touchpad is in use. (If false, the event is a touchpad fling.) + Move(bool), + /// The user ended scrolling. + End, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub struct ScrollLayerId { pub pipeline_id: PipelineId, pub info: ScrollLayerInfo, } -impl ScrollLayerId { - pub fn new(pipeline_id: PipelineId, index: usize) -> ScrollLayerId { - ScrollLayerId { - pipeline_id: pipeline_id, - info: ScrollLayerInfo::Scrollable(index), - } - } +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub enum ScrollLayerInfo { + Fixed, + Scrollable(usize) +} - pub fn create_fixed(pipeline_id: PipelineId) -> ScrollLayerId { - ScrollLayerId { - pipeline_id: pipeline_id, - info: ScrollLayerInfo::Fixed, - } - } +#[derive(Clone, Deserialize, Serialize)] +pub struct ScrollLayerState { + pub pipeline_id: PipelineId, + pub stacking_context_id: ServoStackingContextId, + pub scroll_offset: Point2D, } -#[derive(Clone, PartialEq, Eq, Copy, Deserialize, Serialize, Debug)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] pub enum ScrollPolicy { Scrollable, Fixed, } -#[derive(Serialize, Deserialize, Clone)] -pub struct ScrollLayerState { - pub pipeline_id: PipelineId, - pub stacking_context_id: ServoStackingContextId, - pub scroll_offset: Point2D, +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct ServoStackingContextId(pub FragmentType, pub usize); + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub enum SpecificDisplayItem { + Rectangle(RectangleDisplayItem), + Text(TextDisplayItem), + Image(ImageDisplayItem), + WebGL(WebGLDisplayItem), + Border(BorderDisplayItem), + BoxShadow(BoxShadowDisplayItem), + Gradient(GradientDisplayItem), } +#[derive(Clone, Copy, Deserialize, Serialize)] +pub enum SpecificDisplayListItem { + DrawList(DrawListInfo), + StackingContext(StackingContextInfo), + Iframe(IframeInfo), +} + +#[derive(Deserialize, Serialize)] +pub struct StackingContext { + pub servo_id: ServoStackingContextId, + pub scroll_layer_id: Option, + pub scroll_policy: ScrollPolicy, + pub bounds: Rect, + pub overflow: Rect, + pub z_index: i32, + pub display_lists: Vec, + pub transform: Matrix4, + pub perspective: Matrix4, + pub establishes_3d_context: bool, + pub mix_blend_mode: MixBlendMode, + pub filters: ItemRange, + pub has_stacking_contexts: bool, +} + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct StackingContextId(pub u32, pub u32); + +#[derive(Clone, Copy, Deserialize, Serialize)] +pub struct StackingContextInfo { + pub id: StackingContextId, +} + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct TextDisplayItem { + pub glyphs: ItemRange, + pub font_key: FontKey, + pub size: Au, + pub color: ColorF, + pub blur_radius: Au, +} + +#[derive(Clone, Deserialize, Serialize)] +pub enum WebGLCommand { + GetContextAttributes(IpcSender), + ActiveTexture(u32), + BlendColor(f32, f32, f32, f32), + BlendEquation(u32), + BlendEquationSeparate(u32, u32), + BlendFunc(u32, u32), + BlendFuncSeparate(u32, u32, u32, u32), + AttachShader(u32, u32), + DetachShader(u32, u32), + BindAttribLocation(u32, u32, String), + BufferData(u32, Vec, u32), + BufferSubData(u32, isize, Vec), + Clear(u32), + ClearColor(f32, f32, f32, f32), + ClearDepth(f64), + ClearStencil(i32), + ColorMask(bool, bool, bool, bool), + CullFace(u32), + FrontFace(u32), + DepthFunc(u32), + DepthMask(bool), + DepthRange(f64, f64), + Enable(u32), + Disable(u32), + CompileShader(u32, String), + CopyTexImage2D(u32, i32, u32, i32, i32, i32, i32, i32), + CopyTexSubImage2D(u32, i32, i32, i32, i32, i32, i32, i32), + CreateBuffer(IpcSender>>), + CreateFramebuffer(IpcSender>>), + CreateRenderbuffer(IpcSender>>), + CreateTexture(IpcSender>>), + CreateProgram(IpcSender>>), + CreateShader(u32, IpcSender>>), + DeleteBuffer(u32), + DeleteFramebuffer(u32), + DeleteRenderbuffer(u32), + DeleteTexture(u32), + DeleteProgram(u32), + DeleteShader(u32), + BindBuffer(u32, u32), + BindFramebuffer(u32, WebGLFramebufferBindingRequest), + BindRenderbuffer(u32, u32), + BindTexture(u32, u32), + DrawArrays(u32, i32, i32), + DrawElements(u32, i32, u32, i64), + EnableVertexAttribArray(u32), + GetBufferParameter(u32, u32, IpcSender>), + GetParameter(u32, IpcSender>), + GetProgramParameter(u32, u32, IpcSender>), + GetShaderParameter(u32, u32, IpcSender>), + GetActiveAttrib(u32, u32, IpcSender>), + GetActiveUniform(u32, u32, IpcSender>), + GetAttribLocation(u32, String, IpcSender>), + GetUniformLocation(u32, String, IpcSender>), + GetVertexAttrib(u32, u32, IpcSender>), + PolygonOffset(f32, f32), + ReadPixels(i32, i32, i32, i32, u32, u32, IpcSender>), + SampleCoverage(f32, bool), + Scissor(i32, i32, i32, i32), + StencilFunc(u32, i32, u32), + StencilFuncSeparate(u32, u32, i32, u32), + StencilMask(u32), + StencilMaskSeparate(u32, u32), + StencilOp(u32, u32, u32), + StencilOpSeparate(u32, u32, u32, u32), + Hint(u32, u32), + LineWidth(f32), + PixelStorei(u32, i32), + LinkProgram(u32), + Uniform1f(i32, f32), + Uniform1fv(i32, Vec), + Uniform1i(i32, i32), + Uniform1iv(i32, Vec), + Uniform2f(i32, f32, f32), + Uniform2fv(i32, Vec), + Uniform2i(i32, i32, i32), + Uniform2iv(i32, Vec), + Uniform3f(i32, f32, f32, f32), + Uniform3fv(i32, Vec), + Uniform3i(i32, i32, i32, i32), + Uniform3iv(i32, Vec), + Uniform4f(i32, f32, f32, f32, f32), + Uniform4fv(i32, Vec), + Uniform4i(i32, i32, i32, i32, i32), + Uniform4iv(i32, Vec), + UniformMatrix2fv(i32, bool, Vec), + UniformMatrix3fv(i32, bool, Vec), + UniformMatrix4fv(i32, bool, Vec), + UseProgram(u32), + VertexAttrib(u32, f32, f32, f32, f32), + VertexAttribPointer2f(u32, i32, bool, i32, u32), + Viewport(i32, i32, i32, i32), + TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec), + TexParameteri(u32, u32, i32), + TexParameterf(u32, u32, f32), + TexSubImage2D(u32, i32, i32, i32, i32, i32, u32, u32, Vec), + DrawingBufferWidth(IpcSender), + DrawingBufferHeight(IpcSender), + Finish(IpcSender<()>), + Flush, + GenerateMipmap(u32), +} + +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +pub struct WebGLContextId(pub usize); + +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct WebGLDisplayItem { + pub context_id: WebGLContextId, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum WebGLError { + InvalidEnum, + InvalidOperation, + InvalidValue, + OutOfMemory, + ContextLost, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum WebGLFramebufferBindingRequest { + Explicit(u32), + Default, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum WebGLParameter { + Int(i32), + Bool(bool), + String(String), + Float(f32), + FloatArray(Vec), + Invalid, +} + +pub type WebGLResult = Result; + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum WebGLShaderParameter { + Int(i32), + Bool(bool), + Invalid, +} diff --git a/src/webgl.rs b/src/webgl.rs index e67f864ac6..2f5a2185c6 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -5,150 +5,10 @@ use core::nonzero::NonZero; use gleam::gl; use ipc_channel::ipc::IpcSender; -use offscreen_gl_context::{GLContext, GLContextAttributes, NativeGLContextMethods}; +use offscreen_gl_context::{GLContext, NativeGLContextMethods}; use std::fmt; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -pub struct WebGLContextId(pub usize); - -#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)] -pub enum WebGLError { - InvalidEnum, - InvalidOperation, - InvalidValue, - OutOfMemory, - ContextLost, -} - -pub type WebGLResult = Result; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum WebGLFramebufferBindingRequest { - Explicit(u32), - Default, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum WebGLParameter { - Int(i32), - Bool(bool), - String(String), - Float(f32), - FloatArray(Vec), - Invalid, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum WebGLShaderParameter { - Int(i32), - Bool(bool), - Invalid, -} - -#[derive(Clone, Deserialize, Serialize)] -pub enum WebGLCommand { - GetContextAttributes(IpcSender), - ActiveTexture(u32), - BlendColor(f32, f32, f32, f32), - BlendEquation(u32), - BlendEquationSeparate(u32, u32), - BlendFunc(u32, u32), - BlendFuncSeparate(u32, u32, u32, u32), - AttachShader(u32, u32), - DetachShader(u32, u32), - BindAttribLocation(u32, u32, String), - BufferData(u32, Vec, u32), - BufferSubData(u32, isize, Vec), - Clear(u32), - ClearColor(f32, f32, f32, f32), - ClearDepth(f64), - ClearStencil(i32), - ColorMask(bool, bool, bool, bool), - CullFace(u32), - FrontFace(u32), - DepthFunc(u32), - DepthMask(bool), - DepthRange(f64, f64), - Enable(u32), - Disable(u32), - CompileShader(u32, String), - CopyTexImage2D(u32, i32, u32, i32, i32, i32, i32, i32), - CopyTexSubImage2D(u32, i32, i32, i32, i32, i32, i32, i32), - CreateBuffer(IpcSender>>), - CreateFramebuffer(IpcSender>>), - CreateRenderbuffer(IpcSender>>), - CreateTexture(IpcSender>>), - CreateProgram(IpcSender>>), - CreateShader(u32, IpcSender>>), - DeleteBuffer(u32), - DeleteFramebuffer(u32), - DeleteRenderbuffer(u32), - DeleteTexture(u32), - DeleteProgram(u32), - DeleteShader(u32), - BindBuffer(u32, u32), - BindFramebuffer(u32, WebGLFramebufferBindingRequest), - BindRenderbuffer(u32, u32), - BindTexture(u32, u32), - DrawArrays(u32, i32, i32), - DrawElements(u32, i32, u32, i64), - EnableVertexAttribArray(u32), - GetBufferParameter(u32, u32, IpcSender>), - GetParameter(u32, IpcSender>), - GetProgramParameter(u32, u32, IpcSender>), - GetShaderParameter(u32, u32, IpcSender>), - GetActiveAttrib(u32, u32, IpcSender>), - GetActiveUniform(u32, u32, IpcSender>), - GetAttribLocation(u32, String, IpcSender>), - GetUniformLocation(u32, String, IpcSender>), - GetVertexAttrib(u32, u32, IpcSender>), - PolygonOffset(f32, f32), - ReadPixels(i32, i32, i32, i32, u32, u32, IpcSender>), - SampleCoverage(f32, bool), - Scissor(i32, i32, i32, i32), - StencilFunc(u32, i32, u32), - StencilFuncSeparate(u32, u32, i32, u32), - StencilMask(u32), - StencilMaskSeparate(u32, u32), - StencilOp(u32, u32, u32), - StencilOpSeparate(u32, u32, u32, u32), - Hint(u32, u32), - LineWidth(f32), - PixelStorei(u32, i32), - LinkProgram(u32), - Uniform1f(i32, f32), - Uniform1fv(i32, Vec), - Uniform1i(i32, i32), - Uniform1iv(i32, Vec), - Uniform2f(i32, f32, f32), - Uniform2fv(i32, Vec), - Uniform2i(i32, i32, i32), - Uniform2iv(i32, Vec), - Uniform3f(i32, f32, f32, f32), - Uniform3fv(i32, Vec), - Uniform3i(i32, i32, i32, i32), - Uniform3iv(i32, Vec), - Uniform4f(i32, f32, f32, f32, f32), - Uniform4fv(i32, Vec), - Uniform4i(i32, i32, i32, i32, i32), - Uniform4iv(i32, Vec), - UniformMatrix2fv(i32, bool, Vec), - UniformMatrix3fv(i32, bool, Vec), - UniformMatrix4fv(i32, bool, Vec), - UseProgram(u32), - VertexAttrib(u32, f32, f32, f32, f32), - VertexAttribPointer2f(u32, i32, bool, i32, u32), - Viewport(i32, i32, i32, i32), - TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec), - TexParameteri(u32, u32, i32), - TexParameterf(u32, u32, f32), - TexSubImage2D(u32, i32, i32, i32, i32, i32, u32, u32, Vec), - DrawingBufferWidth(IpcSender), - DrawingBufferHeight(IpcSender), - Finish(IpcSender<()>), - Flush, - GenerateMipmap(u32), -} +use {WebGLCommand, WebGLError, WebGLFramebufferBindingRequest}; +use {WebGLParameter, WebGLResult}; impl fmt::Debug for WebGLCommand { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { From 581c8459e963b1ddbf6169375b1286ff645a3675 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 26 Jun 2016 03:23:36 +0200 Subject: [PATCH 80/97] Allow serde_macros to be used --- Cargo.toml | 6 +++++- build.rs | 46 +++++++++++++++++++++++++++++++++++++--------- src/lib.rs | 6 ++++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3adff18c1b..a82937986f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,9 @@ version = "0.2.0" authors = ["Glenn Watson "] build = "build.rs" +[features] +default = ["serde_codegen"] + [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" @@ -14,9 +17,10 @@ euclid = "0.7.1" gleam = "0.2.19" offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} serde = {version = "0.7.11", features = ["nightly"]} +serde_macros = {version = "0.7.11", optional = true} [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" [build-dependencies] -serde_codegen = "0.7.11" +serde_codegen = {version = "0.7.11", optional = true} diff --git a/build.rs b/build.rs index d61b453f34..e954b0bbfe 100644 --- a/build.rs +++ b/build.rs @@ -2,17 +2,45 @@ * 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/. */ -extern crate serde_codegen; +#[cfg(all(feature = "serde_codegen", not(feature = "serde_macros")))] +mod inner { + extern crate serde_codegen; -use std::env; -use std::path::Path; + use std::env; + use std::path::Path; -pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); + pub fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); - let src = Path::new("src/types.rs"); - let dst = Path::new(&out_dir).join("types.rs"); + let src = Path::new("src/types.rs"); + let dst = Path::new(&out_dir).join("types.rs"); - serde_codegen::expand(&src, &dst).unwrap(); - println!("cargo:rerun-if-changed=src/types.rs"); + serde_codegen::expand(&src, &dst).unwrap(); + println!("cargo:rerun-if-changed=src/types.rs"); + } +} + +#[cfg(all(feature = "serde_macros", not(feature = "serde_codegen")))] +mod inner { + pub fn main() {} +} + +#[cfg(all(feature = "serde_codegen", feature = "serde_macros"))] +mod inner { + pub fn main() { + panic!("serde_codegen and serde_macros are both used. " + "You probably forgot --no-default-features.") + } +} + +#[cfg(not(any(feature = "serde_codegen", feature = "serde_macros")))] +mod inner { + pub fn main() { + panic!("Neither serde_codegen nor serde_macros are used. " + "You probably want --features serde_macros --no-default-features.") + } +} + +fn main() { + inner::main(); } diff --git a/src/lib.rs b/src/lib.rs index e7c456a75e..fddc7c3774 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +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/. */ +#![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))] +#![cfg_attr(feature = "serde_macros", plugin(serde_macros))] #![feature(nonzero)] extern crate app_units; @@ -15,8 +17,12 @@ extern crate serde; #[cfg(target_os = "macos")] extern crate core_graphics; +#[cfg(feature = "serde_codegen")] include!(concat!(env!("OUT_DIR"), "/types.rs")); +#[cfg(feature = "serde_macros")] +include!("types.rs"); + mod api; mod display_item; mod display_list; From 093273f90ab2b194deb9a5314dd79524e5c90457 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 26 Jun 2016 10:30:40 +0200 Subject: [PATCH 81/97] Restore all derivations on WebGLError They went away when I made serde_codegen usable with the crate. --- src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 398c2d506f..b97339929f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -539,7 +539,7 @@ pub struct WebGLDisplayItem { pub context_id: WebGLContextId, } -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub enum WebGLError { InvalidEnum, InvalidOperation, From 48350aa396279171c1f3d54847256aa9a8ea23ff Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 28 Jun 2016 14:44:47 +0200 Subject: [PATCH 82/97] Use wrappers for GL IDs These wrappers make the handling of buffers, framebuffers, programs, renderbuffers, shaders and textures a bit more type-safe and allow us to make nonzero usage optional. --- Cargo.toml | 4 +- src/lib.rs | 4 +- src/types.rs | 152 +++++++++++++++++++++++++++++++++++++++++---------- src/webgl.rs | 98 ++++++++++++++++----------------- 4 files changed, 179 insertions(+), 79 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a82937986f..035f16e29b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ build = "build.rs" [features] default = ["serde_codegen"] +nightly = ["euclid/unstable", "serde/nightly"] [dependencies.ipc-channel] git = "https://github.com/servo/ipc-channel" @@ -15,8 +16,9 @@ app_units = "0.2.5" byteorder = "0.5" euclid = "0.7.1" gleam = "0.2.19" +heapsize = "0.3.6" offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} -serde = {version = "0.7.11", features = ["nightly"]} +serde = "0.7.11" serde_macros = {version = "0.7.11", optional = true} [target.x86_64-apple-darwin.dependencies] diff --git a/src/lib.rs b/src/lib.rs index fddc7c3774..a26813a181 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,15 +2,17 @@ * 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/. */ +#![cfg_attr(feature = "nightly", feature(nonzero))] #![cfg_attr(feature = "serde_macros", feature(custom_derive, plugin))] #![cfg_attr(feature = "serde_macros", plugin(serde_macros))] -#![feature(nonzero)] extern crate app_units; extern crate byteorder; +#[cfg(feature = "nightly")] extern crate core; extern crate euclid; extern crate gleam; +extern crate heapsize; extern crate ipc_channel; extern crate offscreen_gl_context; extern crate serde; diff --git a/src/types.rs b/src/types.rs index b97339929f..67f2f9b2d4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -6,6 +6,7 @@ // for the serde implementations. use app_units::Au; +#[cfg(feature = "nightly")] use core::nonzero::NonZero; use euclid::{Matrix4, Point2D, Rect, Size2D}; use ipc_channel::ipc::{IpcBytesSender, IpcSender}; @@ -435,9 +436,9 @@ pub enum WebGLCommand { BlendEquationSeparate(u32, u32), BlendFunc(u32, u32), BlendFuncSeparate(u32, u32, u32, u32), - AttachShader(u32, u32), - DetachShader(u32, u32), - BindAttribLocation(u32, u32, String), + AttachShader(WebGLProgramId, WebGLShaderId), + DetachShader(WebGLProgramId, WebGLShaderId), + BindAttribLocation(WebGLProgramId, u32, String), BufferData(u32, Vec, u32), BufferSubData(u32, isize, Vec), Clear(u32), @@ -452,36 +453,36 @@ pub enum WebGLCommand { DepthRange(f64, f64), Enable(u32), Disable(u32), - CompileShader(u32, String), + CompileShader(WebGLShaderId, String), CopyTexImage2D(u32, i32, u32, i32, i32, i32, i32, i32), CopyTexSubImage2D(u32, i32, i32, i32, i32, i32, i32, i32), - CreateBuffer(IpcSender>>), - CreateFramebuffer(IpcSender>>), - CreateRenderbuffer(IpcSender>>), - CreateTexture(IpcSender>>), - CreateProgram(IpcSender>>), - CreateShader(u32, IpcSender>>), - DeleteBuffer(u32), - DeleteFramebuffer(u32), - DeleteRenderbuffer(u32), - DeleteTexture(u32), - DeleteProgram(u32), - DeleteShader(u32), - BindBuffer(u32, u32), + CreateBuffer(IpcSender>), + CreateFramebuffer(IpcSender>), + CreateRenderbuffer(IpcSender>), + CreateTexture(IpcSender>), + CreateProgram(IpcSender>), + CreateShader(u32, IpcSender>), + DeleteBuffer(WebGLBufferId), + DeleteFramebuffer(WebGLFramebufferId), + DeleteRenderbuffer(WebGLRenderbufferId), + DeleteTexture(WebGLTextureId), + DeleteProgram(WebGLProgramId), + DeleteShader(WebGLShaderId), + BindBuffer(u32, Option), BindFramebuffer(u32, WebGLFramebufferBindingRequest), - BindRenderbuffer(u32, u32), - BindTexture(u32, u32), + BindRenderbuffer(u32, Option), + BindTexture(u32, Option), DrawArrays(u32, i32, i32), DrawElements(u32, i32, u32, i64), EnableVertexAttribArray(u32), GetBufferParameter(u32, u32, IpcSender>), GetParameter(u32, IpcSender>), - GetProgramParameter(u32, u32, IpcSender>), - GetShaderParameter(u32, u32, IpcSender>), - GetActiveAttrib(u32, u32, IpcSender>), - GetActiveUniform(u32, u32, IpcSender>), - GetAttribLocation(u32, String, IpcSender>), - GetUniformLocation(u32, String, IpcSender>), + GetProgramParameter(WebGLProgramId, u32, IpcSender>), + GetShaderParameter(WebGLShaderId, u32, IpcSender>), + GetActiveAttrib(WebGLProgramId, u32, IpcSender>), + GetActiveUniform(WebGLProgramId, u32, IpcSender>), + GetAttribLocation(WebGLProgramId, String, IpcSender>), + GetUniformLocation(WebGLProgramId, String, IpcSender>), GetVertexAttrib(u32, u32, IpcSender>), PolygonOffset(f32, f32), ReadPixels(i32, i32, i32, i32, u32, u32, IpcSender>), @@ -496,7 +497,7 @@ pub enum WebGLCommand { Hint(u32, u32), LineWidth(f32), PixelStorei(u32, i32), - LinkProgram(u32), + LinkProgram(WebGLProgramId), Uniform1f(i32, f32), Uniform1fv(i32, Vec), Uniform1i(i32, i32), @@ -516,7 +517,7 @@ pub enum WebGLCommand { UniformMatrix2fv(i32, bool, Vec), UniformMatrix3fv(i32, bool, Vec), UniformMatrix4fv(i32, bool, Vec), - UseProgram(u32), + UseProgram(WebGLProgramId), VertexAttrib(u32, f32, f32, f32, f32), VertexAttribPointer2f(u32, i32, bool, i32, u32), Viewport(i32, i32, i32, i32), @@ -531,6 +532,101 @@ pub enum WebGLCommand { GenerateMipmap(u32), } +#[cfg(feature = "nightly")] +macro_rules! define_resource_id_struct { + ($name:ident) => { + #[derive(Clone, Copy, PartialEq)] + pub struct $name(NonZero); + + impl $name { + #[inline] + unsafe fn new(id: u32) -> Self { + $name(NonZero::new(id)) + } + + #[inline] + fn get(self) -> u32 { + *self.0 + } + } + + }; +} + +#[cfg(not(feature = "nightly"))] +macro_rules! define_resource_id_struct { + ($name:ident) => { + #[derive(Clone, Copy, PartialEq)] + pub struct $name(u32); + + impl $name { + #[inline] + unsafe fn new(id: u32) -> Self { + $name(id) + } + + #[inline] + fn get(self) -> u32 { + self.0 + } + } + }; +} + +macro_rules! define_resource_id { + ($name:ident) => { + define_resource_id_struct!($name); + + impl ::serde::Deserialize for $name { + fn deserialize(deserializer: &mut D) -> Result + where D: ::serde::Deserializer + { + let id = try!(u32::deserialize(deserializer)); + if id == 0 { + Err(::serde::Error::invalid_value("expected a non-zero value")) + } else { + Ok(unsafe { $name::new(id) }) + } + } + } + + impl ::serde::Serialize for $name { + fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> + where S: ::serde::Serializer + { + self.get().serialize(serializer) + } + } + + impl ::std::fmt::Debug for $name { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) + -> Result<(), ::std::fmt::Error> { + fmt.debug_tuple(stringify!($name)) + .field(&self.get()) + .finish() + } + } + + impl ::std::fmt::Display for $name { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) + -> Result<(), ::std::fmt::Error> { + write!(fmt, "{}", self.get()) + } + } + + impl ::heapsize::HeapSizeOf for $name { + fn heap_size_of_children(&self) -> usize { 0 } + } + } +} + +define_resource_id!(WebGLBufferId); +define_resource_id!(WebGLFramebufferId); +define_resource_id!(WebGLRenderbufferId); +define_resource_id!(WebGLTextureId); +define_resource_id!(WebGLProgramId); +define_resource_id!(WebGLShaderId); + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub struct WebGLContextId(pub usize); @@ -550,7 +646,7 @@ pub enum WebGLError { #[derive(Clone, Debug, Deserialize, Serialize)] pub enum WebGLFramebufferBindingRequest { - Explicit(u32), + Explicit(WebGLFramebufferId), Default, } diff --git a/src/webgl.rs b/src/webgl.rs index 2f5a2185c6..94d3cfd021 100644 --- a/src/webgl.rs +++ b/src/webgl.rs @@ -2,13 +2,13 @@ * 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 core::nonzero::NonZero; use gleam::gl; use ipc_channel::ipc::IpcSender; use offscreen_gl_context::{GLContext, NativeGLContextMethods}; use std::fmt; -use {WebGLCommand, WebGLError, WebGLFramebufferBindingRequest}; -use {WebGLParameter, WebGLResult}; +use {WebGLBufferId, WebGLCommand, WebGLError, WebGLFramebufferBindingRequest}; +use {WebGLFramebufferId, WebGLParameter, WebGLProgramId, WebGLRenderbufferId}; +use {WebGLResult, WebGLShaderId, WebGLTextureId}; impl fmt::Debug for WebGLCommand { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -130,11 +130,11 @@ impl WebGLCommand { WebGLCommand::ActiveTexture(target) => gl::active_texture(target), WebGLCommand::AttachShader(program_id, shader_id) => - gl::attach_shader(program_id, shader_id), + gl::attach_shader(program_id.get(), shader_id.get()), WebGLCommand::DetachShader(program_id, shader_id) => - gl::detach_shader(program_id, shader_id), + gl::detach_shader(program_id.get(), shader_id.get()), WebGLCommand::BindAttribLocation(program_id, index, name) => - gl::bind_attrib_location(program_id, index, &name), + gl::bind_attrib_location(program_id.get(), index, &name), WebGLCommand::BlendColor(r, g, b, a) => gl::blend_color(r, g, b, a), WebGLCommand::BlendEquation(mode) => @@ -242,27 +242,27 @@ impl WebGLCommand { WebGLCommand::CreateShader(shader_type, chan) => Self::create_shader(shader_type, chan), WebGLCommand::DeleteBuffer(id) => - gl::delete_buffers(&[id]), + gl::delete_buffers(&[id.get()]), WebGLCommand::DeleteFramebuffer(id) => - gl::delete_framebuffers(&[id]), + gl::delete_framebuffers(&[id.get()]), WebGLCommand::DeleteRenderbuffer(id) => - gl::delete_renderbuffers(&[id]), + gl::delete_renderbuffers(&[id.get()]), WebGLCommand::DeleteTexture(id) => - gl::delete_textures(&[id]), + gl::delete_textures(&[id.get()]), WebGLCommand::DeleteProgram(id) => - gl::delete_program(id), + gl::delete_program(id.get()), WebGLCommand::DeleteShader(id) => - gl::delete_shader(id), + gl::delete_shader(id.get()), WebGLCommand::BindBuffer(target, id) => - gl::bind_buffer(target, id), + gl::bind_buffer(target, id.map_or(0, WebGLBufferId::get)), WebGLCommand::BindFramebuffer(target, request) => Self::bind_framebuffer(target, request, ctx), WebGLCommand::BindRenderbuffer(target, id) => - gl::bind_renderbuffer(target, id), + gl::bind_renderbuffer(target, id.map_or(0, WebGLRenderbufferId::get)), WebGLCommand::BindTexture(target, id) => - gl::bind_texture(target, id), + gl::bind_texture(target, id.map_or(0, WebGLTextureId::get)), WebGLCommand::LinkProgram(program_id) => - gl::link_program(program_id), + gl::link_program(program_id.get()), WebGLCommand::Uniform1f(uniform_id, v) => gl::uniform_1f(uniform_id, v), WebGLCommand::Uniform1fv(uniform_id, v) => @@ -302,7 +302,7 @@ impl WebGLCommand { WebGLCommand::UniformMatrix4fv(uniform_id, transpose, v) => gl::uniform_matrix_4fv(uniform_id, transpose, &v), WebGLCommand::UseProgram(program_id) => - gl::use_program(program_id), + gl::use_program(program_id.get()), WebGLCommand::VertexAttrib(attrib_id, x, y, z, w) => gl::vertex_attrib_4f(attrib_id, x, y, z, w), WebGLCommand::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset) => @@ -340,32 +340,32 @@ impl WebGLCommand { chan.send(result).unwrap() } - fn active_attrib(program_id: u32, + fn active_attrib(program_id: WebGLProgramId, index: u32, chan: IpcSender>) { - let result = if index >= gl::get_program_iv(program_id, gl::ACTIVE_ATTRIBUTES) as u32 { + let result = if index >= gl::get_program_iv(program_id.get(), gl::ACTIVE_ATTRIBUTES) as u32 { Err(WebGLError::InvalidValue) } else { - Ok(gl::get_active_attrib(program_id, index)) + Ok(gl::get_active_attrib(program_id.get(), index)) }; chan.send(result).unwrap(); } - fn active_uniform(program_id: u32, + fn active_uniform(program_id: WebGLProgramId, index: u32, chan: IpcSender>) { - let result = if index >= gl::get_program_iv(program_id, gl::ACTIVE_UNIFORMS) as u32 { + let result = if index >= gl::get_program_iv(program_id.get(), gl::ACTIVE_UNIFORMS) as u32 { Err(WebGLError::InvalidValue) } else { - Ok(gl::get_active_uniform(program_id, index)) + Ok(gl::get_active_uniform(program_id.get(), index)) }; chan.send(result).unwrap(); } - fn attrib_location(program_id: u32, + fn attrib_location(program_id: WebGLProgramId, name: String, chan: IpcSender> ) { - let attrib_location = gl::get_attrib_location(program_id, &name); + let attrib_location = gl::get_attrib_location(program_id.get(), &name); let attrib_location = if attrib_location == -1 { None @@ -540,43 +540,43 @@ impl WebGLCommand { chan.send(result).unwrap(); } - fn program_parameter(program_id: u32, + fn program_parameter(program_id: WebGLProgramId, param_id: u32, chan: IpcSender>) { let result = match param_id { gl::DELETE_STATUS | gl::LINK_STATUS | gl::VALIDATE_STATUS => - Ok(WebGLParameter::Bool(gl::get_program_iv(program_id, param_id) != 0)), + Ok(WebGLParameter::Bool(gl::get_program_iv(program_id.get(), param_id) != 0)), gl::ATTACHED_SHADERS | gl::ACTIVE_ATTRIBUTES | gl::ACTIVE_UNIFORMS => - Ok(WebGLParameter::Int(gl::get_program_iv(program_id, param_id))), + Ok(WebGLParameter::Int(gl::get_program_iv(program_id.get(), param_id))), _ => Err(WebGLError::InvalidEnum), }; chan.send(result).unwrap(); } - fn shader_parameter(shader_id: u32, + fn shader_parameter(shader_id: WebGLShaderId, param_id: u32, chan: IpcSender>) { let result = match param_id { gl::SHADER_TYPE => - Ok(WebGLParameter::Int(gl::get_shader_iv(shader_id, param_id))), + Ok(WebGLParameter::Int(gl::get_shader_iv(shader_id.get(), param_id))), gl::DELETE_STATUS | gl::COMPILE_STATUS => - Ok(WebGLParameter::Bool(gl::get_shader_iv(shader_id, param_id) != 0)), + Ok(WebGLParameter::Bool(gl::get_shader_iv(shader_id.get(), param_id) != 0)), _ => Err(WebGLError::InvalidEnum), }; chan.send(result).unwrap(); } - fn uniform_location(program_id: u32, + fn uniform_location(program_id: WebGLProgramId, name: String, chan: IpcSender>) { - let location = gl::get_uniform_location(program_id, &name); + let location = gl::get_uniform_location(program_id.get(), &name); let location = if location == -1 { None } else { @@ -586,64 +586,64 @@ impl WebGLCommand { chan.send(location).unwrap(); } - fn create_buffer(chan: IpcSender>>) { + fn create_buffer(chan: IpcSender>) { let buffer = gl::gen_buffers(1)[0]; let buffer = if buffer == 0 { None } else { - Some(unsafe { NonZero::new(buffer) }) + Some(unsafe { WebGLBufferId::new(buffer) }) }; chan.send(buffer).unwrap(); } - fn create_framebuffer(chan: IpcSender>>) { + fn create_framebuffer(chan: IpcSender>) { let framebuffer = gl::gen_framebuffers(1)[0]; let framebuffer = if framebuffer == 0 { None } else { - Some(unsafe { NonZero::new(framebuffer) }) + Some(unsafe { WebGLFramebufferId::new(framebuffer) }) }; chan.send(framebuffer).unwrap(); } - fn create_renderbuffer(chan: IpcSender>>) { + fn create_renderbuffer(chan: IpcSender>) { let renderbuffer = gl::gen_renderbuffers(1)[0]; let renderbuffer = if renderbuffer == 0 { None } else { - Some(unsafe { NonZero::new(renderbuffer) }) + Some(unsafe { WebGLRenderbufferId::new(renderbuffer) }) }; chan.send(renderbuffer).unwrap(); } - fn create_texture(chan: IpcSender>>) { + fn create_texture(chan: IpcSender>) { let texture = gl::gen_textures(1)[0]; let texture = if texture == 0 { None } else { - Some(unsafe { NonZero::new(texture) }) + Some(unsafe { WebGLTextureId::new(texture) }) }; chan.send(texture).unwrap(); } - fn create_program(chan: IpcSender>>) { + fn create_program(chan: IpcSender>) { let program = gl::create_program(); let program = if program == 0 { None } else { - Some(unsafe { NonZero::new(program) }) + Some(unsafe { WebGLProgramId::new(program) }) }; chan.send(program).unwrap(); } - fn create_shader(shader_type: u32, chan: IpcSender>>) { + fn create_shader(shader_type: u32, chan: IpcSender>) { let shader = gl::create_shader(shader_type); let shader = if shader == 0 { None } else { - Some(unsafe { NonZero::new(shader) }) + Some(unsafe { WebGLShaderId::new(shader) }) }; chan.send(shader).unwrap(); } @@ -653,7 +653,7 @@ impl WebGLCommand { request: WebGLFramebufferBindingRequest, ctx: &GLContext) { let id = match request { - WebGLFramebufferBindingRequest::Explicit(id) => id, + WebGLFramebufferBindingRequest::Explicit(id) => id.get(), WebGLFramebufferBindingRequest::Default => ctx.borrow_draw_buffer().unwrap().get_framebuffer(), }; @@ -663,8 +663,8 @@ impl WebGLCommand { #[inline] - fn compile_shader(shader_id: u32, source: String) { - gl::shader_source(shader_id, &[source.as_bytes()]); - gl::compile_shader(shader_id); + fn compile_shader(shader_id: WebGLShaderId, source: String) { + gl::shader_source(shader_id.get(), &[source.as_bytes()]); + gl::compile_shader(shader_id.get()); } } From 5812449da680055a7ab568ca95754b2eb5199848 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 28 Jun 2016 23:43:40 +0200 Subject: [PATCH 83/97] Remove use of Matrix4 that is deprecated --- src/stacking_context.rs | 6 +++--- src/types.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/stacking_context.rs b/src/stacking_context.rs index 14a54f0d91..1ad24417dc 100644 --- a/src/stacking_context.rs +++ b/src/stacking_context.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use display_list::AuxiliaryListsBuilder; -use euclid::{Matrix4, Rect}; +use euclid::{Matrix4D, Rect}; use {FilterOp, MixBlendMode, ScrollLayerId, ScrollPolicy}; use {ServoStackingContextId, StackingContext}; @@ -14,8 +14,8 @@ impl StackingContext { bounds: Rect, overflow: Rect, z_index: i32, - transform: &Matrix4, - perspective: &Matrix4, + transform: &Matrix4D, + perspective: &Matrix4D, establishes_3d_context: bool, mix_blend_mode: MixBlendMode, filters: Vec, diff --git a/src/types.rs b/src/types.rs index 67f2f9b2d4..e8666227e8 100644 --- a/src/types.rs +++ b/src/types.rs @@ -8,7 +8,7 @@ use app_units::Au; #[cfg(feature = "nightly")] use core::nonzero::NonZero; -use euclid::{Matrix4, Point2D, Rect, Size2D}; +use euclid::{Matrix4D, Point2D, Rect, Size2D}; use ipc_channel::ipc::{IpcBytesSender, IpcSender}; use offscreen_gl_context::{GLContextAttributes, GLLimits}; @@ -402,8 +402,8 @@ pub struct StackingContext { pub overflow: Rect, pub z_index: i32, pub display_lists: Vec, - pub transform: Matrix4, - pub perspective: Matrix4, + pub transform: Matrix4D, + pub perspective: Matrix4D, pub establishes_3d_context: bool, pub mix_blend_mode: MixBlendMode, pub filters: ItemRange, From 41334896e0ca610f13487515b7c9a22a9c49dd41 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 14 Jun 2016 15:42:58 +0100 Subject: [PATCH 84/97] Add infrastructure to enable WebRender to skip compositing after scroll events that didn't actually result in motion. --- src/types.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/types.rs b/src/types.rs index 67f2f9b2d4..3fcad32424 100644 --- a/src/types.rs +++ b/src/types.rs @@ -328,9 +328,8 @@ pub struct RenderApiSender { pub trait RenderNotifier: Send { fn new_frame_ready(&mut self); - fn pipeline_size_changed(&mut self, - pipeline_id: PipelineId, - size: Option>); + fn new_scroll_frame_ready(&mut self, composite_needed: bool); + fn pipeline_size_changed(&mut self, pipeline_id: PipelineId, size: Option>); } #[derive(Clone, Copy, Debug, Deserialize, Serialize)] From 803d13d6fdf1e3c74ceef3f00f811c685bb0da2a Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 12 Jul 2016 14:08:06 +0300 Subject: [PATCH 85/97] rustup to 2016-07-11 --- .travis.yml | 2 +- Cargo.toml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36d89bb81c..497ac459f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: rust rust: - nightly - - nightly-2016-06-14 # Should be kept in sync with Servo. + - nightly-2016-07-11 # Should be kept in sync with Servo. matrix: allow_failures: diff --git a/Cargo.toml b/Cargo.toml index 035f16e29b..c7102e608f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ euclid = "0.7.1" gleam = "0.2.19" heapsize = "0.3.6" offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} -serde = "0.7.11" -serde_macros = {version = "0.7.11", optional = true} +serde = "0.7.14" +serde_macros = {version = "0.7.14", optional = true} [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" [build-dependencies] -serde_codegen = {version = "0.7.11", optional = true} +serde_codegen = {version = "0.7.14", optional = true} From 6985c238fd92f69f09e4b70fe85726c7d0de93d6 Mon Sep 17 00:00:00 2001 From: lana Date: Wed, 27 Jul 2016 19:55:32 -0700 Subject: [PATCH 86/97] add derive trait to StackingContexts --- .gitignore | 1 + src/types.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a9d37c560c..45a758bb26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.cargo/ target Cargo.lock diff --git a/src/types.rs b/src/types.rs index 2cda8dd0c6..0e4e81b9a3 100644 --- a/src/types.rs +++ b/src/types.rs @@ -392,7 +392,7 @@ pub enum SpecificDisplayListItem { Iframe(IframeInfo), } -#[derive(Deserialize, Serialize)] +#[derive(Clone, Deserialize, Serialize)] pub struct StackingContext { pub servo_id: ServoStackingContextId, pub scroll_layer_id: Option, From af7639caa416dfc395d345c99b9785a0ddab275d Mon Sep 17 00:00:00 2001 From: MSleepyPanda Date: Sun, 31 Jul 2016 11:50:18 +0200 Subject: [PATCH 87/97] Fix Argument List Md doesn't recognizes lists if they don't have a leading space --- src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index e97fcab7e4..ba9ac33872 100644 --- a/src/api.rs +++ b/src/api.rs @@ -108,6 +108,7 @@ impl RenderApi { /// Supplies a new frame to WebRender. /// /// Arguments: + /// /// * `stacking_context_id`: The ID of the root stacking context. /// * `background_color`: The background color of this pipeline. /// * `epoch`: A monotonically increasing timestamp. @@ -209,4 +210,3 @@ impl RenderApi { (namespace, id) } } - From eff5eff88099f8ed8492d530eefe8be3fc9f39e5 Mon Sep 17 00:00:00 2001 From: MSleepyPanda Date: Sun, 31 Jul 2016 12:11:15 +0200 Subject: [PATCH 88/97] Improve set_root_stacking_context Documentation --- src/api.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index ba9ac33872..e5e772eea7 100644 --- a/src/api.rs +++ b/src/api.rs @@ -107,16 +107,24 @@ impl RenderApi { /// Supplies a new frame to WebRender. /// + /// Non-blocking, it notifies a worker process which processes the stacking context. + /// When it's done and a RenderNotifier has been set in `webrender::renderer::Renderer`, + /// [RenderNotifier][notifier] gets called. + /// + /// Note: Scrolling doesn't require an own Frame. + /// /// Arguments: /// /// * `stacking_context_id`: The ID of the root stacking context. /// * `background_color`: The background color of this pipeline. - /// * `epoch`: A monotonically increasing timestamp. + /// * `epoch`: The unique Frame ID, monotonically increasing. /// * `pipeline_id`: The ID of the pipeline that is supplying this display list. /// * `viewport_size`: The size of the viewport for this frame. /// * `stacking_contexts`: Stacking contexts used in this frame. /// * `display_lists`: Display lists used in this frame. /// * `auxiliary_lists`: Various items that the display lists and stacking contexts reference. + /// + /// [notifier]: trait.RenderNotifier.html#tymethod.new_frame_ready pub fn set_root_stacking_context(&self, stacking_context_id: StackingContextId, background_color: ColorF, From 8a17b3c526f3cf5da7e7a1da3c33b7e4359c6c5b Mon Sep 17 00:00:00 2001 From: MSleepyPanda Date: Sun, 31 Jul 2016 13:55:25 +0200 Subject: [PATCH 89/97] Roughly document the api --- src/api.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index e5e772eea7..50ed56b2ef 100644 --- a/src/api.rs +++ b/src/api.rs @@ -67,11 +67,13 @@ impl RenderApi { key } + /// Creates an `ImageKey`. pub fn alloc_image(&self) -> ImageKey { let new_id = self.next_unique_id(); ImageKey::new(new_id.0, new_id.1) } + /// Adds an image and returns the corresponding `ImageKey`. pub fn add_image(&self, width: u32, height: u32, @@ -84,6 +86,9 @@ impl RenderApi { key } + /// Updates a specific image. + /// + /// Currently doesn't support changing dimensions or format by updating. // TODO: Support changing dimensions (and format) during image update? pub fn update_image(&self, key: ImageKey, @@ -95,11 +100,23 @@ impl RenderApi { self.api_sender.send(msg).unwrap(); } + /// Deletes the specific image. pub fn delete_image(&self, key: ImageKey) { let msg = ApiMsg::DeleteImage(key); self.api_sender.send(msg).unwrap(); } + /// Sets the root pipeline. + /// + /// # Examples + /// + /// ``` + /// let (mut renderer, sender) = webrender::renderer::Renderer::new(opts); + /// let api = sender.create_api(); + /// ... + /// let pipeline_id = PipelineId(0,0); + /// api.set_root_pipeline(pipeline_id); + /// ``` pub fn set_root_pipeline(&self, pipeline_id: PipelineId) { let msg = ApiMsg::SetRootPipeline(pipeline_id); self.api_sender.send(msg).unwrap(); @@ -109,7 +126,7 @@ impl RenderApi { /// /// Non-blocking, it notifies a worker process which processes the stacking context. /// When it's done and a RenderNotifier has been set in `webrender::renderer::Renderer`, - /// [RenderNotifier][notifier] gets called. + /// [new_frame_ready()][notifier] gets called. /// /// Note: Scrolling doesn't require an own Frame. /// @@ -160,6 +177,10 @@ impl RenderApi { self.payload_sender.send(&payload[..]).unwrap(); } + /// Scrolls the scrolling layer under the `cursor` + /// + /// Webrender looks for the layer closest to the user + /// which has `ScrollPolicy::Scrollable` set. pub fn scroll(&self, delta: Point2D, cursor: Point2D, phase: ScrollEventPhase) { let msg = ApiMsg::Scroll(delta, cursor, phase); self.api_sender.send(msg).unwrap(); @@ -170,6 +191,7 @@ impl RenderApi { self.api_sender.send(msg).unwrap(); } + /// Translates a point from viewport coordinates to layer space pub fn translate_point_to_layer_space(&self, point: &Point2D) -> (Point2D, PipelineId) { let (tx, rx) = ipc::channel().unwrap(); From 8f09b02650ea5f8e825337c9246ec17bb59225bd Mon Sep 17 00:00:00 2001 From: MSleepyPanda Date: Sun, 31 Jul 2016 21:20:13 +0200 Subject: [PATCH 90/97] Re-adding newline --- src/api.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api.rs b/src/api.rs index 50ed56b2ef..95202a84b4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -240,3 +240,4 @@ impl RenderApi { (namespace, id) } } + From a375751e128c74d03b96eb7e3292bae24a35b20d Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 3 Aug 2016 09:57:30 +1000 Subject: [PATCH 91/97] Pin ipc-channel dependency. --- Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c7102e608f..e1224dae9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,6 @@ build = "build.rs" default = ["serde_codegen"] nightly = ["euclid/unstable", "serde/nightly"] -[dependencies.ipc-channel] -git = "https://github.com/servo/ipc-channel" - [dependencies] app_units = "0.2.5" byteorder = "0.5" @@ -20,6 +17,7 @@ heapsize = "0.3.6" offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} serde = "0.7.14" serde_macros = {version = "0.7.14", optional = true} +ipc-channel = {git = "https://github.com/servo/ipc-channel", rev="346456b"} [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" From f845b7deaaa954e9598dda4528082d29b96745da Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 3 Aug 2016 09:53:42 +0200 Subject: [PATCH 92/97] Use ipc-channel from crates.io. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e1224dae9b..834534e844 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ heapsize = "0.3.6" offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} serde = "0.7.14" serde_macros = {version = "0.7.14", optional = true} -ipc-channel = {git = "https://github.com/servo/ipc-channel", rev="346456b"} +ipc-channel = "0.4.0" [target.x86_64-apple-darwin.dependencies] core-graphics = ">=0.2, <0.4" From 0519fc5ef601428a99abf8e9f1c178bb6e81cd6f Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 10 Aug 2016 19:29:21 +0200 Subject: [PATCH 93/97] Require euclid 0.8 and bump the version --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 834534e844..e6508247a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webrender_traits" -version = "0.2.0" +version = "0.2.1" authors = ["Glenn Watson "] build = "build.rs" @@ -11,10 +11,10 @@ nightly = ["euclid/unstable", "serde/nightly"] [dependencies] app_units = "0.2.5" byteorder = "0.5" -euclid = "0.7.1" +euclid = "0.8" gleam = "0.2.19" heapsize = "0.3.6" -offscreen_gl_context = {version = "0.1.9", features = ["serde_serialization"]} +offscreen_gl_context = {version = "0.2.0", features = ["serde_serialization"]} serde = "0.7.14" serde_macros = {version = "0.7.14", optional = true} ipc-channel = "0.4.0" From 754457ba73a5d8a3e32d5087d2aabd04731af0b8 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 12 Aug 2016 14:27:27 +0200 Subject: [PATCH 94/97] Update serde to 0.8 --- Cargo.toml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e6508247a1..e9e584bc56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,26 @@ [package] name = "webrender_traits" -version = "0.2.1" +version = "0.3.0" authors = ["Glenn Watson "] build = "build.rs" [features] default = ["serde_codegen"] -nightly = ["euclid/unstable", "serde/nightly"] +nightly = ["euclid/unstable", "serde/unstable"] [dependencies] -app_units = "0.2.5" +app_units = "0.3.0" byteorder = "0.5" -euclid = "0.8" +euclid = "0.9" gleam = "0.2.19" heapsize = "0.3.6" -offscreen_gl_context = {version = "0.2.0", features = ["serde_serialization"]} -serde = "0.7.14" -serde_macros = {version = "0.7.14", optional = true} -ipc-channel = "0.4.0" +offscreen_gl_context = {version = "0.3.0", features = ["serde_serialization"]} +serde = "0.8" +serde_macros = {version = "0.8", optional = true} +ipc-channel = "0.5.0" [target.x86_64-apple-darwin.dependencies] -core-graphics = ">=0.2, <0.4" +core-graphics = "0.4" [build-dependencies] -serde_codegen = {version = "0.7.14", optional = true} +serde_codegen = {version = "0.8", optional = true} From 315b28f24522ee56f934608cec6d33f2ecb52dc6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 6 Aug 2016 15:48:24 +0200 Subject: [PATCH 95/97] Move the crate to its own 'webrender' subdirectory --- .travis.yml | 2 ++ appveyor.yml | 1 + Cargo.toml => webrender/Cargo.toml | 0 {res => webrender/res}/blend.fs.glsl | 0 {res => webrender/res}/blend.vs.glsl | 0 {res => webrender/res}/blur.fs.glsl | 0 {res => webrender/res}/blur.vs.glsl | 0 {res => webrender/res}/box_shadow.fs.glsl | 0 {res => webrender/res}/box_shadow.vs.glsl | 0 {res => webrender/res}/debug_color.fs.glsl | 0 {res => webrender/res}/debug_color.vs.glsl | 0 {res => webrender/res}/debug_font.fs.glsl | 0 {res => webrender/res}/debug_font.vs.glsl | 0 {res => webrender/res}/es2_common.fs.glsl | 0 {res => webrender/res}/es2_common.vs.glsl | 0 {res => webrender/res}/filter.fs.glsl | 0 {res => webrender/res}/filter.vs.glsl | 0 {res => webrender/res}/gl3_common.fs.glsl | 0 {res => webrender/res}/gl3_common.vs.glsl | 0 {res => webrender/res}/prim_shared.glsl | 0 {res => webrender/res}/ps_angle_gradient.fs.glsl | 0 {res => webrender/res}/ps_angle_gradient.glsl | 0 {res => webrender/res}/ps_angle_gradient.vs.glsl | 0 {res => webrender/res}/ps_blend.fs.glsl | 0 {res => webrender/res}/ps_blend.glsl | 0 {res => webrender/res}/ps_blend.vs.glsl | 0 {res => webrender/res}/ps_border.fs.glsl | 0 {res => webrender/res}/ps_border.glsl | 0 {res => webrender/res}/ps_border.vs.glsl | 0 {res => webrender/res}/ps_box_shadow.fs.glsl | 0 {res => webrender/res}/ps_box_shadow.glsl | 0 {res => webrender/res}/ps_box_shadow.vs.glsl | 0 {res => webrender/res}/ps_clear.fs.glsl | 0 {res => webrender/res}/ps_clear.glsl | 0 {res => webrender/res}/ps_clear.vs.glsl | 0 {res => webrender/res}/ps_composite.fs.glsl | 0 {res => webrender/res}/ps_composite.glsl | 0 {res => webrender/res}/ps_composite.vs.glsl | 0 {res => webrender/res}/ps_gradient.fs.glsl | 0 {res => webrender/res}/ps_gradient.glsl | 0 {res => webrender/res}/ps_gradient.vs.glsl | 0 {res => webrender/res}/ps_image.fs.glsl | 0 {res => webrender/res}/ps_image.glsl | 0 {res => webrender/res}/ps_image.vs.glsl | 0 {res => webrender/res}/ps_image_clip.fs.glsl | 0 {res => webrender/res}/ps_image_clip.glsl | 0 {res => webrender/res}/ps_image_clip.vs.glsl | 0 {res => webrender/res}/ps_rectangle.fs.glsl | 0 {res => webrender/res}/ps_rectangle.glsl | 0 {res => webrender/res}/ps_rectangle.vs.glsl | 0 {res => webrender/res}/ps_rectangle_clip.fs.glsl | 0 {res => webrender/res}/ps_rectangle_clip.glsl | 0 {res => webrender/res}/ps_rectangle_clip.vs.glsl | 0 {res => webrender/res}/ps_text.fs.glsl | 0 {res => webrender/res}/ps_text.glsl | 0 {res => webrender/res}/ps_text.vs.glsl | 0 {res => webrender/res}/shared.glsl | 0 {res => webrender/res}/shared_other.glsl | 0 {src => webrender/src}/batch.rs | 0 {src => webrender/src}/batch_builder.rs | 0 {src => webrender/src}/debug_font_data.rs | 0 {src => webrender/src}/debug_render.rs | 0 {src => webrender/src}/device.rs | 0 {src => webrender/src}/frame.rs | 0 {src => webrender/src}/freelist.rs | 0 {src => webrender/src}/geometry.rs | 0 {src => webrender/src}/internal_types.rs | 0 {src => webrender/src}/layer.rs | 0 {src => webrender/src}/lib.rs | 0 {src => webrender/src}/platform/linux/font.rs | 0 {src => webrender/src}/platform/macos/font.rs | 0 {src => webrender/src}/profiler.rs | 0 {src => webrender/src}/render_backend.rs | 0 {src => webrender/src}/renderer.rs | 0 {src => webrender/src}/resource_cache.rs | 0 {src => webrender/src}/resource_list.rs | 0 {src => webrender/src}/scene.rs | 0 {src => webrender/src}/spring.rs | 0 {src => webrender/src}/texture_cache.rs | 0 {src => webrender/src}/tiling.rs | 0 {src => webrender/src}/util.rs | 0 {tests => webrender/tests}/bug_124.html | 0 {tests => webrender/tests}/bug_134.html | 0 {tests => webrender/tests}/bug_137.html | 0 {tests => webrender/tests}/bug_143.html | 0 {tests => webrender/tests}/bug_159.html | 0 {tests => webrender/tests}/bug_166.html | 0 {tests => webrender/tests}/bug_176.html | 0 {tests => webrender/tests}/bug_177.html | 0 {tests => webrender/tests}/bug_178.html | 0 {tests => webrender/tests}/bug_203a.html | 0 {tests => webrender/tests}/bug_203b.html | 0 {tests => webrender/tests}/bug_servo_10136.html | 0 {tests => webrender/tests}/bug_servo_10164.html | 0 {tests => webrender/tests}/bug_servo_10307.html | 0 {tests => webrender/tests}/bug_servo_11358.html | 0 {tests => webrender/tests}/bug_servo_9983a.html | 0 {tests => webrender/tests}/color_pattern_1.png | Bin {tests => webrender/tests}/color_pattern_2.png | Bin {tests => webrender/tests}/fixed-position.html | 0 {tests => webrender/tests}/mix-blend-mode-2.html | 0 {tests => webrender/tests}/mix-blend-mode.html | 0 {tests => webrender/tests}/nav-1.html | 0 {tests => webrender/tests}/nav-2.html | 0 104 files changed, 3 insertions(+) rename Cargo.toml => webrender/Cargo.toml (100%) rename {res => webrender/res}/blend.fs.glsl (100%) rename {res => webrender/res}/blend.vs.glsl (100%) rename {res => webrender/res}/blur.fs.glsl (100%) rename {res => webrender/res}/blur.vs.glsl (100%) rename {res => webrender/res}/box_shadow.fs.glsl (100%) rename {res => webrender/res}/box_shadow.vs.glsl (100%) rename {res => webrender/res}/debug_color.fs.glsl (100%) rename {res => webrender/res}/debug_color.vs.glsl (100%) rename {res => webrender/res}/debug_font.fs.glsl (100%) rename {res => webrender/res}/debug_font.vs.glsl (100%) rename {res => webrender/res}/es2_common.fs.glsl (100%) rename {res => webrender/res}/es2_common.vs.glsl (100%) rename {res => webrender/res}/filter.fs.glsl (100%) rename {res => webrender/res}/filter.vs.glsl (100%) rename {res => webrender/res}/gl3_common.fs.glsl (100%) rename {res => webrender/res}/gl3_common.vs.glsl (100%) rename {res => webrender/res}/prim_shared.glsl (100%) rename {res => webrender/res}/ps_angle_gradient.fs.glsl (100%) rename {res => webrender/res}/ps_angle_gradient.glsl (100%) rename {res => webrender/res}/ps_angle_gradient.vs.glsl (100%) rename {res => webrender/res}/ps_blend.fs.glsl (100%) rename {res => webrender/res}/ps_blend.glsl (100%) rename {res => webrender/res}/ps_blend.vs.glsl (100%) rename {res => webrender/res}/ps_border.fs.glsl (100%) rename {res => webrender/res}/ps_border.glsl (100%) rename {res => webrender/res}/ps_border.vs.glsl (100%) rename {res => webrender/res}/ps_box_shadow.fs.glsl (100%) rename {res => webrender/res}/ps_box_shadow.glsl (100%) rename {res => webrender/res}/ps_box_shadow.vs.glsl (100%) rename {res => webrender/res}/ps_clear.fs.glsl (100%) rename {res => webrender/res}/ps_clear.glsl (100%) rename {res => webrender/res}/ps_clear.vs.glsl (100%) rename {res => webrender/res}/ps_composite.fs.glsl (100%) rename {res => webrender/res}/ps_composite.glsl (100%) rename {res => webrender/res}/ps_composite.vs.glsl (100%) rename {res => webrender/res}/ps_gradient.fs.glsl (100%) rename {res => webrender/res}/ps_gradient.glsl (100%) rename {res => webrender/res}/ps_gradient.vs.glsl (100%) rename {res => webrender/res}/ps_image.fs.glsl (100%) rename {res => webrender/res}/ps_image.glsl (100%) rename {res => webrender/res}/ps_image.vs.glsl (100%) rename {res => webrender/res}/ps_image_clip.fs.glsl (100%) rename {res => webrender/res}/ps_image_clip.glsl (100%) rename {res => webrender/res}/ps_image_clip.vs.glsl (100%) rename {res => webrender/res}/ps_rectangle.fs.glsl (100%) rename {res => webrender/res}/ps_rectangle.glsl (100%) rename {res => webrender/res}/ps_rectangle.vs.glsl (100%) rename {res => webrender/res}/ps_rectangle_clip.fs.glsl (100%) rename {res => webrender/res}/ps_rectangle_clip.glsl (100%) rename {res => webrender/res}/ps_rectangle_clip.vs.glsl (100%) rename {res => webrender/res}/ps_text.fs.glsl (100%) rename {res => webrender/res}/ps_text.glsl (100%) rename {res => webrender/res}/ps_text.vs.glsl (100%) rename {res => webrender/res}/shared.glsl (100%) rename {res => webrender/res}/shared_other.glsl (100%) rename {src => webrender/src}/batch.rs (100%) rename {src => webrender/src}/batch_builder.rs (100%) rename {src => webrender/src}/debug_font_data.rs (100%) rename {src => webrender/src}/debug_render.rs (100%) rename {src => webrender/src}/device.rs (100%) rename {src => webrender/src}/frame.rs (100%) rename {src => webrender/src}/freelist.rs (100%) rename {src => webrender/src}/geometry.rs (100%) rename {src => webrender/src}/internal_types.rs (100%) rename {src => webrender/src}/layer.rs (100%) rename {src => webrender/src}/lib.rs (100%) rename {src => webrender/src}/platform/linux/font.rs (100%) rename {src => webrender/src}/platform/macos/font.rs (100%) rename {src => webrender/src}/profiler.rs (100%) rename {src => webrender/src}/render_backend.rs (100%) rename {src => webrender/src}/renderer.rs (100%) rename {src => webrender/src}/resource_cache.rs (100%) rename {src => webrender/src}/resource_list.rs (100%) rename {src => webrender/src}/scene.rs (100%) rename {src => webrender/src}/spring.rs (100%) rename {src => webrender/src}/texture_cache.rs (100%) rename {src => webrender/src}/tiling.rs (100%) rename {src => webrender/src}/util.rs (100%) rename {tests => webrender/tests}/bug_124.html (100%) rename {tests => webrender/tests}/bug_134.html (100%) rename {tests => webrender/tests}/bug_137.html (100%) rename {tests => webrender/tests}/bug_143.html (100%) rename {tests => webrender/tests}/bug_159.html (100%) rename {tests => webrender/tests}/bug_166.html (100%) rename {tests => webrender/tests}/bug_176.html (100%) rename {tests => webrender/tests}/bug_177.html (100%) rename {tests => webrender/tests}/bug_178.html (100%) rename {tests => webrender/tests}/bug_203a.html (100%) rename {tests => webrender/tests}/bug_203b.html (100%) rename {tests => webrender/tests}/bug_servo_10136.html (100%) rename {tests => webrender/tests}/bug_servo_10164.html (100%) rename {tests => webrender/tests}/bug_servo_10307.html (100%) rename {tests => webrender/tests}/bug_servo_11358.html (100%) rename {tests => webrender/tests}/bug_servo_9983a.html (100%) rename {tests => webrender/tests}/color_pattern_1.png (100%) rename {tests => webrender/tests}/color_pattern_2.png (100%) rename {tests => webrender/tests}/fixed-position.html (100%) rename {tests => webrender/tests}/mix-blend-mode-2.html (100%) rename {tests => webrender/tests}/mix-blend-mode.html (100%) rename {tests => webrender/tests}/nav-1.html (100%) rename {tests => webrender/tests}/nav-2.html (100%) diff --git a/.travis.yml b/.travis.yml index 88e7bcf938..a4a68086a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,3 +10,5 @@ addons: apt: packages: - libgles2-mesa-dev +script: + - (cd webrender && cargo test --verbose) diff --git a/appveyor.yml b/appveyor.yml index f82a3036cf..cc548ab573 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,4 +11,5 @@ install: build: false test_script: + - cd webrender - cargo test --verbose diff --git a/Cargo.toml b/webrender/Cargo.toml similarity index 100% rename from Cargo.toml rename to webrender/Cargo.toml diff --git a/res/blend.fs.glsl b/webrender/res/blend.fs.glsl similarity index 100% rename from res/blend.fs.glsl rename to webrender/res/blend.fs.glsl diff --git a/res/blend.vs.glsl b/webrender/res/blend.vs.glsl similarity index 100% rename from res/blend.vs.glsl rename to webrender/res/blend.vs.glsl diff --git a/res/blur.fs.glsl b/webrender/res/blur.fs.glsl similarity index 100% rename from res/blur.fs.glsl rename to webrender/res/blur.fs.glsl diff --git a/res/blur.vs.glsl b/webrender/res/blur.vs.glsl similarity index 100% rename from res/blur.vs.glsl rename to webrender/res/blur.vs.glsl diff --git a/res/box_shadow.fs.glsl b/webrender/res/box_shadow.fs.glsl similarity index 100% rename from res/box_shadow.fs.glsl rename to webrender/res/box_shadow.fs.glsl diff --git a/res/box_shadow.vs.glsl b/webrender/res/box_shadow.vs.glsl similarity index 100% rename from res/box_shadow.vs.glsl rename to webrender/res/box_shadow.vs.glsl diff --git a/res/debug_color.fs.glsl b/webrender/res/debug_color.fs.glsl similarity index 100% rename from res/debug_color.fs.glsl rename to webrender/res/debug_color.fs.glsl diff --git a/res/debug_color.vs.glsl b/webrender/res/debug_color.vs.glsl similarity index 100% rename from res/debug_color.vs.glsl rename to webrender/res/debug_color.vs.glsl diff --git a/res/debug_font.fs.glsl b/webrender/res/debug_font.fs.glsl similarity index 100% rename from res/debug_font.fs.glsl rename to webrender/res/debug_font.fs.glsl diff --git a/res/debug_font.vs.glsl b/webrender/res/debug_font.vs.glsl similarity index 100% rename from res/debug_font.vs.glsl rename to webrender/res/debug_font.vs.glsl diff --git a/res/es2_common.fs.glsl b/webrender/res/es2_common.fs.glsl similarity index 100% rename from res/es2_common.fs.glsl rename to webrender/res/es2_common.fs.glsl diff --git a/res/es2_common.vs.glsl b/webrender/res/es2_common.vs.glsl similarity index 100% rename from res/es2_common.vs.glsl rename to webrender/res/es2_common.vs.glsl diff --git a/res/filter.fs.glsl b/webrender/res/filter.fs.glsl similarity index 100% rename from res/filter.fs.glsl rename to webrender/res/filter.fs.glsl diff --git a/res/filter.vs.glsl b/webrender/res/filter.vs.glsl similarity index 100% rename from res/filter.vs.glsl rename to webrender/res/filter.vs.glsl diff --git a/res/gl3_common.fs.glsl b/webrender/res/gl3_common.fs.glsl similarity index 100% rename from res/gl3_common.fs.glsl rename to webrender/res/gl3_common.fs.glsl diff --git a/res/gl3_common.vs.glsl b/webrender/res/gl3_common.vs.glsl similarity index 100% rename from res/gl3_common.vs.glsl rename to webrender/res/gl3_common.vs.glsl diff --git a/res/prim_shared.glsl b/webrender/res/prim_shared.glsl similarity index 100% rename from res/prim_shared.glsl rename to webrender/res/prim_shared.glsl diff --git a/res/ps_angle_gradient.fs.glsl b/webrender/res/ps_angle_gradient.fs.glsl similarity index 100% rename from res/ps_angle_gradient.fs.glsl rename to webrender/res/ps_angle_gradient.fs.glsl diff --git a/res/ps_angle_gradient.glsl b/webrender/res/ps_angle_gradient.glsl similarity index 100% rename from res/ps_angle_gradient.glsl rename to webrender/res/ps_angle_gradient.glsl diff --git a/res/ps_angle_gradient.vs.glsl b/webrender/res/ps_angle_gradient.vs.glsl similarity index 100% rename from res/ps_angle_gradient.vs.glsl rename to webrender/res/ps_angle_gradient.vs.glsl diff --git a/res/ps_blend.fs.glsl b/webrender/res/ps_blend.fs.glsl similarity index 100% rename from res/ps_blend.fs.glsl rename to webrender/res/ps_blend.fs.glsl diff --git a/res/ps_blend.glsl b/webrender/res/ps_blend.glsl similarity index 100% rename from res/ps_blend.glsl rename to webrender/res/ps_blend.glsl diff --git a/res/ps_blend.vs.glsl b/webrender/res/ps_blend.vs.glsl similarity index 100% rename from res/ps_blend.vs.glsl rename to webrender/res/ps_blend.vs.glsl diff --git a/res/ps_border.fs.glsl b/webrender/res/ps_border.fs.glsl similarity index 100% rename from res/ps_border.fs.glsl rename to webrender/res/ps_border.fs.glsl diff --git a/res/ps_border.glsl b/webrender/res/ps_border.glsl similarity index 100% rename from res/ps_border.glsl rename to webrender/res/ps_border.glsl diff --git a/res/ps_border.vs.glsl b/webrender/res/ps_border.vs.glsl similarity index 100% rename from res/ps_border.vs.glsl rename to webrender/res/ps_border.vs.glsl diff --git a/res/ps_box_shadow.fs.glsl b/webrender/res/ps_box_shadow.fs.glsl similarity index 100% rename from res/ps_box_shadow.fs.glsl rename to webrender/res/ps_box_shadow.fs.glsl diff --git a/res/ps_box_shadow.glsl b/webrender/res/ps_box_shadow.glsl similarity index 100% rename from res/ps_box_shadow.glsl rename to webrender/res/ps_box_shadow.glsl diff --git a/res/ps_box_shadow.vs.glsl b/webrender/res/ps_box_shadow.vs.glsl similarity index 100% rename from res/ps_box_shadow.vs.glsl rename to webrender/res/ps_box_shadow.vs.glsl diff --git a/res/ps_clear.fs.glsl b/webrender/res/ps_clear.fs.glsl similarity index 100% rename from res/ps_clear.fs.glsl rename to webrender/res/ps_clear.fs.glsl diff --git a/res/ps_clear.glsl b/webrender/res/ps_clear.glsl similarity index 100% rename from res/ps_clear.glsl rename to webrender/res/ps_clear.glsl diff --git a/res/ps_clear.vs.glsl b/webrender/res/ps_clear.vs.glsl similarity index 100% rename from res/ps_clear.vs.glsl rename to webrender/res/ps_clear.vs.glsl diff --git a/res/ps_composite.fs.glsl b/webrender/res/ps_composite.fs.glsl similarity index 100% rename from res/ps_composite.fs.glsl rename to webrender/res/ps_composite.fs.glsl diff --git a/res/ps_composite.glsl b/webrender/res/ps_composite.glsl similarity index 100% rename from res/ps_composite.glsl rename to webrender/res/ps_composite.glsl diff --git a/res/ps_composite.vs.glsl b/webrender/res/ps_composite.vs.glsl similarity index 100% rename from res/ps_composite.vs.glsl rename to webrender/res/ps_composite.vs.glsl diff --git a/res/ps_gradient.fs.glsl b/webrender/res/ps_gradient.fs.glsl similarity index 100% rename from res/ps_gradient.fs.glsl rename to webrender/res/ps_gradient.fs.glsl diff --git a/res/ps_gradient.glsl b/webrender/res/ps_gradient.glsl similarity index 100% rename from res/ps_gradient.glsl rename to webrender/res/ps_gradient.glsl diff --git a/res/ps_gradient.vs.glsl b/webrender/res/ps_gradient.vs.glsl similarity index 100% rename from res/ps_gradient.vs.glsl rename to webrender/res/ps_gradient.vs.glsl diff --git a/res/ps_image.fs.glsl b/webrender/res/ps_image.fs.glsl similarity index 100% rename from res/ps_image.fs.glsl rename to webrender/res/ps_image.fs.glsl diff --git a/res/ps_image.glsl b/webrender/res/ps_image.glsl similarity index 100% rename from res/ps_image.glsl rename to webrender/res/ps_image.glsl diff --git a/res/ps_image.vs.glsl b/webrender/res/ps_image.vs.glsl similarity index 100% rename from res/ps_image.vs.glsl rename to webrender/res/ps_image.vs.glsl diff --git a/res/ps_image_clip.fs.glsl b/webrender/res/ps_image_clip.fs.glsl similarity index 100% rename from res/ps_image_clip.fs.glsl rename to webrender/res/ps_image_clip.fs.glsl diff --git a/res/ps_image_clip.glsl b/webrender/res/ps_image_clip.glsl similarity index 100% rename from res/ps_image_clip.glsl rename to webrender/res/ps_image_clip.glsl diff --git a/res/ps_image_clip.vs.glsl b/webrender/res/ps_image_clip.vs.glsl similarity index 100% rename from res/ps_image_clip.vs.glsl rename to webrender/res/ps_image_clip.vs.glsl diff --git a/res/ps_rectangle.fs.glsl b/webrender/res/ps_rectangle.fs.glsl similarity index 100% rename from res/ps_rectangle.fs.glsl rename to webrender/res/ps_rectangle.fs.glsl diff --git a/res/ps_rectangle.glsl b/webrender/res/ps_rectangle.glsl similarity index 100% rename from res/ps_rectangle.glsl rename to webrender/res/ps_rectangle.glsl diff --git a/res/ps_rectangle.vs.glsl b/webrender/res/ps_rectangle.vs.glsl similarity index 100% rename from res/ps_rectangle.vs.glsl rename to webrender/res/ps_rectangle.vs.glsl diff --git a/res/ps_rectangle_clip.fs.glsl b/webrender/res/ps_rectangle_clip.fs.glsl similarity index 100% rename from res/ps_rectangle_clip.fs.glsl rename to webrender/res/ps_rectangle_clip.fs.glsl diff --git a/res/ps_rectangle_clip.glsl b/webrender/res/ps_rectangle_clip.glsl similarity index 100% rename from res/ps_rectangle_clip.glsl rename to webrender/res/ps_rectangle_clip.glsl diff --git a/res/ps_rectangle_clip.vs.glsl b/webrender/res/ps_rectangle_clip.vs.glsl similarity index 100% rename from res/ps_rectangle_clip.vs.glsl rename to webrender/res/ps_rectangle_clip.vs.glsl diff --git a/res/ps_text.fs.glsl b/webrender/res/ps_text.fs.glsl similarity index 100% rename from res/ps_text.fs.glsl rename to webrender/res/ps_text.fs.glsl diff --git a/res/ps_text.glsl b/webrender/res/ps_text.glsl similarity index 100% rename from res/ps_text.glsl rename to webrender/res/ps_text.glsl diff --git a/res/ps_text.vs.glsl b/webrender/res/ps_text.vs.glsl similarity index 100% rename from res/ps_text.vs.glsl rename to webrender/res/ps_text.vs.glsl diff --git a/res/shared.glsl b/webrender/res/shared.glsl similarity index 100% rename from res/shared.glsl rename to webrender/res/shared.glsl diff --git a/res/shared_other.glsl b/webrender/res/shared_other.glsl similarity index 100% rename from res/shared_other.glsl rename to webrender/res/shared_other.glsl diff --git a/src/batch.rs b/webrender/src/batch.rs similarity index 100% rename from src/batch.rs rename to webrender/src/batch.rs diff --git a/src/batch_builder.rs b/webrender/src/batch_builder.rs similarity index 100% rename from src/batch_builder.rs rename to webrender/src/batch_builder.rs diff --git a/src/debug_font_data.rs b/webrender/src/debug_font_data.rs similarity index 100% rename from src/debug_font_data.rs rename to webrender/src/debug_font_data.rs diff --git a/src/debug_render.rs b/webrender/src/debug_render.rs similarity index 100% rename from src/debug_render.rs rename to webrender/src/debug_render.rs diff --git a/src/device.rs b/webrender/src/device.rs similarity index 100% rename from src/device.rs rename to webrender/src/device.rs diff --git a/src/frame.rs b/webrender/src/frame.rs similarity index 100% rename from src/frame.rs rename to webrender/src/frame.rs diff --git a/src/freelist.rs b/webrender/src/freelist.rs similarity index 100% rename from src/freelist.rs rename to webrender/src/freelist.rs diff --git a/src/geometry.rs b/webrender/src/geometry.rs similarity index 100% rename from src/geometry.rs rename to webrender/src/geometry.rs diff --git a/src/internal_types.rs b/webrender/src/internal_types.rs similarity index 100% rename from src/internal_types.rs rename to webrender/src/internal_types.rs diff --git a/src/layer.rs b/webrender/src/layer.rs similarity index 100% rename from src/layer.rs rename to webrender/src/layer.rs diff --git a/src/lib.rs b/webrender/src/lib.rs similarity index 100% rename from src/lib.rs rename to webrender/src/lib.rs diff --git a/src/platform/linux/font.rs b/webrender/src/platform/linux/font.rs similarity index 100% rename from src/platform/linux/font.rs rename to webrender/src/platform/linux/font.rs diff --git a/src/platform/macos/font.rs b/webrender/src/platform/macos/font.rs similarity index 100% rename from src/platform/macos/font.rs rename to webrender/src/platform/macos/font.rs diff --git a/src/profiler.rs b/webrender/src/profiler.rs similarity index 100% rename from src/profiler.rs rename to webrender/src/profiler.rs diff --git a/src/render_backend.rs b/webrender/src/render_backend.rs similarity index 100% rename from src/render_backend.rs rename to webrender/src/render_backend.rs diff --git a/src/renderer.rs b/webrender/src/renderer.rs similarity index 100% rename from src/renderer.rs rename to webrender/src/renderer.rs diff --git a/src/resource_cache.rs b/webrender/src/resource_cache.rs similarity index 100% rename from src/resource_cache.rs rename to webrender/src/resource_cache.rs diff --git a/src/resource_list.rs b/webrender/src/resource_list.rs similarity index 100% rename from src/resource_list.rs rename to webrender/src/resource_list.rs diff --git a/src/scene.rs b/webrender/src/scene.rs similarity index 100% rename from src/scene.rs rename to webrender/src/scene.rs diff --git a/src/spring.rs b/webrender/src/spring.rs similarity index 100% rename from src/spring.rs rename to webrender/src/spring.rs diff --git a/src/texture_cache.rs b/webrender/src/texture_cache.rs similarity index 100% rename from src/texture_cache.rs rename to webrender/src/texture_cache.rs diff --git a/src/tiling.rs b/webrender/src/tiling.rs similarity index 100% rename from src/tiling.rs rename to webrender/src/tiling.rs diff --git a/src/util.rs b/webrender/src/util.rs similarity index 100% rename from src/util.rs rename to webrender/src/util.rs diff --git a/tests/bug_124.html b/webrender/tests/bug_124.html similarity index 100% rename from tests/bug_124.html rename to webrender/tests/bug_124.html diff --git a/tests/bug_134.html b/webrender/tests/bug_134.html similarity index 100% rename from tests/bug_134.html rename to webrender/tests/bug_134.html diff --git a/tests/bug_137.html b/webrender/tests/bug_137.html similarity index 100% rename from tests/bug_137.html rename to webrender/tests/bug_137.html diff --git a/tests/bug_143.html b/webrender/tests/bug_143.html similarity index 100% rename from tests/bug_143.html rename to webrender/tests/bug_143.html diff --git a/tests/bug_159.html b/webrender/tests/bug_159.html similarity index 100% rename from tests/bug_159.html rename to webrender/tests/bug_159.html diff --git a/tests/bug_166.html b/webrender/tests/bug_166.html similarity index 100% rename from tests/bug_166.html rename to webrender/tests/bug_166.html diff --git a/tests/bug_176.html b/webrender/tests/bug_176.html similarity index 100% rename from tests/bug_176.html rename to webrender/tests/bug_176.html diff --git a/tests/bug_177.html b/webrender/tests/bug_177.html similarity index 100% rename from tests/bug_177.html rename to webrender/tests/bug_177.html diff --git a/tests/bug_178.html b/webrender/tests/bug_178.html similarity index 100% rename from tests/bug_178.html rename to webrender/tests/bug_178.html diff --git a/tests/bug_203a.html b/webrender/tests/bug_203a.html similarity index 100% rename from tests/bug_203a.html rename to webrender/tests/bug_203a.html diff --git a/tests/bug_203b.html b/webrender/tests/bug_203b.html similarity index 100% rename from tests/bug_203b.html rename to webrender/tests/bug_203b.html diff --git a/tests/bug_servo_10136.html b/webrender/tests/bug_servo_10136.html similarity index 100% rename from tests/bug_servo_10136.html rename to webrender/tests/bug_servo_10136.html diff --git a/tests/bug_servo_10164.html b/webrender/tests/bug_servo_10164.html similarity index 100% rename from tests/bug_servo_10164.html rename to webrender/tests/bug_servo_10164.html diff --git a/tests/bug_servo_10307.html b/webrender/tests/bug_servo_10307.html similarity index 100% rename from tests/bug_servo_10307.html rename to webrender/tests/bug_servo_10307.html diff --git a/tests/bug_servo_11358.html b/webrender/tests/bug_servo_11358.html similarity index 100% rename from tests/bug_servo_11358.html rename to webrender/tests/bug_servo_11358.html diff --git a/tests/bug_servo_9983a.html b/webrender/tests/bug_servo_9983a.html similarity index 100% rename from tests/bug_servo_9983a.html rename to webrender/tests/bug_servo_9983a.html diff --git a/tests/color_pattern_1.png b/webrender/tests/color_pattern_1.png similarity index 100% rename from tests/color_pattern_1.png rename to webrender/tests/color_pattern_1.png diff --git a/tests/color_pattern_2.png b/webrender/tests/color_pattern_2.png similarity index 100% rename from tests/color_pattern_2.png rename to webrender/tests/color_pattern_2.png diff --git a/tests/fixed-position.html b/webrender/tests/fixed-position.html similarity index 100% rename from tests/fixed-position.html rename to webrender/tests/fixed-position.html diff --git a/tests/mix-blend-mode-2.html b/webrender/tests/mix-blend-mode-2.html similarity index 100% rename from tests/mix-blend-mode-2.html rename to webrender/tests/mix-blend-mode-2.html diff --git a/tests/mix-blend-mode.html b/webrender/tests/mix-blend-mode.html similarity index 100% rename from tests/mix-blend-mode.html rename to webrender/tests/mix-blend-mode.html diff --git a/tests/nav-1.html b/webrender/tests/nav-1.html similarity index 100% rename from tests/nav-1.html rename to webrender/tests/nav-1.html diff --git a/tests/nav-2.html b/webrender/tests/nav-2.html similarity index 100% rename from tests/nav-2.html rename to webrender/tests/nav-2.html From 72097caf7742bdad9b70e3c64ad8e9639874d3e4 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 6 Aug 2016 15:55:21 +0200 Subject: [PATCH 96/97] Adapt the build system for the now-included webrender_traits crate --- .travis.yml | 1 + appveyor.yml | 4 +- webrender/Cargo.toml | 2 +- webrender_traits/LICENSE | 374 --------------------------------------- 4 files changed, 5 insertions(+), 376 deletions(-) delete mode 100644 webrender_traits/LICENSE diff --git a/.travis.yml b/.travis.yml index a4a68086a3..d1f205e109 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,5 @@ addons: packages: - libgles2-mesa-dev script: + - (cd webrender_traits && cargo test --verbose) - (cd webrender && cargo test --verbose) diff --git a/appveyor.yml b/appveyor.yml index cc548ab573..3f266fe943 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,5 +11,7 @@ install: build: false test_script: - - cd webrender + - cd webrender_traits + - cargo test --verbose + - cd ../webrender - cargo test --verbose diff --git a/webrender/Cargo.toml b/webrender/Cargo.toml index 4d12756f3c..c700558e8c 100644 --- a/webrender/Cargo.toml +++ b/webrender/Cargo.toml @@ -22,7 +22,7 @@ num-traits = "0.1.32" offscreen_gl_context = {version = "0.3", features = ["serde_serialization"]} rayon = "0.4.0" time = "0.1" -webrender_traits = {git = "https://github.com/servo/webrender_traits", default-features = false} +webrender_traits = {path = "../webrender_traits", default-features = false} [target.'cfg(any(target_os = "android", target_os = "linux", target_os = "windows"))'.dependencies] freetype = {git = "https://github.com/servo/rust-freetype"} diff --git a/webrender_traits/LICENSE b/webrender_traits/LICENSE deleted file mode 100644 index 398385c9fb..0000000000 --- a/webrender_traits/LICENSE +++ /dev/null @@ -1,374 +0,0 @@ - Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" -means each individual or legal entity that creates, contributes to -the creation of, or owns Covered Software. - -1.2. "Contributor Version" -means the combination of the Contributions of others (if any) used -by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" -means Covered Software of a particular Contributor. - -1.4. "Covered Software" -means Source Code Form to which the initial Contributor has attached -the notice in Exhibit A, the Executable Form of such Source Code -Form, and Modifications of such Source Code Form, in each case -including portions thereof. - -1.5. "Incompatible With Secondary Licenses" -means - -(a) that the initial Contributor has attached the notice described -in Exhibit B to the Covered Software; or - -(b) that the Covered Software was made available under the terms of -version 1.1 or earlier of the License, but not also under the -terms of a Secondary License. - -1.6. "Executable Form" -means any form of the work other than Source Code Form. - -1.7. "Larger Work" -means a work that combines Covered Software with other material, in -a separate file or files, that is not Covered Software. - -1.8. "License" -means this document. - -1.9. "Licensable" -means having the right to grant, to the maximum extent possible, -whether at the time of the initial grant or subsequently, any and -all of the rights conveyed by this License. - -1.10. "Modifications" -means any of the following: - -(a) any file in Source Code Form that results from an addition to, -deletion from, or modification of the contents of Covered -Software; or - -(b) any new file in Source Code Form that contains any Covered -Software. - -1.11. "Patent Claims" of a Contributor -means any patent claim(s), including without limitation, method, -process, and apparatus claims, in any patent Licensable by such -Contributor that would be infringed, but for the grant of the -License, by the making, using, selling, offering for sale, having -made, import, or transfer of either its Contributions or its -Contributor Version. - -1.12. "Secondary License" -means either the GNU General Public License, Version 2.0, the GNU -Lesser General Public License, Version 2.1, the GNU Affero General -Public License, Version 3.0, or any later versions of those -licenses. - -1.13. "Source Code Form" -means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") -means an individual or a legal entity exercising rights under this -License. For legal entities, "You" includes any entity that -controls, is controlled by, or is under common control with You. For -purposes of this definition, "control" means (a) the power, direct -or indirect, to cause the direction or management of such entity, -whether by contract or otherwise, or (b) ownership of more than -fifty percent (50%) of the outstanding shares or beneficial -ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) -Licensable by such Contributor to use, reproduce, make available, -modify, display, perform, distribute, and otherwise exploit its -Contributions, either on an unmodified basis, with Modifications, or -as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer -for sale, have made, import, and otherwise transfer either its -Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; -or - -(b) for infringements caused by: (i) Your and any other third party's -modifications of Covered Software, or (ii) the combination of its -Contributions with other software (except as part of its Contributor -Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of -its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code -Form, as described in Section 3.1, and You must inform recipients of -the Executable Form how they can obtain a copy of such Source Code -Form by reasonable means in a timely manner, at a charge no more -than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this -License, or sublicense it under different terms, provided that the -license for the Executable Form does not attempt to limit or alter -the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - -This Source Code Form is subject to the terms of the Mozilla Public -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/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - -This Source Code Form is "Incompatible With Secondary Licenses", as -defined by the Mozilla Public License, v. 2.0. - From cf3966b13fc8ee3d589da3344eeadfa48c88e0a1 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 6 Aug 2016 16:15:02 +0200 Subject: [PATCH 97/97] Clean up both Cargo.toml files and bump to 0.4.0 --- webrender/Cargo.toml | 5 +++-- webrender_traits/Cargo.toml | 4 +++- webrender_traits/src/api.rs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/webrender/Cargo.toml b/webrender/Cargo.toml index c700558e8c..84e6a66360 100644 --- a/webrender/Cargo.toml +++ b/webrender/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "webrender" -version = "0.2.0" +version = "0.4.0" authors = ["Glenn Watson "] +license = "MPL-2.0" +repository = "https://github.com/servo/webrender" [features] default = ["webrender_traits/serde_codegen"] @@ -17,7 +19,6 @@ gleam = "0.2" ipc-channel = "0.5" lazy_static = "0.2" log = "0.3" -#notify = {git = "https://github.com/glennw/rsnotify.git", branch = "inotify-modify"} num-traits = "0.1.32" offscreen_gl_context = {version = "0.3", features = ["serde_serialization"]} rayon = "0.4.0" diff --git a/webrender_traits/Cargo.toml b/webrender_traits/Cargo.toml index e9e584bc56..89517dc78b 100644 --- a/webrender_traits/Cargo.toml +++ b/webrender_traits/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "webrender_traits" -version = "0.3.0" +version = "0.4.0" authors = ["Glenn Watson "] +license = "MPL-2.0" +repository = "https://github.com/servo/webrender" build = "build.rs" [features] diff --git a/webrender_traits/src/api.rs b/webrender_traits/src/api.rs index 95202a84b4..d94804fb06 100644 --- a/webrender_traits/src/api.rs +++ b/webrender_traits/src/api.rs @@ -110,7 +110,7 @@ impl RenderApi { /// /// # Examples /// - /// ``` + /// ```ignore /// let (mut renderer, sender) = webrender::renderer::Renderer::new(opts); /// let api = sender.create_api(); /// ...