Bug 1345975 - Use some enums with repr(u32) directly r?kats draft
authorRyan Hunt <rhunt@eqrion.net>
Thu, 09 Mar 2017 17:39:40 -0500
changeset 496202 1ff190b22dbe3b5d16c487c210e82c5de352b6a9
parent 496201 93c2cdaf1b9310b0a2218a9f255fe4d2ecae6499
child 496203 6a1550bc1f2e70cc29a18343f9893041f0a255bf
push id48552
push userbmo:rhunt@eqrion.net
push dateThu, 09 Mar 2017 23:26:57 +0000
reviewerskats
bugs1345975
milestone55.0a1
Bug 1345975 - Use some enums with repr(u32) directly r?kats MozReview-Commit-ID: Hbr2aNTUhDA
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -45,87 +45,21 @@ macro_rules! check_ffi_type {
 
 check_ffi_type!(_pipeline_id_repr struct PipelineId as (u32, u32));
 check_ffi_type!(_image_key_repr struct ImageKey as (u32, u32));
 check_ffi_type!(_font_key_repr struct FontKey as (u32, u32));
 check_ffi_type!(_epoch_repr struct Epoch as (u32));
 check_ffi_type!(_image_format_repr enum ImageFormat as u32);
 check_ffi_type!(_border_style_repr enum BorderStyle as u32);
 check_ffi_type!(_image_rendering_repr enum ImageRendering as u32);
+check_ffi_type!(_mix_blend_mode_repr enum MixBlendMode as u32);
+check_ffi_type!(_box_shadow_clip_mode_repr enum BoxShadowClipMode as u32);
 check_ffi_type!(_namespace_id_repr struct IdNamespace as (u32));
 
 #[repr(C)]
-pub enum WrBoxShadowClipMode
-{
-    None,
-    Outset,
-    Inset,
-}
-
-impl WrBoxShadowClipMode
-{
-   pub fn to_box_shadow_clip_mode(self) -> BoxShadowClipMode
-   {
-       match self
-       {
-           WrBoxShadowClipMode::None => BoxShadowClipMode::None,
-           WrBoxShadowClipMode::Outset => BoxShadowClipMode::Outset,
-           WrBoxShadowClipMode::Inset => BoxShadowClipMode::Inset,
-       }
-   }
-}
-
-#[repr(C)]
-pub enum WrMixBlendMode
-{
-    Normal,
-    Multiply,
-    Screen,
-    Overlay,
-    Darken,
-    Lighten,
-    ColorDodge,
-    ColorBurn,
-    HardLight,
-    SoftLight,
-    Difference,
-    Exclusion,
-    Hue,
-    Saturation,
-    Color,
-    Luminosity,
-}
-
-impl WrMixBlendMode
-{
-    pub fn to_mix_blend_mode(self) -> MixBlendMode
-    {
-        match self
-        {
-            WrMixBlendMode::Normal => MixBlendMode::Normal,
-            WrMixBlendMode::Multiply => MixBlendMode::Multiply,
-            WrMixBlendMode::Screen => MixBlendMode::Screen,
-            WrMixBlendMode::Overlay => MixBlendMode::Overlay,
-            WrMixBlendMode::Darken => MixBlendMode::Darken,
-            WrMixBlendMode::Lighten => MixBlendMode::Lighten,
-            WrMixBlendMode::ColorDodge => MixBlendMode::ColorDodge,
-            WrMixBlendMode::ColorBurn => MixBlendMode::ColorBurn,
-            WrMixBlendMode::HardLight => MixBlendMode::HardLight,
-            WrMixBlendMode::SoftLight => MixBlendMode::SoftLight,
-            WrMixBlendMode::Difference => MixBlendMode::Difference,
-            WrMixBlendMode::Exclusion => MixBlendMode::Exclusion,
-            WrMixBlendMode::Hue => MixBlendMode::Hue,
-            WrMixBlendMode::Saturation => MixBlendMode::Saturation,
-            WrMixBlendMode::Color => MixBlendMode::Color,
-            WrMixBlendMode::Luminosity => MixBlendMode::Luminosity,
-        }
-    }
-}
-
-#[repr(C)]
 pub enum WrGradientExtendMode
 {
     Clamp,
     Repeat,
 }
 
 impl WrGradientExtendMode
 {
@@ -297,17 +231,16 @@ impl WrBorderRadius
     {
         BorderRadius { top_left: self.top_left.to_size(),
                        top_right: self.top_right.to_size(),
                        bottom_left: self.bottom_left.to_size(),
                        bottom_right: self.bottom_right.to_size() }
     }
 }
 
-
 #[repr(C)]
 pub struct WrImageMask
 {
     image: ImageKey,
     rect: WrRect,
     repeat: bool
 }
 
@@ -970,24 +903,23 @@ pub extern fn wr_dp_new_clip_region(stat
     let mask = unsafe { image_mask.as_ref().map(|x| x.to_image_mask()) };
 
     let clip_region = state.frame_builder.dl_builder.new_clip_region(&main, complex, mask);
 
     clip_region.into()
 }
 
 #[no_mangle]
-pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, overflow: WrRect, mask: *const WrImageMask, opacity: f32, transform: &LayoutTransform, mix_blend_mode: WrMixBlendMode)
+pub extern fn wr_dp_push_stacking_context(state:&mut WrState, bounds: WrRect, overflow: WrRect, mask: *const WrImageMask, opacity: f32, transform: &LayoutTransform, mix_blend_mode: MixBlendMode)
 {
     assert!( unsafe { is_in_main_thread() });
     state.z_index += 1;
 
     let bounds = bounds.to_rect();
     let overflow = overflow.to_rect();
-    let mix_blend_mode = mix_blend_mode.to_mix_blend_mode();
     //println!("stacking context: {:?} {:?} {:?} {:?} {:?}", state.pipeline_id, bounds, overflow, mask, transform);
     // convert from the C type to the Rust type
     let mask = unsafe { mask.as_ref().map(|&WrImageMask{image, ref rect,repeat}| ImageMask{image: image, rect: rect.to_rect(), repeat: repeat}) };
 
     let clip_region2 = state.frame_builder.dl_builder.new_clip_region(&overflow, vec![], None);
     let clip_region = state.frame_builder.dl_builder.new_clip_region(&overflow, vec![], mask);
 
     let mut filters: Vec<FilterOp> = Vec::new();
@@ -1165,28 +1097,28 @@ pub extern fn wr_dp_push_radial_gradient
                                     extend_mode.to_gradient_extend_mode()
                                     );
 }
 
 #[no_mangle]
 pub extern fn wr_dp_push_box_shadow(state: &mut WrState, rect: WrRect, clip: WrClipRegion,
                                     box_bounds: WrRect, offset: WrPoint, color: WrColor,
                                     blur_radius: f32, spread_radius: f32, border_radius: f32,
-                                    clip_mode: WrBoxShadowClipMode) {
+                                    clip_mode: BoxShadowClipMode) {
     assert!( unsafe { is_in_main_thread() });
 
     state.frame_builder.dl_builder.push_box_shadow(rect.to_rect(),
                                                    clip.to_clip_region(),
                                                    box_bounds.to_rect(),
                                                    offset.to_point(),
                                                    color.to_color(),
                                                    blur_radius,
                                                    spread_radius,
                                                    border_radius,
-                                                   clip_mode.to_box_shadow_clip_mode());
+                                                   clip_mode);
 }
 
 #[no_mangle]
 pub unsafe extern fn wr_api_finalize_builder(state: &mut WrState,
                                              dl_descriptor: &mut BuiltDisplayListDescriptor,
                                              dl_data: &mut WrVecU8,
                                              aux_descriptor: &mut AuxiliaryListsDescriptor,
                                              aux_data: &mut WrVecU8)