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

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

Issue 640203002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr [part-… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format fix. Created 6 years, 2 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
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 <set> 7 #include <set>
8 8
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/animation/transform_operations.h" 10 #include "cc/animation/transform_operations.h"
(...skipping 5703 matching lines...) Expand 10 before | Expand all | Expand 10 after
5714 scoped_ptr<FakeLayerTreeHost> host_; 5714 scoped_ptr<FakeLayerTreeHost> host_;
5715 scoped_refptr<Layer> root_; 5715 scoped_refptr<Layer> root_;
5716 scoped_refptr<Layer> child_; 5716 scoped_refptr<Layer> child_;
5717 scoped_refptr<Layer> grand_child_; 5717 scoped_refptr<Layer> grand_child_;
5718 }; 5718 };
5719 5719
5720 TEST_P(LCDTextTest, CanUseLCDText) { 5720 TEST_P(LCDTextTest, CanUseLCDText) {
5721 // Case 1: Identity transform. 5721 // Case 1: Identity transform.
5722 gfx::Transform identity_matrix; 5722 gfx::Transform identity_matrix;
5723 ExecuteCalculateDrawProperties( 5723 ExecuteCalculateDrawProperties(
5724 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5724 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5725 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5725 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5726 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 5726 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
5727 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 5727 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
5728 5728
5729 // Case 2: Integral translation. 5729 // Case 2: Integral translation.
5730 gfx::Transform integral_translation; 5730 gfx::Transform integral_translation;
5731 integral_translation.Translate(1.0, 2.0); 5731 integral_translation.Translate(1.0, 2.0);
5732 child_->SetTransform(integral_translation); 5732 child_->SetTransform(integral_translation);
5733 ExecuteCalculateDrawProperties( 5733 ExecuteCalculateDrawProperties(
5734 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5734 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5735 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5735 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5736 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 5736 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
5737 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 5737 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
5738 5738
5739 // Case 3: Non-integral translation. 5739 // Case 3: Non-integral translation.
5740 gfx::Transform non_integral_translation; 5740 gfx::Transform non_integral_translation;
5741 non_integral_translation.Translate(1.5, 2.5); 5741 non_integral_translation.Translate(1.5, 2.5);
5742 child_->SetTransform(non_integral_translation); 5742 child_->SetTransform(non_integral_translation);
5743 ExecuteCalculateDrawProperties( 5743 ExecuteCalculateDrawProperties(
5744 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5744 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5745 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5745 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5746 EXPECT_FALSE(child_->can_use_lcd_text()); 5746 EXPECT_FALSE(child_->can_use_lcd_text());
5747 EXPECT_FALSE(grand_child_->can_use_lcd_text()); 5747 EXPECT_FALSE(grand_child_->can_use_lcd_text());
5748 5748
5749 // Case 4: Rotation. 5749 // Case 4: Rotation.
5750 gfx::Transform rotation; 5750 gfx::Transform rotation;
5751 rotation.Rotate(10.0); 5751 rotation.Rotate(10.0);
5752 child_->SetTransform(rotation); 5752 child_->SetTransform(rotation);
5753 ExecuteCalculateDrawProperties( 5753 ExecuteCalculateDrawProperties(
5754 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5754 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5755 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5755 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5756 EXPECT_FALSE(child_->can_use_lcd_text()); 5756 EXPECT_FALSE(child_->can_use_lcd_text());
5757 EXPECT_FALSE(grand_child_->can_use_lcd_text()); 5757 EXPECT_FALSE(grand_child_->can_use_lcd_text());
5758 5758
5759 // Case 5: Scale. 5759 // Case 5: Scale.
5760 gfx::Transform scale; 5760 gfx::Transform scale;
5761 scale.Scale(2.0, 2.0); 5761 scale.Scale(2.0, 2.0);
5762 child_->SetTransform(scale); 5762 child_->SetTransform(scale);
5763 ExecuteCalculateDrawProperties( 5763 ExecuteCalculateDrawProperties(
5764 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5764 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5765 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5765 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5766 EXPECT_FALSE(child_->can_use_lcd_text()); 5766 EXPECT_FALSE(child_->can_use_lcd_text());
5767 EXPECT_FALSE(grand_child_->can_use_lcd_text()); 5767 EXPECT_FALSE(grand_child_->can_use_lcd_text());
5768 5768
5769 // Case 6: Skew. 5769 // Case 6: Skew.
5770 gfx::Transform skew; 5770 gfx::Transform skew;
5771 skew.SkewX(10.0); 5771 skew.SkewX(10.0);
5772 child_->SetTransform(skew); 5772 child_->SetTransform(skew);
5773 ExecuteCalculateDrawProperties( 5773 ExecuteCalculateDrawProperties(
5774 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5774 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5775 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5775 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5776 EXPECT_FALSE(child_->can_use_lcd_text()); 5776 EXPECT_FALSE(child_->can_use_lcd_text());
5777 EXPECT_FALSE(grand_child_->can_use_lcd_text()); 5777 EXPECT_FALSE(grand_child_->can_use_lcd_text());
5778 5778
5779 // Case 7: Translucent. 5779 // Case 7: Translucent.
5780 child_->SetTransform(identity_matrix); 5780 child_->SetTransform(identity_matrix);
5781 child_->SetOpacity(0.5f); 5781 child_->SetOpacity(0.5f);
5782 ExecuteCalculateDrawProperties( 5782 ExecuteCalculateDrawProperties(
5783 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5783 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5784 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5784 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5785 EXPECT_FALSE(child_->can_use_lcd_text()); 5785 EXPECT_FALSE(child_->can_use_lcd_text());
5786 EXPECT_FALSE(grand_child_->can_use_lcd_text()); 5786 EXPECT_FALSE(grand_child_->can_use_lcd_text());
5787 5787
5788 // Case 8: Sanity check: restore transform and opacity. 5788 // Case 8: Sanity check: restore transform and opacity.
5789 child_->SetTransform(identity_matrix); 5789 child_->SetTransform(identity_matrix);
5790 child_->SetOpacity(1.f); 5790 child_->SetOpacity(1.f);
5791 ExecuteCalculateDrawProperties( 5791 ExecuteCalculateDrawProperties(
5792 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5792 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5793 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5793 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5794 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 5794 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
5795 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 5795 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
5796 } 5796 }
5797 5797
5798 TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) { 5798 TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) {
5799 // Sanity check: Make sure can_use_lcd_text_ is set on each node. 5799 // Sanity check: Make sure can_use_lcd_text_ is set on each node.
5800 ExecuteCalculateDrawProperties( 5800 ExecuteCalculateDrawProperties(
5801 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5801 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5802 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5802 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5803 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 5803 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
5804 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 5804 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
5805 5805
5806 // Add opacity animation. 5806 // Add opacity animation.
5807 child_->SetOpacity(0.9f); 5807 child_->SetOpacity(0.9f);
5808 AddOpacityTransitionToController( 5808 AddOpacityTransitionToController(
5809 child_->layer_animation_controller(), 10.0, 0.9f, 0.1f, false); 5809 child_->layer_animation_controller(), 10.0, 0.9f, 0.1f, false);
5810 5810
5811 ExecuteCalculateDrawProperties( 5811 ExecuteCalculateDrawProperties(
5812 root_.get(), 1.f, 1.f, NULL, can_use_lcd_text_); 5812 root_.get(), 1.f, 1.f, nullptr, can_use_lcd_text_);
5813 // Text AA should not be adjusted while animation is active. 5813 // Text AA should not be adjusted while animation is active.
5814 // Make sure LCD text AA setting remains unchanged. 5814 // Make sure LCD text AA setting remains unchanged.
5815 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text()); 5815 EXPECT_EQ(can_use_lcd_text_, root_->can_use_lcd_text());
5816 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text()); 5816 EXPECT_EQ(can_use_lcd_text_, child_->can_use_lcd_text());
5817 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text()); 5817 EXPECT_EQ(can_use_lcd_text_, grand_child_->can_use_lcd_text());
5818 } 5818 }
5819 5819
5820 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 5820 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
5821 LCDTextTest, 5821 LCDTextTest,
5822 testing::Combine(testing::Bool(), testing::Bool())); 5822 testing::Combine(testing::Bool(), testing::Bool()));
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after
8596 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); 8596 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D);
8597 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client); 8597 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client);
8598 host->SetRootLayer(root); 8598 host->SetRootLayer(root);
8599 8599
8600 gfx::Size device_viewport_size(768, 582); 8600 gfx::Size device_viewport_size(768, 582);
8601 RenderSurfaceLayerList render_surface_layer_list; 8601 RenderSurfaceLayerList render_surface_layer_list;
8602 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 8602 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
8603 host->root_layer(), device_viewport_size, &render_surface_layer_list); 8603 host->root_layer(), device_viewport_size, &render_surface_layer_list);
8604 inputs.device_scale_factor = 2.f; 8604 inputs.device_scale_factor = 2.f;
8605 inputs.page_scale_factor = 1.f; 8605 inputs.page_scale_factor = 1.f;
8606 inputs.page_scale_application_layer = NULL; 8606 inputs.page_scale_application_layer = nullptr;
8607 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8607 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8608 8608
8609 // Layers in the root render surface have their visible content rect clipped 8609 // Layers in the root render surface have their visible content rect clipped
8610 // by the viewport. 8610 // by the viewport.
8611 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); 8611 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect());
8612 8612
8613 // Layers drawing to a child render surface should still have their visible 8613 // Layers drawing to a child render surface should still have their visible
8614 // content rect clipped by the viewport. 8614 // content rect clipped by the viewport.
8615 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); 8615 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect());
8616 } 8616 }
8617 8617
8618 } // namespace 8618 } // namespace
8619 } // namespace cc 8619 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698