servo: Merge #4808 - Using color helpers in Compositor and PaintContext (from Adenilson:usingColorHelpers01); r=pcwalton

Using color helpers in Compositor and PaintContext (plus added TODO related to equality operators).

Source-Repo: https://github.com/servo/servo
Source-Revision: 99600726f3c25ed205b86a27c764887e0cc1a461
This commit is contained in:
Adenilson Cavalcanti 2015-02-02 15:54:52 -07:00
Родитель ad1e1db195
Коммит 6317f67ce1
2 изменённых файлов: 10 добавлений и 8 удалений

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

@ -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,
};

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

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