Skip to content

Commit

Permalink
avm2: Use VectorStorage in Matrix3D object construction
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Jarosz <[email protected]>
  • Loading branch information
cookie-s and kjarosh committed Dec 13, 2024
1 parent bf3b8fa commit 404c545
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/avm2/globals/flash/geom/transform.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::avm2::globals::slots::flash_geom_color_transform as ct_slots;
use crate::avm2::globals::slots::flash_geom_matrix as matrix_slots;
use crate::avm2::globals::slots::flash_geom_transform as transform_slots;
use crate::avm2::object::VectorObject;
use crate::avm2::parameters::ParametersExt;
use crate::avm2::vector::VectorStorage;
use crate::avm2::{Activation, Error, Object, TObject, Value};
use crate::display_object::TDisplayObject;
use crate::prelude::{DisplayObject, Matrix, Twips};
Expand Down Expand Up @@ -193,12 +195,17 @@ fn matrix3d_to_object<'gc>(
matrix: Matrix3D,
activation: &mut Activation<'_, 'gc>,
) -> Result<Value<'gc>, Error<'gc>> {
let args = matrix.raw_data.map(Into::into);
let number = activation.avm2().class_defs().number;
let mut raw_data_storage = VectorStorage::new(16, true, Some(number), activation);
for (i, data) in matrix.raw_data.iter().enumerate() {
raw_data_storage.set(i, Value::Number(*data), activation)?;
}
let vector = VectorObject::from_vector(raw_data_storage, activation)?.into();
let object = activation
.avm2()
.classes()
.matrix3d
.construct(activation, &args)?;
.construct(activation, &[vector])?;
Ok(object.into())
}

Expand Down

0 comments on commit 404c545

Please sign in to comment.