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 5478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5489 PostSetNeedsCommitToMainThread(); | 5489 PostSetNeedsCommitToMainThread(); |
5490 } | 5490 } |
5491 | 5491 |
5492 void BeginMainFrame(const BeginFrameArgs& args) override { | 5492 void BeginMainFrame(const BeginFrameArgs& args) override { |
5493 EXPECT_EQ(nullptr, layer_tree_host()->root_layer()); | 5493 EXPECT_EQ(nullptr, layer_tree_host()->root_layer()); |
5494 | 5494 |
5495 layer_tree_host()->ApplyScrollAndScale(&info_); | 5495 layer_tree_host()->ApplyScrollAndScale(&info_); |
5496 EndTest(); | 5496 EndTest(); |
5497 } | 5497 } |
5498 | 5498 |
5499 void ApplyViewportDeltas( | 5499 void ApplyViewportDeltas(const gfx::Vector2d& inner, |
5500 const gfx::Vector2d& inner, | 5500 const gfx::Vector2d& outer, |
5501 const gfx::Vector2d& outer, | 5501 const gfx::Vector2dF& elastic_overscroll_delta, |
5502 float scale_delta, | 5502 float scale_delta, |
5503 float top_controls_delta) override { | 5503 float top_controls_delta) override { |
5504 EXPECT_EQ(info_.page_scale_delta, scale_delta); | 5504 EXPECT_EQ(info_.page_scale_delta, scale_delta); |
5505 EXPECT_EQ(info_.top_controls_delta, top_controls_delta); | 5505 EXPECT_EQ(info_.top_controls_delta, top_controls_delta); |
5506 deltas_sent_to_client_ = true; | 5506 deltas_sent_to_client_ = true; |
5507 } | 5507 } |
5508 | 5508 |
5509 void ApplyViewportDeltas( | 5509 void ApplyViewportDeltas( |
5510 const gfx::Vector2d& scroll, | 5510 const gfx::Vector2d& scroll, |
5511 float scale_delta, | 5511 float scale_delta, |
5512 float top_controls_delta) override { | 5512 float top_controls_delta) override { |
5513 EXPECT_EQ(info_.page_scale_delta, scale_delta); | 5513 EXPECT_EQ(info_.page_scale_delta, scale_delta); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5903 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } | 5903 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
5904 | 5904 |
5905 FakeContentLayerClient client_; | 5905 FakeContentLayerClient client_; |
5906 int step_; | 5906 int step_; |
5907 int continuous_draws_; | 5907 int continuous_draws_; |
5908 base::WaitableEvent playback_allowed_event_; | 5908 base::WaitableEvent playback_allowed_event_; |
5909 }; | 5909 }; |
5910 | 5910 |
5911 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5911 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
5912 | 5912 |
5913 class LayerTreeHostTestOneActivatePerManageTiles : public LayerTreeHostTest { | 5913 class LayerTreeHostTestOneActivatePerPrepareTiles : public LayerTreeHostTest { |
5914 public: | 5914 public: |
5915 LayerTreeHostTestOneActivatePerManageTiles() | 5915 LayerTreeHostTestOneActivatePerPrepareTiles() |
5916 : notify_ready_to_activate_count_(0u), scheduled_manage_tiles_count_(0) {} | 5916 : notify_ready_to_activate_count_(0u), |
| 5917 scheduled_prepare_tiles_count_(0) {} |
5917 | 5918 |
5918 void SetupTree() override { | 5919 void SetupTree() override { |
5919 client_.set_fill_with_nonsolid_color(true); | 5920 client_.set_fill_with_nonsolid_color(true); |
5920 scoped_refptr<FakePictureLayer> root_layer = | 5921 scoped_refptr<FakePictureLayer> root_layer = |
5921 FakePictureLayer::Create(&client_); | 5922 FakePictureLayer::Create(&client_); |
5922 root_layer->SetBounds(gfx::Size(1500, 1500)); | 5923 root_layer->SetBounds(gfx::Size(1500, 1500)); |
5923 root_layer->SetIsDrawable(true); | 5924 root_layer->SetIsDrawable(true); |
5924 | 5925 |
5925 layer_tree_host()->SetRootLayer(root_layer); | 5926 layer_tree_host()->SetRootLayer(root_layer); |
5926 LayerTreeHostTest::SetupTree(); | 5927 LayerTreeHostTest::SetupTree(); |
5927 } | 5928 } |
5928 | 5929 |
5929 void BeginTest() override { | 5930 void BeginTest() override { |
5930 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); | 5931 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); |
5931 PostSetNeedsCommitToMainThread(); | 5932 PostSetNeedsCommitToMainThread(); |
5932 } | 5933 } |
5933 | 5934 |
5934 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, | 5935 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
5935 bool success) override { | 5936 bool success) override { |
5936 ASSERT_TRUE(success); | 5937 ASSERT_TRUE(success); |
5937 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); | 5938 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); |
5938 } | 5939 } |
5939 | 5940 |
5940 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { | 5941 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
5941 ++notify_ready_to_activate_count_; | 5942 ++notify_ready_to_activate_count_; |
5942 EndTestAfterDelayMs(100); | 5943 EndTestAfterDelayMs(100); |
5943 } | 5944 } |
5944 | 5945 |
5945 void ScheduledActionManageTiles() override { | 5946 void ScheduledActionPrepareTiles() override { |
5946 ++scheduled_manage_tiles_count_; | 5947 ++scheduled_prepare_tiles_count_; |
5947 } | 5948 } |
5948 | 5949 |
5949 void AfterTest() override { | 5950 void AfterTest() override { |
5950 // Expect at most a notification for each scheduled manage tiles, plus one | 5951 // Expect at most a notification for each scheduled prepare tiles, plus one |
5951 // for the initial commit (which doesn't go through scheduled actions). | 5952 // for the initial commit (which doesn't go through scheduled actions). |
5952 // The reason this is not an equality is because depending on timing, we | 5953 // The reason this is not an equality is because depending on timing, we |
5953 // might get a manage tiles but not yet get a notification that we're | 5954 // might get a prepare tiles but not yet get a notification that we're |
5954 // ready to activate. The intent of a test is to ensure that we don't | 5955 // ready to activate. The intent of a test is to ensure that we don't |
5955 // get more than one notification per manage tiles, so this is OK. | 5956 // get more than one notification per prepare tiles, so this is OK. |
5956 EXPECT_LE(notify_ready_to_activate_count_, | 5957 EXPECT_LE(notify_ready_to_activate_count_, |
5957 1u + scheduled_manage_tiles_count_); | 5958 1u + scheduled_prepare_tiles_count_); |
5958 } | 5959 } |
5959 | 5960 |
5960 protected: | 5961 protected: |
5961 FakeContentLayerClient client_; | 5962 FakeContentLayerClient client_; |
5962 size_t notify_ready_to_activate_count_; | 5963 size_t notify_ready_to_activate_count_; |
5963 size_t scheduled_manage_tiles_count_; | 5964 size_t scheduled_prepare_tiles_count_; |
5964 }; | 5965 }; |
5965 | 5966 |
5966 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerManageTiles); | 5967 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
5967 | 5968 |
5968 } // namespace cc | 5969 } // namespace cc |
OLD | NEW |