Rename Au methods with f32/f64 instead of frac32/frac/subpx

This commit is contained in:
Simon Sapin 2015-05-05 18:23:29 +02:00
parent 32d5e24922
commit 8b522f2e7d
23 changed files with 99 additions and 99 deletions

View file

@ -489,9 +489,9 @@ impl StackingContext {
point = point - self.bounds.origin;
debug_assert!(!topmost_only || result.is_empty());
let frac_point = self.transform.transform_point(&Point2D(point.x.to_frac32_px(),
point.y.to_frac32_px()));
point = Point2D(Au::from_frac32_px(frac_point.x), Au::from_frac32_px(frac_point.y));
let frac_point = self.transform.transform_point(&Point2D(point.x.to_f32_px(),
point.y.to_f32_px()));
point = Point2D(Au::from_f32_px(frac_point.x), Au::from_f32_px(frac_point.y));
// Iterate through display items in reverse stacking order. Steps here refer to the
// painting steps in CSS 2.1 Appendix E.

View file

@ -95,7 +95,7 @@ pub fn create_filters(draw_target: &DrawTarget,
}
filter::Filter::Blur(amount) => {
*accumulated_blur_radius = accumulated_blur_radius.clone() + amount;
let amount = amount.to_frac32_px();
let amount = amount.to_f32_px();
let blur = draw_target.create_filter(FilterType::GaussianBlur);
blur.set_attribute(GaussianBlurAttribute::StdDeviation(amount));
blur.set_input(GaussianBlurInput, &filter);

View file

@ -36,13 +36,13 @@ use azure::scaled_font::FontInfo;
#[cfg(any(target_os="linux", target_os = "android"))]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes),
pt_size.to_subpx() as AzFloat)
pt_size.to_f64_px() as AzFloat)
}
#[cfg(target_os="macos")]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
let cgfont = template.ctfont.as_ref().unwrap().copy_to_CGFont();
ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_subpx() as AzFloat)
ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f64_px() as AzFloat)
}
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)

View file

