Remove gfx_traits::color.

This commit is contained in:
Ms2ger 2016-10-31 18:15:25 +01:00
parent 1f109dd1b2
commit a9e3fe75b5
11 changed files with 26 additions and 81 deletions

View file

@ -13,7 +13,6 @@ path = "lib.rs"
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
canvas_traits = {path = "../canvas_traits"}
euclid = "0.10.1"
gfx_traits = {path = "../gfx_traits"}
gleam = "0.2.8"
ipc-channel = "0.5"
log = "0.3.5"

View file

@ -2,16 +2,15 @@
* 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 azure::azure::{AzColor, AzFloat};
use azure::azure::AzFloat;
use azure::azure_hl::{AntialiasMode, CapStyle, CompositionOp, JoinStyle};
use azure::azure_hl::{BackendType, DrawOptions, DrawTarget, Pattern, StrokeOptions, SurfaceFormat};
use azure::azure_hl::{ColorPattern, DrawSurfaceOptions, Filter, PathBuilder};
use azure::azure_hl::{Color, ColorPattern, DrawSurfaceOptions, Filter, PathBuilder};
use canvas_traits::*;
use euclid::matrix2d::Matrix2D;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use gfx_traits::color;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::ipc::IpcSharedMemory;
use num_traits::ToPrimitive;
@ -73,7 +72,7 @@ struct CanvasPaintState<'a> {
shadow_offset_x: f64,
shadow_offset_y: f64,
shadow_blur: f64,
shadow_color: AzColor,
shadow_color: Color,
}
impl<'a> CanvasPaintState<'a> {
@ -86,14 +85,14 @@ impl<'a> CanvasPaintState<'a> {
CanvasPaintState {
draw_options: DrawOptions::new(1.0, CompositionOp::Over, antialias),
fill_style: Pattern::Color(ColorPattern::new(color::black())),
stroke_style: Pattern::Color(ColorPattern::new(color::black())),
fill_style: Pattern::Color(ColorPattern::new(Color::black())),
stroke_style: Pattern::Color(ColorPattern::new(Color::black())),
stroke_opts: StrokeOptions::new(1.0, JoinStyle::MiterOrBevel, CapStyle::Butt, 10.0, &[]),
transform: Matrix2D::identity(),
shadow_offset_x: 0.0,
shadow_offset_y: 0.0,
shadow_blur: 0.0,
shadow_color: color::transparent(),
shadow_color: Color::transparent(),
}
}
}
@ -665,7 +664,7 @@ impl<'a> CanvasPaintThread<'a> {
self.state.shadow_blur = value;
}
fn set_shadow_color(&mut self, value: AzColor) {
fn set_shadow_color(&mut self, value: Color) {
self.state.shadow_color = value;
}

View file

@ -11,7 +11,6 @@ extern crate azure;
extern crate canvas_traits;
extern crate core;
extern crate euclid;
extern crate gfx_traits;
extern crate gleam;
extern crate ipc_channel;
#[macro_use]

View file

@ -13,7 +13,6 @@ path = "lib.rs"
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
cssparser = {version = "0.7", features = ["heap_size", "serde-serialization"]}
euclid = "0.10.1"
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
ipc-channel = "0.5"

View file

@ -16,7 +16,6 @@ extern crate azure;
extern crate core;
extern crate cssparser;
extern crate euclid;
extern crate gfx_traits;
extern crate heapsize;
extern crate ipc_channel;
extern crate serde;
@ -24,9 +23,9 @@ extern crate serde;
extern crate serde_derive;
extern crate webrender_traits;
use azure::azure::{AzColor, AzFloat};
use azure::azure::AzFloat;
use azure::azure_hl::{CapStyle, CompositionOp, JoinStyle};
use azure::azure_hl::{ColorPattern, DrawTarget, Pattern};
use azure::azure_hl::{Color, ColorPattern, DrawTarget, Pattern};
use azure::azure_hl::{ExtendMode, GradientStop, LinearGradientPattern, RadialGradientPattern};
use azure::azure_hl::{SurfaceFormat, SurfacePattern};
use cssparser::RGBA;
@ -34,7 +33,6 @@ use euclid::matrix2d::Matrix2D;
use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use gfx_traits::color;
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
use std::default::Default;
use std::str::FromStr;
@ -205,16 +203,13 @@ impl FillOrStrokeStyle {
pub fn to_azure_pattern(&self, drawtarget: &DrawTarget) -> Option<Pattern> {
match *self {
FillOrStrokeStyle::Color(ref color) => {
Some(Pattern::Color(ColorPattern::new(color::new(color.red,
color.green,
color.blue,
color.alpha))))
Some(Pattern::Color(ColorPattern::new(color.to_azcolor())))
},
FillOrStrokeStyle::LinearGradient(ref linear_gradient_style) => {
let gradient_stops: Vec<GradientStop> = linear_gradient_style.stops.iter().map(|s| {
GradientStop {
offset: s.offset as AzFloat,
color: color::new(s.color.red, s.color.green, s.color.blue, s.color.alpha)
color: s.color.to_azcolor()
}
}).collect();
@ -228,7 +223,7 @@ impl FillOrStrokeStyle {
let gradient_stops: Vec<GradientStop> = radial_gradient_style.stops.iter().map(|s| {
GradientStop {
offset: s.offset as AzFloat,
color: color::new(s.color.red, s.color.green, s.color.blue, s.color.alpha)
color: s.color.to_azcolor()
}
}).collect();
@ -532,12 +527,12 @@ impl CompositionOrBlending {
}
pub trait ToAzColor {
fn to_azcolor(&self) -> AzColor;
fn to_azcolor(&self) -> Color;
}
impl ToAzColor for RGBA {
fn to_azcolor(&self) -> AzColor {
color::rgba(self.red as AzFloat,
fn to_azcolor(&self) -> Color {
Color::rgba(self.red as AzFloat,
self.green as AzFloat,
self.blue as AzFloat,
self.alpha as AzFloat)

View file

@ -1,41 +0,0 @@
/* 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 azure::AzFloat;
use azure::azure::AzColor;
#[inline]
pub fn new(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor {
AzColor { r: r, g: g, b: b, a: a }
}
#[inline]
pub fn rgb(r: u8, g: u8, b: u8) -> AzColor {
AzColor {
r: (r as AzFloat) / (255.0 as AzFloat),
g: (g as AzFloat) / (255.0 as AzFloat),
b: (b as AzFloat) / (255.0 as AzFloat),
a: 1.0 as AzFloat
}
}
#[inline]
pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor {
AzColor { r: r, g: g, b: b, a: a }
}
#[inline]
pub fn black() -> AzColor {
AzColor { r: 0.0, g: 0.0, b: 0.0, a: 1.0 }
}
#[inline]
pub fn transparent() -> AzColor {
AzColor { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }
}
#[inline]
pub fn white() -> AzColor {
AzColor { r: 1.0, g: 1.0, b: 1.0, a: 1.0 }
}

View file

@ -19,7 +19,6 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;
pub mod color;
pub mod print_tree;
use range::RangeIndex;

View file

@ -28,7 +28,7 @@ use gfx::display_list::{GradientStop, IframeDisplayItem, ImageDisplayItem, WebGL
use gfx::display_list::{LineDisplayItem, OpaqueNode};
use gfx::display_list::{SolidColorDisplayItem, StackingContext, StackingContextType};
use gfx::display_list::{TextDisplayItem, TextOrientation, WebRenderImageInfo};
use gfx_traits::{ScrollPolicy, ScrollRootId, StackingContextId, color};
use gfx_traits::{ScrollPolicy, ScrollRootId, StackingContextId};
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
use ipc_channel::ipc;
use list_item::ListItemFlow;
@ -963,7 +963,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(Color::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid),
radius: Default::default(),
}));
@ -983,7 +983,7 @@ impl FragmentDisplayListBuilding for Fragment {
DisplayListSection::Content);
state.add_display_item(DisplayItem::Line(box LineDisplayItem {
base: base,
color: color::rgb(0, 200, 0),
color: Color::rgb(0, 200, 0),
style: border_style::T::dashed,
}));
}
@ -1001,7 +1001,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(Color::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid),
radius: Default::default(),
}));
@ -2106,7 +2106,7 @@ pub trait ToGfxColor {
impl ToGfxColor for RGBA {
fn to_gfx_color(&self) -> Color {
color::rgba(self.red, self.green, self.blue, self.alpha)
Color::rgba(self.red, self.green, self.blue, self.alpha)
}
}

View file

@ -45,7 +45,7 @@ extern crate util;
extern crate webrender_traits;
use app_units::Au;
use azure::azure::AzColor;
use azure::azure_hl::Color;
use euclid::Matrix4D;
use euclid::point::Point2D;
use euclid::rect::Rect;
@ -57,7 +57,7 @@ use gfx::display_list::{StackingContext, StackingContextType, WebRenderImageInfo
use gfx::font;
use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context;
use gfx_traits::{Epoch, FragmentType, ScrollPolicy, ScrollRootId, StackingContextId, color};
use gfx_traits::{Epoch, FragmentType, ScrollPolicy, ScrollRootId, StackingContextId};
use heapsize::HeapSizeOf;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
@ -1519,18 +1519,18 @@ 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) -> AzColor {
fn get_root_flow_background_color(flow: &mut Flow) -> Color {
if !flow.is_block_like() {
return color::transparent()
return Color::transparent()
}
let block_flow = flow.as_mut_block();
let kid = match block_flow.base.children.iter_mut().next() {
None => return color::transparent(),
None => return Color::transparent(),
Some(kid) => kid,
};
if !kid.is_block_like() {
return color::transparent()
return Color::transparent()
}
let kid_block_flow = kid.as_block();

View file

@ -225,7 +225,6 @@ dependencies = [
"azure 0.9.0 (git+https://github.com/servo/rust-azure)",
"canvas_traits 0.0.1",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"gleam 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -243,7 +242,6 @@ dependencies = [
"azure 0.9.0 (git+https://github.com/servo/rust-azure)",
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",

2
ports/cef/Cargo.lock generated
View file

@ -198,7 +198,6 @@ dependencies = [
"azure 0.9.0 (git+https://github.com/servo/rust-azure)",
"canvas_traits 0.0.1",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"gleam 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -216,7 +215,6 @@ dependencies = [
"azure 0.9.0 (git+https://github.com/servo/rust-azure)",
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_traits 0.0.1",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",