Skip to content

Commit

Permalink
avm2: Support matrix3D in transform copy
Browse files Browse the repository at this point in the history
  • Loading branch information
cookie-s committed Dec 13, 2024
1 parent 404c545 commit a3a3018
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/avm2/globals/flash/display/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::avm2::activation::Activation;
use crate::avm2::error::{illegal_operation_error, make_error_2007, make_error_2008};
use crate::avm2::filters::FilterAvm2Ext;
use crate::avm2::globals::flash::geom::transform::color_transform_from_transform_object;
use crate::avm2::globals::flash::geom::transform::has_matrix3d_from_transform_object;
use crate::avm2::globals::flash::geom::transform::matrix_from_transform_object;
use crate::avm2::globals::slots::flash_display_shader as shader_slots;
use crate::avm2::globals::slots::flash_geom_point as point_slots;
Expand Down Expand Up @@ -755,14 +756,15 @@ pub fn set_transform<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
let transform = args.get_object(activation, 0, "transform")?;

// FIXME - consider 3D matrix and pixel bounds
// FIXME - consider pixel bounds
let matrix = matrix_from_transform_object(transform);

let has_matrix3d = has_matrix3d_from_transform_object(transform);
let color_transform = color_transform_from_transform_object(transform);

let dobj = this.as_display_object().unwrap();
let mut write = dobj.base_mut(activation.context.gc_context);
write.set_matrix(matrix);
write.set_has_matrix3d_stub(has_matrix3d);
write.set_color_transform(color_transform);
drop(write);
if let Some(parent) = dobj.parent() {
Expand Down
6 changes: 6 additions & 0 deletions core/src/avm2/globals/flash/geom/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ pub fn get_concatenated_matrix<'gc>(
}
}

pub fn has_matrix3d_from_transform_object(transform_object: Object<'_>) -> bool {
get_display_object(transform_object)
.base()
.has_matrix3d_stub()
}

pub fn matrix_from_transform_object(transform_object: Object<'_>) -> Matrix {
*get_display_object(transform_object).base().matrix()
}
Expand Down

0 comments on commit a3a3018

Please sign in to comment.