aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-10-31 14:58:03 -0500
committerGitHub <noreply@github.com>2016-10-31 14:58:03 -0500
commit1a213bf22d48fc3cf8882f609e3aa7fe8ba2f60a (patch)
tree97de23c91b4f0b3ddd6e78d5c0749cd6f246e590
parentceb18e7d8624a6d78e3f712dc335928adaa7dc79 (diff)
parenta9e3fe75b542882368b0ef5c1d360a1fd651e8ab (diff)
downloadservo-1a213bf22d48fc3cf8882f609e3aa7fe8ba2f60a.tar.gz
servo-1a213bf22d48fc3cf8882f609e3aa7fe8ba2f60a.zip
Auto merge of #14004 - servo:gfx, r=glennw
Various gfx cleanup. <!-- 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/14004) <!-- Reviewable:end -->
-rw-r--r--components/canvas/Cargo.toml1
-rw-r--r--components/canvas/canvas_paint_thread.rs15
-rw-r--r--components/canvas/lib.rs1
-rw-r--r--components/canvas_traits/Cargo.toml1
-rw-r--r--components/canvas_traits/lib.rs21
-rw-r--r--components/gfx/font_context.rs59
-rw-r--r--components/gfx_traits/color.rs41
-rw-r--r--components/gfx_traits/lib.rs1
-rw-r--r--components/layout/display_list_builder.rs10
-rw-r--r--components/layout_thread/lib.rs12
-rw-r--r--components/servo/Cargo.lock4
-rw-r--r--ports/cef/Cargo.lock4
12 files changed, 28 insertions, 142 deletions
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml
index d94cdb22818..80976a68577 100644
--- a/components/canvas/Cargo.toml
+++ b/components/canvas/Cargo.toml
@@ -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"
diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs
index 238ff9c06db..b87470f53c6 100644
--- a/components/canvas/canvas_paint_thread.rs
+++ b/components/canvas/canvas_paint_thread.rs
@@ -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;
}
diff --git a/components/canvas/lib.rs b/components/canvas/lib.rs
index 027036db74c..752207aa127 100644
--- a/components/canvas/lib.rs
+++ b/components/canvas/lib.rs
@@ -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]
diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml
index eae4b94e294..bf085994f0b 100644
--- a/components/canvas_traits/Cargo.toml
+++ b/components/canvas_traits/Cargo.toml
@@ -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"
diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs
index 2fa18937c17..2024d7e14ce 100644
--- a/components/canvas_traits/lib.rs
+++ b/components/canvas_traits/lib.rs
@@ -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)
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index 1ffa1b32c21..f5a7b9659a5 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -3,10 +3,6 @@
* 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;
@@ -23,23 +19,10 @@ 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)]
@@ -53,15 +36,6 @@ 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;
@@ -79,10 +53,6 @@ pub struct FontContext {
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>>,
@@ -97,7 +67,6 @@ impl FontContext {
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,
}
@@ -133,7 +102,6 @@ impl FontContext {
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
}
@@ -260,33 +228,6 @@ impl FontContext {
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 {
diff --git a/components/gfx_traits/color.rs b/components/gfx_traits/color.rs
deleted file mode 100644
index a128d364432..00000000000
--- a/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 }
-}
diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs
index bdf1a7591eb..a198a436dfb 100644
--- a/components/gfx_traits/lib.rs
+++ b/components/gfx_traits/lib.rs
@@ -19,7 +19,6 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;
-pub mod color;
pub mod print_tree;
use range::RangeIndex;
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index d665734f947..bcf3f0f8f6c 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -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)
}
}
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 71d98a21e4f..b531e035c68 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -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();
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index de2f30c74ac..be7ade81c54 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -110,7 +110,7 @@ dependencies = [
[[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)",
@@ -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)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index a34bbbb4334..eb159a59e02 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -83,7 +83,7 @@ dependencies = [
[[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)",
@@ -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)",