servo: Merge #14004 - Various gfx cleanup (from servo:gfx); r=glennw
authorMs2ger <Ms2ger@gmail.com>
Mon, 31 Oct 2016 14:58:03 -0500
changeset 369057 5ab0fd2dd6822efd47bf67a4d42ef27e6ecf0dfd
parent 369056 3e93d75d067a3c186be310cdd7e817df7663b453
child 369058 393f1d3fd5233494255b55d981607e84427f4d96
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglennw
servo: Merge #14004 - Various gfx cleanup (from servo:gfx); r=glennw Source-Repo: https://github.com/servo/servo Source-Revision: 1a213bf22d48fc3cf8882f609e3aa7fe8ba2f60a
servo/components/canvas/Cargo.toml
servo/components/canvas/canvas_paint_thread.rs
servo/components/canvas/lib.rs
servo/components/canvas_traits/Cargo.toml
servo/components/canvas_traits/lib.rs
servo/components/gfx/font_context.rs
servo/components/gfx_traits/color.rs
servo/components/gfx_traits/lib.rs
servo/components/layout/display_list_builder.rs
servo/components/layout_thread/lib.rs
servo/components/servo/Cargo.lock
servo/ports/cef/Cargo.lock
--- a/servo/components/canvas/Cargo.toml
+++ b/servo/components/canvas/Cargo.toml
@@ -8,17 +8,16 @@ publish = false
 [lib]
 name = "canvas"
 path = "lib.rs"
 
 [dependencies]
 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"
 num-traits = "0.1.32"
 offscreen_gl_context = "0.4"
 plugins = {path = "../plugins"}
 util = {path = "../util"}
 
