remove @ from FontContextHandle in linux

This commit is contained in:
patrick kim 2013-12-03 20:02:22 +09:00
parent dda6d2b53c
commit c60ab361a5
2 changed files with 45 additions and 20 deletions

View file

@ -8,6 +8,7 @@ use font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTableMethods};
use font::{FontTableTag, FractionalPixel, SpecifiedFontStyle, UsedFontStyle, FontWeight100};
use font::{FontWeight200, FontWeight300, FontWeight400, FontWeight500, FontWeight600};
use font::{FontWeight700, FontWeight800, FontWeight900};
use font_context::FontContextHandleMethods;
use servo_util::geometry::Au;
use servo_util::geometry;
use platform::font_context::FontContextHandle;
@ -93,7 +94,7 @@ impl FontHandleMethods for FontHandle {
let handle = FontHandle {
face: face,
source: FontSourceMem(buf),
handle: *fctx
handle: fctx.clone()
};
Ok(handle)
}
@ -295,7 +296,7 @@ impl<'self> FontHandle {
Ok(FontHandle {
source: FontSourceFile(file.to_str()),
face: face,
handle: *fctx
handle: fctx.clone()
})
} else {
Err(())
@ -323,7 +324,7 @@ impl<'self> FontHandle {
Ok(FontHandle {
source: FontSourceFile(file),
face: face,
handle: *fctx
handle: fctx.clone()
})
}
}

View file

@ -12,34 +12,53 @@ use freetype::freetype::{FT_Done_FreeType, FT_Init_FreeType};
use std::ptr;
#[deriving(Clone)]
struct FreeTypeLibraryHandle {
ctx: FT_Library,
}
impl Drop for FreeTypeLibraryHandle {
#[fixed_stack_segment]
fn drop(&mut self) {
assert!(self.ctx.is_not_null());
unsafe {
FT_Done_FreeType(self.ctx);
}
}
// FIXME(ksh8281) this value have to use atomic operation for counting ref
static mut font_context_ref_count: uint = 0;
static mut ft_pointer: Option<FT_Library> = None;
pub struct FontContextHandle {
ctx: FreeTypeLibraryHandle,
}
pub struct FontContextHandle {
ctx: @FreeTypeLibraryHandle,
impl Drop for FontContextHandle {
#[fixed_stack_segment]
fn drop(&mut self) {
assert!(self.ctx.ctx.is_not_null());
unsafe {
assert!(font_context_ref_count >= 1);
font_context_ref_count = font_context_ref_count - 1;
if font_context_ref_count == 0 {
FT_Done_FreeType(self.ctx.ctx);
}
}
}
}
impl FontContextHandle {
#[fixed_stack_segment]
pub fn new() -> FontContextHandle {
unsafe {
let ctx: FT_Library = ptr::null();
let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx));
if !result.succeeded() { fail!(); }
FontContextHandle {
ctx: @FreeTypeLibraryHandle { ctx: ctx },
match ft_pointer {
Some(ref ctx) => {
font_context_ref_count = font_context_ref_count + 1;
FontContextHandle {
ctx: FreeTypeLibraryHandle { ctx: ctx.clone() },
}
},
None => {
let ctx: FT_Library = ptr::null();
let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx));
if !result.succeeded() { fail!(); }
ft_pointer = Some(ctx);
font_context_ref_count = font_context_ref_count + 1;
FontContextHandle {
ctx: FreeTypeLibraryHandle { ctx: ctx },
}
}
}
}
}
@ -47,7 +66,12 @@ impl FontContextHandle {
impl FontContextHandleMethods for FontContextHandle {
fn clone(&self) -> FontContextHandle {
FontContextHandle { ctx: self.ctx }
unsafe {
font_context_ref_count = font_context_ref_count + 1;
FontContextHandle{
ctx: self.ctx.clone()
}
}
}
fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle)