| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 5959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5970 child_->SetContentsOpaque(true); | 5970 child_->SetContentsOpaque(true); |
| 5971 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5971 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5972 layers_always_allowed_lcd_text_); | 5972 layers_always_allowed_lcd_text_); |
| 5973 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5973 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5974 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5974 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
| 5975 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5975 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 5976 } | 5976 } |
| 5977 | 5977 |
| 5978 TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) { | 5978 TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) { |
| 5979 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 5979 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
| 5980 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
| 5980 | 5981 |
| 5981 // Sanity check: Make sure can_use_lcd_text_ is set on each node. | 5982 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 5982 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5983 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5983 layers_always_allowed_lcd_text_); | 5984 layers_always_allowed_lcd_text_); |
| 5984 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 5985 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5985 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 5986 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
| 5986 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 5987 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 5987 | 5988 |
| 5988 // Add opacity animation. | 5989 // Add opacity animation. |
| 5989 child_->SetOpacity(0.9f); | 5990 child_->SetOpacity(0.9f); |
| 5990 AddOpacityTransitionToController( | 5991 AddOpacityTransitionToController( |
| 5991 child_->layer_animation_controller(), 10.0, 0.9f, 0.1f, false); | 5992 child_->layer_animation_controller(), 10.0, 0.9f, 0.1f, false); |
| 5992 | 5993 |
| 5993 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, | 5994 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 5994 layers_always_allowed_lcd_text_); | 5995 layers_always_allowed_lcd_text_); |
| 5995 // Text AA should not be adjusted while animation is active. | 5996 // Text LCD should be adjusted while animation is active. |
| 5996 // Make sure LCD text AA setting remains unchanged. | 5997 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5998 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
| 5999 EXPECT_EQ(expect_not_lcd_text, grand_child_->can_use_lcd_text()); |
| 6000 } |
| 6001 |
| 6002 TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { |
| 6003 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
| 6004 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
| 6005 |
| 6006 // Sanity check: Make sure can_use_lcd_text_ is set on each node. |
| 6007 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 6008 layers_always_allowed_lcd_text_); |
| 5997 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); | 6009 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 5998 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); | 6010 EXPECT_EQ(expect_lcd_text, child_->can_use_lcd_text()); |
| 5999 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); | 6011 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 6012 |
| 6013 // Mark contents non-opaque within the first animation frame. |
| 6014 child_->SetContentsOpaque(false); |
| 6015 AddOpacityTransitionToController(child_->layer_animation_controller(), 10.0, |
| 6016 0.9f, 0.1f, false); |
| 6017 |
| 6018 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, |
| 6019 layers_always_allowed_lcd_text_); |
| 6020 // LCD text should be disabled for non-opaque layers even during animations. |
| 6021 EXPECT_EQ(expect_lcd_text, root_->can_use_lcd_text()); |
| 6022 EXPECT_EQ(expect_not_lcd_text, child_->can_use_lcd_text()); |
| 6023 EXPECT_EQ(expect_lcd_text, grand_child_->can_use_lcd_text()); |
| 6000 } | 6024 } |
| 6001 | 6025 |
| 6002 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 6026 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 6003 LCDTextTest, | 6027 LCDTextTest, |
| 6004 testing::Combine(testing::Bool(), | 6028 testing::Combine(testing::Bool(), |
| 6005 testing::Bool(), | 6029 testing::Bool(), |
| 6006 testing::Bool())); | 6030 testing::Bool())); |
| 6007 | 6031 |
| 6008 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { | 6032 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayer) { |
| 6009 FakeImplProxy proxy; | 6033 FakeImplProxy proxy; |
| (...skipping 3557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9567 | 9591 |
| 9568 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0); | 9592 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0); |
| 9569 ExecuteCalculateDrawProperties(root.get()); | 9593 ExecuteCalculateDrawProperties(root.get()); |
| 9570 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 1); | 9594 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 1); |
| 9571 child->SetHaveWheelEventHandlers(false); | 9595 child->SetHaveWheelEventHandlers(false); |
| 9572 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0); | 9596 EXPECT_EQ(root->num_layer_or_descendants_with_input_handler(), 0); |
| 9573 } | 9597 } |
| 9574 | 9598 |
| 9575 } // namespace | 9599 } // namespace |
| 9576 } // namespace cc | 9600 } // namespace cc |
| OLD | NEW |