servo: Merge #14060 - Remove the direct azure dependencies from gfx, layout and layout_thread (from servo:gfx-azure); r=nox

Source-Repo: https://github.com/servo/servo
Source-Revision: f7875dad1a43792ff3869f292990d03d30ebd9eb
This commit is contained in:
Ms2ger 2016-11-05 07:26:30 -05:00
Родитель 6ad46429a2
Коммит 50df78169c
11 изменённых файлов: 52 добавлений и 87 удалений

Просмотреть файл

@ -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"

Просмотреть файл

@ -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;
@ -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;
@ -750,7 +745,7 @@ pub struct SolidColorDisplayItem {
pub base: BaseDisplayItem,
/// The color.
pub color: Color,
pub color: ColorF,
}
/// Paints text.
@ -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>,
@ -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>,
@ -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
@ -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,

Просмотреть файл

@ -18,7 +18,6 @@
extern crate alloc;
extern crate app_units;
extern crate azure;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;

Просмотреть файл

@ -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(),

Просмотреть файл

@ -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"}

Просмотреть файл

@ -13,7 +13,6 @@
#![plugin(plugins)]
extern crate app_units;
extern crate azure;
extern crate core;
extern crate euclid;
extern crate fnv;
@ -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;
@ -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());
@ -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();

3
servo/components/servo/Cargo.lock сгенерированный
Просмотреть файл

@ -811,7 +811,6 @@ name = "gfx"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1194,7 +1193,6 @@ name = "layout"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas_traits 0.0.1",
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1243,7 +1241,6 @@ name = "layout_thread"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",

3
servo/ports/cef/Cargo.lock сгенерированный
Просмотреть файл

@ -725,7 +725,6 @@ name = "gfx"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1099,7 +1098,6 @@ name = "layout"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"canvas_traits 0.0.1",
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1141,7 +1139,6 @@ name = "layout_thread"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"azure 0.9.1 (git+https://github.com/servo/rust-azure)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.0.1",