Auto merge of #5571 - jdm:gfx_uint, r=Ms2ger

r? @Ms2ger
This commit is contained in:
bors-servo 2015-04-08 03:06:09 -05:00
commit 83d9ab3ba5
13 changed files with 103 additions and 97 deletions

View file

@ -111,19 +111,19 @@ pub fn transform_text(text: &str,
}
}
pub fn float_to_fixed(before: int, f: f64) -> i32 {
((1i32 << before as uint) as f64 * f) as i32
pub fn float_to_fixed(before: usize, f: f64) -> i32 {
((1i32 << before) as f64 * f) as i32
}
pub fn fixed_to_float(before: int, f: i32) -> f64 {
f as f64 * 1.0f64 / ((1i32 << before as uint) as f64)
pub fn fixed_to_float(before: usize, f: i32) -> f64 {
f as f64 * 1.0f64 / ((1i32 << before) as f64)
}
pub fn fixed_to_rounded_int(before: int, f: i32) -> int {
let half = 1i32 << (before-1) as uint;
pub fn fixed_to_rounded_int(before: isize, f: i32) -> isize {
let half = 1i32 << (before-1) as usize;
if f > 0i32 {
((half + f) >> before as uint) as int
((half + f) >> before) as isize
} else {
-((half - f) >> before as uint) as int
-((half - f) >> before) as isize
}
}