diff --git a/Makefile.in b/Makefile.in index 238e86d..bfdb2f8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -157,7 +157,7 @@ ALL_OBJS = $(ALL_CPP_SRC:%.cpp=%.o) $(ALL_OBJCPP_SRC:%.mm=%.o) RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs') .PHONY: all -all: libazure.dummy +all: libazure-servo.dummy %.o: %.cpp $(CXX) $< -o $@ -c $(CXXFLAGS) @@ -165,8 +165,8 @@ all: libazure.dummy %.o: %.mm $(CXX) -ObjC++ $< -o $@ -c $(CXXFLAGS) -libazure.dummy: azure.rc $(RUST_SRC) libazure.a $(EXT_DEPS) - $(RUSTC) $(RUSTFLAGS) $< --out-dir . +libazure-servo.dummy: azure.rc $(RUST_SRC) libazure.a $(EXT_DEPS) + $(RUSTC) $(RUSTFLAGS) $< --out-dir . -C extra-filename=-servo touch $@ azure-test: azure.rc $(RUST_SRC) libazure.a diff --git a/azure-c.cpp b/azure-c.cpp index 93398d7..abe4a94 100644 --- a/azure-c.cpp +++ b/azure-c.cpp @@ -388,14 +388,14 @@ AzDrawTargetGetSnapshot(AzDrawTargetRef aDrawTarget) { extern "C" AzSourceSurfaceRef AzDrawTargetCreateSourceSurfaceFromData(AzDrawTargetRef aDrawTarget, - unsigned char *aData, + const unsigned char *aData, AzIntSize *aSize, int32_t aStride, AzSurfaceFormat aFormat) { gfx::DrawTarget *gfxDrawTarget = static_cast(aDrawTarget); gfx::IntSize *gfxSize = reinterpret_cast(aSize); gfx::SurfaceFormat gfxSurfaceFormat = static_cast(aFormat); - RefPtr gfxSourceSurface = gfxDrawTarget->CreateSourceSurfaceFromData(aData, *gfxSize, aStride, gfxSurfaceFormat); + RefPtr gfxSourceSurface = gfxDrawTarget->CreateSourceSurfaceFromData(const_cast(aData), *gfxSize, aStride, gfxSurfaceFormat); gfxSourceSurface->AddRef(); return gfxSourceSurface; } diff --git a/azure-c.h b/azure-c.h index 2393adb..cd0a65b 100644 --- a/azure-c.h +++ b/azure-c.h @@ -362,7 +362,7 @@ void AzDrawTargetDrawSurface(AzDrawTargetRef aDrawTarget, AzDrawOptions *aOptions); AzSourceSurfaceRef AzDrawTargetGetSnapshot(AzDrawTargetRef aDrawTarget); AzSourceSurfaceRef AzDrawTargetCreateSourceSurfaceFromData(AzDrawTargetRef aDrawTarget, - unsigned char *aData, + const unsigned char *aData, AzIntSize *aSize, int32_t aStride, AzSurfaceFormat aFormat); diff --git a/azure.rc b/azure.rc index a5ac942..c00b5bf 100644 --- a/azure.rc +++ b/azure.rc @@ -2,13 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#![crate_id = "github.com/mozilla-servo/rust-azure#azure:0.1"] -#![crate_type = "lib"] -#![crate_type = "dylib"] +#![crate_name = "azure"] #![crate_type = "rlib"] #![feature(globs)] +#![allow(non_snake_case_functions)] + extern crate libc; extern crate std; extern crate sync; diff --git a/azure.rs b/azure.rs index b7b99cd..2050e2f 100644 --- a/azure.rs +++ b/azure.rs @@ -8,7 +8,7 @@ use libc::*; -pub type AzFontOptions = *c_void; +pub type AzFontOptions = *mut c_void; pub type AzFloat = c_float; pub type enum_AzSurfaceType = c_uint; @@ -230,7 +230,7 @@ pub type AzDrawOptions = struct__AzDrawOptions; pub struct struct__AzStrokeOptions { pub mLineWidth: AzFloat, pub mMiterLimit: AzFloat, - pub mDashPattern: *AzFloat, + pub mDashPattern: *mut AzFloat, pub mDashLength: size_t, pub mDashOffset: AzFloat, pub fields: uint8_t, @@ -252,7 +252,7 @@ pub struct struct__AzGlyph { pub type AzGlyph = struct__AzGlyph; pub struct struct__AzGlyphBuffer { - pub mGlyphs: *AzGlyph, + pub mGlyphs: *mut AzGlyph, pub mNumGlyphs: uint32_t, } @@ -260,59 +260,59 @@ pub type AzGlyphBuffer = struct__AzGlyphBuffer; pub struct struct__AzNativeFont { pub mType: enum_AzNativeFontType, - pub mFont: *c_void, + pub mFont: *mut c_void, } pub type AzNativeFont = struct__AzNativeFont; -pub type AzGradientStopsRef = *c_void; +pub type AzGradientStopsRef = *mut c_void; -pub type AzSkiaSharedGLContextRef = *c_void; +pub type AzSkiaSharedGLContextRef = *mut c_void; -pub type AzSkiaSharedGrGLContextRef = *c_void; +pub type AzSkiaSharedGrGLContextRef = *mut c_void; -pub type AzSkiaGrContextRef = *c_void; +pub type AzSkiaGrContextRef = *mut c_void; -pub type AzSkiaGrGLSharedSurfaceRef = *c_void; +pub type AzSkiaGrGLSharedSurfaceRef = *mut c_void; -pub type AzDrawTargetRef = *c_void; +pub type AzDrawTargetRef = *mut c_void; -pub type AzPatternRef = *c_void; +pub type AzPatternRef = *mut c_void; -pub type AzColorPatternRef = *c_void; +pub type AzColorPatternRef = *mut c_void; -pub type AzScaledFontRef = *c_void; +pub type AzScaledFontRef = *mut c_void; -pub type AzGlyphRenderingOptionsRef = *c_void; +pub type AzGlyphRenderingOptionsRef = *mut c_void; -pub type AzSourceSurfaceRef = *c_void; +pub type AzSourceSurfaceRef = *mut c_void; -pub type AzDataSourceSurfaceRef = *c_void; +pub type AzDataSourceSurfaceRef = *mut c_void; -pub type AzDrawSurfaceOptionsRef = *AzDrawSurfaceOptions; +pub type AzDrawSurfaceOptionsRef = *mut AzDrawSurfaceOptions; -pub type AzGLContext = *c_void; +pub type AzGLContext = *mut c_void; -pub type AzSkiaGrGLSharedContextRef = *c_void; +pub type AzSkiaGrGLSharedContextRef = *mut c_void; -pub type AzGLContextMetadataRef = *c_void; +pub type AzGLContextMetadataRef = *mut c_void; -pub type AzGLNativeContextRef = *c_void; +pub type AzGLNativeContextRef = *mut c_void; -pub type AzPathRef = *c_void; +pub type AzPathRef = *mut c_void; -pub type AzPathBuilderRef = *c_void; +pub type AzPathBuilderRef = *mut c_void; #[link(name = "azure")] extern { pub fn AzSanityCheck(/* FIXME: variadic function */); -pub fn AzCreateColorPattern(aColor: *AzColor) -> AzColorPatternRef; +pub fn AzCreateColorPattern(aColor: *mut AzColor) -> AzColorPatternRef; pub fn AzReleaseColorPattern(aColorPattern: AzColorPatternRef); -pub fn AzCreateSkiaSharedGLContext(aNativeContext: AzGLNativeContextRef, aSize: *AzIntSize) +pub fn AzCreateSkiaSharedGLContext(aNativeContext: AzGLNativeContextRef, aSize: *mut AzIntSize) -> AzSkiaSharedGLContextRef; pub fn AzRetainSkiaSharedGLContext(aGLContext: AzSkiaSharedGLContextRef); @@ -329,11 +329,11 @@ pub fn AzSkiaSharedGLContextMakeCurrent(aGLContext: AzSkiaSharedGLContextRef); pub fn AzSkiaSharedGLContextFlush(aGLContext: AzSkiaSharedGLContextRef); -pub fn AzCreateDrawTarget(aBackend: AzBackendType, aSize: *AzIntSize, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; +pub fn AzCreateDrawTarget(aBackend: AzBackendType, aSize: *mut AzIntSize, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; -pub fn AzCreateDrawTargetForData(aBackend: AzBackendType, aData: *c_uchar, aSize: *AzIntSize, aStride: i32, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; +pub fn AzCreateDrawTargetForData(aBackend: AzBackendType, aData: *mut c_uchar, aSize: *mut AzIntSize, aStride: i32, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; -pub fn AzCreateSkiaDrawTargetForFBO(aGLContext: AzSkiaSharedGLContextRef, aSize: *AzIntSize, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; +pub fn AzCreateSkiaDrawTargetForFBO(aGLContext: AzSkiaSharedGLContextRef, aSize: *mut AzIntSize, aFormat: AzSurfaceFormat) -> AzDrawTargetRef; pub fn AzRetainDrawTarget(aTarget: AzDrawTargetRef); @@ -343,30 +343,30 @@ pub fn AzDrawTargetGetSize(aDrawTarget: AzDrawTargetRef) -> AzIntSize; pub fn AzDrawTargetFlush(aDrawTarget: AzDrawTargetRef); -pub fn AzDrawTargetClearRect(aDrawTarget: AzDrawTargetRef, aRect: *AzRect); +pub fn AzDrawTargetClearRect(aDrawTarget: AzDrawTargetRef, aRect: *mut AzRect); pub fn AzDrawTargetFillRect(aDrawTarget: AzDrawTargetRef, - aRect: *AzRect, + aRect: *mut AzRect, aPattern: AzPatternRef, - aDrawOptions: *AzDrawOptions); + aDrawOptions: *mut AzDrawOptions); -pub fn AzDrawTargetStrokeRect(aDrawTarget: AzDrawTargetRef, aRect: *AzRect, aPattern: AzPatternRef, aStrokeOptions: *AzStrokeOptions, aDrawOptions: *AzDrawOptions); +pub fn AzDrawTargetStrokeRect(aDrawTarget: AzDrawTargetRef, aRect: *mut AzRect, aPattern: AzPatternRef, aStrokeOptions: *mut AzStrokeOptions, aDrawOptions: *mut AzDrawOptions); -pub fn AzDrawTargetStrokeLine(aDrawTarget: AzDrawTargetRef, aStart: *AzPoint, aEnd: *AzPoint, aPattern: AzPatternRef, aStrokeOptions: *AzStrokeOptions, aDrawOptions: *AzDrawOptions); +pub fn AzDrawTargetStrokeLine(aDrawTarget: AzDrawTargetRef, aStart: *mut AzPoint, aEnd: *mut AzPoint, aPattern: AzPatternRef, aStrokeOptions: *mut AzStrokeOptions, aDrawOptions: *mut AzDrawOptions); -pub fn AzDrawTargetFill(aDrawTarget: AzDrawTargetRef, aPath: AzPathRef, aPattern: AzPatternRef, aOptions: *AzDrawOptions); +pub fn AzDrawTargetFill(aDrawTarget: AzDrawTargetRef, aPath: AzPathRef, aPattern: AzPatternRef, aOptions: *mut AzDrawOptions); pub fn AzDrawTargetPushClip(aDrawTarget: AzDrawTargetRef, aPath: AzPathRef); pub fn AzDrawTargetPopClip(aDrawTarget: AzDrawTargetRef); -pub fn AzDrawTargetFillGlyphs(aDrawTarget: AzDrawTargetRef, aFont: AzScaledFontRef, aGlyphBuffer: *AzGlyphBuffer, aPattern: AzPatternRef, aOptions: *AzDrawOptions, aRenderingOptions: AzGlyphRenderingOptionsRef); +pub fn AzDrawTargetFillGlyphs(aDrawTarget: AzDrawTargetRef, aFont: AzScaledFontRef, aGlyphBuffer: *mut AzGlyphBuffer, aPattern: AzPatternRef, aOptions: *mut AzDrawOptions, aRenderingOptions: AzGlyphRenderingOptionsRef); -pub fn AzDrawTargetDrawSurface(aDrawTarget: AzDrawTargetRef, aSurface: AzSourceSurfaceRef, aDest: *AzRect, aSource: *AzRect, aSurfOptions: AzDrawSurfaceOptionsRef, aOptions: *AzDrawOptions); +pub fn AzDrawTargetDrawSurface(aDrawTarget: AzDrawTargetRef, aSurface: AzSourceSurfaceRef, aDest: *mut AzRect, aSource: *mut AzRect, aSurfOptions: AzDrawSurfaceOptionsRef, aOptions: *mut AzDrawOptions); pub fn AzDrawTargetGetSnapshot(aDrawTarget: AzDrawTargetRef) -> AzSourceSurfaceRef; -pub fn AzDrawTargetCreateSourceSurfaceFromData(aDrawTarget: AzDrawTargetRef, aData: *u8, aSize: *AzIntSize, aStride: i32, aFormat: AzSurfaceFormat) -> AzSourceSurfaceRef; +pub fn AzDrawTargetCreateSourceSurfaceFromData(aDrawTarget: AzDrawTargetRef, aData: *const u8, aSize: *mut AzIntSize, aStride: i32, aFormat: AzSurfaceFormat) -> AzSourceSurfaceRef; pub fn AzReleaseSourceSurface(aSurface: AzSourceSurfaceRef); @@ -376,21 +376,21 @@ pub fn AzSourceSurfaceGetFormat(aSurface: AzSourceSurfaceRef) -> AzSurfaceFormat pub fn AzSourceSurfaceGetDataSurface(aSurface: AzSourceSurfaceRef) -> AzDataSourceSurfaceRef; -pub fn AzDataSourceSurfaceGetData(aSurface: AzDataSourceSurfaceRef) -> *u8; +pub fn AzDataSourceSurfaceGetData(aSurface: AzDataSourceSurfaceRef) -> *mut u8; pub fn AzDataSourceSurfaceGetStride(aSurface: AzDataSourceSurfaceRef) -> i32; -pub fn AzCreateScaledFontForNativeFont(aNativeFont: *AzNativeFont, aSize: AzFloat) -> AzScaledFontRef; +pub fn AzCreateScaledFontForNativeFont(aNativeFont: *mut AzNativeFont, aSize: AzFloat) -> AzScaledFontRef; pub fn AzReleaseScaledFont(aFont: AzScaledFontRef); -pub fn AzDrawTargetSetTransform(aDrawTarget: AzDrawTargetRef, aTransform: *AzMatrix); +pub fn AzDrawTargetSetTransform(aDrawTarget: AzDrawTargetRef, aTransform: *mut AzMatrix); -pub fn AzCreateFontOptionsForData(aFontData: *u8, aFontDataSize: u32) -> *AzFontOptions; +pub fn AzCreateFontOptionsForData(aFontData: *const u8, aFontDataSize: u32) -> *mut AzFontOptions; -pub fn AzCreateFontOptionsForName(aName: *c_char, aStyle: enum_AzFontStyle) -> *AzFontOptions; +pub fn AzCreateFontOptionsForName(aName: *const c_char, aStyle: enum_AzFontStyle) -> *mut AzFontOptions; -pub fn AzDestroyFontOptions(aOptions: *AzFontOptions); +pub fn AzDestroyFontOptions(aOptions: *mut AzFontOptions); pub fn AzSkiaGetCurrentGLContext() -> AzGLContext; @@ -398,9 +398,9 @@ pub fn AzCreatePathBuilder(aDrawTarget: AzDrawTargetRef) -> AzPathBuilderRef; pub fn AzReleasePathBuilder(aPathBuilder: AzPathBuilderRef); -pub fn AzPathBuilderMoveTo(aPathBuilder: AzPathBuilderRef, aPoint: *AzPoint); +pub fn AzPathBuilderMoveTo(aPathBuilder: AzPathBuilderRef, aPoint: *mut AzPoint); -pub fn AzPathBuilderLineTo(aPathBuilder: AzPathBuilderRef, aPoint: *AzPoint); +pub fn AzPathBuilderLineTo(aPathBuilder: AzPathBuilderRef, aPoint: *mut AzPoint); pub fn AzPathBuilderFinish(aPathBuilder: AzPathBuilderRef) -> AzPathRef; diff --git a/azure_hl.rs b/azure_hl.rs index f451b90..69c0670 100644 --- a/azure_hl.rs +++ b/azure_hl.rs @@ -40,7 +40,6 @@ use libc::types::common::c99::{uint8_t, uint16_t}; use libc::size_t; use std::mem; use std::ptr; -use std::ptr::null; use std::slice; #[cfg(target_os="linux")] @@ -123,7 +122,7 @@ impl ColorPattern { pub fn new(color: Color) -> ColorPattern { unsafe { ColorPattern { - azure_color_pattern: AzCreateColorPattern(&color.as_azure_color()) + azure_color_pattern: AzCreateColorPattern(&mut color.as_azure_color()) } } } @@ -161,7 +160,7 @@ pub enum CompositionOp { pub struct StrokeOptions { pub line_width: AzFloat, pub miter_limit: AzFloat, - pub mDashPattern: *AzFloat, + pub mDashPattern: *mut AzFloat, pub mDashLength: size_t, pub fields: uint8_t } @@ -171,7 +170,7 @@ impl StrokeOptions { StrokeOptions { line_width: line_width, miter_limit: miter_limit, - mDashPattern: null(), + mDashPattern: ptr::mut_null(), mDashLength: 0, fields: AZ_CAP_BUTT as u8 << 4 | AZ_JOIN_MITER_OR_BEVEL as u8 } @@ -347,9 +346,9 @@ impl DrawTarget { -> DrawTarget { unsafe { let azure_draw_target = AzCreateDrawTarget(backend.as_azure_backend_type(), - &size.as_azure_int_size(), + &mut size.as_azure_int_size(), format.as_azure_surface_format()); - if azure_draw_target == ptr::null() { fail!("null azure draw target"); } + if azure_draw_target == ptr::mut_null() { fail!("null azure draw target"); } DrawTarget { azure_draw_target: azure_draw_target, data: None, @@ -359,7 +358,7 @@ impl DrawTarget { } pub fn new_with_data(backend: BackendType, - data: Vec, + mut data: Vec, offset: uint, size: Size2D, stride: i32, @@ -368,11 +367,11 @@ impl DrawTarget { assert!((data.len() - offset) as i32 >= stride * size.height); let azure_draw_target = AzCreateDrawTargetForData(backend.as_azure_backend_type(), - data.get(offset), - &size.as_azure_int_size(), + data.get_mut(offset), + &mut size.as_azure_int_size(), stride, format.as_azure_surface_format()); - if azure_draw_target == ptr::null() { fail!("null azure draw target"); } + if azure_draw_target == ptr::mut_null() { fail!("null azure draw target"); } DrawTarget { azure_draw_target: azure_draw_target, data: Some(Arc::new(data)), @@ -389,11 +388,11 @@ impl DrawTarget { unsafe { let native_graphics_context = mem::transmute(native_graphics_context); let skia_context = AzCreateSkiaSharedGLContext(native_graphics_context, - &size.as_azure_int_size()); + &mut size.as_azure_int_size()); let azure_draw_target = AzCreateSkiaDrawTargetForFBO(skia_context, - &size.as_azure_int_size(), + &mut size.as_azure_int_size(), format.as_azure_surface_format()); - if azure_draw_target == ptr::null() { + if azure_draw_target == ptr::mut_null() { fail!("null azure draw target"); } DrawTarget { @@ -465,7 +464,7 @@ impl DrawTarget { pub fn clear_rect(&self, rect: &Rect) { unsafe { - AzDrawTargetClearRect(self.azure_draw_target, &rect.as_azure_rect()); + AzDrawTargetClearRect(self.azure_draw_target, &mut rect.as_azure_rect()); } } @@ -474,7 +473,7 @@ impl DrawTarget { AzDrawTargetFill(self.azure_draw_target, path.azure_path, pattern.azure_color_pattern, - &draw_options.as_azure_draw_options()); + &mut draw_options.as_azure_draw_options()); } } @@ -487,14 +486,14 @@ impl DrawTarget { draw_options.as_azure_draw_options() }); let draw_options = match draw_options { - None => ptr::null(), - Some(draw_options) => { - let draw_options: *AzDrawOptions = &draw_options; + None => ptr::mut_null(), + Some(mut draw_options) => { + let draw_options: *mut AzDrawOptions = &mut draw_options; draw_options } }; AzDrawTargetFillRect(self.azure_draw_target, - &rect.as_azure_rect(), + &mut rect.as_azure_rect(), pattern.azure_color_pattern, draw_options); } @@ -508,11 +507,11 @@ impl DrawTarget { draw_options: &DrawOptions) { unsafe { AzDrawTargetStrokeLine(self.azure_draw_target, - &start.as_azure_point(), - &end.as_azure_point(), + &mut start.as_azure_point(), + &mut end.as_azure_point(), pattern.azure_color_pattern, - &stroke_options.as_azure_stroke_options(), - &draw_options.as_azure_draw_options()); + &mut stroke_options.as_azure_stroke_options(), + &mut draw_options.as_azure_draw_options()); } } @@ -523,10 +522,10 @@ impl DrawTarget { draw_options: &DrawOptions) { unsafe { AzDrawTargetStrokeRect(self.azure_draw_target, - &rect.as_azure_rect(), + &mut rect.as_azure_rect(), pattern.azure_color_pattern, - &stroke_options.as_azure_stroke_options(), - &draw_options.as_azure_draw_options()); + &mut stroke_options.as_azure_stroke_options(), + &mut draw_options.as_azure_draw_options()); } } @@ -539,10 +538,10 @@ impl DrawTarget { unsafe { AzDrawTargetDrawSurface(self.azure_draw_target, surface.azure_source_surface, - &dest.as_azure_rect(), - &source.as_azure_rect(), - &surf_options.as_azure_draw_surface_options(), - &options.as_azure_draw_options()); + &mut dest.as_azure_rect(), + &mut source.as_azure_rect(), + &mut surf_options.as_azure_draw_surface_options(), + &mut options.as_azure_draw_options()); } } @@ -564,7 +563,7 @@ impl DrawTarget { let azure_surface = AzDrawTargetCreateSourceSurfaceFromData( self.azure_draw_target, &data[0], - &size.as_azure_int_size(), + &mut size.as_azure_int_size(), stride, format.as_azure_surface_format()); SourceSurface::new(azure_surface) @@ -577,16 +576,18 @@ impl DrawTarget { } } - pub fn fill_glyphs(&self, azfontref: AzScaledFontRef, glyphbuf: struct__AzGlyphBuffer, - azure_pattern: AzColorPatternRef, - options: struct__AzDrawOptions, - renderingOptions: AzGlyphRenderingOptionsRef) { + pub fn fill_glyphs(&self, + azfontref: AzScaledFontRef, + mut glyphbuf: struct__AzGlyphBuffer, + azure_pattern: AzColorPatternRef, + mut options: struct__AzDrawOptions, + renderingOptions: AzGlyphRenderingOptionsRef) { unsafe { AzDrawTargetFillGlyphs(self.azure_draw_target, azfontref, - &glyphbuf, + &mut glyphbuf, azure_pattern, - &options, + &mut options, renderingOptions); } } @@ -696,7 +697,7 @@ impl Drop for DataSourceSurface { impl DataSourceSurface { pub fn with_data(&self, f: |&[u8]|) { unsafe { - let buf = AzDataSourceSurfaceGetData(self.azure_data_source_surface); + let buf = AzDataSourceSurfaceGetData(self.azure_data_source_surface) as *const u8; let len = self.stride() * self.size().height; slice::raw::buf_as_slice(buf, len as uint, f); } @@ -739,15 +740,15 @@ pub struct PathBuilder { impl PathBuilder { pub fn move_to(&self, point: Point2D) { unsafe { - let az_point = point.as_azure_point(); - AzPathBuilderMoveTo(self.azure_path_builder, &az_point); + let mut az_point = point.as_azure_point(); + AzPathBuilderMoveTo(self.azure_path_builder, &mut az_point); } } pub fn line_to(&self, point: Point2D) { unsafe { - let az_point = point.as_azure_point(); - AzPathBuilderLineTo(self.azure_path_builder, &az_point); + let mut az_point = point.as_azure_point(); + AzPathBuilderLineTo(self.azure_path_builder, &mut az_point); } } @@ -776,7 +777,7 @@ pub fn current_gl_context() -> AzGLContext { } #[cfg(target_os="linux")] -pub fn current_display() -> *c_void { +pub fn current_display() -> *mut c_void { use glfw; unsafe { glfw::ffi::glfwGetX11Display() diff --git a/linkhack.rs b/linkhack.rs index 0d7f7cf..ad2b26d 100644 --- a/linkhack.rs +++ b/linkhack.rs @@ -5,9 +5,9 @@ // Some crumminess to make sure we link correctly #[cfg(target_os = "linux")] -#[link(name = "azure")] +#[link(name = "azure", kind = "static")] #[link(name = "stdc++")] -#[link(name = "skia")] +#[link(name = "skia", kind = "static")] // skia must come before freetype for linking to succeed #[link(name = "freetype")] // fontconfig must come before expat for linking to succeed @@ -17,18 +17,18 @@ extern { } #[cfg(target_os = "android")] -#[link(name = "azure")] +#[link(name = "azure", kind = "static")] #[link(name = "stdc++")] -#[link(name = "skia")] +#[link(name = "skia", kind = "static")] #[link(name = "expat")] #[link(name = "fontconfig")] #[link(name = "EGL")] extern { } #[cfg(target_os = "macos")] -#[link(name = "azure")] +#[link(name = "azure", kind = "static")] #[link(name = "stdc++")] -#[link(name = "skia")] +#[link(name = "skia", kind = "static")] #[link(name = "objc")] #[link(name = "IOSurface", kind = "framework")] #[link(name = "OpenGL", kind = "framework")] diff --git a/scaled_font.rs b/scaled_font.rs index fa638e1..390d4b5 100644 --- a/scaled_font.rs +++ b/scaled_font.rs @@ -45,7 +45,7 @@ pub mod android { pub use scaled_font::android::freetype::freetype::{FT_Face, FT_LOAD_DEFAULT}; } -pub type SkTypeface = *c_void; +pub type SkTypeface = *mut c_void; #[cfg(target_os="linux")] #[cfg(target_os="android")] @@ -80,7 +80,7 @@ impl ScaledFont { let mut azure_native_font = struct__AzNativeFont { mType: 0, - mFont: ptr::null() + mFont: ptr::mut_null() }; match backend { @@ -90,7 +90,7 @@ impl ScaledFont { 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) + AzCreateFontOptionsForName(&*(*native_font).family_name, style) }, FontData(bytes) => { AzCreateFontOptionsForData(bytes.as_ptr(), bytes.len() as u32) @@ -98,7 +98,7 @@ impl ScaledFont { }; azure_native_font.mType = AZ_NATIVE_FONT_SKIA_FONT_FACE; azure_native_font.mFont = mem::transmute(options); - let azure_native_font_ptr = &azure_native_font; + let azure_native_font_ptr = &mut azure_native_font; let azure_scaled_font = AzCreateScaledFontForNativeFont(azure_native_font_ptr, size); AzDestroyFontOptions(options); ScaledFont { azure_scaled_font: azure_scaled_font } @@ -117,7 +117,7 @@ impl ScaledFont { let mut azure_native_font = struct__AzNativeFont { mType: 0, - mFont: ptr::null() + mFont: ptr::mut_null() }; match backend { @@ -133,7 +133,7 @@ impl ScaledFont { } unsafe { - let azure_scaled_font = AzCreateScaledFontForNativeFont(&azure_native_font, size); + let azure_scaled_font = AzCreateScaledFontForNativeFont(&mut azure_native_font, size); ScaledFont { azure_scaled_font: azure_scaled_font } @@ -146,6 +146,6 @@ impl ScaledFont { #[cfg(target_os="macos")] #[link(name = "skia")] extern { - pub fn _Z26SkCreateTypefaceFromCTFontPK8__CTFont(font: CTFontRef) -> *SkTypeface; + pub fn _Z26SkCreateTypefaceFromCTFontPK8__CTFont(font: CTFontRef) -> *mut SkTypeface; }