Skip to content

Commit

Permalink
Auto merge of #14060 - servo:gfx-azure, r=nox
Browse files Browse the repository at this point in the history
Remove the direct azure dependencies from gfx, layout and layout_thread.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14060)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 5, 2016
2 parents 516be8f + 81ee81c commit f7875da
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 87 deletions.
1 change: 0 additions & 1 deletion components/gfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ path = "lib.rs"

[dependencies]
app_units = "0.3"
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
bitflags = "0.7"
euclid = "0.10.1"
fnv = "1.0"
Expand Down
17 changes: 6 additions & 11 deletions components/gfx/display_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//! low-level drawing primitives.

use app_units::Au;
use azure::azure_hl::Color;
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use euclid::num::{One, Zero};
use euclid::rect::TypedRect;
Expand All @@ -35,14 +34,10 @@ use style_traits::cursor::Cursor;
use text::TextRun;
use text::glyph::ByteIndex;
use util::geometry::{self, max_rect};
use webrender_traits::{self, WebGLContextId};
use webrender_traits::{self, ColorF, GradientStop, WebGLContextId};

pub use style::dom::OpaqueNode;

// It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for
// layout to use.
pub use azure::azure_hl::GradientStop;

/// The factor that we multiply the blur radius by in order to inflate the boundaries of display
/// items that involve a blur. This ensures that the display item boundaries include all the ink.
pub static BLUR_INFLATION_FACTOR: i32 = 3;
Expand Down Expand Up @@ -750,7 +745,7 @@ pub struct SolidColorDisplayItem {
pub base: BaseDisplayItem,

/// The color.
pub color: Color,
pub color: ColorF,
}

