diff --git a/azure_hl.rs b/azure_hl.rs index ab2686f..1fa323f 100644 --- a/azure_hl.rs +++ b/azure_hl.rs @@ -80,6 +80,7 @@ impl AsAzurePoint for Point2D { } } +#[deriving(Clone)] pub struct Color { r: AzFloat, g: AzFloat, @@ -104,6 +105,7 @@ pub struct ColorPattern { } impl Drop for ColorPattern { + #[fixed_stack_segment] fn drop(&self) { unsafe { AzReleaseColorPattern(self.azure_color_pattern); @@ -111,6 +113,7 @@ impl Drop for ColorPattern { } } +#[fixed_stack_segment] pub fn ColorPattern(color: Color) -> ColorPattern { unsafe { ColorPattern { @@ -258,6 +261,7 @@ pub struct DrawTarget { } impl Drop for DrawTarget { + #[fixed_stack_segment] fn drop(&self) { unsafe { match self.skia_context { @@ -270,6 +274,7 @@ impl Drop for DrawTarget { } impl DrawTarget { + #[fixed_stack_segment] pub fn new(backend: BackendType, size: Size2D, format: SurfaceFormat) -> DrawTarget { unsafe { @@ -285,6 +290,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn new_with_data(backend: BackendType, data: ~[u8], offset: uint, @@ -308,6 +314,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn new_with_fbo(backend: BackendType, share_context: AzGLContext, size: Size2D, @@ -329,6 +336,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn clone(&self) -> DrawTarget { unsafe { AzRetainDrawTarget(self.azure_draw_target); @@ -347,6 +355,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn make_current(&self) { match self.skia_context { None => {} @@ -358,6 +367,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn get_texture_id(&self) -> Option { match self.skia_context { None => None, @@ -369,12 +379,14 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn get_size(&self) -> AzIntSize { unsafe { AzDrawTargetGetSize(self.azure_draw_target) } } + #[fixed_stack_segment] pub fn flush(&self) { unsafe { AzDrawTargetFlush(self.azure_draw_target); @@ -385,12 +397,14 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn clear_rect(&self, rect: &Rect) { unsafe { AzDrawTargetClearRect(self.azure_draw_target, &rect.as_azure_rect()); } } + #[fixed_stack_segment] pub fn fill_rect(&self, rect: &Rect, pattern: &ColorPattern) { unsafe { AzDrawTargetFillRect(self.azure_draw_target, @@ -399,6 +413,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn stroke_line(&self, start: Point2D, end: Point2D, @@ -415,6 +430,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn stroke_rect(&self, rect: &Rect, pattern: &ColorPattern, @@ -429,6 +445,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn draw_surface(&self, surface: SourceSurface, dest: Rect, @@ -445,6 +462,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn snapshot(&self) -> SourceSurface { unsafe { let azure_surface = AzDrawTargetGetSnapshot(self.azure_draw_target); @@ -452,6 +470,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn create_source_surface_from_data(&self, data: &[u8], size: Size2D, @@ -470,6 +489,7 @@ impl DrawTarget { } } + #[fixed_stack_segment] pub fn set_transform(&self, matrix: &Matrix2D) { unsafe { AzDrawTargetSetTransform(self.azure_draw_target, transmute(matrix)); @@ -494,6 +514,7 @@ pub struct SourceSurface { } impl Drop for SourceSurface { + #[fixed_stack_segment] fn drop(&self) { unsafe { AzReleaseSourceSurface(self.azure_source_surface); @@ -507,24 +528,39 @@ pub fn SourceSurface(azure_source_surface: AzSourceSurfaceRef) -> SourceSurface } } +// FIXME Rust #8753 no fixed stack segment for default methods +#[fixed_stack_segment] +unsafe fn AzSourceSurfaceGetSize_(aSurface: AzSourceSurfaceRef) -> AzIntSize { + AzSourceSurfaceGetSize(aSurface) +} + +// FIXME Rust #8753 no fixed stack segment for default methods +#[fixed_stack_segment] +unsafe fn AzSourceSurfaceGetFormat_(aSurface: AzSourceSurfaceRef) -> AzSurfaceFormat { + AzSourceSurfaceGetFormat(aSurface) +} + pub trait SourceSurfaceMethods { fn get_azure_source_surface(&self) -> AzSourceSurfaceRef; + #[fixed_stack_segment] fn size(&self) -> Size2D { unsafe { - let size = AzSourceSurfaceGetSize(self.get_azure_source_surface()); + let size = AzSourceSurfaceGetSize_(self.get_azure_source_surface()); Size2D { width: size.width, height: size.height } } } + #[fixed_stack_segment] fn format(&self) -> SurfaceFormat { unsafe { - SurfaceFormat::new(AzSourceSurfaceGetFormat(self.get_azure_source_surface())) + SurfaceFormat::new(AzSourceSurfaceGetFormat_(self.get_azure_source_surface())) } } } impl SourceSurface { + #[fixed_stack_segment] pub fn get_data_surface(&self) -> DataSourceSurface { unsafe { let data_source_surface = AzSourceSurfaceGetDataSurface( @@ -545,6 +581,7 @@ pub struct DataSourceSurface { } impl Drop for DataSourceSurface { + #[fixed_stack_segment] fn drop(&self) { unsafe { AzReleaseSourceSurface(self.azure_data_source_surface); @@ -553,6 +590,7 @@ impl Drop for DataSourceSurface { } impl DataSourceSurface { + #[fixed_stack_segment] pub fn with_data(&self, f: &fn(&[u8])) { unsafe { let buf = AzDataSourceSurfaceGetData(self.azure_data_source_surface); @@ -561,6 +599,7 @@ impl DataSourceSurface { } } + #[fixed_stack_segment] pub fn stride(&self) -> i32 { unsafe { AzDataSourceSurfaceGetStride(self.azure_data_source_surface) @@ -579,6 +618,7 @@ impl SourceSurfaceMethods for DataSourceSurface { } } +#[fixed_stack_segment] pub fn current_gl_context() -> AzGLContext { unsafe { AzSkiaGetCurrentGLContext() @@ -586,6 +626,7 @@ pub fn current_gl_context() -> AzGLContext { } #[cfg(target_os="linux")] +#[fixed_stack_segment] fn current_display() -> *c_void { use glfw; unsafe { glfw::ffi::glfwGetX11Display() } diff --git a/scaled_font.rs b/scaled_font.rs index e77b55d..9e0ae96 100644 --- a/scaled_font.rs +++ b/scaled_font.rs @@ -51,6 +51,7 @@ pub struct ScaledFont { } impl Drop for ScaledFont { + #[fixed_stack_segment] fn drop(&self) { unsafe { AzReleaseScaledFont(self.azure_scaled_font); @@ -65,6 +66,7 @@ impl ScaledFont { #[cfg(target_os="linux")] #[cfg(target_os="android")] + #[fixed_stack_segment] pub fn new(backend: BackendType, native_font: FT_Face, size: AzFloat) -> ScaledFont { use azure::AZ_NATIVE_FONT_SKIA_FONT_FACE; @@ -95,6 +97,7 @@ impl ScaledFont { /// Mac-specific function to create a font for the given backend. #[cfg(target_os="macos")] + #[fixed_stack_segment] pub fn new(backend: BackendType, native_font: &CGFont, size: AzFloat) -> ScaledFont { use azure::AZ_NATIVE_FONT_MAC_FONT_FACE; use azure_hl::{CoreGraphicsBackend,CoreGraphicsAcceleratedBackend}; diff --git a/test.rs b/test.rs index 4af49b2..c7f804f 100644 --- a/test.rs +++ b/test.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #[test] +#[fixed_stack_segment] fn sanity_check() { use azure::AzSanityCheck;