@ -826,16 +826,16 @@ impl<'a> PaintContext<'a> {
let baseline_origin = match text.orientation {
Upright => text.baseline_origin,
SidewaysLeft => {
let x = text.baseline_origin.x.to_subpx() as AzFloat;
let y = text.baseline_origin.y.to_subpx() as AzFloat;
let x = text.baseline_origin.x.to_f64_px() as AzFloat;
let y = text.baseline_origin.y.to_f64_px() as AzFloat;
self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., -1.,
1., 0.,
x, y)));
Point2D::zero()
}
SidewaysRight => {
let x = text.baseline_origin.x.to_subpx() as AzFloat;
let y = text.baseline_origin.y.to_subpx() as AzFloat;
let x = text.baseline_origin.x.to_f64_px() as AzFloat;
let y = text.baseline_origin.y.to_f64_px() as AzFloat;
self.draw_target.set_transform(&draw_target_transform.mul(&Matrix2D::new(0., 1.,
-1., 0.,
x, y)));
@ -1060,7 +1060,7 @@ impl<'a> PaintContext<'a> {
}
let blur_filter = self.draw_target.create_filter(FilterType::GaussianBlur);
blur_filter.set_attribute(GaussianBlurAttribute::StdDeviation(blur_radius.to_subpx() as
blur_filter.set_attribute(GaussianBlurAttribute::StdDeviation(blur_radius.to_f64_px() as
AzFloat));
blur_filter.set_input(GaussianBlurInput, &temporary_draw_target.draw_target.snapshot());
temporary_draw_target.draw_filter(&self.draw_target, blur_filter);
@ -1104,21 +1104,21 @@ impl<'a> PaintContext<'a> {
pub trait ToAzurePoint {
fn to_azure_point(&self) -> Point2D<AzFloat>;
fn to_subpx_azure_point(&self) -> Point2D<AzFloat>;
fn to_f64_px_azure_point(&self) -> Point2D<AzFloat>;
}
impl ToAzurePoint for Point2D<Au> {
fn to_azure_point(&self) -> Point2D<AzFloat> {
Point2D(self.x.to_nearest_px() as AzFloat, self.y.to_nearest_px() as AzFloat)
}
fn to_subpx_azure_point(&self) -> Point2D<AzFloat> {
Point2D(self.x.to_subpx() as AzFloat, self.y.to_subpx() as AzFloat)
fn to_f64_px_azure_point(&self) -> Point2D<AzFloat> {
Point2D(self.x.to_f64_px() as AzFloat, self.y.to_f64_px() as AzFloat)
}
}
pub trait ToAzureRect {
fn to_azure_rect(&self) -> Rect<AzFloat>;
fn to_subpx_azure_rect(&self) -> Rect<AzFloat>;
fn to_f64_px_azure_rect(&self) -> Rect<AzFloat>;
}
impl ToAzureRect for Rect<Au> {
@ -1127,9 +1127,9 @@ impl ToAzureRect for Rect<Au> {
self.size.height.to_nearest_px() as AzFloat))
}
fn to_subpx_azure_rect(&self) -> Rect<AzFloat> {
Rect(self.origin.to_subpx_azure_point(), Size2D(self.size.width.to_subpx() as AzFloat,
self.size.height.to_subpx() as AzFloat))
fn to_f64_px_azure_rect(&self) -> Rect<AzFloat> {
Rect(self.origin.to_f64_px_azure_point(), Size2D(self.size.width.to_f64_px() as AzFloat,
self.size.height.to_f64_px() as AzFloat))
}
}
@ -1241,8 +1241,8 @@ impl ScaledFontExtensionMethods for ScaledFont {
let azglyph = struct__AzGlyph {
mIndex: glyph.id() as uint32_t,
mPosition: struct__AzPoint {
x: (origin.x + glyph_offset.x).to_subpx() as AzFloat,
y: (origin.y + glyph_offset.y).to_subpx() as AzFloat
x: (origin.x + glyph_offset.x).to_f64_px() as AzFloat,
y: (origin.y + glyph_offset.y).to_f64_px() as AzFloat
}
};
origin = Point2D(origin.x + glyph_advance, origin.y);
@ -1385,7 +1385,7 @@ impl TemporaryDrawTarget {
fn from_bounds(main_draw_target: &DrawTarget, bounds: &Rect<Au>) -> TemporaryDrawTarget {
let draw_target_transform = main_draw_target.get_transform();
let temporary_draw_target_bounds =
draw_target_transform.transform_rect(&bounds.to_subpx_azure_rect());
draw_target_transform.transform_rect(&bounds.to_f64_px_azure_rect());
let temporary_draw_target_size =
Size2D(temporary_draw_target_bounds.size.width.ceil() as i32,
temporary_draw_target_bounds.size.height.ceil() as i32);

View file

@ -546,8 +546,8 @@ impl WorkerThread {
// Apply a translation to start at the boundaries of the stacking context, since the
// layer's origin starts at its overflow rect's origin.
let tile_bounds = tile.page_rect.translate(
&Point2D(stacking_context.overflow.origin.x.to_subpx() as AzFloat,
stacking_context.overflow.origin.y.to_subpx() as AzFloat));
&Point2D(stacking_context.overflow.origin.x.to_f64_px() as AzFloat,
stacking_context.overflow.origin.y.to_f64_px() as AzFloat));
// Apply the translation to paint the tile we want.
let matrix: Matrix2D<AzFloat> = Matrix2D::identity();

View file

@ -257,7 +257,7 @@ impl FontHandleMethods for FontHandle {
line_gap: height,
};
debug!("Font metrics (@{}px): {:?}", em_size.to_frac32_px(), metrics);
debug!("Font metrics (@{}px): {:?}", em_size.to_f32_px(), metrics);
return metrics;
}
@ -268,7 +268,7 @@ impl FontHandleMethods for FontHandle {
impl<'a> FontHandle {
fn set_char_size(face: FT_Face, pt_size: Au) -> Result<(), ()>{
let char_width = float_to_fixed_ft((0.5f64 + pt_size.to_subpx()).floor()) as FT_F26Dot6;
let char_width = float_to_fixed_ft((0.5f64 + pt_size.to_f64_px()).floor()) as FT_F26Dot6;
unsafe {
let result = FT_Set_Char_Size(face, char_width, 0, 0, 0);
@ -296,6 +296,6 @@ impl<'a> FontHandle {
// If this isn't true then we're scaling one of the axes wrong
assert!(metrics.x_ppem == metrics.y_ppem);
return Au::from_frac_px(value * x_scale);
return Au::from_f64_px(value * x_scale);
}
}

View file

@ -62,7 +62,7 @@ impl FontHandleMethods for FontHandle {
pt_size: Option<Au>)
-> Result<FontHandle, ()> {
let size = match pt_size {
Some(s) => s.to_subpx(),
Some(s) => s.to_f64_px(),
None => 0.0
};
match template.ctfont {
@ -162,7 +162,7 @@ impl FontHandleMethods for FontHandle {
let bounding_rect: CGRect = self.ctfont.bounding_box();
let ascent = self.ctfont.ascent() as f64;
let descent = self.ctfont.descent() as f64;
let em_size = Au::from_frac_px(self.ctfont.pt_size() as f64);
let em_size = Au::from_f64_px(self.ctfont.pt_size() as f64);
let leading = self.ctfont.leading() as f64;
let scale = px_to_pt(self.ctfont.pt_size() as f64) / (ascent + descent);
@ -171,7 +171,7 @@ impl FontHandleMethods for FontHandle {
let max_advance_width = Au::from_pt(bounding_rect.size.width as f64);
let average_advance = self.glyph_index('0')
.and_then(|idx| self.glyph_h_advance(idx))
.map(|advance| Au::from_frac_px(advance))
.map(|advance| Au::from_f64_px(advance))
.unwrap_or(max_advance_width);
let metrics = FontMetrics {
@ -191,7 +191,7 @@ impl FontHandleMethods for FontHandle {
descent: Au::from_pt(descent * scale),
max_advance: max_advance_width,
average_advance: average_advance,
line_gap: Au::from_frac_px(line_gap),
line_gap: Au::from_f64_px(line_gap),
};
debug!("Font metrics (@{} pt): {:?}", self.ctfont.pt_size() as f64, metrics);
return metrics;

View file

@ -728,7 +728,7 @@ impl<'a> GlyphStore {
// FIXME(pcwalton): This can overflow for very large font-sizes.
let advance =
((entry.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) +
Au::from_frac_px(space).0 as u32;
Au::from_f64_px(space).0 as u32;
entry.value = (entry.value & !GLYPH_ADVANCE_MASK) |
(advance << GLYPH_ADVANCE_SHIFT);
}

View file

@ -117,10 +117,10 @@ impl ShapedGlyphData {
let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance);
let y_advance = Shaper::fixed_to_float((*pos_info_i).y_advance);
let x_offset = Au::from_frac_px(x_offset);
let y_offset = Au::from_frac_px(y_offset);
let x_advance = Au::from_frac_px(x_advance);
let y_advance = Au::from_frac_px(y_advance);
let x_offset = Au::from_f64_px(x_offset);
let y_offset = Au::from_f64_px(y_offset);
let x_advance = Au::from_f64_px(x_advance);
let y_advance = Au::from_f64_px(y_advance);
let offset = if x_offset == Au(0) && y_offset == Au(0) && y_advance == Au(0) {
None
@ -185,7 +185,7 @@ impl Shaper {
let hb_font: *mut hb_font_t = RUST_hb_font_create(hb_face);
// Set points-per-em. if zero, performs no hinting in that direction.
let pt_size = font.actual_pt_size.to_subpx();
let pt_size = font.actual_pt_size.to_f64_px();
RUST_hb_font_set_ppem(hb_font, pt_size as c_uint, pt_size as c_uint);
// Set scaling. Note that this takes 16.16 fixed point.
@ -518,7 +518,7 @@ impl Shaper {
advance = advance + options.word_spacing
} else if character == '\t' {
let tab_size = 8f64;
advance = Au::from_frac_px(tab_size * glyph_space_advance(self.font_and_shaping_options.font));
advance = Au::from_f64_px(tab_size * glyph_space_advance(self.font_and_shaping_options.font));
}
advance