From c1daf889afd396226bf4eb6a90a0a084e4677dc5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 26 May 2015 23:34:17 +0530 Subject: [PATCH] use HeapSizeOf plugin in gfx --- components/gfx/display_list/mod.rs | 20 ++++++++------------ components/gfx/lib.rs | 3 ++- components/plugins/heapsize.rs | 8 ++++++-- components/plugins/lib.rs | 6 +++--- components/util/mem.rs | 6 +++--- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 1aef67246a8..393b909ed96 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -27,7 +27,7 @@ use azure::azure::AzFloat; use azure::azure_hl::{Color}; use collections::linked_list::{self, LinkedList}; -use geom::{Matrix2D, Point2D, Rect, SideOffsets2D, Size2D, Matrix4}; +use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D}; use geom::approxeq::ApproxEq; use geom::num::Zero; use libc::uintptr_t; @@ -254,7 +254,8 @@ pub struct StackingContext { pub blend_mode: mix_blend_mode::T, /// A transform to be applied to this stacking context. - pub transform: Matrix4, + #[ignore_heap_size] + pub transform: Matrix2D, } impl StackingContext { @@ -264,7 +265,7 @@ impl StackingContext { bounds: &Rect, overflow: &Rect, z_index: i32, - transform: &Matrix4, + transform: &Matrix2D, filters: filter::T, blend_mode: mix_blend_mode::T, layer: Option>) @@ -285,7 +286,7 @@ impl StackingContext { pub fn optimize_and_draw_into_context(&self, paint_context: &mut PaintContext, tile_bounds: &Rect, - transform: &Matrix4, + transform: &Matrix2D, clip_rect: Option<&Rect>) { let transform = transform.mul(&self.transform); let temporary_draw_target = @@ -318,10 +319,7 @@ impl StackingContext { // Set up our clip rect and transform. let old_transform = paint_subcontext.draw_target.get_transform(); - let xform_2d = Matrix2D::new(transform.m11, transform.m12, - transform.m21, transform.m22, - transform.m41, transform.m42); - paint_subcontext.draw_target.set_transform(&xform_2d); + paint_subcontext.draw_target.set_transform(&transform); paint_subcontext.push_clip_if_applicable(); // Steps 1 and 2: Borders and background for the root. @@ -343,8 +341,7 @@ impl StackingContext { positioned_kid.bounds .origin .y - .to_nearest_px() as AzFloat, - 0.0); + .to_nearest_px() as AzFloat); let new_tile_rect = self.compute_tile_rect_for_child_stacking_context(tile_bounds, &**positioned_kid); @@ -392,8 +389,7 @@ impl StackingContext { positioned_kid.bounds .origin .y - .to_nearest_px() as AzFloat, - 0.0); + .to_nearest_px() as AzFloat); let new_tile_rect = self.compute_tile_rect_for_child_stacking_context(tile_bounds, &**positioned_kid); diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 236eafd83d8..90d3d8ca962 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -6,7 +6,8 @@ #![feature(box_syntax)] #![feature(collections)] #![feature(core)] -#![feature(plugin)] +#![feature(plugin, custom_attribute)] +#![feature(custom_derive)] #![feature(rustc_private)] #![feature(std_misc)] #![feature(str_char)] diff --git a/components/plugins/heapsize.rs b/components/plugins/heapsize.rs index 4da8cc070a8..1a6d27fea22 100644 --- a/components/plugins/heapsize.rs +++ b/components/plugins/heapsize.rs @@ -1,3 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ use syntax::ext::base::{Annotatable, ExtCtxt}; use syntax::codemap::Span; @@ -7,7 +10,8 @@ use syntax::attr::AttrMetaMethods; use syntax::ext::build::AstBuilder; use syntax::ext::deriving::generic::*; -pub fn expand_heapsize(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: Annotatable, push: &mut FnMut(Annotatable)) { +pub fn expand_heapsize(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, + item: Annotatable, push: &mut FnMut(Annotatable)) { let trait_def = TraitDef { span: span, attributes: Vec::new(), @@ -40,7 +44,7 @@ fn heapsize_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructu fields.iter().fold(cx.expr_usize(trait_span, 0), |acc, ref item| { if item.attrs.iter() - .find(|ref a| a.check_name("ignore_heapsize")) + .find(|ref a| a.check_name("ignore_heap_size")) .is_some() { acc } else { diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 6138e4bef84..fd8fdd615b7 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -8,9 +8,10 @@ //! //! - `#[privatize]` : Forces all fields in a struct/enum to be private //! - `#[jstraceable]` : Auto-derives an implementation of `JSTraceable` for a struct in the script crate -//! - `#[must_root]` : Prevents data of the marked type from being used on the stack. See the lints module for more details +//! - `#[must_root]` : Prevents data of the marked type from being used on the stack. +//! See the lints module for more details //! - `#[dom_struct]` : Implies `#[privatize]`,`#[jstraceable]`, and `#[must_root]`. -//! Use this for structs that correspond to a DOM type +//! Use this for structs that correspond to a DOM type #![feature(plugin_registrar, quote, plugin, box_syntax, rustc_private, collections)] @@ -45,7 +46,6 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension(intern("jstraceable"), MultiDecorator(box jstraceable::expand_jstraceable)); reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector)); reg.register_syntax_extension(intern("derive_HeapSizeOf"), MultiDecorator(box heapsize::expand_heapsize)); - reg.register_syntax_extension(intern("heapsize"), MultiDecorator(box heapsize::expand_heapsize)); reg.register_macro("to_lower", casing::expand_lower); reg.register_macro("to_upper", casing::expand_upper); reg.register_lint_pass(box lints::transmute_type::TransmutePass as LintPassObject); diff --git a/components/util/mem.rs b/components/util/mem.rs index 175863ddb9e..8bbfb909199 100644 --- a/components/util/mem.rs +++ b/components/util/mem.rs @@ -165,7 +165,7 @@ macro_rules! known_heap_size( ($size:expr, $($ty:ident),+) => ( $( impl $crate::mem::HeapSizeOf for $ty { - #[inline] + #[inline(always)] fn heap_size_of_children(&self) -> usize { $size } @@ -174,7 +174,7 @@ macro_rules! known_heap_size( ); ($size: expr, $ty:ident<$($gen:ident),+>) => ( impl<$($gen),+> $crate::mem::HeapSizeOf for $ty<$($gen),+> { - #[inline] + #[inline(always)] fn heap_size_of_children(&self) -> usize { $size } @@ -185,4 +185,4 @@ macro_rules! known_heap_size( known_heap_size!(0, u8, u16, u32, u64, usize); known_heap_size!(0, i8, i16, i32, i64, isize); -known_heap_size!(0, bool); \ No newline at end of file +known_heap_size!(0, bool);