--- a/servo/components/canvas/canvas_paint_thread.rs
+++ b/servo/components/canvas/canvas_paint_thread.rs
@@ -1,22 +1,21 @@
 /* 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::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;
 use std::borrow::ToOwned;
 use std::mem;
 use util::thread::spawn_named;
 use webrender_traits;
 
@@ -68,37 +67,37 @@ struct CanvasPaintState<'a> {
     fill_style: Pattern,
     stroke_style: Pattern,
     stroke_opts: StrokeOptions<'a>,
     /// The current 2D transform matrix.
     transform: Matrix2D<f32>,
     shadow_offset_x: f64,
     shadow_offset_y: f64,
     shadow_blur: f64,
-    shadow_color: AzColor,
+    shadow_color: Color,
 }
 
 impl<'a> CanvasPaintState<'a> {
     fn new(antialias: bool) -> CanvasPaintState<'a> {
         let antialias = if antialias {
             AntialiasMode::Default
         } else {
             AntialiasMode::None
         };
 
         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(),
         }
     }
 }
 
 impl<'a> CanvasPaintThread<'a> {
     fn new(size: Size2D<i32>,
            webrender_api_sender: webrender_traits::RenderApiSender,
            antialias: bool) -> CanvasPaintThread<'a> {
@@ -660,17 +659,17 @@ impl<'a> CanvasPaintThread<'a> {
     fn set_shadow_offset_y(&mut self, value: f64) {
         self.state.shadow_offset_y = value;
     }
 
     fn set_shadow_blur(&mut self, value: f64) {
         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;
     }
 
     // https://html.spec.whatwg.org/multipage/#when-shadows-are-drawn
     fn need_to_draw_shadow(&self) -> bool {
         self.state.shadow_color.a != 0.0f32 &&
         (self.state.shadow_offset_x != 0.0f64 ||
          self.state.shadow_offset_y != 0.0f64 ||
--- a/servo/components/canvas/lib.rs
+++ b/servo/components/canvas/lib.rs
@@ -6,17 +6,16 @@
 #![plugin(plugins)]
 
 #![deny(unsafe_code)]
 
 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]
 extern crate log;
 extern crate num_traits;
 extern crate offscreen_gl_context;
 extern crate util;
 extern crate webrender_traits;
--- a/servo/components/canvas_traits/Cargo.toml
+++ b/servo/components/canvas_traits/Cargo.toml
@@ -8,17 +8,16 @@ publish = false
 [lib]
 name = "canvas_traits"
 path = "lib.rs"
 
 [dependencies]
 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"
 plugins = {path = "../plugins"}
 serde = {version = "0.8", features = ["unstable"]}
 serde_derive = "0.8"
 
 [dependencies.webrender_traits]
--- a/servo/components/canvas_traits/lib.rs
+++ b/servo/components/canvas_traits/lib.rs
@@ -11,35 +11,33 @@
 #![plugin(heapsize_plugin, plugins)]
 
 #![deny(unsafe_code)]
 
 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;
 #[macro_use]
 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;
 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;
 use webrender_traits::{WebGLCommand, WebGLContextId};
 
 #[derive(Clone, Deserialize, Serialize)]
 pub enum FillRule {
     Nonzero,
@@ -200,40 +198,37 @@ pub enum FillOrStrokeStyle {
     RadialGradient(RadialGradientStyle),
     Surface(SurfaceStyle),
 }
 
 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();
 
                 Some(Pattern::LinearGradient(LinearGradientPattern::new(
                     &Point2D::new(linear_gradient_style.x0 as AzFloat, linear_gradient_style.y0 as AzFloat),
                     &Point2D::new(linear_gradient_style.x1 as AzFloat, linear_gradient_style.y1 as AzFloat),
                     drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
                     &Matrix2D::identity())))
             },
             FillOrStrokeStyle::RadialGradient(ref radial_gradient_style) => {
                 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();
 
                 Some(Pattern::RadialGradient(RadialGradientPattern::new(
                     &Point2D::new(radial_gradient_style.x0 as AzFloat, radial_gradient_style.y0 as AzFloat),
                     &Point2D::new(radial_gradient_style.x1 as AzFloat, radial_gradient_style.y1 as AzFloat),
                     radial_gradient_style.r0 as AzFloat, radial_gradient_style.r1 as AzFloat,
                     drawtarget.create_gradient_stops(&gradient_stops, ExtendMode::Clamp),
@@ -527,22 +522,22 @@ impl CompositionOrBlending {
         match *self {
             CompositionOrBlending::Composition(op) => op.to_azure_style(),
             CompositionOrBlending::Blending(op) => op.to_azure_style(),
         }
     }
 }
 
 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)
     }
 }
 
 // TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
 pub fn byte_swap(data: &mut [u8]) {
--- a/servo/components/gfx/font_context.rs
+++ b/servo/components/gfx/font_context.rs
@@ -1,72 +1,46 @@
 /* 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 azure::azure_hl::BackendType;
-#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
-use azure::scaled_font::FontInfo;
-use azure::scaled_font::ScaledFont;
 use fnv::FnvHasher;
 use font::{Font, FontGroup, FontHandleMethods};
 use font_cache_thread::FontCacheThread;
 use font_template::FontTemplateDescriptor;
 use heapsize::HeapSizeOf;
 use platform::font::FontHandle;
 use platform::font_context::FontContextHandle;
 use platform::font_template::FontTemplateData;
 use smallvec::SmallVec;
 use std::cell::RefCell;
 use std::collections::HashMap;
 use std::default::Default;
 use std::hash::{BuildHasherDefault, Hash, Hasher};
 use std::rc::Rc;
 use std::sync::Arc;
 use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
-use string_cache::Atom;
 use style::computed_values::{font_style, font_variant};
 use style::properties::style_structs;
 use webrender_traits;
 
-#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
-fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
-    ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes),
-                    pt_size.to_f32_px())
-}
-
-#[cfg(target_os = "macos")]
-fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
-    let cgfont = template.ctfont(pt_size.to_f64_px()).as_ref().unwrap().copy_to_CGFont();
-    ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f32_px())
-}
-
 static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8;      // Matches FireFox (see gfxFont.h)
 
 #[derive(Debug)]
 struct LayoutFontCacheEntry {
     family: String,
     font: Option<Rc<RefCell<Font>>>,
 }
 
 #[derive(Debug)]
 struct FallbackFontCacheEntry {
     font: Rc<RefCell<Font>>,
 }
 
-/// A cached azure font (per paint thread) that
-/// can be shared by multiple text runs.
-#[derive(Debug)]
-struct PaintFontCacheEntry {
-    pt_size: Au,
-    identifier: Atom,
-    font: Rc<RefCell<ScaledFont>>,
-}
-
 /// An epoch for the font context cache. The cache is flushed if the current epoch does not match
 /// this one.
 static FONT_CACHE_EPOCH: AtomicUsize = ATOMIC_USIZE_INIT;
 
 /// The FontContext represents the per-thread/thread state necessary for
 /// working with fonts. It is the public API used by the layout and
 /// paint code. It talks directly to the font cache thread where
 /// required.
@@ -74,35 +48,30 @@ static FONT_CACHE_EPOCH: AtomicUsize = A
 pub struct FontContext {
     platform_handle: FontContextHandle,
     font_cache_thread: FontCacheThread,
 
     /// TODO: See bug https://github.com/servo/servo/issues/3300.
     layout_font_cache: Vec<LayoutFontCacheEntry>,
     fallback_font_cache: Vec<FallbackFontCacheEntry>,
 
-    /// Strong reference as the paint FontContext is (for now) recycled
-    /// per frame. TODO: Make this weak when incremental redraw is done.
-    paint_font_cache: Vec<PaintFontCacheEntry>,
-
     layout_font_group_cache:
         HashMap<LayoutFontGroupCacheKey, Rc<FontGroup>, BuildHasherDefault<FnvHasher>>,
 
     epoch: usize,
 }
 
 impl FontContext {
     pub fn new(font_cache_thread: FontCacheThread) -> FontContext {
         let handle = FontContextHandle::new();
         FontContext {
             platform_handle: handle,
             font_cache_thread: font_cache_thread,
             layout_font_cache: vec!(),
             fallback_font_cache: vec!(),
-            paint_font_cache: vec!(),
             layout_font_group_cache: HashMap::with_hasher(Default::default()),
             epoch: 0,
         }
     }
 
     /// Create a font for use in layout calculations.
     fn create_layout_font(&self,
                           template: Arc<FontTemplateData>,
@@ -128,17 +97,16 @@ impl FontContext {
     fn expire_font_caches_if_necessary(&mut self) {
         let current_epoch = FONT_CACHE_EPOCH.load(Ordering::SeqCst);
         if current_epoch == self.epoch {
             return
         }
 
         self.layout_font_cache.clear();
         self.fallback_font_cache.clear();
-        self.paint_font_cache.clear();
         self.layout_font_group_cache.clear();
         self.epoch = current_epoch
     }
 
     /// Create a group of fonts for use in layout calculations. May return
     /// a cached font if this font instance has already been used by
     /// this context.
     pub fn layout_font_group_for_style(&mut self, style: Arc<style_structs::Font>)
@@ -255,43 +223,16 @@ impl FontContext {
                 Err(_) => debug!("Failed to create fallback layout font!")
             }
         }
 
         let font_group = Rc::new(FontGroup::new(fonts));
         self.layout_font_group_cache.insert(layout_font_group_cache_key, font_group.clone());
         font_group
     }
-
-    /// Create a paint font for use with azure. May return a cached
-    /// reference if already used by this font context.
-    pub fn paint_font_from_template(&mut self,
-                                        template: &Arc<FontTemplateData>,
-                                        pt_size: Au)
-                                        -> Rc<RefCell<ScaledFont>> {
-        for cached_font in &self.paint_font_cache {
-            if cached_font.pt_size == pt_size &&
-               cached_font.identifier == template.identifier {
-                return cached_font.font.clone();
-            }
-        }
-
-        let paint_font = Rc::new(RefCell::new(create_scaled_font(template, pt_size)));
-        self.paint_font_cache.push(PaintFontCacheEntry {
-            font: paint_font.clone(),
-            pt_size: pt_size,
-            identifier: template.identifier.clone(),
-        });
-        paint_font
-    }
-
-    /// Returns a reference to the font cache thread.
-    pub fn font_cache_thread(&self) -> FontCacheThread {
-        self.font_cache_thread.clone()
-    }
 }
 
 impl HeapSizeOf for FontContext {
     fn heap_size_of_children(&self) -> usize {
         // FIXME(njn): Measure other fields eventually.
         self.platform_handle.heap_size_of_children()
     }
 }
deleted file mode 100644
--- a/servo/components/gfx_traits/color.rs
+++ /dev/null
@@ -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 }
-}
--- a/servo/components/gfx_traits/lib.rs
+++ b/servo/components/gfx_traits/lib.rs
@@ -14,17 +14,16 @@ extern crate azure;
 extern crate heapsize;
 #[macro_use]
 extern crate range;
 extern crate rustc_serialize;
 extern crate serde;
 #[macro_use]
 extern crate serde_derive;
 
-pub mod color;
 pub mod print_tree;
 
 use range::RangeIndex;
 use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
 
 /// The next ID that will be used for a special stacking context.
 ///
 /// A special stacking context is a stacking context that is one of (a) the outer stacking context
--- a/servo/components/layout/display_list_builder.rs
+++ b/servo/components/layout/display_list_builder.rs
@@ -23,17 +23,17 @@ use fragment::{CoordinateSystem, Fragmen
 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, DisplayListSection, GradientDisplayItem};
 use gfx::display_list::{GradientStop, IframeDisplayItem, ImageDisplayItem, WebGLDisplayItem};
 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;
 use model::{self, MaybeAuto, ToGfxMatrix};
 use net_traits::image::base::PixelFormat;
 use net_traits::image_cache_thread::UsePlaceholder;
 use range::Range;
 use script_layout_interface::restyle_damage::REPAINT;
@@ -958,17 +958,17 @@ impl FragmentDisplayListBuilding for Fra
         let base = state.create_base_display_item(stacking_relative_border_box,
                                                   clip,
                                                   self.node,
                                                   style.get_cursor(Cursor::Default),
                                                   DisplayListSection::Content);
         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(),
         }));
 
         // Draw a rectangle representing the baselines.
         let mut baseline = LogicalRect::from_physical(self.style.writing_mode,
                                                       *stacking_relative_content_box,
                                                       container_size);
@@ -978,17 +978,17 @@ impl FragmentDisplayListBuilding for Fra
 
         let base = state.create_base_display_item(&baseline,
                                                   clip,
                                                   self.node,
                                                   style.get_cursor(Cursor::Default),
                                                   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,
         }));
     }
 
     fn build_debug_borders_around_fragment(&self,
                                            state: &mut DisplayListBuildState,
                                            stacking_relative_border_box: &Rect<Au>,
                                            clip: &ClippingRegion) {
@@ -996,17 +996,17 @@ impl FragmentDisplayListBuilding for Fra
         let base = state.create_base_display_item(stacking_relative_border_box,
                                                   clip,
                                                   self.node,
                                                   self.style.get_cursor(Cursor::Default),
                                                   DisplayListSection::Content);
         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(),
         }));
     }
 
     fn adjust_clip_for_style(&self,
                              parent_clip: &mut ClippingRegion,
                              stacking_relative_border_box: &Rect<Au>) {
@@ -2101,17 +2101,17 @@ fn shadow_bounds(content_rect: &Rect<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;
 }
 
 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)
     }
 }
 
 /// Describes how to paint the borders.
 #[derive(Copy, Clone)]
 pub enum BorderPaintingMode<'a> {
     /// Paint borders separately (`border-collapse: separate`).
     Separate,
--- a/servo/components/layout_thread/lib.rs
+++ b/servo/components/layout_thread/lib.rs
@@ -40,29 +40,29 @@ extern crate script_traits;
 extern crate selectors;
 extern crate serde_json;
 extern crate style;
 extern crate url;
 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;
 use euclid::scale_factor::ScaleFactor;
 use euclid::size::Size2D;
 use fnv::FnvHasher;
 use gfx::display_list::{ClippingRegion, DisplayList, OpaqueNode};
 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;
 use layout::animation;
 use layout::construct::ConstructionResult;
 use layout::context::{LayoutContext, SharedLayoutContext, heap_size_of_local_context};
 use layout::display_list_builder::ToGfxColor;
 use layout::flow::{self, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
@@ -1514,28 +1514,28 @@ impl LayoutThread {
 // http://dev.w3.org/csswg/css-backgrounds/#background-color). However, we
 // need to propagate the background color from the root HTML/Body
 // element (http://dev.w3.org/csswg/css-backgrounds/#special-backgrounds) if
 // it is non-transparent. The phrase in the spec "If the canvas background
 // is not opaque, what shows through is UA-dependent." is handled by rust-layers
 // 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();
     kid_block_flow.fragment
                   .style
                   .resolve_color(kid_block_flow.fragment.style.get_background().background_color)
                   .to_gfx_color()
 }
--- a/servo/components/servo/Cargo.lock
+++ b/servo/components/servo/Cargo.lock
@@ -105,17 +105,17 @@ dependencies = [
  "mp3-metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "mp4parse 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ogg_metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "azure"
 version = "0.9.0"
-source = "git+https://github.com/servo/rust-azure#4a2ca5018c97d356a2d2959a074ca98e1f6adba8"
+source = "git+https://github.com/servo/rust-azure#4890bf0b438cbeff4cd269441f4db19a413024ca"
 dependencies = [
  "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
  "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -220,17 +220,16 @@ source = "registry+https://github.com/ru
 
 [[package]]
 name = "canvas"
 version = "0.0.1"
 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)",
  "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
  "offscreen_gl_context 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "plugins 0.0.1",
  "util 0.0.1",
  "webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
@@ -238,17 +237,16 @@ dependencies = [
 
 [[package]]
 name = "canvas_traits"
 version = "0.0.1"
 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)",
  "plugins 0.0.1",
  "serde 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
 ]
--- a/servo/ports/cef/Cargo.lock
+++ b/servo/ports/cef/Cargo.lock
@@ -78,17 +78,17 @@ dependencies = [
  "mp3-metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "mp4parse 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ogg_metadata 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "azure"
 version = "0.9.0"
-source = "git+https://github.com/servo/rust-azure#4a2ca5018c97d356a2d2959a074ca98e1f6adba8"
+source = "git+https://github.com/servo/rust-azure#4890bf0b438cbeff4cd269441f4db19a413024ca"
 dependencies = [
  "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
  "heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -193,17 +193,16 @@ source = "registry+https://github.com/ru
 
 [[package]]
 name = "canvas"
 version = "0.0.1"
 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)",
  "num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
  "offscreen_gl_context 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "plugins 0.0.1",
  "util 0.0.1",
  "webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
@@ -211,17 +210,16 @@ dependencies = [
 
 [[package]]
 name = "canvas_traits"
 version = "0.0.1"
 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)",
  "plugins 0.0.1",
  "serde 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender_traits 0.8.0 (git+https://github.com/servo/webrender)",
 ]