From 8d7c7af5fdda839bae9ae69a2044e7cfd55f0a44 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 28 Nov 2014 13:36:06 +0100 Subject: [PATCH] Update for namespaced enums. --- src/azure_hl.rs | 30 ++++++++++++++++-------------- src/scaled_font.rs | 7 ++++--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/azure_hl.rs b/src/azure_hl.rs index 3ae2069..a06b9de 100644 --- a/src/azure_hl.rs +++ b/src/azure_hl.rs @@ -258,10 +258,10 @@ impl SurfaceFormat { pub fn new(azure_surface_format: AzSurfaceFormat) -> SurfaceFormat { match azure_surface_format { - 0 => B8G8R8A8, - 1 => B8G8R8X8, - 2 => R5G6B5, - 3 => A8, + 0 => SurfaceFormat::B8G8R8A8, + 1 => SurfaceFormat::B8G8R8X8, + 2 => SurfaceFormat::R5G6B5, + 3 => SurfaceFormat::A8, _ => panic!("SurfaceFormat::new(): unknown Azure surface format") } } @@ -313,13 +313,13 @@ pub enum BackendType { impl BackendType { pub fn as_azure_backend_type(self) -> AzBackendType { match self { - NoBackend => 0, - Direct2DBackend => 1, - CoreGraphicsBackend => 2, - CoreGraphicsAcceleratedBackend => 3, - CairoBackend => 4, - SkiaBackend => 5, - RecordingBackend => 6, + BackendType::NoBackend => 0, + BackendType::Direct2DBackend => 1, + BackendType::CoreGraphicsBackend => 2, + BackendType::CoreGraphicsAcceleratedBackend => 3, + BackendType::CairoBackend => 4, + BackendType::SkiaBackend => 5, + BackendType::RecordingBackend => 6, } } } @@ -394,7 +394,7 @@ impl DrawTarget { native_graphics_context: &NativePaintingGraphicsContext, size: Size2D, format: SurfaceFormat) -> DrawTarget { - assert!(backend == SkiaBackend); + assert!(backend == BackendType::SkiaBackend); let native_graphics_context = native_graphics_context as *const _ as AzGLNativeContextRef; let skia_context = unsafe { AzCreateSkiaSharedGLContext(native_graphics_context, @@ -906,8 +906,10 @@ pub enum PatternRef<'a> { impl<'a> PatternRef<'a> { fn as_azure_pattern(&self) -> AzPatternRef { match *self { - ColorPatternRef(color_pattern) => color_pattern.azure_color_pattern, - LinearGradientPatternRef(linear_gradient_pattern) => { + PatternRef::ColorPatternRef(color_pattern) => { + color_pattern.azure_color_pattern + }, + PatternRef::LinearGradientPatternRef(linear_gradient_pattern) => { linear_gradient_pattern.azure_linear_gradient_pattern } } diff --git a/src/scaled_font.rs b/src/scaled_font.rs index 09cd2ac..3b5e856 100644 --- a/src/scaled_font.rs +++ b/src/scaled_font.rs @@ -5,7 +5,8 @@ use azure::{AzScaledFontRef, AzFloat}; use azure::{struct__AzNativeFont}; -use azure_hl::{BackendType,SkiaBackend}; +use azure_hl::BackendType; +use azure_hl::BackendType::SkiaBackend; use azure::{AzCreateScaledFontForNativeFont, AzReleaseScaledFont}; use libc::c_void; @@ -77,12 +78,12 @@ impl ScaledFont { SkiaBackend => { unsafe { let options = match font_info { - NativeFont(native_font) => { + FontInfo::NativeFont(native_font) => { // NOTE: azure style flags and freetype style flags are the same in the lowest 2 bits let style = ((*native_font).style_flags & 3) as u32; AzCreateFontOptionsForName(&*(*native_font).family_name, style) }, - FontData(bytes) => { + FontInfo::FontData(bytes) => { AzCreateFontOptionsForData(bytes.as_ptr(), bytes.len() as u32) }, };