Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text: Lazily layout text #7749

Closed
wants to merge 10 commits into from
8 changes: 4 additions & 4 deletions core/src/avm1/object/stage_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,8 @@ fn set_visible<'gc>(
Ok(())
}

fn width<'gc>(_activation: &mut Activation<'_, 'gc, '_>, this: DisplayObject<'gc>) -> Value<'gc> {
this.width().into()
fn width<'gc>(activation: &mut Activation<'_, 'gc, '_>, this: DisplayObject<'gc>) -> Value<'gc> {
this.width(&mut activation.context).into()
}

fn set_width<'gc>(
Expand All @@ -768,8 +768,8 @@ fn set_width<'gc>(
Ok(())
}

fn height<'gc>(_activation: &mut Activation<'_, 'gc, '_>, this: DisplayObject<'gc>) -> Value<'gc> {
this.height().into()
fn height<'gc>(activation: &mut Activation<'_, 'gc, '_>, this: DisplayObject<'gc>) -> Value<'gc> {
this.height(&mut activation.context).into()
}

fn set_height<'gc>(
Expand Down
8 changes: 4 additions & 4 deletions core/src/avm2/globals/flash/display/displayobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ pub fn set_alpha<'gc>(

/// Implements `height`'s getter.
pub fn height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.height().into());
return Ok(dobj.height(&mut activation.context).into());
}

Ok(Value::Undefined)
Expand Down Expand Up @@ -175,12 +175,12 @@ pub fn set_scale_y<'gc>(

/// Implements `width`'s getter.
pub fn width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.width().into());
return Ok(dobj.width(&mut activation.context).into());
}

Ok(Value::Undefined)
Expand Down
5 changes: 4 additions & 1 deletion core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<'gc> Default for ActionQueue<'gc> {

/// Shared data used during rendering.
/// `Player` creates this when it renders a frame and passes it down to display objects.
pub struct RenderContext<'a, 'gc> {
pub struct RenderContext<'a, 'gc, 'gc_context> {
/// The renderer, used by the display objects to draw themselves.
pub renderer: &'a mut dyn RenderBackend,

Expand All @@ -437,6 +437,9 @@ pub struct RenderContext<'a, 'gc> {
/// Whether to allow pushing a new mask. A masker-inside-a-masker does not work in Flash, instead
/// causing the inner mask to be included as part of the outer mask. Maskee-inside-a-maskee works as one expects.
pub allow_mask: bool,

/// The mutation context to allocate and mutate `GcCell` types.
pub gc_context: MutationContext<'gc, 'gc_context>,
}

/// The type of action being run.
Expand Down
10 changes: 5 additions & 5 deletions core/src/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'gc> DisplayObjectBase<'gc> {
}
}

pub fn render_base<'gc>(this: DisplayObject<'gc>, context: &mut RenderContext<'_, 'gc>) {
pub fn render_base<'gc>(this: DisplayObject<'gc>, context: &mut RenderContext<'_, 'gc, '_>) {
if this.maskee().is_some() {
return;
}
Expand Down Expand Up @@ -704,7 +704,7 @@ pub trait TDisplayObject<'gc>:

/// Gets the pixel width of the AABB containing this display object in local space.
/// Returned by the ActionScript `_width`/`width` properties.
fn width(&self) -> f64 {
fn width(&self, _context: &mut UpdateContext<'_, 'gc, '_>) -> f64 {
let bounds = self.local_bounds();
(bounds.x_max - bounds.x_min).to_pixels()
}
Expand Down Expand Up @@ -753,7 +753,7 @@ pub trait TDisplayObject<'gc>:

/// Gets the pixel height of the AABB containing this display object in local space.
/// Returned by the ActionScript `_height`/`height` properties.
fn height(&self) -> f64 {
fn height(&self, _context: &mut UpdateContext<'_, 'gc, '_>) -> f64 {
let bounds = self.local_bounds();
(bounds.y_max - bounds.y_min).to_pixels()
}
Expand Down Expand Up @@ -1187,9 +1187,9 @@ pub trait TDisplayObject<'gc>:
}
}

fn render_self(&self, _context: &mut RenderContext<'_, 'gc>) {}
fn render_self(&self, _context: &mut RenderContext<'_, 'gc, '_>) {}

fn render(&self, context: &mut RenderContext<'_, 'gc>) {
fn render(&self, context: &mut RenderContext<'_, 'gc, '_>) {
render_base((*self).into(), context)
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/avm1_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl<'gc> TDisplayObject<'gc> for Avm1Button<'gc> {
}
}

fn render_self(&self, context: &mut RenderContext<'_, 'gc>) {
fn render_self(&self, context: &mut RenderContext<'_, 'gc, '_>) {
self.render_children(context);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/avm2_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
}
}

fn render_self(&self, context: &mut RenderContext<'_, 'gc>) {
fn render_self(&self, context: &mut RenderContext<'_, 'gc, '_>) {
let state = self.0.read().state;
let current_state = self.get_state_child(state.into());

Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub trait TDisplayObjectContainer<'gc>:
}

/// Renders the children of this container in render list order.
fn render_children(self, context: &mut RenderContext<'_, 'gc>) {
fn render_children(self, context: &mut RenderContext<'_, 'gc, '_>) {
let mut clip_depth = 0;
let mut clip_depth_stack: Vec<(Depth, DisplayObject<'_>)> = vec![];
for child in self.iter_render_list() {
Expand Down
Loading