mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove the direct azure dependencies from gfx, layout and layout_thread.
This does not cover transitive dependencies through canvas_traits, though that should not be too hard to solve either.
This commit is contained in:
parent
651e40f33e
commit
81ee81cbb0
11 changed files with 52 additions and 87 deletions
|
@ -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"]}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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};
|
||||
|
@ -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 {
|
||||
|
@ -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(),
|
||||
}));
|
||||
|
@ -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,
|
||||
}));
|
||||
}
|
||||
|
@ -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(),
|
||||
}));
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#![plugin(plugins)]
|
||||
|
||||
extern crate app_units;
|
||||
extern crate azure;
|
||||
#[allow(unused_extern_crates)]
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
|
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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(..) => {
|
||||
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue