| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 PostSetNeedsCommitToMainThread(); | 869 PostSetNeedsCommitToMainThread(); |
| 870 client_.set_bounds(root_layer_->bounds()); | 870 client_.set_bounds(root_layer_->bounds()); |
| 871 } | 871 } |
| 872 | 872 |
| 873 void InitializeSettings(LayerTreeSettings* settings) override { | 873 void InitializeSettings(LayerTreeSettings* settings) override { |
| 874 settings->gpu_rasterization_enabled = true; | 874 settings->gpu_rasterization_enabled = true; |
| 875 settings->gpu_rasterization_forced = true; | 875 settings->gpu_rasterization_forced = true; |
| 876 } | 876 } |
| 877 | 877 |
| 878 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 878 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 879 // Perform 2 commits. | 879 if (num_draws_ < 2) |
| 880 if (!num_draws_) { | |
| 881 PostSetNeedsRedrawRectToMainThread(invalid_rect_); | 880 PostSetNeedsRedrawRectToMainThread(invalid_rect_); |
| 882 } else { | |
| 883 EndTest(); | |
| 884 } | |
| 885 num_draws_++; | 881 num_draws_++; |
| 886 } | 882 } |
| 887 | 883 |
| 888 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 884 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 889 if (num_draws_ == 2) { | 885 if (num_draws_ == 2) { |
| 890 auto pending_tree = host_impl->pending_tree(); | 886 auto pending_tree = host_impl->pending_tree(); |
| 891 auto pending_layer_impl = | 887 auto pending_layer_impl = |
| 892 static_cast<FakePictureLayerImpl*>(pending_tree->root_layer()); | 888 static_cast<FakePictureLayerImpl*>(pending_tree->root_layer()); |
| 893 EXPECT_NE(pending_layer_impl, nullptr); | 889 EXPECT_NE(pending_layer_impl, nullptr); |
| 894 | 890 |
| 895 auto active_tree = host_impl->pending_tree(); | 891 auto active_tree = host_impl->pending_tree(); |
| 896 auto active_layer_impl = | 892 auto active_layer_impl = |
| 897 static_cast<FakePictureLayerImpl*>(active_tree->root_layer()); | 893 static_cast<FakePictureLayerImpl*>(active_tree->root_layer()); |
| 898 EXPECT_NE(pending_layer_impl, nullptr); | 894 EXPECT_NE(pending_layer_impl, nullptr); |
| 899 | 895 |
| 900 auto active_tiling_set = active_layer_impl->picture_layer_tiling_set(); | 896 auto active_tiling_set = active_layer_impl->picture_layer_tiling_set(); |
| 901 auto active_tiling = active_tiling_set->tiling_at(0); | 897 auto active_tiling = active_tiling_set->tiling_at(0); |
| 902 auto pending_tiling_set = pending_layer_impl->picture_layer_tiling_set(); | 898 auto pending_tiling_set = pending_layer_impl->picture_layer_tiling_set(); |
| 903 auto pending_tiling = pending_tiling_set->tiling_at(0); | 899 auto pending_tiling = pending_tiling_set->tiling_at(0); |
| 904 EXPECT_EQ( | 900 EXPECT_EQ( |
| 905 pending_tiling->TilingDataForTesting().max_texture_size().width(), | 901 pending_tiling->TilingDataForTesting().max_texture_size().width(), |
| 906 active_tiling->TilingDataForTesting().max_texture_size().width()); | 902 active_tiling->TilingDataForTesting().max_texture_size().width()); |
| 903 EndTest(); |
| 907 } | 904 } |
| 908 } | 905 } |
| 909 | 906 |
| 910 void DidCommitAndDrawFrame() override { | 907 void DidCommitAndDrawFrame() override { |
| 911 // On the second commit, resize the viewport. | 908 // On the second commit, resize the viewport. |
| 912 if (num_draws_ == 1) { | 909 if (num_draws_ == 1) { |
| 913 layer_tree_host()->SetViewportSize(gfx::Size(400, 64)); | 910 layer_tree_host()->SetViewportSize(gfx::Size(400, 64)); |
| 914 } | 911 } |
| 915 } | 912 } |
| 916 | 913 |
| 917 void AfterTest() override {} | 914 void AfterTest() override {} |
| 918 | 915 |
| 919 private: | 916 private: |
| 920 int num_draws_; | 917 int num_draws_; |
| 921 const gfx::Size bounds_; | 918 const gfx::Size bounds_; |
| 922 const gfx::Rect invalid_rect_; | 919 const gfx::Rect invalid_rect_; |
| 923 FakeContentLayerClient client_; | 920 FakeContentLayerClient client_; |
| 924 scoped_refptr<FakePictureLayer> root_layer_; | 921 scoped_refptr<FakePictureLayer> root_layer_; |
| 925 }; | 922 }; |
| 926 | 923 |
| 927 #if !defined(OS_WIN) | 924 // As there's no pending tree in single-threaded case, this test should run |
| 928 // Flaky on win: http://crbug.com/596880 | 925 // only for multi-threaded case. |
| 929 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterDeviceSizeChanged); | 926 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterDeviceSizeChanged); |
| 930 #endif | |
| 931 | 927 |
| 932 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 928 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
| 933 public: | 929 public: |
| 934 void InitializeSettings(LayerTreeSettings* settings) override { | 930 void InitializeSettings(LayerTreeSettings* settings) override { |
| 935 settings->layer_transforms_should_scale_layer_contents = true; | 931 settings->layer_transforms_should_scale_layer_contents = true; |
| 936 } | 932 } |
| 937 | 933 |
| 938 void SetupTree() override { | 934 void SetupTree() override { |
| 939 root_layer_ = Layer::Create(); | 935 root_layer_ = Layer::Create(); |
| 940 root_layer_->SetBounds(gfx::Size(10, 20)); | 936 root_layer_->SetBounds(gfx::Size(10, 20)); |
| (...skipping 5714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6655 EndTest(); | 6651 EndTest(); |
| 6656 } | 6652 } |
| 6657 | 6653 |
| 6658 void AfterTest() override {} | 6654 void AfterTest() override {} |
| 6659 }; | 6655 }; |
| 6660 | 6656 |
| 6661 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6657 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6662 | 6658 |
| 6663 } // namespace | 6659 } // namespace |
| 6664 } // namespace cc | 6660 } // namespace cc |
| OLD | NEW |