| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 5916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5927 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } | 5927 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
| 5928 | 5928 |
| 5929 FakeContentLayerClient client_; | 5929 FakeContentLayerClient client_; |
| 5930 int step_; | 5930 int step_; |
| 5931 int continuous_draws_; | 5931 int continuous_draws_; |
| 5932 base::WaitableEvent playback_allowed_event_; | 5932 base::WaitableEvent playback_allowed_event_; |
| 5933 }; | 5933 }; |
| 5934 | 5934 |
| 5935 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5935 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5936 | 5936 |
| 5937 class LayerTreeHostTestOneActivatePerManageTiles : public LayerTreeHostTest { | 5937 class LayerTreeHostTestOneActivatePerPrepareTiles : public LayerTreeHostTest { |
| 5938 public: | 5938 public: |
| 5939 LayerTreeHostTestOneActivatePerManageTiles() | 5939 LayerTreeHostTestOneActivatePerPrepareTiles() |
| 5940 : notify_ready_to_activate_count_(0u), scheduled_manage_tiles_count_(0) {} | 5940 : notify_ready_to_activate_count_(0u), |
| 5941 scheduled_prepare_tiles_count_(0) {} |
| 5941 | 5942 |
| 5942 void SetupTree() override { | 5943 void SetupTree() override { |
| 5943 client_.set_fill_with_nonsolid_color(true); | 5944 client_.set_fill_with_nonsolid_color(true); |
| 5944 scoped_refptr<FakePictureLayer> root_layer = | 5945 scoped_refptr<FakePictureLayer> root_layer = |
| 5945 FakePictureLayer::Create(&client_); | 5946 FakePictureLayer::Create(&client_); |
| 5946 root_layer->SetBounds(gfx::Size(1500, 1500)); | 5947 root_layer->SetBounds(gfx::Size(1500, 1500)); |
| 5947 root_layer->SetIsDrawable(true); | 5948 root_layer->SetIsDrawable(true); |
| 5948 | 5949 |
| 5949 layer_tree_host()->SetRootLayer(root_layer); | 5950 layer_tree_host()->SetRootLayer(root_layer); |
| 5950 LayerTreeHostTest::SetupTree(); | 5951 LayerTreeHostTest::SetupTree(); |
| 5951 } | 5952 } |
| 5952 | 5953 |
| 5953 void BeginTest() override { | 5954 void BeginTest() override { |
| 5954 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); | 5955 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); |
| 5955 PostSetNeedsCommitToMainThread(); | 5956 PostSetNeedsCommitToMainThread(); |
| 5956 } | 5957 } |
| 5957 | 5958 |
| 5958 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, | 5959 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 5959 bool success) override { | 5960 bool success) override { |
| 5960 ASSERT_TRUE(success); | 5961 ASSERT_TRUE(success); |
| 5961 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); | 5962 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); |
| 5962 } | 5963 } |
| 5963 | 5964 |
| 5964 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { | 5965 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
| 5965 ++notify_ready_to_activate_count_; | 5966 ++notify_ready_to_activate_count_; |
| 5966 EndTestAfterDelayMs(100); | 5967 EndTestAfterDelayMs(100); |
| 5967 } | 5968 } |
| 5968 | 5969 |
| 5969 void ScheduledActionManageTiles() override { | 5970 void ScheduledActionPrepareTiles() override { |
| 5970 ++scheduled_manage_tiles_count_; | 5971 ++scheduled_prepare_tiles_count_; |
| 5971 } | 5972 } |
| 5972 | 5973 |
| 5973 void AfterTest() override { | 5974 void AfterTest() override { |
| 5974 // Expect at most a notification for each scheduled manage tiles, plus one | 5975 // Expect at most a notification for each scheduled prepare tiles, plus one |
| 5975 // for the initial commit (which doesn't go through scheduled actions). | 5976 // for the initial commit (which doesn't go through scheduled actions). |
| 5976 // The reason this is not an equality is because depending on timing, we | 5977 // The reason this is not an equality is because depending on timing, we |
| 5977 // might get a manage tiles but not yet get a notification that we're | 5978 // might get a prepare tiles but not yet get a notification that we're |
| 5978 // ready to activate. The intent of a test is to ensure that we don't | 5979 // ready to activate. The intent of a test is to ensure that we don't |
| 5979 // get more than one notification per manage tiles, so this is OK. | 5980 // get more than one notification per prepare tiles, so this is OK. |
| 5980 EXPECT_LE(notify_ready_to_activate_count_, | 5981 EXPECT_LE(notify_ready_to_activate_count_, |
| 5981 1u + scheduled_manage_tiles_count_); | 5982 1u + scheduled_prepare_tiles_count_); |
| 5982 } | 5983 } |
| 5983 | 5984 |
| 5984 protected: | 5985 protected: |
| 5985 FakeContentLayerClient client_; | 5986 FakeContentLayerClient client_; |
| 5986 size_t notify_ready_to_activate_count_; | 5987 size_t notify_ready_to_activate_count_; |
| 5987 size_t scheduled_manage_tiles_count_; | 5988 size_t scheduled_prepare_tiles_count_; |
| 5988 }; | 5989 }; |
| 5989 | 5990 |
| 5990 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerManageTiles); | 5991 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
| 5991 | 5992 |
| 5992 } // namespace cc | 5993 } // namespace cc |
| OLD | NEW |