Skip to content

Commit

Permalink
Fabric: Fixes transform when there are multiple values that contain a…
Browse files Browse the repository at this point in the history
… matrix (facebook#47477)

Summary:
Fixes facebook#47467 .

## Changelog:

[IOS] [FIXED] - Fabric: Fixes transform when there are multiple values that contain a matrix

Pull Request resolved: facebook#47477

Test Plan: Repro in Fixes facebook#47467

Reviewed By: javache

Differential Revision: D65594337

Pulled By: cipolleschi

fbshipit-source-id: 50f255e753e2f233415099c3fbdd0e43b0afefc0
  • Loading branch information
zhongwuzw authored and facebook-github-bot committed Dec 10, 2024
1 parent 9a21b99 commit d20897f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function _validateTransforms(transform: Array<Object>): void {
);
const key = keys[0];
const value = transformation[key];
if (key === 'matrix' && transform.length > 1) {
console.error(
'When using a matrix transform, you must specify exactly one transform object. Passed transform: ' +
stringifySafe(transform),
);
}
_validateTransform(key, value, transformation);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ Transform BaseViewProps::resolveTransform(
for (const auto& operation : transform.operations) {
transformMatrix = transformMatrix *
Transform::FromTransformOperation(
operation, layoutMetrics.frame.size);
operation, layoutMetrics.frame.size, transform);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ Transform Transform::Rotate(Float x, Float y, Float z) {

Transform Transform::FromTransformOperation(
TransformOperation transformOperation,
const Size& size) {
const Size& size,
const Transform& transform) {
if (transformOperation.type == TransformOperationType::Perspective) {
return Transform::Perspective(transformOperation.x.resolve(0));
}
Expand All @@ -196,8 +197,16 @@ Transform Transform::FromTransformOperation(
transformOperation.y.resolve(0),
transformOperation.z.resolve(0));
}
// when using arbitrary transform, the caller is responsible for applying the
// value
if (transformOperation.type == TransformOperationType::Arbitrary) {
auto arbitraryTransform = Transform{};
arbitraryTransform.operations.push_back(transformOperation);
arbitraryTransform.matrix = transform.matrix;
return arbitraryTransform;
}

// Identity or Arbitrary
// Identity
return Transform::Identity();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ struct Transform {
*/
static Transform FromTransformOperation(
TransformOperation transformOperation,
const Size& size);
const Size& size,
const Transform& transform = Transform::Identity());
static TransformOperation DefaultTransformOperation(
TransformOperationType type);

Expand Down

0 comments on commit d20897f

Please sign in to comment.