use bitflags::bitflags;
use crate::Matrix;
use crate::Vector;
use crate::rendering::composition::ICompositionObjectHost;
use crate::rendering::composition::animations::AnimationInstanceFactory;
use crate::rendering::composition::animations::ICompositionAnimation;
use crate::rendering::composition::expressions::ExpressionVariant;
use crate::rendering::composition::server::CompositionProperty;
use crate::rendering::composition::server::CompositionPropertyOf;
use crate::rendering::composition::server::IServerAnimatedPropertyHost;
use crate::rendering::composition::server::ServerPropertyValue;
use crate::rendering::composition::server::props_of;
use crate::rendering::composition::transport::BatchStreamReader;
use crate::rendering::composition::transport::BatchStreamWriter;
use crate::rendering::composition::transport::BatchValue;
use crate::rendering::composition::transport::BatchValueReader;
use std::any::Any;
use std::any::TypeId;
use std::cell::Cell;
use std::sync::OnceLock;
use std::time::Duration;
bitflags! {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompositionShapeChangedFields: u16 {
const CENTER_POINT = 1;
const CENTER_POINT_ANIMATED = 2;
const OFFSET = 4;
const OFFSET_ANIMATED = 8;
const ROTATION_ANGLE = 16;
const ROTATION_ANGLE_ANIMATED = 32;
const SCALE = 64;
const SCALE_ANIMATED = 128;
const TRANSFORM_MATRIX = 256;
const TRANSFORM_MATRIX_ANIMATED = 512;
}
}
impl BatchValue for CompositionShapeChangedFields {
#[inline]
fn write_to(&self, out: &mut Vec<u8>) {
self.bits().write_to(out);
}
#[inline]
fn read_from(input: &mut BatchValueReader<'_>) -> Self {
CompositionShapeChangedFields::from_bits_retain(u16::read_from(input))
}
}
pub trait CompositionShapeHooks: ICompositionObjectHost {
fn initialize_defaults_extra(&self) {}
fn validate_center_point_change(&self, _old_value: Vector, _new_value: Vector) {}
fn on_center_point_changed(&self) {}
fn on_center_point_changing(&self) {}
fn validate_offset_change(&self, _old_value: Vector, _new_value: Vector) {}
fn on_offset_changed(&self) {}
fn on_offset_changing(&self) {}
fn validate_rotation_angle_change(&self, _old_value: f32, _new_value: f32) {}
fn on_rotation_angle_changed(&self) {}
fn on_rotation_angle_changing(&self) {}
fn validate_scale_change(&self, _old_value: Vector, _new_value: Vector) {}
fn on_scale_changed(&self) {}
fn on_scale_changing(&self) {}
fn validate_transform_matrix_change(&self, _old_value: Matrix, _new_value: Matrix) {}
fn on_transform_matrix_changed(&self) {}
fn on_transform_matrix_changing(&self) {}
}
pub struct CompositionShapeProps {
changed_fields_of_composition_shape: Cell<CompositionShapeChangedFields>,
center_point: Cell<Vector>,
offset: Cell<Vector>,
rotation_angle: Cell<f32>,
scale: Cell<Vector>,
transform_matrix: Cell<Matrix>,
}
impl Default for CompositionShapeProps {
fn default() -> Self {
Self::new()
}
}
impl CompositionShapeProps {
pub fn new() -> Self {
Self {
changed_fields_of_composition_shape: Cell::new(CompositionShapeChangedFields::empty()),
center_point: Cell::new(Default::default()),
offset: Cell::new(Default::default()),
rotation_angle: Cell::new(Default::default()),
scale: Cell::new(Default::default()),
transform_matrix: Cell::new(Default::default()),
}
}
pub fn initialize_defaults(&self, host: &dyn CompositionShapeHooks) {
self.initialize_own_defaults(host);
}
pub fn initialize_own_defaults(&self, host: &dyn CompositionShapeHooks) {
CompositionShapeHooks::initialize_defaults_extra(host);
self.set_scale(host, Vector::new(1.0, 1.0));
self.set_transform_matrix(host, Matrix::IDENTITY);
}
pub fn center_point(&self) -> Vector {
self.center_point.get()
}
pub fn set_center_point(&self, host: &dyn CompositionShapeHooks, value: Vector) {
let mut changed = false;
let old_value = self.center_point.get();
if old_value.differs(&value) {
CompositionShapeHooks::validate_center_point_change(host, old_value, value);
CompositionShapeHooks::on_center_point_changing(host);
changed = true;
self.center_point.set(value);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::CENTER_POINT);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionShapeProps::id_of_center_point_property().base());
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() & !CompositionShapeChangedFields::CENTER_POINT_ANIMATED);
if let Some(animation) = host.implicit_animation("CenterPoint") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::CENTER_POINT_ANIMATED);
host.pending_animations().set(
ServerCompositionShapeProps::id_of_center_point_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "CenterPoint", ExpressionVariant::create(value));
}
}
self.center_point.set(value);
if changed {
CompositionShapeHooks::on_center_point_changed(host);
}
}
pub fn offset(&self) -> Vector {
self.offset.get()
}
pub fn set_offset(&self, host: &dyn CompositionShapeHooks, value: Vector) {
let mut changed = false;
let old_value = self.offset.get();
if old_value.differs(&value) {
CompositionShapeHooks::validate_offset_change(host, old_value, value);
CompositionShapeHooks::on_offset_changing(host);
changed = true;
self.offset.set(value);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::OFFSET);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionShapeProps::id_of_offset_property().base());
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() & !CompositionShapeChangedFields::OFFSET_ANIMATED);
if let Some(animation) = host.implicit_animation("Offset") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::OFFSET_ANIMATED);
host.pending_animations().set(
ServerCompositionShapeProps::id_of_offset_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "Offset", ExpressionVariant::create(value));
}
}
self.offset.set(value);
if changed {
CompositionShapeHooks::on_offset_changed(host);
}
}
pub fn rotation_angle(&self) -> f32 {
self.rotation_angle.get()
}
pub fn set_rotation_angle(&self, host: &dyn CompositionShapeHooks, value: f32) {
let mut changed = false;
let old_value = self.rotation_angle.get();
if old_value.differs(&value) {
CompositionShapeHooks::validate_rotation_angle_change(host, old_value, value);
CompositionShapeHooks::on_rotation_angle_changing(host);
changed = true;
self.rotation_angle.set(value);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::ROTATION_ANGLE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionShapeProps::id_of_rotation_angle_property().base());
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() & !CompositionShapeChangedFields::ROTATION_ANGLE_ANIMATED);
if let Some(animation) = host.implicit_animation("RotationAngle") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::ROTATION_ANGLE_ANIMATED);
host.pending_animations().set(
ServerCompositionShapeProps::id_of_rotation_angle_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "RotationAngle", ExpressionVariant::create(value));
}
}
self.rotation_angle.set(value);
if changed {
CompositionShapeHooks::on_rotation_angle_changed(host);
}
}
pub fn scale(&self) -> Vector {
self.scale.get()
}
pub fn set_scale(&self, host: &dyn CompositionShapeHooks, value: Vector) {
let mut changed = false;
let old_value = self.scale.get();
if old_value.differs(&value) {
CompositionShapeHooks::validate_scale_change(host, old_value, value);
CompositionShapeHooks::on_scale_changing(host);
changed = true;
self.scale.set(value);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::SCALE);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionShapeProps::id_of_scale_property().base());
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() & !CompositionShapeChangedFields::SCALE_ANIMATED);
if let Some(animation) = host.implicit_animation("Scale") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::SCALE_ANIMATED);
host.pending_animations().set(
ServerCompositionShapeProps::id_of_scale_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "Scale", ExpressionVariant::create(value));
}
}
self.scale.set(value);
if changed {
CompositionShapeHooks::on_scale_changed(host);
}
}
pub fn transform_matrix(&self) -> Matrix {
self.transform_matrix.get()
}
pub fn set_transform_matrix(&self, host: &dyn CompositionShapeHooks, value: Matrix) {
let mut changed = false;
let old_value = self.transform_matrix.get();
if old_value.differs(&value) {
CompositionShapeHooks::validate_transform_matrix_change(host, old_value, value);
CompositionShapeHooks::on_transform_matrix_changing(host);
changed = true;
self.transform_matrix.set(value);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::TRANSFORM_MATRIX);
host.register_for_serialization();
host.pending_animations().remove(ServerCompositionShapeProps::id_of_transform_matrix_property().base());
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() & !CompositionShapeChangedFields::TRANSFORM_MATRIX_ANIMATED);
if let Some(animation) = host.implicit_animation("TransformMatrix") {
if let Some(a) = animation.as_composition_animation() {
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::TRANSFORM_MATRIX_ANIMATED);
host.pending_animations().set(
ServerCompositionShapeProps::id_of_transform_matrix_property().base(),
a.create_instance(host.server(), Some(ExpressionVariant::create(value))),
);
}
host.start_animation_group(&animation, "TransformMatrix", ExpressionVariant::create(value));
}
}
self.transform_matrix.set(value);
if changed {
CompositionShapeHooks::on_transform_matrix_changed(host);
}
}
pub fn start_animation(
&self,
host: &dyn CompositionShapeHooks,
property_name: &str,
animation: &dyn ICompositionAnimation,
final_value: Option<ExpressionVariant>,
) -> bool {
if property_name == "CenterPoint" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionShapeProps::id_of_center_point_property().base(), server);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::CENTER_POINT_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "Offset" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionShapeProps::id_of_offset_property().base(), server);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::OFFSET_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "RotationAngle" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionShapeProps::id_of_rotation_angle_property().base(), server);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::ROTATION_ANGLE_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "Scale" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionShapeProps::id_of_scale_property().base(), server);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::SCALE_ANIMATED);
host.register_for_serialization();
return true;
}
if property_name == "TransformMatrix" {
let server = animation.create_instance(host.server(), final_value);
host.pending_animations().set(ServerCompositionShapeProps::id_of_transform_matrix_property().base(), server);
self.changed_fields_of_composition_shape.set(self.changed_fields_of_composition_shape.get() | CompositionShapeChangedFields::TRANSFORM_MATRIX_ANIMATED);
host.register_for_serialization();
return true;
}
false
}
pub fn serialize_changes_core(&self, host: &dyn CompositionShapeHooks, writer: &mut BatchStreamWriter<'_>) {
let changed = self.changed_fields_of_composition_shape.get();
writer.write(changed);
if changed.contains(CompositionShapeChangedFields::CENTER_POINT_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionShapeProps::id_of_center_point_property().base()));
} else if changed.contains(CompositionShapeChangedFields::CENTER_POINT) {
writer.write(self.center_point.get());
}
if changed.contains(CompositionShapeChangedFields::OFFSET_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionShapeProps::id_of_offset_property().base()));
} else if changed.contains(CompositionShapeChangedFields::OFFSET) {
writer.write(self.offset.get());
}
if changed.contains(CompositionShapeChangedFields::ROTATION_ANGLE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionShapeProps::id_of_rotation_angle_property().base()));
} else if changed.contains(CompositionShapeChangedFields::ROTATION_ANGLE) {
writer.write(self.rotation_angle.get());
}
if changed.contains(CompositionShapeChangedFields::SCALE_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionShapeProps::id_of_scale_property().base()));
} else if changed.contains(CompositionShapeChangedFields::SCALE) {
writer.write(self.scale.get());
}
if changed.contains(CompositionShapeChangedFields::TRANSFORM_MATRIX_ANIMATED) {
writer.write_value(host.pending_animations().get_and_remove(ServerCompositionShapeProps::id_of_transform_matrix_property().base()));
} else if changed.contains(CompositionShapeChangedFields::TRANSFORM_MATRIX) {
writer.write(self.transform_matrix.get());
}
self.changed_fields_of_composition_shape.set(CompositionShapeChangedFields::empty());
}
}
pub trait ServerCompositionShapeHooks: IServerAnimatedPropertyHost {
fn deserialize_changes_extra(&self, _reader: &mut BatchStreamReader<'_>) {}
fn on_fields_deserialized(&self, _changed: CompositionShapeChangedFields) {}
}
pub struct ServerCompositionShapeProps {
center_point: Cell<Vector>,
offset: Cell<Vector>,
rotation_angle: Cell<f32>,
scale: Cell<Vector>,
transform_matrix: Cell<Matrix>,
}
impl Default for ServerCompositionShapeProps {
fn default() -> Self {
Self::new()
}
}
impl ServerCompositionShapeProps {
pub fn new() -> Self {
Self {
center_point: Cell::new(Default::default()),
offset: Cell::new(Default::default()),
rotation_angle: Cell::new(Default::default()),
scale: Cell::new(Default::default()),
transform_matrix: Cell::new(Default::default()),
}
}
pub fn find_props(&self, type_id: TypeId) -> Option<&dyn Any> {
if type_id == TypeId::of::<Self>() {
return Some(self);
}
None
}
pub fn id_of_center_point_property() -> &'static CompositionPropertyOf<Vector> {
static PROPERTY: OnceLock<CompositionPropertyOf<Vector>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionShapeProps, Vector>(
"CenterPoint",
"ServerCompositionShape",
|obj| props_of::<ServerCompositionShapeProps>(obj).center_point.get(),
|obj, v| props_of::<ServerCompositionShapeProps>(obj).center_point.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionShapeProps>(obj).center_point.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionShapeProps>(obj).center_point.set(v.cast_or_default::<Vector>())),
)
})
}
pub fn center_point(&self) -> Vector {
self.center_point.get()
}
pub fn set_center_point(&self, host: &dyn ServerCompositionShapeHooks, value: Vector) {
self.center_point.set(value);
host.remove_animation_for_property(Self::id_of_center_point_property().base());
}
pub fn id_of_offset_property() -> &'static CompositionPropertyOf<Vector> {
static PROPERTY: OnceLock<CompositionPropertyOf<Vector>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionShapeProps, Vector>(
"Offset",
"ServerCompositionShape",
|obj| props_of::<ServerCompositionShapeProps>(obj).offset.get(),
|obj, v| props_of::<ServerCompositionShapeProps>(obj).offset.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionShapeProps>(obj).offset.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionShapeProps>(obj).offset.set(v.cast_or_default::<Vector>())),
)
})
}
pub fn offset(&self) -> Vector {
self.offset.get()
}
pub fn set_offset(&self, host: &dyn ServerCompositionShapeHooks, value: Vector) {
self.offset.set(value);
host.remove_animation_for_property(Self::id_of_offset_property().base());
}
pub fn id_of_rotation_angle_property() -> &'static CompositionPropertyOf<f32> {
static PROPERTY: OnceLock<CompositionPropertyOf<f32>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionShapeProps, f32>(
"RotationAngle",
"ServerCompositionShape",
|obj| props_of::<ServerCompositionShapeProps>(obj).rotation_angle.get(),
|obj, v| props_of::<ServerCompositionShapeProps>(obj).rotation_angle.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionShapeProps>(obj).rotation_angle.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionShapeProps>(obj).rotation_angle.set(v.cast_or_default::<f32>())),
)
})
}
pub fn rotation_angle(&self) -> f32 {
self.rotation_angle.get()
}
pub fn set_rotation_angle(&self, host: &dyn ServerCompositionShapeHooks, value: f32) {
self.rotation_angle.set(value);
host.remove_animation_for_property(Self::id_of_rotation_angle_property().base());
}
pub fn id_of_scale_property() -> &'static CompositionPropertyOf<Vector> {
static PROPERTY: OnceLock<CompositionPropertyOf<Vector>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionShapeProps, Vector>(
"Scale",
"ServerCompositionShape",
|obj| props_of::<ServerCompositionShapeProps>(obj).scale.get(),
|obj, v| props_of::<ServerCompositionShapeProps>(obj).scale.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionShapeProps>(obj).scale.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionShapeProps>(obj).scale.set(v.cast_or_default::<Vector>())),
)
})
}
pub fn scale(&self) -> Vector {
self.scale.get()
}
pub fn set_scale(&self, host: &dyn ServerCompositionShapeHooks, value: Vector) {
self.scale.set(value);
host.remove_animation_for_property(Self::id_of_scale_property().base());
}
pub fn id_of_transform_matrix_property() -> &'static CompositionPropertyOf<Matrix> {
static PROPERTY: OnceLock<CompositionPropertyOf<Matrix>> = OnceLock::new();
PROPERTY.get_or_init(|| {
CompositionProperty::register::<ServerCompositionShapeProps, Matrix>(
"TransformMatrix",
"ServerCompositionShape",
|obj| props_of::<ServerCompositionShapeProps>(obj).transform_matrix.get(),
|obj, v| props_of::<ServerCompositionShapeProps>(obj).transform_matrix.set(v),
Some(|obj| ExpressionVariant::create(props_of::<ServerCompositionShapeProps>(obj).transform_matrix.get())),
Some(|obj, v: ExpressionVariant| props_of::<ServerCompositionShapeProps>(obj).transform_matrix.set(v.cast_or_default::<Matrix>())),
)
})
}
pub fn transform_matrix(&self) -> Matrix {
self.transform_matrix.get()
}
pub fn set_transform_matrix(&self, host: &dyn ServerCompositionShapeHooks, value: Matrix) {
self.transform_matrix.set(value);
host.remove_animation_for_property(Self::id_of_transform_matrix_property().base());
}
pub fn deserialize_changes_core(
&self,
host: &dyn ServerCompositionShapeHooks,
reader: &mut BatchStreamReader<'_>,
committed_at: Duration,
) {
ServerCompositionShapeHooks::deserialize_changes_extra(host, reader);
let changed = reader.read::<CompositionShapeChangedFields>();
if changed.contains(CompositionShapeChangedFields::CENTER_POINT_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `CenterPoint` without an animation instance");
};
host.set_animated_value(
Self::id_of_center_point_property().base(),
ExpressionVariant::create(self.center_point.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionShapeChangedFields::CENTER_POINT) {
let value = reader.read::<Vector>();
self.set_center_point(host, value);
}
if changed.contains(CompositionShapeChangedFields::OFFSET_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `Offset` without an animation instance");
};
host.set_animated_value(
Self::id_of_offset_property().base(),
ExpressionVariant::create(self.offset.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionShapeChangedFields::OFFSET) {
let value = reader.read::<Vector>();
self.set_offset(host, value);
}
if changed.contains(CompositionShapeChangedFields::ROTATION_ANGLE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `RotationAngle` without an animation instance");
};
host.set_animated_value(
Self::id_of_rotation_angle_property().base(),
ExpressionVariant::create(self.rotation_angle.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionShapeChangedFields::ROTATION_ANGLE) {
let value = reader.read::<f32>();
self.set_rotation_angle(host, value);
}
if changed.contains(CompositionShapeChangedFields::SCALE_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `Scale` without an animation instance");
};
host.set_animated_value(
Self::id_of_scale_property().base(),
ExpressionVariant::create(self.scale.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionShapeChangedFields::SCALE) {
let value = reader.read::<Vector>();
self.set_scale(host, value);
}
if changed.contains(CompositionShapeChangedFields::TRANSFORM_MATRIX_ANIMATED) {
let Some(animation) = reader.read_value::<AnimationInstanceFactory>().map(AnimationInstanceFactory::create) else {
panic!("a batch starts an animation of `TransformMatrix` without an animation instance");
};
host.set_animated_value(
Self::id_of_transform_matrix_property().base(),
ExpressionVariant::create(self.transform_matrix.get()),
committed_at,
animation,
);
} else if changed.contains(CompositionShapeChangedFields::TRANSFORM_MATRIX) {
let value = reader.read::<Matrix>();
self.set_transform_matrix(host, value);
}
ServerCompositionShapeHooks::on_fields_deserialized(host, changed);
}
pub fn get_composition_property(name: &str) -> Option<&'static CompositionProperty> {
if name == "CenterPoint" {
return Some(Self::id_of_center_point_property().base());
}
if name == "Offset" {
return Some(Self::id_of_offset_property().base());
}
if name == "RotationAngle" {
return Some(Self::id_of_rotation_angle_property().base());
}
if name == "Scale" {
return Some(Self::id_of_scale_property().base());
}
if name == "TransformMatrix" {
return Some(Self::id_of_transform_matrix_property().base());
}
None
}
}