diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 00:51:26 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 00:51:26 +0000 |
commit | 803f6b54878c02a34499262aa9a6f9cd8813d1b1 (patch) | |
tree | 382613dcc17866aebd627d8e67b06625f9b88305 /cc/animation | |
parent | 5939b835c80fd4bfaf8b077375ba29cc8eb0cd4e (diff) | |
download | chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.zip chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.tar.gz chromium_src-803f6b54878c02a34499262aa9a6f9cd8813d1b1.tar.bz2 |
cc: Use SkMScalar instead of doubles for transforms in cc
BUG=269819
Review URL: https://chromiumcodereview.appspot.com/23043011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation')
-rw-r--r-- | cc/animation/layer_animation_controller_unittest.cc | 3 | ||||
-rw-r--r-- | cc/animation/transform_operation.cc | 153 | ||||
-rw-r--r-- | cc/animation/transform_operation.h | 18 | ||||
-rw-r--r-- | cc/animation/transform_operations.cc | 26 | ||||
-rw-r--r-- | cc/animation/transform_operations.h | 20 | ||||
-rw-r--r-- | cc/animation/transform_operations_unittest.cc | 202 |
6 files changed, 216 insertions, 206 deletions
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc index 6e94734..e55c53c 100644 --- a/cc/animation/layer_animation_controller_unittest.cc +++ b/cc/animation/layer_animation_controller_unittest.cc @@ -18,9 +18,6 @@ namespace cc { namespace { -void ExpectTranslateX(double translate_x, const gfx::Transform& matrix) { - EXPECT_FLOAT_EQ(translate_x, matrix.matrix().getDouble(0, 3)); } - scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, int id, Animation::TargetProperty property) { diff --git a/cc/animation/transform_operation.cc b/cc/animation/transform_operation.cc index ea3b0b2..93f40f3 100644 --- a/cc/animation/transform_operation.cc +++ b/cc/animation/transform_operation.cc @@ -12,7 +12,7 @@ #include "ui/gfx/vector3d_f.h" namespace { -const double kAngleEpsilon = 1e-4; +const SkMScalar kAngleEpsilon = 1e-4; } namespace cc { @@ -27,10 +27,10 @@ static bool IsOperationIdentity(const TransformOperation* operation) { static bool ShareSameAxis(const TransformOperation* from, const TransformOperation* to, - double* axis_x, - double* axis_y, - double* axis_z, - double* angle_from) { + SkMScalar* axis_x, + SkMScalar* axis_y, + SkMScalar* axis_z, + SkMScalar* angle_from) { if (IsOperationIdentity(from) && IsOperationIdentity(to)) return false; @@ -50,20 +50,21 @@ static bool ShareSameAxis(const TransformOperation* from, return true; } - double length_2 = from->rotate.axis.x * from->rotate.axis.x + - from->rotate.axis.y * from->rotate.axis.y + - from->rotate.axis.z * from->rotate.axis.z; - double other_length_2 = to->rotate.axis.x * to->rotate.axis.x + - to->rotate.axis.y * to->rotate.axis.y + - to->rotate.axis.z * to->rotate.axis.z; + SkMScalar length_2 = from->rotate.axis.x * from->rotate.axis.x + + from->rotate.axis.y * from->rotate.axis.y + + from->rotate.axis.z * from->rotate.axis.z; + SkMScalar other_length_2 = to->rotate.axis.x * to->rotate.axis.x + + to->rotate.axis.y * to->rotate.axis.y + + to->rotate.axis.z * to->rotate.axis.z; if (length_2 <= kAngleEpsilon || other_length_2 <= kAngleEpsilon) return false; - double dot = to->rotate.axis.x * from->rotate.axis.x + - to->rotate.axis.y * from->rotate.axis.y + - to->rotate.axis.z * from->rotate.axis.z; - double error = std::abs(1.0 - (dot * dot) / (length_2 * other_length_2)); + SkMScalar dot = to->rotate.axis.x * from->rotate.axis.x + + to->rotate.axis.y * from->rotate.axis.y + + to->rotate.axis.z * from->rotate.axis.z; + SkMScalar error = + std::abs(SK_MScalar1 - (dot * dot) / (length_2 * other_length_2)); bool result = error < kAngleEpsilon; if (result) { *axis_x = to->rotate.axis.x; @@ -76,14 +77,16 @@ static bool ShareSameAxis(const TransformOperation* from, return result; } -static double BlendDoubles(double from, double to, double progress) { +static SkMScalar BlendSkMScalars(SkMScalar from, + SkMScalar to, + SkMScalar progress) { return from * (1 - progress) + to * progress; } bool TransformOperation::BlendTransformOperations( const TransformOperation* from, const TransformOperation* to, - double progress, + SkMScalar progress, gfx::Transform* result) { if (IsOperationIdentity(from) && IsOperationIdentity(to)) return true; @@ -97,26 +100,26 @@ bool TransformOperation::BlendTransformOperations( switch (interpolation_type) { case TransformOperation::TransformOperationTranslate: { - double from_x = IsOperationIdentity(from) ? 0 : from->translate.x; - double from_y = IsOperationIdentity(from) ? 0 : from->translate.y; - double from_z = IsOperationIdentity(from) ? 0 : from->translate.z; - double to_x = IsOperationIdentity(to) ? 0 : to->translate.x; - double to_y = IsOperationIdentity(to) ? 0 : to->translate.y; - double to_z = IsOperationIdentity(to) ? 0 : to->translate.z; - result->Translate3d(BlendDoubles(from_x, to_x, progress), - BlendDoubles(from_y, to_y, progress), - BlendDoubles(from_z, to_z, progress)); + SkMScalar from_x = IsOperationIdentity(from) ? 0 : from->translate.x; + SkMScalar from_y = IsOperationIdentity(from) ? 0 : from->translate.y; + SkMScalar from_z = IsOperationIdentity(from) ? 0 : from->translate.z; + SkMScalar to_x = IsOperationIdentity(to) ? 0 : to->translate.x; + SkMScalar to_y = IsOperationIdentity(to) ? 0 : to->translate.y; + SkMScalar to_z = IsOperationIdentity(to) ? 0 : to->translate.z; + result->Translate3d(BlendSkMScalars(from_x, to_x, progress), + BlendSkMScalars(from_y, to_y, progress), + BlendSkMScalars(from_z, to_z, progress)); break; } case TransformOperation::TransformOperationRotate: { - double axis_x = 0; - double axis_y = 0; - double axis_z = 1; - double from_angle = 0; - double to_angle = IsOperationIdentity(to) ? 0 : to->rotate.angle; + SkMScalar axis_x = 0; + SkMScalar axis_y = 0; + SkMScalar axis_z = 1; + SkMScalar from_angle = 0; + SkMScalar to_angle = IsOperationIdentity(to) ? 0 : to->rotate.angle; if (ShareSameAxis(from, to, &axis_x, &axis_y, &axis_z, &from_angle)) { result->RotateAbout(gfx::Vector3dF(axis_x, axis_y, axis_z), - BlendDoubles(from_angle, to_angle, progress)); + BlendSkMScalars(from_angle, to_angle, progress)); } else { gfx::Transform to_matrix; if (!IsOperationIdentity(to)) @@ -131,33 +134,35 @@ bool TransformOperation::BlendTransformOperations( break; } case TransformOperation::TransformOperationScale: { - double from_x = IsOperationIdentity(from) ? 1 : from->scale.x; - double from_y = IsOperationIdentity(from) ? 1 : from->scale.y; - double from_z = IsOperationIdentity(from) ? 1 : from->scale.z; - double to_x = IsOperationIdentity(to) ? 1 : to->scale.x; - double to_y = IsOperationIdentity(to) ? 1 : to->scale.y; - double to_z = IsOperationIdentity(to) ? 1 : to->scale.z; - result->Scale3d(BlendDoubles(from_x, to_x, progress), - BlendDoubles(from_y, to_y, progress), - BlendDoubles(from_z, to_z, progress)); + SkMScalar from_x = IsOperationIdentity(from) ? 1 : from->scale.x; + SkMScalar from_y = IsOperationIdentity(from) ? 1 : from->scale.y; + SkMScalar from_z = IsOperationIdentity(from) ? 1 : from->scale.z; + SkMScalar to_x = IsOperationIdentity(to) ? 1 : to->scale.x; + SkMScalar to_y = IsOperationIdentity(to) ? 1 : to->scale.y; + SkMScalar to_z = IsOperationIdentity(to) ? 1 : to->scale.z; + result->Scale3d(BlendSkMScalars(from_x, to_x, progress), + BlendSkMScalars(from_y, to_y, progress), + BlendSkMScalars(from_z, to_z, progress)); break; } case TransformOperation::TransformOperationSkew: { - double from_x = IsOperationIdentity(from) ? 0 : from->skew.x; - double from_y = IsOperationIdentity(from) ? 0 : from->skew.y; - double to_x = IsOperationIdentity(to) ? 0 : to->skew.x; - double to_y = IsOperationIdentity(to) ? 0 : to->skew.y; - result->SkewX(BlendDoubles(from_x, to_x, progress)); - result->SkewY(BlendDoubles(from_y, to_y, progress)); + SkMScalar from_x = IsOperationIdentity(from) ? 0 : from->skew.x; + SkMScalar from_y = IsOperationIdentity(from) ? 0 : from->skew.y; + SkMScalar to_x = IsOperationIdentity(to) ? 0 : to->skew.x; + SkMScalar to_y = IsOperationIdentity(to) ? 0 : to->skew.y; + result->SkewX(BlendSkMScalars(from_x, to_x, progress)); + result->SkewY(BlendSkMScalars(from_y, to_y, progress)); break; } case TransformOperation::TransformOperationPerspective: { - double from_perspective_depth = IsOperationIdentity(from) ? - std::numeric_limits<double>::max() : from->perspective_depth; - double to_perspective_depth = IsOperationIdentity(to) ? - std::numeric_limits<double>::max() : to->perspective_depth; - result->ApplyPerspectiveDepth( - BlendDoubles(from_perspective_depth, to_perspective_depth, progress)); + SkMScalar from_perspective_depth = + IsOperationIdentity(from) ? std::numeric_limits<SkMScalar>::max() + : from->perspective_depth; + SkMScalar to_perspective_depth = IsOperationIdentity(to) + ? std::numeric_limits<SkMScalar>::max() + : to->perspective_depth; + result->ApplyPerspectiveDepth(BlendSkMScalars( + from_perspective_depth, to_perspective_depth, progress)); break; } case TransformOperation::TransformOperationMatrix: { @@ -207,8 +212,8 @@ static void UnionBoxWithZeroScale(gfx::BoxF* box) { bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, const TransformOperation* from, const TransformOperation* to, - double min_progress, - double max_progress, + SkMScalar min_progress, + SkMScalar max_progress, gfx::BoxF* bounds) { bool is_identity_from = IsOperationIdentity(from); bool is_identity_to = IsOperationIdentity(to); @@ -226,7 +231,7 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, switch (interpolation_type) { case TransformOperation::TransformOperationTranslate: { - double from_x, from_y, from_z; + SkMScalar from_x, from_y, from_z; if (is_identity_from) { from_x = from_y = from_z = 0.0; } else { @@ -234,7 +239,7 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, from_y = from->translate.y; from_z = from->translate.z; } - double to_x, to_y, to_z; + SkMScalar to_x, to_y, to_z; if (is_identity_to) { to_x = to_y = to_z = 0.0; } else { @@ -243,18 +248,18 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, to_z = to->translate.z; } *bounds = box; - *bounds += gfx::Vector3dF(BlendDoubles(from_x, to_x, min_progress), - BlendDoubles(from_y, to_y, min_progress), - BlendDoubles(from_z, to_z, min_progress)); + *bounds += gfx::Vector3dF(BlendSkMScalars(from_x, to_x, min_progress), + BlendSkMScalars(from_y, to_y, min_progress), + BlendSkMScalars(from_z, to_z, min_progress)); gfx::BoxF bounds_max = box; - bounds_max += gfx::Vector3dF(BlendDoubles(from_x, to_x, max_progress), - BlendDoubles(from_y, to_y, max_progress), - BlendDoubles(from_z, to_z, max_progress)); + bounds_max += gfx::Vector3dF(BlendSkMScalars(from_x, to_x, max_progress), + BlendSkMScalars(from_y, to_y, max_progress), + BlendSkMScalars(from_z, to_z, max_progress)); bounds->Union(bounds_max); return true; } case TransformOperation::TransformOperationScale: { - double from_x, from_y, from_z; + SkMScalar from_x, from_y, from_z; if (is_identity_from) { from_x = from_y = from_z = 1.0; } else { @@ -262,7 +267,7 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, from_y = from->scale.y; from_z = from->scale.z; } - double to_x, to_y, to_z; + SkMScalar to_x, to_y, to_z; if (is_identity_to) { to_x = to_y = to_z = 1.0; } else { @@ -271,15 +276,17 @@ bool TransformOperation::BlendedBoundsForBox(const gfx::BoxF& box, to_z = to->scale.z; } *bounds = box; - ApplyScaleToBox(BlendDoubles(from_x, to_x, min_progress), - BlendDoubles(from_y, to_y, min_progress), - BlendDoubles(from_z, to_z, min_progress), - bounds); + ApplyScaleToBox( + SkMScalarToFloat(BlendSkMScalars(from_x, to_x, min_progress)), + SkMScalarToFloat(BlendSkMScalars(from_y, to_y, min_progress)), + SkMScalarToFloat(BlendSkMScalars(from_z, to_z, min_progress)), + bounds); gfx::BoxF bounds_max = box; - ApplyScaleToBox(BlendDoubles(from_x, to_x, max_progress), - BlendDoubles(from_y, to_y, max_progress), - BlendDoubles(from_z, to_z, max_progress), - &bounds_max); + ApplyScaleToBox( + SkMScalarToFloat(BlendSkMScalars(from_x, to_x, max_progress)), + SkMScalarToFloat(BlendSkMScalars(from_y, to_y, max_progress)), + SkMScalarToFloat(BlendSkMScalars(from_z, to_z, max_progress)), + &bounds_max); if (!bounds->IsEmpty() && !bounds_max.IsEmpty()) { bounds->Union(bounds_max); } else if (!bounds->IsEmpty()) { diff --git a/cc/animation/transform_operation.h b/cc/animation/transform_operation.h index d5f2830..345ff295e 100644 --- a/cc/animation/transform_operation.h +++ b/cc/animation/transform_operation.h @@ -32,40 +32,40 @@ struct TransformOperation { gfx::Transform matrix; union { - double perspective_depth; + SkMScalar perspective_depth; struct { - double x, y; + SkMScalar x, y; } skew; struct { - double x, y, z; + SkMScalar x, y, z; } scale; struct { - double x, y, z; + SkMScalar x, y, z; } translate; struct { struct { - double x, y, z; + SkMScalar x, y, z; } axis; - double angle; + SkMScalar angle; } rotate; }; bool IsIdentity() const; static bool BlendTransformOperations(const TransformOperation* from, const TransformOperation* to, - double progress, + SkMScalar progress, gfx::Transform* result); static bool BlendedBoundsForBox(const gfx::BoxF& box, const TransformOperation* from, const TransformOperation* to, - double min_progress, - double max_progress, + SkMScalar min_progress, + SkMScalar max_progress, gfx::BoxF* bounds); }; diff --git a/cc/animation/transform_operations.cc b/cc/animation/transform_operations.cc index 42b3559..f8abe44 100644 --- a/cc/animation/transform_operations.cc +++ b/cc/animation/transform_operations.cc @@ -35,8 +35,8 @@ gfx::Transform TransformOperations::Apply() const { return to_return; } -gfx::Transform TransformOperations::Blend( - const TransformOperations& from, double progress) const { +gfx::Transform TransformOperations::Blend(const TransformOperations& from, + SkMScalar progress) const { gfx::Transform to_return; BlendInternal(from, progress, &to_return); return to_return; @@ -44,8 +44,8 @@ gfx::Transform TransformOperations::Blend( bool TransformOperations::BlendedBoundsForBox(const gfx::BoxF& box, const TransformOperations& from, - double min_progress, - double max_progress, + SkMScalar min_progress, + SkMScalar max_progress, gfx::BoxF* bounds) const { *bounds = box; @@ -101,7 +101,9 @@ bool TransformOperations::CanBlendWith( return BlendInternal(other, 0.5, &dummy); } -void TransformOperations::AppendTranslate(double x, double y, double z) { +void TransformOperations::AppendTranslate(SkMScalar x, + SkMScalar y, + SkMScalar z) { TransformOperation to_add; to_add.matrix.Translate3d(x, y, z); to_add.type = TransformOperation::TransformOperationTranslate; @@ -112,8 +114,10 @@ void TransformOperations::AppendTranslate(double x, double y, double z) { decomposed_transform_dirty_ = true; } -void TransformOperations::AppendRotate(double x, double y, double z, - double degrees) { +void TransformOperations::AppendRotate(SkMScalar x, + SkMScalar y, + SkMScalar z, + SkMScalar degrees) { TransformOperation to_add; to_add.matrix.RotateAbout(gfx::Vector3dF(x, y, z), degrees); to_add.type = TransformOperation::TransformOperationRotate; @@ -125,7 +129,7 @@ void TransformOperations::AppendRotate(double x, double y, double z, decomposed_transform_dirty_ = true; } -void TransformOperations::AppendScale(double x, double y, double z) { +void TransformOperations::AppendScale(SkMScalar x, SkMScalar y, SkMScalar z) { TransformOperation to_add; to_add.matrix.Scale3d(x, y, z); to_add.type = TransformOperation::TransformOperationScale; @@ -136,7 +140,7 @@ void TransformOperations::AppendScale(double x, double y, double z) { decomposed_transform_dirty_ = true; } -void TransformOperations::AppendSkew(double x, double y) { +void TransformOperations::AppendSkew(SkMScalar x, SkMScalar y) { TransformOperation to_add; to_add.matrix.SkewX(x); to_add.matrix.SkewY(y); @@ -147,7 +151,7 @@ void TransformOperations::AppendSkew(double x, double y) { decomposed_transform_dirty_ = true; } -void TransformOperations::AppendPerspective(double depth) { +void TransformOperations::AppendPerspective(SkMScalar depth) { TransformOperation to_add; to_add.matrix.ApplyPerspectiveDepth(depth); to_add.type = TransformOperation::TransformOperationPerspective; @@ -177,7 +181,7 @@ bool TransformOperations::IsIdentity() const { } bool TransformOperations::BlendInternal(const TransformOperations& from, - double progress, + SkMScalar progress, gfx::Transform* result) const { bool from_identity = from.IsIdentity(); bool to_identity = IsIdentity(); diff --git a/cc/animation/transform_operations.h b/cc/animation/transform_operations.h index 96bf1d1..7c50934 100644 --- a/cc/animation/transform_operations.h +++ b/cc/animation/transform_operations.h @@ -44,7 +44,8 @@ class CC_EXPORT TransformOperations { // transforms are baked to matrices (using apply), and the matrices are // then decomposed and interpolated. For more information, see // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposition. - gfx::Transform Blend(const TransformOperations& from, double progress) const; + gfx::Transform Blend(const TransformOperations& from, + SkMScalar progress) const; // Sets |bounds| be the bounding box for the region within which |box| will // exist when it is transformed by the result of calling Blend on |from| and @@ -52,8 +53,8 @@ class CC_EXPORT TransformOperations { // cannot be computed, returns false. bool BlendedBoundsForBox(const gfx::BoxF& box, const TransformOperations& from, - double min_progress, - double max_progress, + SkMScalar min_progress, + SkMScalar max_progress, gfx::BoxF* bounds) const; // Returns true if this operation and its descendants have the same types @@ -65,17 +66,18 @@ class CC_EXPORT TransformOperations { // fails (this can happen if either matrix cannot be decomposed). bool CanBlendWith(const TransformOperations& other) const; - void AppendTranslate(double x, double y, double z); - void AppendRotate(double x, double y, double z, double degrees); - void AppendScale(double x, double y, double z); - void AppendSkew(double x, double y); - void AppendPerspective(double depth); + void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z); + void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees); + void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z); + void AppendSkew(SkMScalar x, SkMScalar y); + void AppendPerspective(SkMScalar depth); void AppendMatrix(const gfx::Transform& matrix); void AppendIdentity(); bool IsIdentity() const; private: - bool BlendInternal(const TransformOperations& from, double progress, + bool BlendInternal(const TransformOperations& from, + SkMScalar progress, gfx::Transform* result) const; std::vector<TransformOperation> operations_; diff --git a/cc/animation/transform_operations_unittest.cc b/cc/animation/transform_operations_unittest.cc index b82d911..a7e4c51 100644 --- a/cc/animation/transform_operations_unittest.cc +++ b/cc/animation/transform_operations_unittest.cc @@ -147,9 +147,9 @@ TEST(TransformOperationTest, IdentityAlwaysMatches) { } TEST(TransformOperationTest, ApplyTranslate) { - double x = 1; - double y = 2; - double z = 3; + SkMScalar x = 1; + SkMScalar y = 2; + SkMScalar z = 3; TransformOperations operations; operations.AppendTranslate(x, y, z); gfx::Transform expected; @@ -158,10 +158,10 @@ TEST(TransformOperationTest, ApplyTranslate) { } TEST(TransformOperationTest, ApplyRotate) { - double x = 1; - double y = 2; - double z = 3; - double degrees = 80; + SkMScalar x = 1; + SkMScalar y = 2; + SkMScalar z = 3; + SkMScalar degrees = 80; TransformOperations operations; operations.AppendRotate(x, y, z, degrees); gfx::Transform expected; @@ -170,9 +170,9 @@ TEST(TransformOperationTest, ApplyRotate) { } TEST(TransformOperationTest, ApplyScale) { - double x = 1; - double y = 2; - double z = 3; + SkMScalar x = 1; + SkMScalar y = 2; + SkMScalar z = 3; TransformOperations operations; operations.AppendScale(x, y, z); gfx::Transform expected; @@ -181,8 +181,8 @@ TEST(TransformOperationTest, ApplyScale) { } TEST(TransformOperationTest, ApplySkew) { - double x = 1; - double y = 2; + SkMScalar x = 1; + SkMScalar y = 2; TransformOperations operations; operations.AppendSkew(x, y); gfx::Transform expected; @@ -192,7 +192,7 @@ TEST(TransformOperationTest, ApplySkew) { } TEST(TransformOperationTest, ApplyPerspective) { - double depth = 800; + SkMScalar depth = 800; TransformOperations operations; operations.AppendPerspective(depth); gfx::Transform expected; @@ -201,9 +201,9 @@ TEST(TransformOperationTest, ApplyPerspective) { } TEST(TransformOperationTest, ApplyMatrix) { - double dx = 1; - double dy = 2; - double dz = 3; + SkMScalar dx = 1; + SkMScalar dy = 2; + SkMScalar dz = 3; gfx::Transform expected_matrix; expected_matrix.Translate3d(dx, dy, dz); TransformOperations matrix_transform; @@ -212,13 +212,13 @@ TEST(TransformOperationTest, ApplyMatrix) { } TEST(TransformOperationTest, ApplyOrder) { - double sx = 2; - double sy = 4; - double sz = 8; + SkMScalar sx = 2; + SkMScalar sy = 4; + SkMScalar sz = 8; - double dx = 1; - double dy = 2; - double dz = 3; + SkMScalar dx = 1; + SkMScalar dy = 2; + SkMScalar dz = 3; TransformOperations operations; operations.AppendScale(sx, sy, sz); @@ -237,21 +237,21 @@ TEST(TransformOperationTest, ApplyOrder) { } TEST(TransformOperationTest, BlendOrder) { - double sx1 = 2; - double sy1 = 4; - double sz1 = 8; + SkMScalar sx1 = 2; + SkMScalar sy1 = 4; + SkMScalar sz1 = 8; - double dx1 = 1; - double dy1 = 2; - double dz1 = 3; + SkMScalar dx1 = 1; + SkMScalar dy1 = 2; + SkMScalar dz1 = 3; - double sx2 = 4; - double sy2 = 8; - double sz2 = 16; + SkMScalar sx2 = 4; + SkMScalar sy2 = 8; + SkMScalar sz2 = 16; - double dx2 = 10; - double dy2 = 20; - double dz2 = 30; + SkMScalar dx2 = 10; + SkMScalar dy2 = 20; + SkMScalar dz2 = 30; TransformOperations operations_from; operations_from.AppendScale(sx1, sy1, sz1); @@ -271,7 +271,7 @@ TEST(TransformOperationTest, BlendOrder) { gfx::Transform translate_to; translate_to.Translate3d(dx2, dy2, dz2); - double progress = 0.25; + SkMScalar progress = 0.25f; gfx::Transform blended_scale = scale_to; blended_scale.Blend(scale_from, progress); @@ -286,11 +286,11 @@ TEST(TransformOperationTest, BlendOrder) { expected, operations_to.Blend(operations_from, progress)); } -static void CheckProgress(double progress, - const gfx::Transform& from_matrix, - const gfx::Transform& to_matrix, - const TransformOperations& from_transform, - const TransformOperations& to_transform) { +static void CheckProgress(SkMScalar progress, + const gfx::Transform& from_matrix, + const gfx::Transform& to_matrix, + const TransformOperations& from_transform, + const TransformOperations& to_transform) { gfx::Transform expected_matrix = to_matrix; expected_matrix.Blend(from_matrix, progress); EXPECT_TRANSFORMATION_MATRIX_EQ( @@ -298,9 +298,9 @@ static void CheckProgress(double progress, } TEST(TransformOperationTest, BlendProgress) { - double sx = 2; - double sy = 4; - double sz = 8; + SkMScalar sx = 2; + SkMScalar sy = 4; + SkMScalar sz = 8; TransformOperations operations_from; operations_from.AppendScale(sx, sy, sz); @@ -318,28 +318,28 @@ TEST(TransformOperationTest, BlendProgress) { CheckProgress(-1, matrix_from, matrix_to, operations_from, operations_to); CheckProgress(0, matrix_from, matrix_to, operations_from, operations_to); - CheckProgress(0.25, matrix_from, matrix_to, operations_from, operations_to); - CheckProgress(0.5, matrix_from, matrix_to, operations_from, operations_to); + CheckProgress(0.25f, matrix_from, matrix_to, operations_from, operations_to); + CheckProgress(0.5f, matrix_from, matrix_to, operations_from, operations_to); CheckProgress(1, matrix_from, matrix_to, operations_from, operations_to); CheckProgress(2, matrix_from, matrix_to, operations_from, operations_to); } TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) { - double sx1 = 2; - double sy1 = 4; - double sz1 = 8; + SkMScalar sx1 = 2; + SkMScalar sy1 = 4; + SkMScalar sz1 = 8; - double dx1 = 1; - double dy1 = 2; - double dz1 = 3; + SkMScalar dx1 = 1; + SkMScalar dy1 = 2; + SkMScalar dz1 = 3; - double sx2 = 4; - double sy2 = 8; - double sz2 = 16; + SkMScalar sx2 = 4; + SkMScalar sy2 = 8; + SkMScalar sz2 = 16; - double dx2 = 10; - double dy2 = 20; - double dz2 = 30; + SkMScalar dx2 = 10; + SkMScalar dy2 = 20; + SkMScalar dz2 = 30; TransformOperations operations_from; operations_from.AppendScale(sx1, sy1, sz1); @@ -357,7 +357,7 @@ TEST(TransformOperationTest, BlendWhenTypesDoNotMatch) { to.Translate3d(dx2, dy2, dz2); to.Scale3d(sx2, sy2, sz2); - double progress = 0.25; + SkMScalar progress = 0.25f; gfx::Transform expected = to; expected.Blend(from, progress); @@ -373,7 +373,7 @@ TEST(TransformOperationTest, LargeRotationsWithSameAxis) { TransformOperations operations_to; operations_to.AppendRotate(0, 0, 2, 360); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); @@ -389,7 +389,7 @@ TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { TransformOperations operations_to; operations_to.AppendRotate(0, 0, -1, 180); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; @@ -404,7 +404,7 @@ TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { TransformOperations operations_to; operations_to.AppendRotate(0, 1, 0, 175); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform matrix_from; matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175); @@ -426,7 +426,7 @@ TEST(TransformOperationTest, BlendRotationFromIdentity) { TransformOperations operations; operations.AppendRotate(0, 0, 1, 360); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); @@ -434,7 +434,7 @@ TEST(TransformOperationTest, BlendRotationFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = -0.5; + progress = -0.5f; expected.MakeIdentity(); expected.RotateAbout(gfx::Vector3dF(0, 0, 1), -180); @@ -442,7 +442,7 @@ TEST(TransformOperationTest, BlendRotationFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = 1.5; + progress = 1.5f; expected.MakeIdentity(); expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 540); @@ -460,7 +460,7 @@ TEST(TransformOperationTest, BlendTranslationFromIdentity) { TransformOperations operations; operations.AppendTranslate(2, 2, 2); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.Translate3d(1, 1, 1); @@ -468,7 +468,7 @@ TEST(TransformOperationTest, BlendTranslationFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = -0.5; + progress = -0.5f; expected.MakeIdentity(); expected.Translate3d(-1, -1, -1); @@ -476,7 +476,7 @@ TEST(TransformOperationTest, BlendTranslationFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = 1.5; + progress = 1.5f; expected.MakeIdentity(); expected.Translate3d(3, 3, 3); @@ -494,7 +494,7 @@ TEST(TransformOperationTest, BlendScaleFromIdentity) { TransformOperations operations; operations.AppendScale(3, 3, 3); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.Scale3d(2, 2, 2); @@ -502,7 +502,7 @@ TEST(TransformOperationTest, BlendScaleFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = -0.5; + progress = -0.5f; expected.MakeIdentity(); expected.Scale3d(0, 0, 0); @@ -510,7 +510,7 @@ TEST(TransformOperationTest, BlendScaleFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = 1.5; + progress = 1.5f; expected.MakeIdentity(); expected.Scale3d(4, 4, 4); @@ -528,7 +528,7 @@ TEST(TransformOperationTest, BlendSkewFromIdentity) { TransformOperations operations; operations.AppendSkew(2, 2); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.SkewX(1); @@ -537,7 +537,7 @@ TEST(TransformOperationTest, BlendSkewFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = -0.5; + progress = -0.5f; expected.MakeIdentity(); expected.SkewX(-1); @@ -546,7 +546,7 @@ TEST(TransformOperationTest, BlendSkewFromIdentity) { EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); - progress = 1.5; + progress = 1.5f; expected.MakeIdentity(); expected.SkewX(3); @@ -565,11 +565,11 @@ TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { TransformOperations operations; operations.AppendPerspective(1000); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; - expected.ApplyPerspectiveDepth( - 500 + 0.5 * std::numeric_limits<double>::max()); + expected.ApplyPerspectiveDepth(500 + + 0.5 * std::numeric_limits<SkMScalar>::max()); EXPECT_TRANSFORMATION_MATRIX_EQ( expected, operations.Blend(*identity_operations[i], progress)); @@ -584,7 +584,7 @@ TEST(TransformOperationTest, BlendRotationToIdentity) { TransformOperations operations; operations.AppendRotate(0, 0, 1, 360); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); @@ -602,7 +602,7 @@ TEST(TransformOperationTest, BlendTranslationToIdentity) { TransformOperations operations; operations.AppendTranslate(2, 2, 2); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.Translate3d(1, 1, 1); @@ -620,7 +620,7 @@ TEST(TransformOperationTest, BlendScaleToIdentity) { TransformOperations operations; operations.AppendScale(3, 3, 3); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.Scale3d(2, 2, 2); @@ -638,7 +638,7 @@ TEST(TransformOperationTest, BlendSkewToIdentity) { TransformOperations operations; operations.AppendSkew(2, 2); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; expected.SkewX(1); @@ -657,11 +657,11 @@ TEST(TransformOperationTest, BlendPerspectiveToIdentity) { TransformOperations operations; operations.AppendPerspective(1000); - double progress = 0.5; + SkMScalar progress = 0.5f; gfx::Transform expected; - expected.ApplyPerspectiveDepth( - 500 + 0.5 * std::numeric_limits<double>::max()); + expected.ApplyPerspectiveDepth(500 + + 0.5 * std::numeric_limits<SkMScalar>::max()); EXPECT_TRANSFORMATION_MATRIX_EQ( expected, identity_operations[i]->Blend(operations, progress)); @@ -720,8 +720,8 @@ TEST(TransformOperationTest, BlendedBoundsWhenTypesDoNotMatch) { gfx::BoxF box(1.f, 1.f, 1.f); gfx::BoxF bounds; - double min_progress = 0.0; - double max_progress = 1.0; + SkMScalar min_progress = 0.f; + SkMScalar max_progress = 1.f; EXPECT_FALSE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); @@ -736,8 +736,8 @@ TEST(TransformOperationTest, BlendedBoundsForIdentity) { gfx::BoxF box(1.f, 2.f, 3.f); gfx::BoxF bounds; - double min_progress = 0.0; - double max_progress = 1.0; + SkMScalar min_progress = 0.f; + SkMScalar max_progress = 1.f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); @@ -753,15 +753,15 @@ TEST(TransformOperationTest, BlendedBoundsForTranslate) { gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); gfx::BoxF bounds; - double min_progress = -0.5; - double max_progress = 1.5; + SkMScalar min_progress = -0.5f; + SkMScalar max_progress = 1.5f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(2.f, -6.f, -1.f, 12.f, 20.f, 12.f).ToString(), bounds.ToString()); - min_progress = 0.0; - max_progress = 1.0; + min_progress = 0.f; + max_progress = 1.f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(4.f, -2.f, 1.f, 8.f, 12.f, 8.f).ToString(), @@ -788,15 +788,15 @@ TEST(TransformOperationTest, BlendedBoundsForScale) { gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); gfx::BoxF bounds; - double min_progress = -0.5; - double max_progress = 1.5; + SkMScalar min_progress = -0.5f; + SkMScalar max_progress = 1.5f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(1.f, -7.5f, -28.f, 44.f, 42.f, 56.f).ToString(), bounds.ToString()); - min_progress = 0.0; - max_progress = 1.0; + min_progress = 0.f; + max_progress = 1.f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(3.f, 1.f, -14.f, 32.f, 23.f, 28.f).ToString(), @@ -823,8 +823,8 @@ TEST(TransformOperationTest, BlendedBoundsWithZeroScale) { gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); gfx::BoxF bounds; - double min_progress = 0.0; - double max_progress = 1.0; + SkMScalar min_progress = 0.f; + SkMScalar max_progress = 1.f; EXPECT_TRUE(zero_scale.BlendedBoundsForBox( box, non_zero_scale, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(0.f, -24.f, 0.f, 10.f, 24.f, 35.f).ToString(), @@ -853,15 +853,15 @@ TEST(TransformOperationTest, BlendedBoundsForSequence) { gfx::BoxF box(1.f, 2.f, 3.f, 4.f, 4.f, 4.f); gfx::BoxF bounds; - double min_progress = -0.5; - double max_progress = 1.5; + SkMScalar min_progress = -0.5f; + SkMScalar max_progress = 1.5f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(-57.f, -59.f, -1.f, 76.f, 112.f, 80.f).ToString(), bounds.ToString()); - min_progress = 0.0; - max_progress = 1.0; + min_progress = 0.f; + max_progress = 1.f; EXPECT_TRUE(operations_to.BlendedBoundsForBox( box, operations_from, min_progress, max_progress, &bounds)); EXPECT_EQ(gfx::BoxF(-32.f, -25.f, 7.f, 42.f, 44.f, 48.f).ToString(), |