Loading libs/ui/Transform.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,11 @@ Transform Transform::operator * (float value) const { R[i][j] = M[i][j] * value; } } if (value != 1.0) { // If a non-unity scale is applied, the type might change. // Mark it as UNKNOWN to force re-computation. r.mType = UNKNOWN_TYPE; } r.type(); return r; } Loading libs/ui/tests/Transform_test.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,15 @@ TEST(TransformTest, inverseRotation_hasCorrectType) { testRotationFlagsForInverse(Transform::FLIP_V, Transform::FLIP_V, false); } TEST(TransformTest, scaling_hasCorrectType) { const Transform identityTransform = Transform(); EXPECT_TRUE(identityTransform.getType() == Transform::IDENTITY); // An unity scale should keep transform unchanged. EXPECT_TRUE(identityTransform == (identityTransform * 1.0)); // A non-unity scale should result in SCALE transform. EXPECT_TRUE((identityTransform * 2.0).getType() == Transform::SCALE); } } // namespace android::ui Loading
libs/ui/Transform.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,11 @@ Transform Transform::operator * (float value) const { R[i][j] = M[i][j] * value; } } if (value != 1.0) { // If a non-unity scale is applied, the type might change. // Mark it as UNKNOWN to force re-computation. r.mType = UNKNOWN_TYPE; } r.type(); return r; } Loading
libs/ui/tests/Transform_test.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,15 @@ TEST(TransformTest, inverseRotation_hasCorrectType) { testRotationFlagsForInverse(Transform::FLIP_V, Transform::FLIP_V, false); } TEST(TransformTest, scaling_hasCorrectType) { const Transform identityTransform = Transform(); EXPECT_TRUE(identityTransform.getType() == Transform::IDENTITY); // An unity scale should keep transform unchanged. EXPECT_TRUE(identityTransform == (identityTransform * 1.0)); // A non-unity scale should result in SCALE transform. EXPECT_TRUE((identityTransform * 2.0).getType() == Transform::SCALE); } } // namespace android::ui