Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2491)

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2105673003: cc: Compute animation scale on demand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 54d00cb4c3e88b49e6af0554a89c8a2c1d0f9e3e..e069cc4f97bef1319615cc168797092553ad46b5 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -7336,25 +7336,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// No layers have animations.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
TransformOperations translation;
translation.AppendTranslate(1.f, 2.f, 3.f);
@@ -7367,25 +7357,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
TransformOperations(), translation);
// No layers have scale-affecting animations.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
TransformOperations scale;
scale.AppendScale(5.f, 4.f, 3.f);
@@ -7396,25 +7376,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// Only |child| has a scale-affecting animation.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(5.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(1.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 1.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(1.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(1.f, GetStartingAnimationScale(grand_child_raw));
AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0,
TransformOperations(), scale);
@@ -7422,27 +7392,17 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent| and |child| have scale-affecting animations.
- EXPECT_EQ(
- 5.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(5.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(5.f, GetMaximumAnimationScale(parent_raw));
// We don't support combining animated scales from two nodes; 0.f means
// that the maximum scale could not be computed.
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 1.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(1.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(1.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(1.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
TransformOperations(), scale);
@@ -7450,25 +7410,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent|, |parent|, and |child| have scale-affecting animations.
- EXPECT_EQ(
- 5.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(5.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 1.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(1.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline,
TargetProperty::TRANSFORM);
@@ -7487,25 +7437,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
// |child| has a scale-affecting animation but computing the maximum of this
// animation is not supported.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline,
TargetProperty::TRANSFORM);
@@ -7521,27 +7461,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
// |grand_parent| and |parent| each have scale 2.f. |parent| has a scale
// animation with maximum scale 5.f.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(10.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(10.f,
- child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 10.f,
- grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(10.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(10.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(2.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(2.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 2.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(2.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(2.f, GetStartingAnimationScale(grand_child_raw));
gfx::Transform perspective_matrix;
perspective_matrix.ApplyPerspectiveDepth(2.f);
@@ -7550,25 +7478,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// |child| has a transform that's neither a translation nor a scale.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(10.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(2.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
parent_raw->SetTransform(perspective_matrix);
grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
@@ -7576,25 +7494,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
// |parent| and |child| have transforms that are neither translations nor
// scales.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
parent_raw->SetTransform(identity_matrix);
child_raw->SetTransform(identity_matrix);
@@ -7604,25 +7512,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent| has a transform that's neither a translation nor a scale.
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(
- 0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw));
- EXPECT_EQ(
- 0.f,
- grand_parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- parent_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(0.f,
- child_raw->draw_properties().starting_animation_contents_scale);
- EXPECT_EQ(
- 0.f,
- grand_child_raw->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw));
+ EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw));
}
static void GatherDrawnLayers(LayerImplList* rsll,
@@ -7974,12 +7872,9 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
child1_layer->test_properties()->mask_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(5.f, child2_layer->GetIdealContentsScale());
- EXPECT_FLOAT_EQ(
- 0.f, root_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 0.f, child1_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 8.f, child2_layer->draw_properties().maximum_animation_contents_scale);
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer));
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer));
+ EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer));
// Changing page-scale would affect ideal_contents_scale and
// maximum_animation_contents_scale.
@@ -8008,12 +7903,9 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
->mask_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(15.f, child2_layer->GetIdealContentsScale());
- EXPECT_FLOAT_EQ(
- 0.f, root_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 0.f, child1_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 24.f, child2_layer->draw_properties().maximum_animation_contents_scale);
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer));
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer));
+ EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer));
// Changing device-scale would affect ideal_contents_scale and
// maximum_animation_contents_scale.
@@ -8034,12 +7926,9 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
->mask_layer->GetIdealContentsScale());
EXPECT_FLOAT_EQ(60.f, child2_layer->GetIdealContentsScale());
- EXPECT_FLOAT_EQ(
- 0.f, root_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 0.f, child1_layer->draw_properties().maximum_animation_contents_scale);
- EXPECT_FLOAT_EQ(
- 96.f, child2_layer->draw_properties().maximum_animation_contents_scale);
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer));
+ EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer));
+ EXPECT_FLOAT_EQ(96.f, GetMaximumAnimationScale(child2_layer));
}
TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) {

Powered by Google App Engine
This is Rietveld 408576698