/// Paints text.
Expand All @@ -767,7 +762,7 @@ pub struct TextDisplayItem {
pub range: Range<ByteIndex>,

/// The color of the text.
pub text_color: Color,
pub text_color: ColorF,

/// The position of the start of the baseline of this text.
pub baseline_origin: Point2D<Au>,
Expand Down Expand Up @@ -851,7 +846,7 @@ pub struct BorderDisplayItem {
pub border_widths: SideOffsets2D<Au>,

/// Border colors.
pub color: SideOffsets2D<Color>,
pub color: SideOffsets2D<ColorF>,

/// Border styles.
pub style: SideOffsets2D<border_style::T>,
Expand Down Expand Up @@ -932,7 +927,7 @@ pub struct LineDisplayItem {
pub base: BaseDisplayItem,

/// The line segment color.
pub color: Color,
pub color: ColorF,

/// The line segment style.
pub style: border_style::T
Expand All @@ -951,7 +946,7 @@ pub struct BoxShadowDisplayItem {
pub offset: Point2D<Au>,

/// The color of this shadow.
pub color: Color,
pub color: ColorF,

/// The blur radius for this shadow.
pub blur_radius: Au,
Expand Down
1 change: 0 additions & 1 deletion components/gfx/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

extern crate alloc;
extern crate app_units;
extern crate azure;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;
Expand Down
1 change: 0 additions & 1 deletion components/layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ path = "lib.rs"

[dependencies]
app_units = "0.3"
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
bitflags = "0.7"
canvas_traits = {path = "../canvas_traits"}
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
Expand Down
49 changes: 32 additions & 17 deletions components/layout/display_list_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![deny(unsafe_code)]

use app_units::{AU_PER_PX, Au};
use azure::azure_hl::Color;
use block::{BlockFlow, BlockStackingContextType};
use canvas_traits::{CanvasData, CanvasMsg, FromLayoutMsg};
use context::SharedLayoutContext;
Expand All @@ -24,7 +23,7 @@ use fragment::SpecificFragmentInfo;
use gfx::display_list::{BLUR_INFLATION_FACTOR, BaseDisplayItem, BorderDisplayItem};
use gfx::display_list::{BorderRadii, BoxShadowClipMode, BoxShadowDisplayItem, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayItemMetadata, DisplayList, DisplayListSection};
use gfx::display_list::{GradientDisplayItem, GradientStop, IframeDisplayItem, ImageDisplayItem};
use gfx::display_list::{GradientDisplayItem, IframeDisplayItem, ImageDisplayItem};
use gfx::display_list::{LineDisplayItem, OpaqueNode};
use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType};
use gfx::display_list::{TextDisplayItem, TextOrientation, WebGLDisplayItem, WebRenderImageInfo};
Expand Down Expand Up @@ -60,16 +59,32 @@ use style_traits::cursor::Cursor;
use table_cell::CollapsedBordersForCell;
use url::Url;
use util::opts;
use webrender_traits::{ColorF, GradientStop};

static THREAD_TINT_COLORS: [Color; 8] = [
Color { r: 6.0 / 255.0, g: 153.0 / 255.0, b: 198.0 / 255.0, a: 0.7 },
Color { r: 255.0 / 255.0, g: 212.0 / 255.0, b: 83.0 / 255.0, a: 0.7 },
Color { r: 116.0 / 255.0, g: 29.0 / 255.0, b: 109.0 / 255.0, a: 0.7 },
Color { r: 204.0 / 255.0, g: 158.0 / 255.0, b: 199.0 / 255.0, a: 0.7 },
Color { r: 242.0 / 255.0, g: 46.0 / 255.0, b: 121.0 / 255.0, a: 0.7 },
Color { r: 116.0 / 255.0, g: 203.0 / 255.0, b: 196.0 / 255.0, a: 0.7 },
Color { r: 255.0 / 255.0, g: 249.0 / 255.0, b: 201.0 / 255.0, a: 0.7 },
Color { r: 137.0 / 255.0, g: 196.0 / 255.0, b: 78.0 / 255.0, a: 0.7 },
trait RgbColor {
fn rgb(r: u8, g: u8, b: u8) -> Self;
}

impl RgbColor for ColorF {
fn rgb(r: u8, g: u8, b: u8) -> Self {
ColorF {
r: (r as f32) / (255.0 as f32),
g: (g as f32) / (255.0 as f32),
b: (b as f32) / (255.0 as f32),
a: 1.0 as f32
}
}
}

static THREAD_TINT_COLORS: [ColorF; 8] = [
ColorF { r: 6.0 / 255.0, g: 153.0 / 255.0, b: 198.0 / 255.0, a: 0.7 },
ColorF { r: 255.0 / 255.0, g: 212.0 / 255.0, b: 83.0 / 255.0, a: 0.7 },
ColorF { r: 116.0 / 255.0, g: 29.0 / 255.0, b: 109.0 / 255.0, a: 0.7 },
ColorF { r: 204.0 / 255.0, g: 158.0 / 255.0, b: 199.0 / 255.0, a: 0.7 },
ColorF { r: 242.0 / 255.0, g: 46.0 / 255.0, b: 121.0 / 255.0, a: 0.7 },
ColorF { r: 116.0 / 255.0, g: 203.0 / 255.0, b: 196.0 / 255.0, a: 0.7 },
ColorF { r: 255.0 / 255.0, g: 249.0 / 255.0, b: 201.0 / 255.0, a: 0.7 },
ColorF { r: 137.0 / 255.0, g: 196.0 / 255.0, b: 78.0 / 255.0, a: 0.7 },
];

fn get_cyclic<T>(arr: &[T], index: usize) -> &T {
Expand Down Expand Up @@ -1053,7 +1068,7 @@ impl FragmentDisplayListBuilding for Fragment {
state.add_display_item(DisplayItem::Border(box BorderDisplayItem {
base: base,
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
color: SideOffsets2D::new_all_same(Color::rgb(0, 0, 200)),
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid),
radius: Default::default(),
}));
Expand All @@ -1073,7 +1088,7 @@ impl FragmentDisplayListBuilding for Fragment {
DisplayListSection::Content);
state.add_display_item(DisplayItem::Line(box LineDisplayItem {
base: base,
color: Color::rgb(0, 200, 0),
color: ColorF::rgb(0, 200, 0),
style: border_style::T::dashed,
}));
}
Expand All @@ -1091,7 +1106,7 @@ impl FragmentDisplayListBuilding for Fragment {
state.add_display_item(DisplayItem::Border(box BorderDisplayItem {
base: base,
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
color: SideOffsets2D::new_all_same(Color::rgb(0, 0, 200)),
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid),
radius: Default::default(),
}));
Expand Down Expand Up @@ -2191,12 +2206,12 @@ fn shadow_bounds(content_rect: &Rect<Au>, blur_radius: Au, spread_radius: Au) ->
/// Allows a CSS color to be converted into a graphics color.
pub trait ToGfxColor {
/// Converts a CSS color to a graphics color.
fn to_gfx_color(&self) -> Color;
fn to_gfx_color(&self) -> ColorF;
}

impl ToGfxColor for RGBA {
fn to_gfx_color(&self) -> Color {
Color::rgba(self.red, self.green, self.blue, self.alpha)
fn to_gfx_color(&self) -> ColorF {
ColorF::new(self.red, self.green, self.blue, self.alpha)
}
}

Expand Down
1 change: 0 additions & 1 deletion components/layout/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#![plugin(plugins)]

extern crate app_units;
extern crate azure;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;
Expand Down
46 changes: 9 additions & 37 deletions components/layout/webrender_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
// completely converting layout to directly generate WebRender display lists, for example.

use app_units::Au;
use azure::azure_hl::Color;
use euclid::{Point2D, Rect, Size2D};
use gfx::display_list::{BorderRadii, BoxShadowClipMode, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal};
use gfx::display_list::{GradientStop, StackingContext, StackingContextType};
use gfx::display_list::{StackingContext, StackingContextType};
use gfx_traits::{FragmentType, ScrollPolicy, StackingContextId, ScrollRootId};
use style::computed_values::{image_rendering, mix_blend_mode};
use style::computed_values::filter::{self, Filter};
Expand Down Expand Up @@ -122,29 +121,6 @@ impl ToRectF for Rect<Au> {
}
}

trait ToColorF {
fn to_colorf(&self) -> webrender_traits::ColorF;
}

impl ToColorF for Color {
fn to_colorf(&self) -> webrender_traits::ColorF {
webrender_traits::ColorF::new(self.r, self.g, self.b, self.a)
}
}

trait ToGradientStop {
fn to_gradient_stop(&self) -> webrender_traits::GradientStop;
}

impl ToGradientStop for GradientStop {
fn to_gradient_stop(&self) -> webrender_traits::GradientStop {
webrender_traits::GradientStop {
offset: self.offset,
color: self.color.to_colorf(),
}
}
}

trait ToClipRegion {
fn to_clip_region(&self, frame_builder: &mut WebRenderFrameBuilder)
-> webrender_traits::ClipRegion;
Expand Down Expand Up @@ -352,7 +328,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
frame_builder: &mut WebRenderFrameBuilder) {
match *self {
DisplayItem::SolidColor(ref item) => {
let color = item.color.to_colorf();
let color = item.color;
if color.a > 0.0 {
builder.push_rect(item.base.bounds.to_rectf(),
item.base.clip.to_clip_region(frame_builder),
Expand Down Expand Up @@ -388,7 +364,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
item.base.clip.to_clip_region(frame_builder),
glyphs,
item.text_run.font_key,
item.text_color.to_colorf(),
item.text_color,
item.text_run.actual_pt_size,
item.blur_radius,
&mut frame_builder.auxiliary_lists_builder);
Expand Down Expand Up @@ -416,22 +392,22 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let rect = item.base.bounds.to_rectf();
let left = webrender_traits::BorderSide {
width: item.border_widths.left.to_f32_px(),
color: item.color.left.to_colorf(),
color: item.color.left,
style: item.style.left.to_border_style(),
};
let top = webrender_traits::BorderSide {
width: item.border_widths.top.to_f32_px(),
color: item.color.top.to_colorf(),
color: item.color.top,
style: item.style.top.to_border_style(),
};
let right = webrender_traits::BorderSide {
width: item.border_widths.right.to_f32_px(),
color: item.color.right.to_colorf(),
color: item.color.right,
style: item.style.right.to_border_style(),
};
let bottom = webrender_traits::BorderSide {
width: item.border_widths.bottom.to_f32_px(),
color: item.color.bottom.to_colorf(),
color: item.color.bottom,
style: item.style.bottom.to_border_style(),
};
let radius = item.radius.to_border_radius();
Expand All @@ -447,15 +423,11 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let rect = item.base.bounds.to_rectf();
let start_point = item.start_point.to_pointf();
let end_point = item.end_point.to_pointf();
let mut stops = Vec::new();
for stop in &item.stops {
stops.push(stop.to_gradient_stop());
}
builder.push_gradient(rect,
item.base.clip.to_clip_region(frame_builder),
start_point,
end_point,
stops,
item.stops.clone(),
&mut frame_builder.auxiliary_lists_builder);
}
DisplayItem::Line(..) => {
Expand All @@ -468,7 +440,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
item.base.clip.to_clip_region(frame_builder),
box_bounds,
item.offset.to_pointf(),
item.color.to_colorf(),
item.color,
item.blur_radius.to_f32_px(),
item.spread_radius.to_f32_px(),
item.border_radius.to_f32_px(),
Expand Down
1 change: 0 additions & 1 deletion components/layout_thread/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ path = "lib.rs"

[dependencies]
app_units = "0.3"
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
euclid = "0.10.1"
fnv = "1.0"
gfx = {path = "../gfx"}
Expand Down
16 changes: 5 additions & 11 deletions components/layout_thread/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#![plugin(plugins)]

extern crate app_units;
extern crate azure;
extern crate core;
extern crate euclid;
extern crate fnv;
Expand Down Expand Up @@ -46,7 +45,6 @@ extern crate util;
extern crate webrender_traits;

use app_units::Au;
use azure::azure_hl::Color;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::scale_factor::ScaleFactor;
Expand Down Expand Up @@ -969,11 +967,6 @@ impl LayoutThread {
epoch,
&mut frame_builder);
let root_background_color = get_root_flow_background_color(layout_root);
let root_background_color =
webrender_traits::ColorF::new(root_background_color.r,
root_background_color.g,
root_background_color.b,
root_background_color.a);

let viewport_size = Size2D::new(self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px());
Expand Down Expand Up @@ -1491,18 +1484,19 @@ impl LayoutThread {
// clearing the frame buffer to white. This ensures that setting a background
// color on an iframe element, while the iframe content itself has a default
// transparent background color is handled correctly.
fn get_root_flow_background_color(flow: &mut Flow) -> Color {
fn get_root_flow_background_color(flow: &mut Flow) -> webrender_traits::ColorF {
let transparent = webrender_traits::ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 };
if !flow.is_block_like() {
return Color::transparent()
return transparent;
}

let block_flow = flow.as_mut_block();
let kid = match block_flow.base.children.iter_mut().next() {
None => return Color::transparent(),
None => return transparent,
Some(kid) => kid,
};
if !kid.is_block_like() {
return Color::transparent()
return transparent;
}

let kid_block_flow = kid.as_block();
Expand Down
Loading

0 comments on commit f7875da

Please sign in to comment.