mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Using color helpers in Compositor and PaintContext
(plus added TODO related to equality operators).
This commit is contained in:
parent
685412ec48
commit
10418a0ea1
2 changed files with 10 additions and 8 deletions
|
@ -11,13 +11,13 @@ use scrolling::ScrollingTimerProxy;
|
||||||
use windowing;
|
use windowing;
|
||||||
use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
||||||
|
|
||||||
use azure::azure_hl;
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use geom::point::{Point2D, TypedPoint2D};
|
use geom::point::{Point2D, TypedPoint2D};
|
||||||
use geom::rect::{Rect, TypedRect};
|
use geom::rect::{Rect, TypedRect};
|
||||||
use geom::size::TypedSize2D;
|
use geom::size::TypedSize2D;
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
use gfx::color;
|
||||||
use gfx::paint_task::Msg as PaintMsg;
|
use gfx::paint_task::Msg as PaintMsg;
|
||||||
use gfx::paint_task::PaintRequest;
|
use gfx::paint_task::PaintRequest;
|
||||||
use layers::geometry::{DevicePixel, LayerPixel};
|
use layers::geometry::{DevicePixel, LayerPixel};
|
||||||
|
@ -508,7 +508,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
epoch: Epoch(0),
|
epoch: Epoch(0),
|
||||||
id: LayerId::null(),
|
id: LayerId::null(),
|
||||||
rect: Rect::zero(),
|
rect: Rect::zero(),
|
||||||
background_color: azure_hl::Color::new(0., 0., 0., 0.),
|
background_color: color::black(),
|
||||||
scroll_policy: ScrollPolicy::Scrollable,
|
scroll_policy: ScrollPolicy::Scrollable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use azure::azure_hl::{GaussianBlurAttribute, StrokeOptions, SurfaceFormat};
|
||||||
use azure::scaled_font::ScaledFont;
|
use azure::scaled_font::ScaledFont;
|
||||||
use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph};
|
use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph};
|
||||||
use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs};
|
use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs};
|
||||||
|
use color;
|
||||||
use display_list::TextOrientation::{SidewaysLeft, SidewaysRight, Upright};
|
use display_list::TextOrientation::{SidewaysLeft, SidewaysRight, Upright};
|
||||||
use display_list::{BOX_SHADOW_INFLATION_FACTOR, BorderRadii, ClippingRegion, TextDisplayItem};
|
use display_list::{BOX_SHADOW_INFLATION_FACTOR, BorderRadii, ClippingRegion, TextDisplayItem};
|
||||||
use filters;
|
use filters;
|
||||||
|
@ -153,7 +154,7 @@ impl<'a> PaintContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&self) {
|
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,
|
let rect = Rect(Point2D(self.page_rect.origin.x as AzFloat,
|
||||||
self.page_rect.origin.y as AzFloat),
|
self.page_rect.origin.y as AzFloat),
|
||||||
Size2D(self.screen_rect.size.width as AzFloat,
|
Size2D(self.screen_rect.size.width as AzFloat,
|
||||||
|
@ -728,9 +729,9 @@ impl<'a> PaintContext<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut lighter_color;
|
let mut lighter_color;
|
||||||
let mut darker_color;
|
let mut darker_color = color::black();;
|
||||||
|
// TODO(Savago): Use equality operators when we sync with rust-azure.
|
||||||
if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 {
|
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 });
|
darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 });
|
||||||
lighter_color = color;
|
lighter_color = color;
|
||||||
} else {
|
} else {
|
||||||
|
@ -773,8 +774,9 @@ impl<'a> PaintContext<'a> {
|
||||||
let original_bounds = self.get_scaled_bounds(bounds, border, 0.0);
|
let original_bounds = self.get_scaled_bounds(bounds, border, 0.0);
|
||||||
|
|
||||||
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black).
|
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black).
|
||||||
let mut scaled_color;
|
let mut scaled_color = color::black();
|
||||||
if color.r != 0.0 || color.g != 0.0 || color.b != 0.0 {
|
// 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 {
|
scaled_color = match direction {
|
||||||
Direction::Top | Direction::Left => {
|
Direction::Top | Direction::Left => {
|
||||||
self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 })
|
self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 })
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue