aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-02 15:54:52 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-02 15:54:52 -0700
commit99600726f3c25ed205b86a27c764887e0cc1a461 (patch)
treed5ae7be60df591e526b4ae10f9584babe70b01eb
parent68ceb6323172ad1b914064cdc496f4c3a2699f76 (diff)
parent10418a0ea199a0fb5dfe997cd796089c27736652 (diff)
downloadservo-99600726f3c25ed205b86a27c764887e0cc1a461.tar.gz
servo-99600726f3c25ed205b86a27c764887e0cc1a461.zip
auto merge of #4808 : Adenilson/servo/usingColorHelpers01, r=pcwalton
Using color helpers in Compositor and PaintContext (plus added TODO related to equality operators).
-rw-r--r--components/compositing/compositor.rs4
-rw-r--r--components/gfx/paint_context.rs14
2 files changed, 10 insertions, 8 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index c427e4e4a6e..f09eb6b51a8 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -11,13 +11,13 @@ use scrolling::ScrollingTimerProxy;
use windowing;
use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
-use azure::azure_hl;
use std::cmp;
use std::mem;
use geom::point::{Point2D, TypedPoint2D};
use geom::rect::{Rect, TypedRect};
use geom::size::TypedSize2D;
use geom::scale_factor::ScaleFactor;
+use gfx::color;
use gfx::paint_task::Msg as PaintMsg;
use gfx::paint_task::PaintRequest;
use layers::geometry::{DevicePixel, LayerPixel};
@@ -508,7 +508,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
epoch: Epoch(0),
id: LayerId::null(),
rect: Rect::zero(),
- background_color: azure_hl::Color::new(0., 0., 0., 0.),
+ background_color: color::black(),
scroll_policy: ScrollPolicy::Scrollable,
};
diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs
index e20aacf1cf3..7a304bfb4cb 100644
--- a/components/gfx/paint_context.rs
+++ b/components/gfx/paint_context.rs
@@ -13,6 +13,7 @@ use azure::azure_hl::{GaussianBlurAttribute, StrokeOptions, SurfaceFormat};
use azure::scaled_font::ScaledFont;
use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph};
use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs};
+use color;
use display_list::TextOrientation::{SidewaysLeft, SidewaysRight, Upright};
use display_list::{BOX_SHADOW_INFLATION_FACTOR, BorderRadii, ClippingRegion, TextDisplayItem};
use filters;
@@ -153,7 +154,7 @@ impl<'a> PaintContext<'a> {
}
pub fn clear(&self) {
- let pattern = ColorPattern::new(Color::new(0.0, 0.0, 0.0, 0.0));
+ let pattern = ColorPattern::new(color::black());
let rect = Rect(Point2D(self.page_rect.origin.x as AzFloat,
self.page_rect.origin.y as AzFloat),
Size2D(self.screen_rect.size.width as AzFloat,
@@ -728,9 +729,9 @@ impl<'a> PaintContext<'a> {
};
let mut lighter_color;
- let mut darker_color;
-
- if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 {
+ let mut darker_color = color::black();;
+ // TODO(Savago): Use equality operators when we sync with rust-azure.
+ if color.r != darker_color.r || color.g != darker_color.g || color.b != darker_color.b {
darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 });
lighter_color = color;
} else {
@@ -773,8 +774,9 @@ impl<'a> PaintContext<'a> {
let original_bounds = self.get_scaled_bounds(bounds, border, 0.0);
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black).
- let mut scaled_color;
- if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 {
+ let mut scaled_color = color::black();
+ // TODO(Savago): Use equality operators when we sync with rust-azure.
+ if color.r != scaled_color.r || color.g != scaled_color.g || color.b != scaled_color.b {
scaled_color = match direction {
Direction::Top | Direction::Left => {
self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 })