mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
use HeapSizeOf plugin in gfx
This commit is contained in:
parent
f4bc92526a
commit
c1daf889af
5 changed files with 22 additions and 21 deletions
|
@ -27,7 +27,7 @@ use azure::azure::AzFloat;
|
||||||
use azure::azure_hl::{Color};
|
use azure::azure_hl::{Color};
|
||||||
|
|
||||||
use collections::linked_list::{self, LinkedList};
|
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::approxeq::ApproxEq;
|
||||||
use geom::num::Zero;
|
use geom::num::Zero;
|
||||||
use libc::uintptr_t;
|
use libc::uintptr_t;
|
||||||
|
@ -254,7 +254,8 @@ pub struct StackingContext {
|
||||||
pub blend_mode: mix_blend_mode::T,
|
pub blend_mode: mix_blend_mode::T,
|
||||||
|
|
||||||
/// A transform to be applied to this stacking context.
|
/// A transform to be applied to this stacking context.
|
||||||
pub transform: Matrix4<AzFloat>,
|
#[ignore_heap_size]
|
||||||
|
pub transform: Matrix2D<AzFloat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StackingContext {
|
impl StackingContext {
|
||||||
|
@ -264,7 +265,7 @@ impl StackingContext {
|
||||||
bounds: &Rect<Au>,
|
bounds: &Rect<Au>,
|
||||||
overflow: &Rect<Au>,
|
overflow: &Rect<Au>,
|
||||||
z_index: i32,
|
z_index: i32,
|
||||||
transform: &Matrix4<AzFloat>,
|
transform: &Matrix2D<AzFloat>,
|
||||||
filters: filter::T,
|
filters: filter::T,
|
||||||
blend_mode: mix_blend_mode::T,
|
blend_mode: mix_blend_mode::T,
|
||||||
layer: Option<Arc<PaintLayer>>)
|
layer: Option<Arc<PaintLayer>>)
|
||||||
|
@ -285,7 +286,7 @@ impl StackingContext {
|
||||||
pub fn optimize_and_draw_into_context(&self,
|
pub fn optimize_and_draw_into_context(&self,
|
||||||
paint_context: &mut PaintContext,
|
paint_context: &mut PaintContext,
|
||||||
tile_bounds: &Rect<AzFloat>,
|
tile_bounds: &Rect<AzFloat>,
|
||||||
transform: &Matrix4<AzFloat>,
|
transform: &Matrix2D<AzFloat>,
|
||||||
clip_rect: Option<&Rect<Au>>) {
|
clip_rect: Option<&Rect<Au>>) {
|
||||||
let transform = transform.mul(&self.transform);
|
let transform = transform.mul(&self.transform);
|
||||||
let temporary_draw_target =
|
let temporary_draw_target =
|
||||||
|
@ -318,10 +319,7 @@ impl StackingContext {
|
||||||
|
|
||||||
// Set up our clip rect and transform.
|
// Set up our clip rect and transform.
|
||||||
let old_transform = paint_subcontext.draw_target.get_transform();
|
let old_transform = paint_subcontext.draw_target.get_transform();
|
||||||
let xform_2d = Matrix2D::new(transform.m11, transform.m12,
|
paint_subcontext.draw_target.set_transform(&transform);
|
||||||
transform.m21, transform.m22,
|
|
||||||
transform.m41, transform.m42);
|
|
||||||
paint_subcontext.draw_target.set_transform(&xform_2d);
|
|
||||||
paint_subcontext.push_clip_if_applicable();
|
paint_subcontext.push_clip_if_applicable();
|
||||||
|
|
||||||
// Steps 1 and 2: Borders and background for the root.
|
// Steps 1 and 2: Borders and background for the root.
|
||||||
|
@ -343,8 +341,7 @@ impl StackingContext {
|
||||||
positioned_kid.bounds
|
positioned_kid.bounds
|
||||||
.origin
|
.origin
|
||||||
.y
|
.y
|
||||||
.to_nearest_px() as AzFloat,
|
.to_nearest_px() as AzFloat);
|
||||||
0.0);
|
|
||||||
let new_tile_rect =
|
let new_tile_rect =
|
||||||
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
||||||
&**positioned_kid);
|
&**positioned_kid);
|
||||||
|
@ -392,8 +389,7 @@ impl StackingContext {
|
||||||
positioned_kid.bounds
|
positioned_kid.bounds
|
||||||
.origin
|
.origin
|
||||||
.y
|
.y
|
||||||
.to_nearest_px() as AzFloat,
|
.to_nearest_px() as AzFloat);
|
||||||
0.0);
|
|
||||||
let new_tile_rect =
|
let new_tile_rect =
|
||||||
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
self.compute_tile_rect_for_child_stacking_context(tile_bounds,
|
||||||
&**positioned_kid);
|
&**positioned_kid);
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(collections)]
|
#![feature(collections)]
|
||||||
#![feature(core)]
|
#![feature(core)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin, custom_attribute)]
|
||||||
|
#![feature(custom_derive)]
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(std_misc)]
|
#![feature(std_misc)]
|
||||||
#![feature(str_char)]
|
#![feature(str_char)]
|
||||||
|
|
|
@ -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::ext::base::{Annotatable, ExtCtxt};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
|
@ -7,7 +10,8 @@ use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ext::deriving::generic::*;
|
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 {
|
let trait_def = TraitDef {
|
||||||
span: span,
|
span: span,
|
||||||
attributes: Vec::new(),
|
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),
|
fields.iter().fold(cx.expr_usize(trait_span, 0),
|
||||||
|acc, ref item| {
|
|acc, ref item| {
|
||||||
if item.attrs.iter()
|
if item.attrs.iter()
|
||||||
.find(|ref a| a.check_name("ignore_heapsize"))
|
.find(|ref a| a.check_name("ignore_heap_size"))
|
||||||
.is_some() {
|
.is_some() {
|
||||||
acc
|
acc
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,9 +8,10 @@
|
||||||
//!
|
//!
|
||||||
//! - `#[privatize]` : Forces all fields in a struct/enum to be private
|
//! - `#[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
|
//! - `#[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]`.
|
//! - `#[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)]
|
#![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("jstraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
|
||||||
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
|
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("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_lower", casing::expand_lower);
|
||||||
reg.register_macro("to_upper", casing::expand_upper);
|
reg.register_macro("to_upper", casing::expand_upper);
|
||||||
reg.register_lint_pass(box lints::transmute_type::TransmutePass as LintPassObject);
|
reg.register_lint_pass(box lints::transmute_type::TransmutePass as LintPassObject);
|
||||||
|
|
|
@ -165,7 +165,7 @@ macro_rules! known_heap_size(
|
||||||
($size:expr, $($ty:ident),+) => (
|
($size:expr, $($ty:ident),+) => (
|
||||||
$(
|
$(
|
||||||
impl $crate::mem::HeapSizeOf for $ty {
|
impl $crate::mem::HeapSizeOf for $ty {
|
||||||
#[inline]
|
#[inline(always)]
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
$size
|
$size
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ macro_rules! known_heap_size(
|
||||||
);
|
);
|
||||||
($size: expr, $ty:ident<$($gen:ident),+>) => (
|
($size: expr, $ty:ident<$($gen:ident),+>) => (
|
||||||
impl<$($gen),+> $crate::mem::HeapSizeOf for $ty<$($gen),+> {
|
impl<$($gen),+> $crate::mem::HeapSizeOf for $ty<$($gen),+> {
|
||||||
#[inline]
|
#[inline(always)]
|
||||||
fn heap_size_of_children(&self) -> usize {
|
fn heap_size_of_children(&self) -> usize {
|
||||||
$size
|
$size
|
||||||
}
|
}
|
||||||
|
@ -185,4 +185,4 @@ macro_rules! known_heap_size(
|
||||||
|
|
||||||
known_heap_size!(0, u8, u16, u32, u64, usize);
|
known_heap_size!(0, u8, u16, u32, u64, usize);
|
||||||
known_heap_size!(0, i8, i16, i32, i64, isize);
|
known_heap_size!(0, i8, i16, i32, i64, isize);
|
||||||
known_heap_size!(0, bool);
|
known_heap_size!(0, bool);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue