summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/animation/layer_animation_controller_unittest.cc3
-rw-r--r--cc/animation/transform_operation.cc153
-rw-r--r--cc/animation/transform_operation.h18
-rw-r--r--cc/animation/transform_operations.cc26
-rw-r--r--cc/animation/transform_operations.h20
-rw-r--r--cc/animation/transform_operations_unittest.cc202
-rw-r--r--cc/base/float_quad_unittest.cc25
-rw-r--r--cc/base/math_util.cc24
-rw-r--r--cc/base/math_util.h4
-rw-r--r--cc/layers/delegated_renderer_layer_impl_unittest.cc66
-rw-r--r--cc/test/geometry_test_utils.cc48
-rw-r--r--cc/trees/damage_tracker_unittest.cc12
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc311
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc4
-rw-r--r--ui/gfx/transform.cc276
-rw-r--r--ui/gfx/transform.h50
-rw-r--r--ui/gfx/transform_util.cc112
-rw-r--r--ui/gfx/transform_util.h12
18 files changed, 662 insertions, 704 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(),
diff --git a/cc/base/float_quad_unittest.cc b/cc/base/float_quad_unittest.cc
index bb3446c..186624e 100644
--- a/cc/base/float_quad_unittest.cc
+++ b/cc/base/float_quad_unittest.cc
@@ -25,15 +25,15 @@ TEST(FloatQuadTest, IsRectilinearTest) {
rectilinear_trans[7].Scale(100000, 100000);
rectilinear_trans[7].Rotate(180.0);
+ gfx::QuadF original(
+ gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
+
for (int i = 0; i < kNumRectilinear; ++i) {
bool clipped = false;
- gfx::QuadF quad = MathUtil::MapQuad(
- rectilinear_trans[i],
- gfx::QuadF(
- gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)),
- &clipped);
- ASSERT_TRUE(!clipped);
- EXPECT_TRUE(quad.IsRectilinear());
+ gfx::QuadF quad =
+ MathUtil::MapQuad(rectilinear_trans[i], original, &clipped);
+ ASSERT_TRUE(!clipped) << "case " << i;
+ EXPECT_TRUE(quad.IsRectilinear()) << "case " << i;
}
const int kNumNonRectilinear = 10;
@@ -51,13 +51,10 @@ TEST(FloatQuadTest, IsRectilinearTest) {
for (int i = 0; i < kNumNonRectilinear; ++i) {
bool clipped = false;
- gfx::QuadF quad = MathUtil::MapQuad(
- non_rectilinear_trans[i],
- gfx::QuadF(
- gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)),
- &clipped);
- ASSERT_TRUE(!clipped);
- EXPECT_FALSE(quad.IsRectilinear());
+ gfx::QuadF quad =
+ MathUtil::MapQuad(non_rectilinear_trans[i], original, &clipped);
+ ASSERT_TRUE(!clipped) << "case " << i;
+ EXPECT_FALSE(quad.IsRectilinear()) << "case " << i;
}
}
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index 919a172f..40b8d11 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -108,15 +108,15 @@ gfx::Rect MathUtil::MapClippedRect(const gfx::Transform& transform,
gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform,
const gfx::RectF& src_rect) {
- if (transform.IsIdentityOrTranslation())
+ if (transform.IsIdentityOrTranslation()) {
return src_rect +
- gfx::Vector2dF(
- static_cast<float>(transform.matrix().getDouble(0, 3)),
- static_cast<float>(transform.matrix().getDouble(1, 3)));
+ gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)),
+ SkMScalarToFloat(transform.matrix().get(1, 3)));
+ }
// Apply the transform, but retain the result in homogeneous coordinates.
- double quad[4 * 2]; // input: 4 x 2D points
+ SkMScalar quad[4 * 2]; // input: 4 x 2D points
quad[0] = src_rect.x();
quad[1] = src_rect.y();
quad[2] = src_rect.right();
@@ -126,7 +126,7 @@ gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform,
quad[6] = src_rect.x();
quad[7] = src_rect.bottom();
- double result[4 * 4]; // output: 4 x 4D homogeneous points
+ SkMScalar result[4 * 4]; // output: 4 x 4D homogeneous points
transform.matrix().map2(quad, 4, result);
HomogeneousCoordinate hc0(result[0], result[1], result[2], result[3]);
@@ -140,9 +140,8 @@ gfx::RectF MathUtil::ProjectClippedRect(const gfx::Transform& transform,
const gfx::RectF& src_rect) {
if (transform.IsIdentityOrTranslation()) {
return src_rect +
- gfx::Vector2dF(
- static_cast<float>(transform.matrix().getDouble(0, 3)),
- static_cast<float>(transform.matrix().getDouble(1, 3)));
+ gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)),
+ SkMScalarToFloat(transform.matrix().get(1, 3)));
}
// Perform the projection, but retain the result in homogeneous coordinates.
@@ -330,8 +329,8 @@ gfx::QuadF MathUtil::MapQuad(const gfx::Transform& transform,
if (transform.IsIdentityOrTranslation()) {
gfx::QuadF mapped_quad(q);
mapped_quad +=
- gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)),
- static_cast<float>(transform.matrix().getDouble(1, 3)));
+ gfx::Vector2dF(SkMScalarToFloat(transform.matrix().get(0, 3)),
+ SkMScalarToFloat(transform.matrix().get(1, 3)));
*clipped = false;
return mapped_quad;
}
@@ -467,7 +466,8 @@ gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect,
}
static inline float ScaleOnAxis(double a, double b, double c) {
- return std::sqrt(a * a + b * b + c * c);
+ // Do the sqrt as a double to not lose precision.
+ return static_cast<float>(std::sqrt(a * a + b * b + c * c));
}
gfx::Vector2dF MathUtil::ComputeTransform2dScaleComponents(
diff --git a/cc/base/math_util.h b/cc/base/math_util.h
index 6cf929c..7912f8a 100644
--- a/cc/base/math_util.h
+++ b/cc/base/math_util.h
@@ -45,7 +45,7 @@ struct HomogeneousCoordinate {
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
DCHECK(w());
- double inv_w = 1.0 / w();
+ SkMScalar inv_w = 1.0 / w();
return gfx::PointF(x() * inv_w, y() * inv_w);
}
@@ -56,7 +56,7 @@ struct HomogeneousCoordinate {
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
DCHECK(w());
- double inv_w = 1.0 / w();
+ SkMScalar inv_w = 1.0 / w();
return gfx::Point3F(x() * inv_w, y() * inv_w, z() * inv_w);
}
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index 400a442..a641e00 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -467,8 +467,8 @@ class DelegatedRendererLayerImplTestTransform
root_layer->SetBounds(gfx::Size(100, 100));
delegated_renderer_layer->SetPosition(gfx::Point(20, 20));
- delegated_renderer_layer->SetBounds(gfx::Size(30, 30));
- delegated_renderer_layer->SetContentBounds(gfx::Size(30, 30));
+ delegated_renderer_layer->SetBounds(gfx::Size(75, 75));
+ delegated_renderer_layer->SetContentBounds(gfx::Size(75, 75));
delegated_renderer_layer->SetDrawsContent(true);
gfx::Transform transform;
transform.Scale(2.0, 2.0);
@@ -513,8 +513,8 @@ class DelegatedRendererLayerImplTestTransform
quad_sink.Append(color_quad.PassAs<DrawQuad>(), &data);
}
- gfx::Size root_pass_content_bounds(50, 50);
- gfx::Rect root_pass_rect(0, 0, 50, 50);
+ gfx::Size root_pass_content_bounds(100, 100);
+ gfx::Rect root_pass_rect(0, 0, 100, 100);
gfx::Transform root_pass_transform;
root_pass_transform.Scale(1.5, 1.5);
root_pass_transform.Translate(7.0, 7.0);
@@ -648,7 +648,7 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_NoSurface) {
// When the quads don't have a clip of their own, the clip rect is set to
// the drawable_content_rect of the delegated renderer layer.
- EXPECT_EQ(gfx::Rect(42, 42, 120, 120).ToString(),
+ EXPECT_EQ(delegated_renderer_layer_->drawable_content_rect().ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// Even though the quads in the root pass have no clip of their own, they
@@ -660,12 +660,12 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_NoSurface) {
// Device scale factor is 2.
expected.Scale(2.0, 2.0);
// This is the transform from the layer's space to its target.
- // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5
- expected.Translate(5.0, 5.0);
+ // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5
+ expected.Translate(-17.5, -17.5);
expected.Scale(2.0, 2.0);
expected.Translate(8.0, 8.0);
- // The frame has size 50x50 but the layer's bounds are 30x30.
- expected.Scale(30.0 / 50.0, 30.0 / 50.0);
+ // The frame has size 100x100 but the layer's bounds are 75x75.
+ expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
@@ -705,15 +705,15 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_NoSurface) {
// Since the quads have a clip_rect it should be modified by delegated
// renderer layer's draw_transform.
// The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (30/50) + translate (8)) *
- // layer scale (2) + layer position (20) = 48
- // But the layer is centered, so: 48 - (width / 2) = 48 - 30 / 2 = 33
- // The device scale is 2, so everything gets doubled, giving 66.
+ // (clip rect position (10) * scale to layer (75/100) + translate (8)) *
+ // layer scale (2) + layer position (20) = 51
+ // But the layer is centered, so: 51 - (75 / 2) = 51 - 75 / 2 = 13.5
+ // The device scale is 2, so everything gets doubled, giving 27.
//
- // The size is 35x35 scaled to fit inside the layer's bounds at 30x30 from
- // a frame at 50x50: 35 * 2 (device scale) * 30 / 50 = 42. The device scale
- // doubles this to 84.
- EXPECT_EQ(gfx::Rect(66, 66, 84, 84).ToString(),
+ // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
+ // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5. The device
+ // scale doubles this to 105.
+ EXPECT_EQ(gfx::Rect(27, 27, 105, 105).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// The quads had a clip and it should be preserved.
@@ -723,12 +723,12 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_NoSurface) {
// Device scale factor is 2.
expected.Scale(2.0, 2.0);
// This is the transform from the layer's space to its target.
- // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5
- expected.Translate(5.0, 5.0);
+ // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5
+ expected.Translate(-17.5, -17.5);
expected.Scale(2.0, 2.0);
expected.Translate(8.0, 8.0);
- // The frame has size 50x50 but the layer's bounds are 30x30.
- expected.Scale(30.0 / 50.0, 30.0 / 50.0);
+ // The frame has size 100x100 but the layer's bounds are 75x75.
+ expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
@@ -770,10 +770,10 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) {
// When the layer owns a surface, then its position and translation are not
// a part of its draw transform.
// The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (30/50)) * device scale (2) = 12
- // The size is 35x35 scaled to fit inside the layer's bounds at 30x30 from
- // a frame at 50x50: 35 * 2 (device scale) * 30 / 50 = 42.
- EXPECT_EQ(gfx::Rect(12, 12, 42, 42).ToString(),
+ // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15
+ // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
+ // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5.
+ EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// Since the layer owns a surface it doesn't need to clip its quads, so
@@ -783,8 +783,8 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) {
gfx::Transform expected;
// Device scale factor is 2.
expected.Scale(2.0, 2.0);
- // The frame has size 50x50 but the layer's bounds are 30x30.
- expected.Scale(30.0 / 50.0, 30.0 / 50.0);
+ // The frame has size 100x100 but the layer's bounds are 75x75.
+ expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
@@ -826,10 +826,10 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) {
// When the layer owns a surface, then its position and translation are not
// a part of its draw transform.
// The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (30/50)) * device scale (2) = 12
- // The size is 35x35 scaled to fit inside the layer's bounds at 30x30 from
- // a frame at 50x50: 35 * 2 (device scale) * 30 / 50 = 42.
- EXPECT_EQ(gfx::Rect(12, 12, 42, 42).ToString(),
+ // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15
+ // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
+ // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5.
+ EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// The quads had a clip and it should be preserved.
@@ -838,8 +838,8 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) {
gfx::Transform expected;
// Device scale factor is 2.
expected.Scale(2.0, 2.0);
- // The frame has size 50x50 but the layer's bounds are 30x30.
- expected.Scale(30.0 / 50.0, 30.0 / 50.0);
+ // The frame has size 100x100 but the layer's bounds are 75x75.
+ expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
diff --git a/cc/test/geometry_test_utils.cc b/cc/test/geometry_test_utils.cc
index 6b9033b..9bf5811 100644
--- a/cc/test/geometry_test_utils.cc
+++ b/cc/test/geometry_test_utils.cc
@@ -16,38 +16,22 @@ namespace cc {
void ExpectTransformationMatrixEq(const gfx::Transform& expected,
const gfx::Transform& actual) {
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0),
- (actual).matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0),
- (actual).matrix().getDouble(1, 0));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0),
- (actual).matrix().getDouble(2, 0));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0),
- (actual).matrix().getDouble(3, 0));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1),
- (actual).matrix().getDouble(0, 1));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1),
- (actual).matrix().getDouble(1, 1));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1),
- (actual).matrix().getDouble(2, 1));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 1),
- (actual).matrix().getDouble(3, 1));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 2),
- (actual).matrix().getDouble(0, 2));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 2),
- (actual).matrix().getDouble(1, 2));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 2),
- (actual).matrix().getDouble(2, 2));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 2),
- (actual).matrix().getDouble(3, 2));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 3),
- (actual).matrix().getDouble(0, 3));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 3),
- (actual).matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 3),
- (actual).matrix().getDouble(2, 3));
- EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 3),
- (actual).matrix().getDouble(3, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().get(0, 0), (actual).matrix().get(0, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().get(1, 0), (actual).matrix().get(1, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().get(2, 0), (actual).matrix().get(2, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().get(3, 0), (actual).matrix().get(3, 0));
+ EXPECT_FLOAT_EQ((expected).matrix().get(0, 1), (actual).matrix().get(0, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().get(1, 1), (actual).matrix().get(1, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().get(2, 1), (actual).matrix().get(2, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().get(3, 1), (actual).matrix().get(3, 1));
+ EXPECT_FLOAT_EQ((expected).matrix().get(0, 2), (actual).matrix().get(0, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().get(1, 2), (actual).matrix().get(1, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().get(2, 2), (actual).matrix().get(2, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().get(3, 2), (actual).matrix().get(3, 2));
+ EXPECT_FLOAT_EQ((expected).matrix().get(0, 3), (actual).matrix().get(0, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().get(1, 3), (actual).matrix().get(1, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().get(2, 3), (actual).matrix().get(2, 3));
+ EXPECT_FLOAT_EQ((expected).matrix().get(3, 3), (actual).matrix().get(3, 3));
}
gfx::Transform Inverse(const gfx::Transform& transform) {
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc
index 9e45379..8a86207 100644
--- a/cc/trees/damage_tracker_unittest.cc
+++ b/cc/trees/damage_tracker_unittest.cc
@@ -340,14 +340,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) {
// should increase the size of the expected rect by sqrt(2), centered around
// (100, 100). The old exposed region should be fully contained in the new
// region.
- double expected_width = 30.0 * sqrt(2.0);
- double expected_position = 100.0 - 0.5 * expected_width;
- gfx::RectF expected_rect(expected_position,
- expected_position,
- expected_width,
- expected_width);
+ float expected_width = 30.f * sqrt(2.f);
+ float expected_position = 100.f - 0.5f * expected_width;
+ gfx::RectF expected_rect(
+ expected_position, expected_position, expected_width, expected_width);
root_damage_rect =
- root->render_surface()->damage_tracker()->current_damage_rect();
+ root->render_surface()->damage_tracker()->current_damage_rect();
EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect);
}
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index cd71c88..5ce1034 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -1372,29 +1372,25 @@ TEST_F(LayerTreeHostCommonTest, TransformsForRenderSurfaceHierarchy) {
// Sanity check. If these fail there is probably a bug in the test itself. It
// is expected that we correctly set up transforms so that the y-component of
// the screen-space transform encodes the "depth" of the layer in the tree.
- EXPECT_FLOAT_EQ(1.0,
- parent->screen_space_transform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(1.0, parent->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(2.0,
+ child_of_root->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 2.0, child_of_root->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 3.0,
- grand_child_of_root->screen_space_transform().matrix().getDouble(1, 3));
+ 3.0, grand_child_of_root->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(2.0,
+ render_surface1->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(3.0,
+ child_of_rs1->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 2.0, render_surface1->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 3.0, child_of_rs1->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 4.0,
- grand_child_of_rs1->screen_space_transform().matrix().getDouble(1, 3));
+ 4.0, grand_child_of_rs1->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(3.0,
+ render_surface2->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(4.0,
+ child_of_rs2->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 3.0, render_surface2->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 4.0, child_of_rs2->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 5.0,
- grand_child_of_rs2->screen_space_transform().matrix().getDouble(1, 3));
+ 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3));
}
TEST_F(LayerTreeHostCommonTest, TransformsForFlatteningLayer) {
@@ -1664,8 +1660,10 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
compositeSquared.ConcatTransform(composite);
gfx::Transform compositeCubed = compositeSquared;
compositeCubed.ConcatTransform(composite);
- EXPECT_EQ(compositeSquared, root->draw_properties().target_space_transform);
- EXPECT_EQ(compositeCubed, child->draw_properties().target_space_transform);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ compositeSquared, root->draw_properties().target_space_transform);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ compositeCubed, child->draw_properties().target_space_transform);
EXPECT_EQ(identity_matrix, root->render_surface()->draw_transform());
}
}
@@ -2638,29 +2636,25 @@ TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
// Sanity check. If these fail there is probably a bug in the test itself.
// It is expected that we correctly set up transforms so that the y-component
// of the screen-space transform encodes the "depth" of the layer in the tree.
- EXPECT_FLOAT_EQ(1.0,
- parent->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 2.0, child_of_root->screen_space_transform().matrix().getDouble(1, 3));
+ EXPECT_FLOAT_EQ(1.0, parent->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(2.0,
+ child_of_root->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 3.0,
- grand_child_of_root->screen_space_transform().matrix().getDouble(1, 3));
+ 3.0, grand_child_of_root->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(2.0,
+ render_surface1->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(3.0,
+ child_of_rs1->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 2.0, render_surface1->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 3.0, child_of_rs1->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 4.0,
- grand_child_of_rs1->screen_space_transform().matrix().getDouble(1, 3));
+ 4.0, grand_child_of_rs1->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(3.0,
+ render_surface2->screen_space_transform().matrix().get(1, 3));
+ EXPECT_FLOAT_EQ(4.0,
+ child_of_rs2->screen_space_transform().matrix().get(1, 3));
EXPECT_FLOAT_EQ(
- 3.0, render_surface2->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 4.0, child_of_rs2->screen_space_transform().matrix().getDouble(1, 3));
- EXPECT_FLOAT_EQ(
- 5.0,
- grand_child_of_rs2->screen_space_transform().matrix().getDouble(1, 3));
+ 5.0, grand_child_of_rs2->screen_space_transform().matrix().get(1, 3));
}
TEST_F(LayerTreeHostCommonTest, VisibleRectForIdentityTransform) {
@@ -2796,7 +2790,8 @@ TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dOrthographicTransform) {
// degrees, but shifted to the side so only the right-half the layer would be
// visible on the surface.
// 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width.
- double half_width_of_rotated_layer = (100.0 / sqrt(2.0)) * 0.5;
+ SkMScalar half_width_of_rotated_layer =
+ SkDoubleToMScalar((100.0 / sqrt(2.0)) * 0.5);
layer_to_surface_transform.MakeIdentity();
layer_to_surface_transform.Translate(-half_width_of_rotated_layer, 0.0);
layer_to_surface_transform.RotateAboutYAxis(45.0); // Rotates about the left
@@ -3219,7 +3214,7 @@ TEST_F(LayerTreeHostCommonTest,
// bounds are visible since there is no way to inverse-project the surface
// bounds to intersect.
uninvertible_matrix.MakeIdentity();
- uninvertible_matrix.matrix().setDouble(2, 2, 0.0);
+ uninvertible_matrix.matrix().set(2, 2, 0.0);
ASSERT_FALSE(uninvertible_matrix.IsInvertible());
SetLayerPropertiesForTesting(child.get(),
@@ -3240,7 +3235,7 @@ TEST_F(LayerTreeHostCommonTest,
// assume that the whole layer is visible.
uninvertible_matrix.MakeIdentity();
uninvertible_matrix.Translate(500.0, 0.0);
- uninvertible_matrix.matrix().setDouble(2, 2, 0.0);
+ uninvertible_matrix.matrix().set(2, 2, 0.0);
ASSERT_FALSE(uninvertible_matrix.IsInvertible());
SetLayerPropertiesForTesting(child.get(),
@@ -3508,10 +3503,10 @@ TEST_F(LayerTreeHostCommonTest,
// regions of the subtree.
int diagonal_radius = ceil(sqrt(2.0) * 25.0);
gfx::Rect expected_surface_drawable_content =
- gfx::Rect(50.0 - diagonal_radius,
- 50.0 - diagonal_radius,
- diagonal_radius * 2.0,
- diagonal_radius * 2.0);
+ gfx::Rect(50 - diagonal_radius,
+ 50 - diagonal_radius,
+ diagonal_radius * 2,
+ diagonal_radius * 2);
EXPECT_RECT_EQ(expected_surface_drawable_content,
render_surface1->render_surface()->DrawableContentRect());
@@ -3570,10 +3565,10 @@ TEST_F(LayerTreeHostCommonTest,
// The clipped surface clamps the DrawableContentRect that encloses the
// rotated layer.
int diagonal_radius = ceil(sqrt(2.0) * 25.0);
- gfx::Rect unclipped_surface_content = gfx::Rect(50.0 - diagonal_radius,
- 50.0 - diagonal_radius,
- diagonal_radius * 2.0,
- diagonal_radius * 2.0);
+ gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius,
+ 50 - diagonal_radius,
+ diagonal_radius * 2,
+ diagonal_radius * 2);
gfx::Rect expected_surface_drawable_content =
gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50));
EXPECT_RECT_EQ(expected_surface_drawable_content,
@@ -3582,6 +3577,8 @@ TEST_F(LayerTreeHostCommonTest,
// On the clipped surface, only a quarter of the child1 is visible, but when
// rotating it back to child1's content space, the actual enclosing rect ends
// up covering the full left half of child1.
+ //
+ // Given the floating point math, this number is a little bit fuzzy.
EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect());
// The child's DrawableContentRect is unclipped.
@@ -4468,10 +4465,10 @@ TEST_F(LayerTreeHostCommonTest, HitTestingForUninvertibleTransform) {
LayerImpl::Create(host_impl.active_tree(), 12345);
gfx::Transform uninvertible_transform;
- uninvertible_transform.matrix().setDouble(0, 0, 0.0);
- uninvertible_transform.matrix().setDouble(1, 1, 0.0);
- uninvertible_transform.matrix().setDouble(2, 2, 0.0);
- uninvertible_transform.matrix().setDouble(3, 3, 0.0);
+ uninvertible_transform.matrix().set(0, 0, 0.0);
+ uninvertible_transform.matrix().set(1, 1, 0.0);
+ uninvertible_transform.matrix().set(2, 2, 0.0);
+ uninvertible_transform.matrix().set(3, 3, 0.0);
ASSERT_FALSE(uninvertible_transform.IsInvertible());
gfx::Transform identity_matrix;
@@ -5054,7 +5051,7 @@ TEST_F(LayerTreeHostCommonTest, HitTestingForMultiClippedRotatedLayer) {
// Around the middle, just to the right and up, would have hit the layer
// except that that area should be clipped away by the parent.
- test_point = gfx::Point(51, 51);
+ test_point = gfx::Point(51, 49);
result_layer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
test_point, render_surface_layer_list);
EXPECT_FALSE(result_layer);
@@ -5567,10 +5564,10 @@ TEST_F(LayerTreeHostCommonTest,
LayerImpl::Create(host_impl.active_tree(), 12345);
gfx::Transform uninvertible_transform;
- uninvertible_transform.matrix().setDouble(0, 0, 0.0);
- uninvertible_transform.matrix().setDouble(1, 1, 0.0);
- uninvertible_transform.matrix().setDouble(2, 2, 0.0);
- uninvertible_transform.matrix().setDouble(3, 3, 0.0);
+ uninvertible_transform.matrix().set(0, 0, 0.0);
+ uninvertible_transform.matrix().set(1, 1, 0.0);
+ uninvertible_transform.matrix().set(2, 2, 0.0);
+ uninvertible_transform.matrix().set(3, 3, 0.0);
ASSERT_FALSE(uninvertible_transform.IsInvertible());
gfx::Transform identity_matrix;
@@ -6470,11 +6467,11 @@ TEST_F(LayerTreeHostCommonTest, ContentsScale) {
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 1.75;
+ SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 1.25;
+ SkMScalar initial_child_scale = 1.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -6555,22 +6552,18 @@ TEST_F(LayerTreeHostCommonTest, ContentsScale) {
// child that can scale its contents should also not need to scale during
// draw. This shouldn't change if the child has empty bounds. The other
// children should.
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(1, 1));
- EXPECT_FLOAT_EQ(1.0,
- child_scale->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0,
- child_scale->draw_transform().matrix().getDouble(1, 1));
- EXPECT_FLOAT_EQ(1.0,
- child_empty->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0,
- child_empty->draw_transform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1));
+ EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, child_scale->draw_transform().matrix().get(1, 1));
+ EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, child_empty->draw_transform().matrix().get(1, 1));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().getDouble(0, 0));
+ child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().getDouble(1, 1));
+ initial_parent_scale * initial_child_scale,
+ child_no_scale->draw_transform().matrix().get(1, 1));
}
// If the device_scale_factor or page_scale_factor changes, then it should be
@@ -6600,7 +6593,7 @@ TEST_F(LayerTreeHostCommonTest, ContentsScale) {
}
// If the transform changes, we expect the raster scale to be reset to 1.0.
- double second_child_scale = 1.75;
+ SkMScalar second_child_scale = 1.75;
child_scale_matrix.Scale(second_child_scale / initial_child_scale,
second_child_scale / initial_child_scale);
child_scale->SetTransform(child_scale_matrix);
@@ -6658,11 +6651,11 @@ TEST_F(LayerTreeHostCommonTest,
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 1.75;
+ SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 1.25;
+ SkMScalar initial_child_scale = 1.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -6738,23 +6731,23 @@ TEST_F(LayerTreeHostCommonTest,
// Since the transform scale does not affect contents scale, it should affect
// the draw transform instead.
EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().getDouble(0, 0));
+ parent->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().getDouble(1, 1));
+ parent->draw_transform().matrix().get(1, 1));
EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_scale->draw_transform().matrix().getDouble(0, 0));
+ child_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_scale->draw_transform().matrix().getDouble(1, 1));
+ child_scale->draw_transform().matrix().get(1, 1));
EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_empty->draw_transform().matrix().getDouble(0, 0));
+ child_empty->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(initial_parent_scale * initial_child_scale,
- child_empty->draw_transform().matrix().getDouble(1, 1));
+ child_empty->draw_transform().matrix().get(1, 1));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().getDouble(0, 0));
+ initial_parent_scale * initial_child_scale,
+ child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- child_no_scale->draw_transform().matrix().getDouble(1, 1));
+ initial_parent_scale * initial_child_scale,
+ child_no_scale->draw_transform().matrix().get(1, 1));
}
TEST_F(LayerTreeHostCommonTest, SmallContentsScale) {
@@ -6762,11 +6755,11 @@ TEST_F(LayerTreeHostCommonTest, SmallContentsScale) {
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 1.75;
+ SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 0.25;
+ SkMScalar initial_child_scale = 0.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -6823,7 +6816,7 @@ TEST_F(LayerTreeHostCommonTest, SmallContentsScale) {
// When chilld's total scale becomes >= 1, we should save and use that scale
// factor.
child_scale_matrix.MakeIdentity();
- double final_child_scale = 0.75;
+ SkMScalar final_child_scale = 0.75;
child_scale_matrix.Scale(final_child_scale, final_child_scale);
child_scale->SetTransform(child_scale_matrix);
@@ -6851,11 +6844,11 @@ TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) {
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 2.0;
+ SkMScalar initial_parent_scale = 2.0;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 3.0;
+ SkMScalar initial_child_scale = 3.0;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -6946,8 +6939,8 @@ TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) {
scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
host->SetRootLayer(root);
- double device_scale_factor = 5;
- double page_scale_factor = 7;
+ SkMScalar device_scale_factor = 5;
+ SkMScalar page_scale_factor = 7;
RenderSurfaceLayerList render_surface_layer_list;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
@@ -6976,86 +6969,74 @@ TEST_F(LayerTreeHostCommonTest, ContentsScaleForSurfaces) {
EXPECT_CONTENTS_SCALE_EQ(1, surface_no_scale_child_no_scale);
// The parent is scaled up and shouldn't need to scale during draw.
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, parent->draw_transform().matrix().get(1, 1));
// RenderSurfaces should always be 1:1 with their target.
EXPECT_FLOAT_EQ(
1.0,
- surface_scale->render_surface()->draw_transform().matrix().getDouble(0,
- 0));
+ surface_scale->render_surface()->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
1.0,
- surface_scale->render_surface()->draw_transform().matrix().getDouble(1,
- 1));
+ surface_scale->render_surface()->draw_transform().matrix().get(1, 1));
// The surface_scale can apply contents scale so the layer shouldn't need to
// scale during draw.
- EXPECT_FLOAT_EQ(1.0,
- surface_scale->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0,
- surface_scale->draw_transform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_scale can apply contents scale so it shouldn't need
// to scale during draw.
EXPECT_FLOAT_EQ(
- 1.0,
- surface_scale_child_scale->draw_transform().matrix().getDouble(0, 0));
+ 1.0, surface_scale_child_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
- 1.0,
- surface_scale_child_scale->draw_transform().matrix().getDouble(1, 1));
+ 1.0, surface_scale_child_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_no_scale can not apply contents scale, so it needs
// to be scaled during draw.
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().getDouble(0, 0));
+ initial_child_scale * initial_child_scale,
+ surface_scale_child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().getDouble(1, 1));
+ initial_child_scale * initial_child_scale,
+ surface_scale_child_no_scale->draw_transform().matrix().get(1, 1));
// RenderSurfaces should always be 1:1 with their target.
EXPECT_FLOAT_EQ(
1.0,
- surface_no_scale->render_surface()->draw_transform().matrix().getDouble(
- 0, 0));
+ surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
1.0,
- surface_no_scale->render_surface()->draw_transform().matrix().getDouble(
- 1, 1));
+ surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1));
// The surface_no_scale layer can not apply contents scale, so it needs to be
// scaled during draw.
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- surface_no_scale->draw_transform().matrix().getDouble(0, 0));
+ initial_parent_scale * initial_child_scale,
+ surface_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor *
- initial_parent_scale * initial_child_scale,
- surface_no_scale->draw_transform().matrix().getDouble(1, 1));
+ initial_parent_scale * initial_child_scale,
+ surface_no_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_scale can apply contents scale so it shouldn't need
// to scale during draw.
EXPECT_FLOAT_EQ(
- 1.0,
- surface_no_scale_child_scale->draw_transform().matrix().getDouble(0, 0));
+ 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
- 1.0,
- surface_no_scale_child_scale->draw_transform().matrix().getDouble(1, 1));
+ 1.0, surface_no_scale_child_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_no_scale can not apply contents scale, so it needs
// to be scaled during draw.
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(0,
- 0));
+ initial_child_scale * initial_child_scale,
+ surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_parent_scale *
- initial_child_scale * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(1,
- 1));
+ initial_child_scale * initial_child_scale,
+ surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1));
}
TEST_F(LayerTreeHostCommonTest,
@@ -7064,11 +7045,11 @@ TEST_F(LayerTreeHostCommonTest,
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 2.0;
+ SkMScalar initial_parent_scale = 2.0;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 3.0;
+ SkMScalar initial_child_scale = 3.0;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -7161,8 +7142,8 @@ TEST_F(LayerTreeHostCommonTest,
RenderSurfaceLayerList render_surface_layer_list;
- double device_scale_factor = 5.0;
- double page_scale_factor = 7.0;
+ SkMScalar device_scale_factor = 5.0;
+ SkMScalar page_scale_factor = 7.0;
LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
root.get(), root->bounds(), &render_surface_layer_list);
inputs.device_scale_factor = device_scale_factor;
@@ -7185,88 +7166,80 @@ TEST_F(LayerTreeHostCommonTest,
// The parent is scaled up during draw, since its contents are not scaled by
// the transform hierarchy.
EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().getDouble(0, 0));
+ parent->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(initial_parent_scale,
- parent->draw_transform().matrix().getDouble(1, 1));
+ parent->draw_transform().matrix().get(1, 1));
// The child surface is scaled up during draw since its subtree is not scaled
// by the transform hierarchy.
EXPECT_FLOAT_EQ(
initial_parent_scale * initial_child_scale,
- surface_scale->render_surface()->draw_transform().matrix().getDouble(0,
- 0));
+ surface_scale->render_surface()->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
initial_parent_scale * initial_child_scale,
- surface_scale->render_surface()->draw_transform().matrix().getDouble(1,
- 1));
+ surface_scale->render_surface()->draw_transform().matrix().get(1, 1));
// The surface_scale's RenderSurface is scaled during draw, so the layer does
// not need to be scaled when drawing into its surface.
- EXPECT_FLOAT_EQ(1.0,
- surface_scale->draw_transform().matrix().getDouble(0, 0));
- EXPECT_FLOAT_EQ(1.0,
- surface_scale->draw_transform().matrix().getDouble(1, 1));
+ EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(0, 0));
+ EXPECT_FLOAT_EQ(1.0, surface_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_scale is scaled when drawing into its surface,
// since its content bounds are not scaled by the transform hierarchy.
EXPECT_FLOAT_EQ(
initial_child_scale,
- surface_scale_child_scale->draw_transform().matrix().getDouble(0, 0));
+ surface_scale_child_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
initial_child_scale,
- surface_scale_child_scale->draw_transform().matrix().getDouble(1, 1));
+ surface_scale_child_scale->draw_transform().matrix().get(1, 1));
// The surface_scale_child_no_scale has a fixed contents scale of 1, so it
// needs to be scaled by the device and page scale factors, along with the
// transform hierarchy.
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().getDouble(0, 0));
+ surface_scale_child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_child_scale,
- surface_scale_child_no_scale->draw_transform().matrix().getDouble(1, 1));
+ surface_scale_child_no_scale->draw_transform().matrix().get(1, 1));
// The child surface is scaled up during draw since its subtree is not scaled
// by the transform hierarchy.
EXPECT_FLOAT_EQ(
initial_parent_scale * initial_child_scale,
- surface_no_scale->render_surface()->draw_transform().matrix().getDouble(
- 0, 0));
+ surface_no_scale->render_surface()->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
initial_parent_scale * initial_child_scale,
- surface_no_scale->render_surface()->draw_transform().matrix().getDouble(
- 1, 1));
+ surface_no_scale->render_surface()->draw_transform().matrix().get(1, 1));
// The surface_no_scale layer has a fixed contents scale of 1, so it needs to
// be scaled by the device and page scale factors. Its surface is already
// scaled by the transform hierarchy so those don't need to scale the layer's
// drawing.
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor,
- surface_no_scale->draw_transform().matrix().getDouble(0, 0));
+ surface_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(device_scale_factor * page_scale_factor,
- surface_no_scale->draw_transform().matrix().getDouble(1, 1));
+ surface_no_scale->draw_transform().matrix().get(1, 1));
// The surface_no_scale_child_scale has its contents scaled by the page and
// device scale factors, but needs to be scaled by the transform hierarchy
// when drawing.
EXPECT_FLOAT_EQ(
initial_child_scale,
- surface_no_scale_child_scale->draw_transform().matrix().getDouble(0, 0));
+ surface_no_scale_child_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
initial_child_scale,
- surface_no_scale_child_scale->draw_transform().matrix().getDouble(1, 1));
+ surface_no_scale_child_scale->draw_transform().matrix().get(1, 1));
// The surface_no_scale_child_no_scale has a fixed contents scale of 1, so it
// needs to be scaled by the device and page scale factors. It also needs to
// be scaled by any transform heirarchy below its target surface.
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(0,
- 0));
+ surface_no_scale_child_no_scale->draw_transform().matrix().get(0, 0));
EXPECT_FLOAT_EQ(
device_scale_factor * page_scale_factor * initial_child_scale,
- surface_no_scale_child_no_scale->draw_transform().matrix().getDouble(1,
- 1));
+ surface_no_scale_child_no_scale->draw_transform().matrix().get(1, 1));
}
TEST_F(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) {
@@ -7274,11 +7247,11 @@ TEST_F(LayerTreeHostCommonTest, ContentsScaleForAnimatingLayer) {
gfx::Transform identity_matrix;
gfx::Transform parent_scale_matrix;
- double initial_parent_scale = 1.75;
+ SkMScalar initial_parent_scale = 1.75;
parent_scale_matrix.Scale(initial_parent_scale, initial_parent_scale);
gfx::Transform child_scale_matrix;
- double initial_child_scale = 1.25;
+ SkMScalar initial_child_scale = 1.25;
child_scale_matrix.Scale(initial_child_scale, initial_child_scale);
scoped_refptr<Layer> root = Layer::Create();
@@ -7460,17 +7433,17 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) {
child->render_surface()->screen_space_transform());
gfx::Transform expected_replica_draw_transform;
- expected_replica_draw_transform.matrix().setDouble(1, 1, -1.0);
- expected_replica_draw_transform.matrix().setDouble(0, 3, 6.0);
- expected_replica_draw_transform.matrix().setDouble(1, 3, 6.0);
+ expected_replica_draw_transform.matrix().set(1, 1, -1.0);
+ expected_replica_draw_transform.matrix().set(0, 3, 6.0);
+ expected_replica_draw_transform.matrix().set(1, 3, 6.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected_replica_draw_transform,
child->render_surface()->replica_draw_transform());
gfx::Transform expected_replica_screen_space_transform;
- expected_replica_screen_space_transform.matrix().setDouble(1, 1, -1.0);
- expected_replica_screen_space_transform.matrix().setDouble(0, 3, 6.0);
- expected_replica_screen_space_transform.matrix().setDouble(1, 3, 6.0);
+ expected_replica_screen_space_transform.matrix().set(1, 1, -1.0);
+ expected_replica_screen_space_transform.matrix().set(0, 3, 6.0);
+ expected_replica_screen_space_transform.matrix().set(1, 3, 6.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected_replica_screen_space_transform,
child->render_surface()->replica_screen_space_transform());
@@ -7570,13 +7543,13 @@ TEST_F(LayerTreeHostCommonTest,
identity_transform, child->render_surface()->screen_space_transform());
gfx::Transform expected_replica_draw_transform;
- expected_replica_draw_transform.matrix().setDouble(1, 1, -1.0);
+ expected_replica_draw_transform.matrix().set(1, 1, -1.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected_replica_draw_transform,
child->render_surface()->replica_draw_transform());
gfx::Transform expected_replica_screen_space_transform;
- expected_replica_screen_space_transform.matrix().setDouble(1, 1, -1.0);
+ expected_replica_screen_space_transform.matrix().set(1, 1, -1.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
expected_replica_screen_space_transform,
child->render_surface()->replica_screen_space_transform());
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 5ad32c5..deaab09 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -2223,7 +2223,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
// Scroll down in screen coordinates with a gesture.
gfx::Vector2d gesture_scroll_delta(0, 10);
EXPECT_EQ(InputHandler::ScrollStarted,
- host_impl_->ScrollBegin(gfx::Point(),
+ host_impl_->ScrollBegin(gfx::Point(1, 1),
InputHandler::Gesture));
host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
host_impl_->ScrollEnd();
@@ -2248,7 +2248,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) {
gfx::Vector2dF());
gfx::Vector2d gesture_scroll_delta(10, 0);
EXPECT_EQ(InputHandler::ScrollStarted,
- host_impl_->ScrollBegin(gfx::Point(),
+ host_impl_->ScrollBegin(gfx::Point(1, 1),
InputHandler::Gesture));
host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
host_impl_->ScrollEnd();
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc
index 3e94f44..25cd6e6 100644
--- a/ui/gfx/transform.cc
+++ b/ui/gfx/transform.cc
@@ -24,61 +24,72 @@ namespace gfx {
namespace {
// Taken from SkMatrix44.
-const double kEpsilon = 1e-8;
+const SkMScalar kEpsilon = 1e-8;
-double TanDegrees(double degrees) {
- double radians = degrees * M_PI / 180;
+SkMScalar TanDegrees(double degrees) {
+ SkMScalar radians = degrees * M_PI / 180;
return std::tan(radians);
}
} // namespace
-Transform::Transform(
- double col1row1, double col2row1, double col3row1, double col4row1,
- double col1row2, double col2row2, double col3row2, double col4row2,
- double col1row3, double col2row3, double col3row3, double col4row3,
- double col1row4, double col2row4, double col3row4, double col4row4)
- : matrix_(SkMatrix44::kUninitialized_Constructor)
-{
- matrix_.setDouble(0, 0, col1row1);
- matrix_.setDouble(1, 0, col1row2);
- matrix_.setDouble(2, 0, col1row3);
- matrix_.setDouble(3, 0, col1row4);
-
- matrix_.setDouble(0, 1, col2row1);
- matrix_.setDouble(1, 1, col2row2);
- matrix_.setDouble(2, 1, col2row3);
- matrix_.setDouble(3, 1, col2row4);
-
- matrix_.setDouble(0, 2, col3row1);
- matrix_.setDouble(1, 2, col3row2);
- matrix_.setDouble(2, 2, col3row3);
- matrix_.setDouble(3, 2, col3row4);
-
- matrix_.setDouble(0, 3, col4row1);
- matrix_.setDouble(1, 3, col4row2);
- matrix_.setDouble(2, 3, col4row3);
- matrix_.setDouble(3, 3, col4row4);
-}
-
-Transform::Transform(
- double col1row1, double col2row1,
- double col1row2, double col2row2,
- double x_translation, double y_translation)
- : matrix_(SkMatrix44::kIdentity_Constructor)
-{
- matrix_.setDouble(0, 0, col1row1);
- matrix_.setDouble(1, 0, col1row2);
- matrix_.setDouble(0, 1, col2row1);
- matrix_.setDouble(1, 1, col2row2);
- matrix_.setDouble(0, 3, x_translation);
- matrix_.setDouble(1, 3, y_translation);
+Transform::Transform(SkMScalar col1row1,
+ SkMScalar col2row1,
+ SkMScalar col3row1,
+ SkMScalar col4row1,
+ SkMScalar col1row2,
+ SkMScalar col2row2,
+ SkMScalar col3row2,
+ SkMScalar col4row2,
+ SkMScalar col1row3,
+ SkMScalar col2row3,
+ SkMScalar col3row3,
+ SkMScalar col4row3,
+ SkMScalar col1row4,
+ SkMScalar col2row4,
+ SkMScalar col3row4,
+ SkMScalar col4row4)
+ : matrix_(SkMatrix44::kUninitialized_Constructor) {
+ matrix_.set(0, 0, col1row1);
+ matrix_.set(1, 0, col1row2);
+ matrix_.set(2, 0, col1row3);
+ matrix_.set(3, 0, col1row4);
+
+ matrix_.set(0, 1, col2row1);
+ matrix_.set(1, 1, col2row2);
+ matrix_.set(2, 1, col2row3);
+ matrix_.set(3, 1, col2row4);
+
+ matrix_.set(0, 2, col3row1);
+ matrix_.set(1, 2, col3row2);
+ matrix_.set(2, 2, col3row3);
+ matrix_.set(3, 2, col3row4);
+
+ matrix_.set(0, 3, col4row1);
+ matrix_.set(1, 3, col4row2);
+ matrix_.set(2, 3, col4row3);
+ matrix_.set(3, 3, col4row4);
+}
+
+Transform::Transform(SkMScalar col1row1,
+ SkMScalar col2row1,
+ SkMScalar col1row2,
+ SkMScalar col2row2,
+ SkMScalar x_translation,
+ SkMScalar y_translation)
+ : matrix_(SkMatrix44::kIdentity_Constructor) {
+ matrix_.set(0, 0, col1row1);
+ matrix_.set(1, 0, col1row2);
+ matrix_.set(0, 1, col2row1);
+ matrix_.set(1, 1, col2row2);
+ matrix_.set(0, 3, x_translation);
+ matrix_.set(1, 3, y_translation);
}
void Transform::RotateAboutXAxis(double degrees) {
double radians = degrees * M_PI / 180;
- double cosTheta = std::cos(radians);
- double sinTheta = std::sin(radians);
+ SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians));
+ SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians));
if (matrix_.isIdentity()) {
matrix_.set3x3(1, 0, 0,
0, cosTheta, sinTheta,
@@ -94,8 +105,8 @@ void Transform::RotateAboutXAxis(double degrees) {
void Transform::RotateAboutYAxis(double degrees) {
double radians = degrees * M_PI / 180;
- double cosTheta = std::cos(radians);
- double sinTheta = std::sin(radians);
+ SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians));
+ SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians));
if (matrix_.isIdentity()) {
// Note carefully the placement of the -sinTheta for rotation about
// y-axis is different than rotation about x-axis or z-axis.
@@ -113,8 +124,8 @@ void Transform::RotateAboutYAxis(double degrees) {
void Transform::RotateAboutZAxis(double degrees) {
double radians = degrees * M_PI / 180;
- double cosTheta = std::cos(radians);
- double sinTheta = std::sin(radians);
+ SkMScalar cosTheta = SkDoubleToMScalar(std::cos(radians));
+ SkMScalar sinTheta = SkDoubleToMScalar(std::sin(radians));
if (matrix_.isIdentity()) {
matrix_.set3x3(cosTheta, sinTheta, 0,
-sinTheta, cosTheta, 0,
@@ -130,68 +141,62 @@ void Transform::RotateAboutZAxis(double degrees) {
void Transform::RotateAbout(const Vector3dF& axis, double degrees) {
if (matrix_.isIdentity()) {
- matrix_.setRotateDegreesAbout(SkDoubleToMScalar(axis.x()),
- SkDoubleToMScalar(axis.y()),
- SkDoubleToMScalar(axis.z()),
- SkDoubleToMScalar(degrees));
+ matrix_.setRotateDegreesAbout(SkFloatToMScalar(axis.x()),
+ SkFloatToMScalar(axis.y()),
+ SkFloatToMScalar(axis.z()),
+ degrees);
} else {
SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor);
- rot.setRotateDegreesAbout(SkDoubleToMScalar(axis.x()),
- SkDoubleToMScalar(axis.y()),
- SkDoubleToMScalar(axis.z()),
- SkDoubleToMScalar(degrees));
+ rot.setRotateDegreesAbout(SkFloatToMScalar(axis.x()),
+ SkFloatToMScalar(axis.y()),
+ SkFloatToMScalar(axis.z()),
+ degrees);
matrix_.preConcat(rot);
}
}
-void Transform::Scale(double x, double y) {
- matrix_.preScale(SkDoubleToMScalar(x), SkDoubleToMScalar(y), 1);
-}
+void Transform::Scale(SkMScalar x, SkMScalar y) { matrix_.preScale(x, y, 1); }
-void Transform::Scale3d(double x, double y, double z) {
- matrix_.preScale(SkDoubleToMScalar(x),
- SkDoubleToMScalar(y),
- SkDoubleToMScalar(z));
+void Transform::Scale3d(SkMScalar x, SkMScalar y, SkMScalar z) {
+ matrix_.preScale(x, y, z);
}
-void Transform::Translate(double x, double y) {
- matrix_.preTranslate(SkDoubleToMScalar(x), SkDoubleToMScalar(y), 0);
+void Transform::Translate(SkMScalar x, SkMScalar y) {
+ matrix_.preTranslate(x, y, 0);
}
-void Transform::Translate3d(double x, double y, double z) {
- matrix_.preTranslate(SkDoubleToMScalar(x),
- SkDoubleToMScalar(y),
- SkDoubleToMScalar(z));
+void Transform::Translate3d(SkMScalar x, SkMScalar y, SkMScalar z) {
+ matrix_.preTranslate(x, y, z);
}
-void Transform::SkewX(double angle_x) {
+void Transform::SkewX(SkMScalar angle_x) {
if (matrix_.isIdentity())
- matrix_.setDouble(0, 1, TanDegrees(angle_x));
+ matrix_.set(0, 1, TanDegrees(angle_x));
else {
SkMatrix44 skew(SkMatrix44::kIdentity_Constructor);
- skew.setDouble(0, 1, TanDegrees(angle_x));
+ skew.set(0, 1, TanDegrees(angle_x));
matrix_.preConcat(skew);
}
}
-void Transform::SkewY(double angle_y) {
+void Transform::SkewY(SkMScalar angle_y) {
if (matrix_.isIdentity())
- matrix_.setDouble(1, 0, TanDegrees(angle_y));
+ matrix_.set(1, 0, TanDegrees(angle_y));
else {
SkMatrix44 skew(SkMatrix44::kIdentity_Constructor);
- skew.setDouble(1, 0, TanDegrees(angle_y));
+ skew.set(1, 0, TanDegrees(angle_y));
matrix_.preConcat(skew);
}
}
-void Transform::ApplyPerspectiveDepth(double depth) {
+void Transform::ApplyPerspectiveDepth(SkMScalar depth) {
if (depth == 0)
return;
if (matrix_.isIdentity())
- matrix_.setDouble(3, 2, -1.0 / depth);
+ matrix_.set(3, 2, -1.0 / depth);
else {
SkMatrix44 m(SkMatrix44::kIdentity_Constructor);
- m.setDouble(3, 2, -1.0 / depth);
+ m.set(3, 2, -1.0 / depth);
matrix_.preConcat(m);
}
}
@@ -209,9 +214,9 @@ bool Transform::IsIdentityOrIntegerTranslation() const {
return false;
bool no_fractional_translation =
- static_cast<int>(matrix_.getDouble(0, 3)) == matrix_.getDouble(0, 3) &&
- static_cast<int>(matrix_.getDouble(1, 3)) == matrix_.getDouble(1, 3) &&
- static_cast<int>(matrix_.getDouble(2, 3)) == matrix_.getDouble(2, 3);
+ static_cast<int>(matrix_.get(0, 3)) == matrix_.get(0, 3) &&
+ static_cast<int>(matrix_.get(1, 3)) == matrix_.get(1, 3) &&
+ static_cast<int>(matrix_.get(2, 3)) == matrix_.get(2, 3);
return no_fractional_translation;
}
@@ -244,34 +249,22 @@ bool Transform::IsBackFaceVisible() const {
// Compute the cofactor of the 3rd row, 3rd column.
double cofactor_part_1 =
- matrix_.getDouble(0, 0) *
- matrix_.getDouble(1, 1) *
- matrix_.getDouble(3, 3);
+ matrix_.get(0, 0) * matrix_.get(1, 1) * matrix_.get(3, 3);
double cofactor_part_2 =
- matrix_.getDouble(0, 1) *
- matrix_.getDouble(1, 3) *
- matrix_.getDouble(3, 0);
+ matrix_.get(0, 1) * matrix_.get(1, 3) * matrix_.get(3, 0);
double cofactor_part_3 =
- matrix_.getDouble(0, 3) *
- matrix_.getDouble(1, 0) *
- matrix_.getDouble(3, 1);
+ matrix_.get(0, 3) * matrix_.get(1, 0) * matrix_.get(3, 1);
double cofactor_part_4 =
- matrix_.getDouble(0, 0) *
- matrix_.getDouble(1, 3) *
- matrix_.getDouble(3, 1);
+ matrix_.get(0, 0) * matrix_.get(1, 3) * matrix_.get(3, 1);
double cofactor_part_5 =
- matrix_.getDouble(0, 1) *
- matrix_.getDouble(1, 0) *
- matrix_.getDouble(3, 3);
+ matrix_.get(0, 1) * matrix_.get(1, 0) * matrix_.get(3, 3);
double cofactor_part_6 =
- matrix_.getDouble(0, 3) *
- matrix_.getDouble(1, 1) *
- matrix_.getDouble(3, 0);
+ matrix_.get(0, 3) * matrix_.get(1, 1) * matrix_.get(3, 0);
double cofactor33 =
cofactor_part_1 +
@@ -317,30 +310,30 @@ bool Transform::Preserves2dAxisAlignment() const {
// values: The current implementation conservatively assumes that axis
// alignment is not preserved.
- bool has_x_or_y_perspective = matrix_.getDouble(3, 0) != 0 ||
- matrix_.getDouble(3, 1) != 0;
+ bool has_x_or_y_perspective =
+ matrix_.get(3, 0) != 0 || matrix_.get(3, 1) != 0;
int num_non_zero_in_row_0 = 0;
int num_non_zero_in_row_1 = 0;
int num_non_zero_in_col_0 = 0;
int num_non_zero_in_col_1 = 0;
- if (std::abs(matrix_.getDouble(0, 0)) > kEpsilon) {
+ if (std::abs(matrix_.get(0, 0)) > kEpsilon) {
num_non_zero_in_row_0++;
num_non_zero_in_col_0++;
}
- if (std::abs(matrix_.getDouble(0, 1)) > kEpsilon) {
+ if (std::abs(matrix_.get(0, 1)) > kEpsilon) {
num_non_zero_in_row_0++;
num_non_zero_in_col_1++;
}
- if (std::abs(matrix_.getDouble(1, 0)) > kEpsilon) {
+ if (std::abs(matrix_.get(1, 0)) > kEpsilon) {
num_non_zero_in_row_1++;
num_non_zero_in_col_0++;
}
- if (std::abs(matrix_.getDouble(1, 1)) > kEpsilon) {
+ if (std::abs(matrix_.get(1, 1)) > kEpsilon) {
num_non_zero_in_row_1++;
num_non_zero_in_col_1++;
}
@@ -358,21 +351,22 @@ void Transform::Transpose() {
}
void Transform::FlattenTo2d() {
- matrix_.setDouble(2, 0, 0.0);
- matrix_.setDouble(2, 1, 0.0);
- matrix_.setDouble(0, 2, 0.0);
- matrix_.setDouble(1, 2, 0.0);
- matrix_.setDouble(2, 2, 1.0);
- matrix_.setDouble(3, 2, 0.0);
- matrix_.setDouble(2, 3, 0.0);
+ matrix_.set(2, 0, 0.0);
+ matrix_.set(2, 1, 0.0);
+ matrix_.set(0, 2, 0.0);
+ matrix_.set(1, 2, 0.0);
+ matrix_.set(2, 2, 1.0);
+ matrix_.set(3, 2, 0.0);
+ matrix_.set(2, 3, 0.0);
}
Vector2dF Transform::To2dTranslation() const {
DCHECK(IsIdentityOrTranslation());
// Ensure that this translation is truly 2d.
- const double translate_z = matrix_.getDouble(2, 3);
- DCHECK_EQ(0.0, translate_z);
- return gfx::Vector2dF(matrix_.getDouble(0, 3), matrix_.getDouble(1, 3));
+ const SkMScalar translate_z = matrix_.get(2, 3);
+ DCHECK_EQ(0.f, translate_z);
+ return gfx::Vector2dF(SkMScalarToFloat(matrix_.get(0, 3)),
+ SkMScalarToFloat(matrix_.get(1, 3)));
}
void Transform::TransformPoint(Point& point) const {
@@ -428,7 +422,7 @@ bool Transform::TransformRectReverse(RectF* rect) const {
return true;
}
-bool Transform::Blend(const Transform& from, double progress) {
+bool Transform::Blend(const Transform& from, SkMScalar progress) {
DecomposedTransform to_decomp;
DecomposedTransform from_decomp;
if (!DecomposeTransform(&to_decomp, *this) ||
@@ -447,12 +441,8 @@ void Transform::TransformPointInternal(const SkMatrix44& xform,
if (xform.isIdentity())
return;
- SkMScalar p[4] = {
- SkDoubleToMScalar(point.x()),
- SkDoubleToMScalar(point.y()),
- SkDoubleToMScalar(point.z()),
- SkDoubleToMScalar(1)
- };
+ SkMScalar p[4] = {SkFloatToMScalar(point.x()), SkFloatToMScalar(point.y()),
+ SkFloatToMScalar(point.z()), 1};
xform.mapMScalars(p);
@@ -468,12 +458,8 @@ void Transform::TransformPointInternal(const SkMatrix44& xform,
if (xform.isIdentity())
return;
- SkMScalar p[4] = {
- SkDoubleToMScalar(point.x()),
- SkDoubleToMScalar(point.y()),
- SkDoubleToMScalar(0),
- SkDoubleToMScalar(1)
- };
+ SkMScalar p[4] = {SkFloatToMScalar(point.x()), SkFloatToMScalar(point.y()), 0,
+ 1};
xform.mapMScalars(p);
@@ -486,22 +472,22 @@ std::string Transform::ToString() const {
" %+0.4f %+0.4f %+0.4f %+0.4f \n"
" %+0.4f %+0.4f %+0.4f %+0.4f \n"
" %+0.4f %+0.4f %+0.4f %+0.4f ]\n",
- matrix_.getDouble(0, 0),
- matrix_.getDouble(0, 1),
- matrix_.getDouble(0, 2),
- matrix_.getDouble(0, 3),
- matrix_.getDouble(1, 0),
- matrix_.getDouble(1, 1),
- matrix_.getDouble(1, 2),
- matrix_.getDouble(1, 3),
- matrix_.getDouble(2, 0),
- matrix_.getDouble(2, 1),
- matrix_.getDouble(2, 2),
- matrix_.getDouble(2, 3),
- matrix_.getDouble(3, 0),
- matrix_.getDouble(3, 1),
- matrix_.getDouble(3, 2),
- matrix_.getDouble(3, 3));
+ matrix_.get(0, 0),
+ matrix_.get(0, 1),
+ matrix_.get(0, 2),
+ matrix_.get(0, 3),
+ matrix_.get(1, 0),
+ matrix_.get(1, 1),
+ matrix_.get(1, 2),
+ matrix_.get(1, 3),
+ matrix_.get(2, 0),
+ matrix_.get(2, 1),
+ matrix_.get(2, 2),
+ matrix_.get(2, 3),
+ matrix_.get(3, 0),
+ matrix_.get(3, 1),
+ matrix_.get(3, 2),
+ matrix_.get(3, 3));
}
} // namespace gfx
diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h
index 1109099..f9819f3 100644
--- a/ui/gfx/transform.h
+++ b/ui/gfx/transform.h
@@ -40,16 +40,31 @@ class UI_EXPORT Transform {
: matrix_(lhs.matrix_, rhs.matrix_) {}
// Constructs a transform from explicit 16 matrix elements. Elements
// should be given in row-major order.
- Transform(double col1row1, double col2row1, double col3row1, double col4row1,
- double col1row2, double col2row2, double col3row2, double col4row2,
- double col1row3, double col2row3, double col3row3, double col4row3,
- double col1row4, double col2row4, double col3row4, double col4row4);
+ Transform(SkMScalar col1row1,
+ SkMScalar col2row1,
+ SkMScalar col3row1,
+ SkMScalar col4row1,
+ SkMScalar col1row2,
+ SkMScalar col2row2,
+ SkMScalar col3row2,
+ SkMScalar col4row2,
+ SkMScalar col1row3,
+ SkMScalar col2row3,
+ SkMScalar col3row3,
+ SkMScalar col4row3,
+ SkMScalar col1row4,
+ SkMScalar col2row4,
+ SkMScalar col3row4,
+ SkMScalar col4row4);
// Constructs a transform from explicit 2d elements. All other matrix
// elements remain the same as the corresponding elements of an identity
// matrix.
- Transform(double col1row1, double col2row1,
- double col1row2, double col2row2,
- double x_translation, double y_translation);
+ Transform(SkMScalar col1row1,
+ SkMScalar col2row1,
+ SkMScalar col1row2,
+ SkMScalar col2row2,
+ SkMScalar x_translation,
+ SkMScalar y_translation);
~Transform() {}
bool operator==(const Transform& rhs) const { return matrix_ == rhs.matrix_; }
@@ -71,22 +86,22 @@ class UI_EXPORT Transform {
// Applies the current transformation on a scaling and assigns the result
// to |this|.
- void Scale(double x, double y);
- void Scale3d(double x, double y, double z);
+ void Scale(SkMScalar x, SkMScalar y);
+ void Scale3d(SkMScalar x, SkMScalar y, SkMScalar z);
// Applies the current transformation on a translation and assigns the result
// to |this|.
- void Translate(double x, double y);
- void Translate3d(double x, double y, double z);
+ void Translate(SkMScalar x, SkMScalar y);
+ void Translate3d(SkMScalar x, SkMScalar y, SkMScalar z);
// Applies the current transformation on a skew and assigns the result
// to |this|.
- void SkewX(double angle_x);
- void SkewY(double angle_y);
+ void SkewX(SkMScalar angle_x);
+ void SkewY(SkMScalar angle_y);
// Applies the current transformation on a perspective transform and assigns
// the result to |this|.
- void ApplyPerspectiveDepth(double depth);
+ void ApplyPerspectiveDepth(SkMScalar depth);
// Applies a transformation on the current transformation
// (i.e. 'this = this * transform;').
@@ -108,9 +123,8 @@ class UI_EXPORT Transform {
bool IsPositiveScaleOrTranslation() const {
if (!IsScaleOrTranslation())
return false;
- return matrix_.getDouble(0, 0) > 0.0 &&
- matrix_.getDouble(1, 1) > 0.0 &&
- matrix_.getDouble(2, 2) > 0.0;
+ return matrix_.get(0, 0) > 0.0 && matrix_.get(1, 1) > 0.0 &&
+ matrix_.get(2, 2) > 0.0;
}
// Returns true if the matrix is either identity or pure, non-fractional
@@ -202,7 +216,7 @@ class UI_EXPORT Transform {
// you're going to be calling this rapidly (e.g., in an animation) you should
// decompose once using gfx::DecomposeTransforms and reuse your
// DecomposedTransform.
- bool Blend(const Transform& from, double progress);
+ bool Blend(const Transform& from, SkMScalar progress);
// Returns |this| * |other|.
Transform operator*(const Transform& other) const {
diff --git a/ui/gfx/transform_util.cc b/ui/gfx/transform_util.cc
index 90c8b56..84b18ad 100644
--- a/ui/gfx/transform_util.cc
+++ b/ui/gfx/transform_util.cc
@@ -12,51 +12,51 @@ namespace gfx {
namespace {
-double Length3(double v[3]) {
+SkMScalar Length3(SkMScalar v[3]) {
return std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
-void Scale3(double v[3], double scale) {
+void Scale3(SkMScalar v[3], SkMScalar scale) {
for (int i = 0; i < 3; ++i)
v[i] *= scale;
}
template <int n>
-double Dot(const double* a, const double* b) {
- double toReturn = 0;
+SkMScalar Dot(const SkMScalar* a, const SkMScalar* b) {
+ SkMScalar toReturn = 0;
for (int i = 0; i < n; ++i)
toReturn += a[i] * b[i];
return toReturn;
}
template <int n>
-void Combine(double* out,
- const double* a,
- const double* b,
- double scale_a,
- double scale_b) {
+void Combine(SkMScalar* out,
+ const SkMScalar* a,
+ const SkMScalar* b,
+ SkMScalar scale_a,
+ SkMScalar scale_b) {
for (int i = 0; i < n; ++i)
out[i] = a[i] * scale_a + b[i] * scale_b;
}
-void Cross3(double out[3], double a[3], double b[3]) {
- double x = a[1] * b[2] - a[2] * b[1];
- double y = a[2] * b[0] - a[0] * b[2];
- double z = a[0] * b[1] - a[1] * b[0];
+void Cross3(SkMScalar out[3], SkMScalar a[3], SkMScalar b[3]) {
+ SkMScalar x = a[1] * b[2] - a[2] * b[1];
+ SkMScalar y = a[2] * b[0] - a[0] * b[2];
+ SkMScalar z = a[0] * b[1] - a[1] * b[0];
out[0] = x;
out[1] = y;
out[2] = z;
}
// Taken from http://www.w3.org/TR/css3-transforms/.
-bool Slerp(double out[4],
- const double q1[4],
- const double q2[4],
- double progress) {
- double product = Dot<4>(q1, q2);
+bool Slerp(SkMScalar out[4],
+ const SkMScalar q1[4],
+ const SkMScalar q2[4],
+ SkMScalar progress) {
+ SkMScalar product = Dot<4>(q1, q2);
// Clamp product to -1.0 <= product <= 1.0.
- product = std::min(std::max(product, -1.0), 1.0);
+ product = std::min(std::max(product, -SK_MScalar1), SK_MScalar1);
// Interpolate angles along the shortest path. For example, to interpolate
// between a 175 degree angle and a 185 degree angle, interpolate along the
@@ -65,25 +65,25 @@ bool Slerp(double out[4],
// the current W3C spec. Fixing the spec to match this approach is discussed
// at:
// http://lists.w3.org/Archives/Public/www-style/2013May/0131.html
- double scale1 = 1.0;
+ SkMScalar scale1 = SK_MScalar1;
if (product < 0) {
product = -product;
- scale1 = -1.0;
+ scale1 = -SK_MScalar1;
}
- const double epsilon = 1e-5;
- if (std::abs(product - 1.0) < epsilon) {
+ const SkMScalar epsilon = 1e-5;
+ if (std::abs(product - SK_MScalar1) < epsilon) {
for (int i = 0; i < 4; ++i)
out[i] = q1[i];
return true;
}
- double denom = std::sqrt(1 - product * product);
- double theta = std::acos(product);
- double w = std::sin(progress * theta) * (1 / denom);
+ SkMScalar denom = std::sqrt(1 - product * product);
+ SkMScalar theta = std::acos(product);
+ SkMScalar w = std::sin(progress * theta) * (1 / denom);
scale1 *= std::cos(progress * theta) - product * w;
- double scale2 = w;
+ SkMScalar scale2 = w;
Combine<4>(out, q1, q2, scale1, scale2);
return true;
@@ -91,14 +91,14 @@ bool Slerp(double out[4],
// Returns false if the matrix cannot be normalized.
bool Normalize(SkMatrix44& m) {
- if (m.getDouble(3, 3) == 0.0)
+ if (m.get(3, 3) == 0.0)
// Cannot normalize.
return false;
- double scale = 1.0 / m.getDouble(3, 3);
+ SkMScalar scale = 1.0 / m.get(3, 3);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
- m.setDouble(i, j, m.getDouble(i, j) * scale);
+ m.set(i, j, m.get(i, j) * scale);
return true;
}
@@ -125,9 +125,9 @@ DecomposedTransform::DecomposedTransform() {
bool BlendDecomposedTransforms(DecomposedTransform* out,
const DecomposedTransform& to,
const DecomposedTransform& from,
- double progress) {
- double scalea = progress;
- double scaleb = 1.0 - progress;
+ SkMScalar progress) {
+ SkMScalar scalea = progress;
+ SkMScalar scaleb = SK_MScalar1 - progress;
Combine<3>(out->translate, to.translate, from.translate, scalea, scaleb);
Combine<3>(out->scale, to.scale, from.scale, scalea, scaleb);
Combine<3>(out->skew, to.skew, from.skew, scalea, scaleb);
@@ -152,18 +152,17 @@ bool DecomposeTransform(DecomposedTransform* decomp,
SkMatrix44 perspectiveMatrix = matrix;
for (int i = 0; i < 3; ++i)
- perspectiveMatrix.setDouble(3, i, 0.0);
+ perspectiveMatrix.set(3, i, 0.0);
- perspectiveMatrix.setDouble(3, 3, 1.0);
+ perspectiveMatrix.set(3, 3, 1.0);
// If the perspective matrix is not invertible, we are also unable to
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
if (std::abs(perspectiveMatrix.determinant()) < 1e-8)
return false;
- if (matrix.getDouble(3, 0) != 0.0 ||
- matrix.getDouble(3, 1) != 0.0 ||
- matrix.getDouble(3, 2) != 0.0) {
+ if (matrix.get(3, 0) != 0.0 || matrix.get(3, 1) != 0.0 ||
+ matrix.get(3, 2) != 0.0) {
// rhs is the right hand side of the equation.
SkMScalar rhs[4] = {
matrix.get(3, 0),
@@ -195,12 +194,12 @@ bool DecomposeTransform(DecomposedTransform* decomp,
}
for (int i = 0; i < 3; i++)
- decomp->translate[i] = matrix.getDouble(i, 3);
+ decomp->translate[i] = matrix.get(i, 3);
- double row[3][3];
+ SkMScalar row[3][3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; ++j)
- row[i][j] = matrix.getDouble(j, i);
+ row[i][j] = matrix.get(j, i);
// Compute X scale factor and normalize first row.
decomp->scale[0] = Length3(row[0]);
@@ -235,7 +234,7 @@ bool DecomposeTransform(DecomposedTransform* decomp,
// At this point, the matrix (in rows) is orthonormal.
// Check for a coordinate system flip. If the determinant
// is -1, then negate the matrix and the scaling factors.
- double pdum3[3];
+ SkMScalar pdum3[3];
Cross3(pdum3, row[1], row[2]);
if (Dot<3>(row[0], pdum3) < 0) {
for (int i = 0; i < 3; i++) {
@@ -268,16 +267,15 @@ bool DecomposeTransform(DecomposedTransform* decomp,
Transform ComposeTransform(const DecomposedTransform& decomp) {
SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor);
for (int i = 0; i < 4; i++)
- matrix.setDouble(3, i, decomp.perspective[i]);
+ matrix.set(3, i, decomp.perspective[i]);
- matrix.preTranslate(SkDoubleToMScalar(decomp.translate[0]),
- SkDoubleToMScalar(decomp.translate[1]),
- SkDoubleToMScalar(decomp.translate[2]));
+ matrix.preTranslate(
+ decomp.translate[0], decomp.translate[1], decomp.translate[2]);
- double x = decomp.quaternion[0];
- double y = decomp.quaternion[1];
- double z = decomp.quaternion[2];
- double w = decomp.quaternion[3];
+ SkMScalar x = decomp.quaternion[0];
+ SkMScalar y = decomp.quaternion[1];
+ SkMScalar z = decomp.quaternion[2];
+ SkMScalar w = decomp.quaternion[3];
SkMatrix44 rotation_matrix(SkMatrix44::kUninitialized_Constructor);
rotation_matrix.set3x3(1.0 - 2.0 * (y * y + z * z),
@@ -294,25 +292,23 @@ Transform ComposeTransform(const DecomposedTransform& decomp) {
SkMatrix44 temp(SkMatrix44::kIdentity_Constructor);
if (decomp.skew[2]) {
- temp.setDouble(1, 2, decomp.skew[2]);
+ temp.set(1, 2, decomp.skew[2]);
matrix.preConcat(temp);
}
if (decomp.skew[1]) {
- temp.setDouble(1, 2, 0);
- temp.setDouble(0, 2, decomp.skew[1]);
+ temp.set(1, 2, 0);
+ temp.set(0, 2, decomp.skew[1]);
matrix.preConcat(temp);
}
if (decomp.skew[0]) {
- temp.setDouble(0, 2, 0);
- temp.setDouble(0, 1, decomp.skew[0]);
+ temp.set(0, 2, 0);
+ temp.set(0, 1, decomp.skew[0]);
matrix.preConcat(temp);
}
- matrix.preScale(SkDoubleToMScalar(decomp.scale[0]),
- SkDoubleToMScalar(decomp.scale[1]),
- SkDoubleToMScalar(decomp.scale[2]));
+ matrix.preScale(decomp.scale[0], decomp.scale[1], decomp.scale[2]);
Transform to_return;
to_return.matrix() = matrix;
diff --git a/ui/gfx/transform_util.h b/ui/gfx/transform_util.h
index 19a98a3..be5ba4c 100644
--- a/ui/gfx/transform_util.h
+++ b/ui/gfx/transform_util.h
@@ -22,11 +22,11 @@ struct UI_EXPORT DecomposedTransform {
// if used with Compose below, will produce the identity transform.
DecomposedTransform();
- double translate[3];
- double scale[3];
- double skew[3];
- double perspective[4];
- double quaternion[4];
+ SkMScalar translate[3];
+ SkMScalar scale[3];
+ SkMScalar skew[3];
+ SkMScalar perspective[4];
+ SkMScalar quaternion[4];
// Copy and assign are allowed.
};
@@ -38,7 +38,7 @@ struct UI_EXPORT DecomposedTransform {
UI_EXPORT bool BlendDecomposedTransforms(DecomposedTransform* out,
const DecomposedTransform& to,
const DecomposedTransform& from,
- double progress);
+ SkMScalar progress);
// Decomposes this transform into its translation, scale, skew, perspective,
// and rotation components following the routines detailed in this spec: