From 6ec7484ac0f631ab11037edf520db0e606d2a14a Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Thu, 12 Feb 2015 10:21:38 -0800 Subject: [PATCH] Remove the second color type and move the auxiliar function to servo's color.rs. --- src/azure.rs | 2 +- src/azure_hl.rs | 31 +++---------------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/azure.rs b/src/azure.rs index a43b076..d8ba0e8 100644 --- a/src/azure.rs +++ b/src/azure.rs @@ -244,7 +244,7 @@ pub static AZ_ATT_TRANSFER_DISABLE_B: u32 = 2; pub static AZ_ATT_TRANSFER_DISABLE_A: u32 = 3; #[repr(C)] -#[derive(Clone)] +#[derive(Copy, Clone)] pub struct struct__AzColor { pub r: AzFloat, pub g: AzFloat, diff --git a/src/azure_hl.rs b/src/azure_hl.rs index 1bfd662..5a7992f 100644 --- a/src/azure_hl.rs +++ b/src/azure_hl.rs @@ -4,6 +4,7 @@ //! High-level bindings to Azure. +pub use AzColor as Color; use azure::{AZ_CAP_BUTT, AZ_JOIN_MITER_OR_BEVEL, AZ_FILTER_TYPE_COLOR_MATRIX}; use azure::{AZ_FILTER_TYPE_FLOOD, AZ_FILTER_TYPE_GAUSSIAN_BLUR, AZ_FILTER_TYPE_LINEAR_TRANSFER}; use azure::{AZ_FILTER_TYPE_TABLE_TRANSFER, AZ_IN_COLOR_MATRIX_IN, AZ_IN_COMPOSITE_IN}; @@ -109,32 +110,6 @@ impl AsAzurePoint for Point2D { } } -#[derive(Copy, Clone)] -pub struct Color { - pub r: AzFloat, - pub g: AzFloat, - pub b: AzFloat, - pub a: AzFloat, -} - -impl Color { - pub fn new(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> Color { - Color { r: r, g: g, b: b, a: a } - } - - fn as_azure_color(&self) -> AzColor { - struct__AzColor { r: self.r, g: self.g, b: self.b, a: self.a } - } -} - -#[inline] -impl PartialEq for Color { - fn eq(&self, other: &Color) -> bool { - self.r == other.r && self.g == other.g && self.b == other.b && self.a == other.a - } -} - - // FIXME: Should have a class hierarchy here starting with Pattern. pub struct ColorPattern { pub azure_color_pattern: AzColorPatternRef, @@ -152,7 +127,7 @@ impl ColorPattern { pub fn new(color: Color) -> ColorPattern { unsafe { ColorPattern { - azure_color_pattern: AzCreateColorPattern(&mut color.as_azure_color()) + azure_color_pattern: AzCreateColorPattern(&mut color.clone()) } } } @@ -1187,7 +1162,7 @@ impl FilterAttribute for FloodAttribute { unsafe { AzFilterNodeSetColorAttribute(filter_node.azure_filter_node, AZ_ATT_FLOOD_COLOR, - &value.as_azure_color()) + &value) } } }