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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2838033002: cc : Don't draw animating layers with singular screen space transform (Closed)
Patch Set: . Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 8981 matching lines...) Expand 10 before | Expand all | Expand 10 after
8992 animated->element_id(), timeline_impl(), 10.0, 0.f, 1.f, false); 8992 animated->element_id(), timeline_impl(), 10.0, 0.f, 1.f, false);
8993 animated->test_properties()->opacity_can_animate = true; 8993 animated->test_properties()->opacity_can_animate = true;
8994 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 8994 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
8995 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 8995 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root);
8996 8996
8997 EXPECT_FALSE(animated->visible_layer_rect().IsEmpty()); 8997 EXPECT_FALSE(animated->visible_layer_rect().IsEmpty());
8998 } 8998 }
8999 8999
9000 TEST_F(LayerTreeHostCommonTest, 9000 TEST_F(LayerTreeHostCommonTest,
9001 VisibleContentRectForAnimatedLayerWithSingularTransform) { 9001 VisibleContentRectForAnimatedLayerWithSingularTransform) {
9002 LayerImpl* root = root_layer_for_testing(); 9002 host_impl()->CreatePendingTree();
9003 LayerImpl* clip = AddChild<LayerImpl>(root); 9003 std::unique_ptr<LayerImpl> root_ptr =
9004 LayerImpl* animated = AddChild<LayerImpl>(clip); 9004 LayerImpl::Create(host_impl()->pending_tree(), 1);
9005 LayerImpl* surface = AddChild<LayerImpl>(animated); 9005 LayerImpl* root = root_ptr.get();
9006 LayerImpl* descendant_of_animation = AddChild<LayerImpl>(surface); 9006 host_impl()->pending_tree()->SetRootLayerForTesting(std::move(root_ptr));
9007 std::unique_ptr<LayerImpl> clip_ptr =
9008 LayerImpl::Create(host_impl()->pending_tree(), 2);
9009 LayerImpl* clip = clip_ptr.get();
9010 root->test_properties()->AddChild(std::move(clip_ptr));
9011 std::unique_ptr<LayerImpl> animated_ptr =
9012 LayerImpl::Create(host_impl()->pending_tree(), 3);
9013 LayerImpl* animated = animated_ptr.get();
9014 clip->test_properties()->AddChild(std::move(animated_ptr));
9015 std::unique_ptr<LayerImpl> surface_ptr =
9016 LayerImpl::Create(host_impl()->pending_tree(), 4);
9017 LayerImpl* surface = surface_ptr.get();
9018 animated->test_properties()->AddChild(std::move(surface_ptr));
9019 std::unique_ptr<LayerImpl> descendant_of_animation_ptr =
9020 LayerImpl::Create(host_impl()->pending_tree(), 5);
9021 LayerImpl* descendant_of_animation = descendant_of_animation_ptr.get();
9022 surface->test_properties()->AddChild(std::move(descendant_of_animation_ptr));
9007 9023
9008 SetElementIdsForTesting(); 9024 host_impl()->pending_tree()->SetElementIdsForTesting();
9009 9025
9026 root->SetDrawsContent(true);
9010 animated->SetDrawsContent(true); 9027 animated->SetDrawsContent(true);
9011 surface->SetDrawsContent(true); 9028 surface->SetDrawsContent(true);
9012 descendant_of_animation->SetDrawsContent(true); 9029 descendant_of_animation->SetDrawsContent(true);
9013 9030
9014 gfx::Transform uninvertible_matrix; 9031 gfx::Transform uninvertible_matrix;
9015 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); 9032 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f);
9016 9033
9017 root->SetBounds(gfx::Size(100, 100)); 9034 root->SetBounds(gfx::Size(100, 100));
9018 clip->SetBounds(gfx::Size(10, 10)); 9035 clip->SetBounds(gfx::Size(10, 10));
9019 clip->SetMasksToBounds(true); 9036 clip->SetMasksToBounds(true);
9020 animated->test_properties()->transform = uninvertible_matrix; 9037 animated->test_properties()->transform = uninvertible_matrix;
9021 animated->SetBounds(gfx::Size(120, 120)); 9038 animated->SetBounds(gfx::Size(120, 120));
9022 surface->SetBounds(gfx::Size(100, 100)); 9039 surface->SetBounds(gfx::Size(100, 100));
9023 surface->test_properties()->force_render_surface = true; 9040 surface->test_properties()->force_render_surface = true;
9024 descendant_of_animation->SetBounds(gfx::Size(200, 200)); 9041 descendant_of_animation->SetBounds(gfx::Size(200, 200));
9025 9042
9026 TransformOperations start_transform_operations; 9043 TransformOperations start_transform_operations;
9027 start_transform_operations.AppendMatrix(uninvertible_matrix); 9044 start_transform_operations.AppendMatrix(uninvertible_matrix);
9028 TransformOperations end_transform_operations; 9045 TransformOperations end_transform_operations;
9029 9046
9030 AddAnimatedTransformToElementWithPlayer( 9047 AddAnimatedTransformToElementWithPlayer(
9031 animated->element_id(), timeline_impl(), 10.0, start_transform_operations, 9048 animated->element_id(), timeline_impl(), 10.0, start_transform_operations,
9032 end_transform_operations); 9049 end_transform_operations);
9033 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 9050 ExecuteCalculateDrawProperties(root);
9051 // Since animated has singular transform, it is not be part of render
9052 // surface layer list but should be rastered.
9053 EXPECT_FALSE(animated->is_drawn_render_surface_layer_list_member());
9054 EXPECT_TRUE(animated->raster_even_if_not_in_rsll());
9034 9055
9035 // The animated layer has a singular transform and maps to a non-empty rect in 9056 // The animated layer has a singular transform and maps to a non-empty rect in
9036 // clipped target space, so is treated as fully visible. 9057 // clipped target space, so is treated as fully visible.
9037 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); 9058 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect());
9038 9059
9039 // The singular transform on |animated| is flattened when inherited by 9060 // The singular transform on |animated| is flattened when inherited by
9040 // |surface|, and this happens to make it invertible. 9061 // |surface|, and this happens to make it invertible.
9041 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); 9062 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect());
9042 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); 9063 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect());
9043 9064
9044 gfx::Transform zero_matrix; 9065 gfx::Transform zero_matrix;
9045 zero_matrix.Scale3d(0.f, 0.f, 0.f); 9066 zero_matrix.Scale3d(0.f, 0.f, 0.f);
9046 root->layer_tree_impl()->SetTransformMutated(animated->element_id(), 9067 root->layer_tree_impl()->SetTransformMutated(animated->element_id(),
9047 zero_matrix); 9068 zero_matrix);
9048 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root); 9069 ExecuteCalculateDrawProperties(root);
9049 9070
9050 // The animated layer will be treated as fully visible when we combine clips 9071 // The animated layer will be treated as fully visible when we combine clips
9051 // in screen space. 9072 // in screen space.
9052 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect()); 9073 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect());
9053 9074
9054 // This time, flattening does not make |animated|'s transform invertible. This 9075 // This time, flattening does not make |animated|'s transform invertible. This
9055 // means the clip cannot be projected into |surface|'s space, so we treat 9076 // means the clip cannot be projected into |surface|'s space, so we treat
9056 // |surface| and layers that draw into it as having empty visible rect. 9077 // |surface| and layers that draw into it as having empty visible rect.
9057 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_layer_rect()); 9078 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_layer_rect());
9058 EXPECT_EQ(gfx::Rect(200, 200), descendant_of_animation->visible_layer_rect()); 9079 EXPECT_EQ(gfx::Rect(200, 200), descendant_of_animation->visible_layer_rect());
9080
9081 host_impl()->ActivateSyncTree();
9082 LayerImpl* active_root = host_impl()->active_tree()->LayerById(root->id());
9083 ExecuteCalculateDrawProperties(active_root);
9084
9085 // Since the animated has singular transform, it is not be part of render
9086 // surface layer list.
9087 LayerImpl* active_animated =
9088 host_impl()->active_tree()->LayerById(animated->id());
9089 EXPECT_TRUE(active_root->is_drawn_render_surface_layer_list_member());
9090 EXPECT_FALSE(active_animated->is_drawn_render_surface_layer_list_member());
9091
9092 // Since animated has singular transform, it is not be part of render
9093 // surface layer list but should be rastered.
9094 EXPECT_TRUE(animated->raster_even_if_not_in_rsll());
9095 EXPECT_EQ(gfx::Rect(120, 120), active_animated->visible_layer_rect());
9059 } 9096 }
9060 9097
9061 // Verify that having animated opacity but current opacity 1 still creates 9098 // Verify that having animated opacity but current opacity 1 still creates
9062 // a render surface. 9099 // a render surface.
9063 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) { 9100 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) {
9064 LayerImpl* root = root_layer_for_testing(); 9101 LayerImpl* root = root_layer_for_testing();
9065 LayerImpl* child = AddChild<LayerImpl>(root); 9102 LayerImpl* child = AddChild<LayerImpl>(root);
9066 LayerImpl* grandchild = AddChild<LayerImpl>(child); 9103 LayerImpl* grandchild = AddChild<LayerImpl>(child);
9067 9104
9068 root->SetBounds(gfx::Size(50, 50)); 9105 root->SetBounds(gfx::Size(50, 50));
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
10865 10902
10866 // Check child layer draw properties. 10903 // Check child layer draw properties.
10867 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10904 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10868 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10905 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10869 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10906 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10870 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10907 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10871 } 10908 }
10872 10909
10873 } // namespace 10910 } // namespace
10874 } // namespace cc 10911 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698