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 5761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5772 EndTest(); | 5772 EndTest(); |
5773 return draw_result; | 5773 return draw_result; |
5774 } | 5774 } |
5775 void AfterTest() override {} | 5775 void AfterTest() override {} |
5776 | 5776 |
5777 FakeContentLayerClient client_; | 5777 FakeContentLayerClient client_; |
5778 }; | 5778 }; |
5779 | 5779 |
5780 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); | 5780 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); |
5781 | 5781 |
| 5782 class GpuRasterizationRasterizesVisibleOnly : public LayerTreeHostTest { |
| 5783 protected: |
| 5784 GpuRasterizationRasterizesVisibleOnly() : viewport_size_(1024, 2048) {} |
| 5785 |
| 5786 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5787 settings->impl_side_painting = true; |
| 5788 settings->gpu_rasterization_enabled = true; |
| 5789 settings->gpu_rasterization_forced = true; |
| 5790 } |
| 5791 |
| 5792 void SetupTree() override { |
| 5793 client_.set_fill_with_nonsolid_color(true); |
| 5794 |
| 5795 scoped_ptr<FakePicturePile> pile(new FakePicturePile); |
| 5796 scoped_refptr<FakePictureLayer> root = |
| 5797 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
| 5798 root->SetBounds(gfx::Size(viewport_size_.width(), 10000)); |
| 5799 root->SetContentsOpaque(true); |
| 5800 |
| 5801 layer_tree_host()->SetRootLayer(root); |
| 5802 LayerTreeHostTest::SetupTree(); |
| 5803 layer_tree_host()->SetViewportSize(viewport_size_); |
| 5804 } |
| 5805 |
| 5806 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5807 |
| 5808 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 5809 LayerTreeHostImpl::FrameData* frame_data, |
| 5810 DrawResult draw_result) override { |
| 5811 EXPECT_EQ(4u, host_impl->resource_provider()->num_resources()); |
| 5812 |
| 5813 // Verify which tiles got resources using an eviction iterator, which has to |
| 5814 // return all tiles that have resources. |
| 5815 EvictionTilePriorityQueue eviction_queue; |
| 5816 host_impl->BuildEvictionQueue(&eviction_queue, |
| 5817 SAME_PRIORITY_FOR_BOTH_TREES); |
| 5818 int tile_count = 0; |
| 5819 for (; !eviction_queue.IsEmpty(); eviction_queue.Pop()) { |
| 5820 Tile* tile = eviction_queue.Top(); |
| 5821 // Ensure this tile is within the viewport. |
| 5822 EXPECT_TRUE(tile->content_rect().Intersects(gfx::Rect(viewport_size_))); |
| 5823 // Ensure that the tile is 1/4 of the viewport tall (plus padding). |
| 5824 EXPECT_EQ(tile->content_rect().height(), |
| 5825 (viewport_size_.height() / 4) + 2); |
| 5826 ++tile_count; |
| 5827 } |
| 5828 EXPECT_EQ(4, tile_count); |
| 5829 EndTest(); |
| 5830 return draw_result; |
| 5831 } |
| 5832 |
| 5833 void AfterTest() override {} |
| 5834 |
| 5835 private: |
| 5836 FakeContentLayerClient client_; |
| 5837 gfx::Size viewport_size_; |
| 5838 }; |
| 5839 |
| 5840 MULTI_THREAD_IMPL_TEST_F(GpuRasterizationRasterizesVisibleOnly); |
| 5841 |
5782 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 5842 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
5783 : public LayerTreeHostTest { | 5843 : public LayerTreeHostTest { |
5784 protected: | 5844 protected: |
5785 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 5845 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
5786 : playback_allowed_event_(true, true) {} | 5846 : playback_allowed_event_(true, true) {} |
5787 | 5847 |
5788 void InitializeSettings(LayerTreeSettings* settings) override { | 5848 void InitializeSettings(LayerTreeSettings* settings) override { |
5789 settings->impl_side_painting = true; | 5849 settings->impl_side_painting = true; |
5790 } | 5850 } |
5791 | 5851 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6087 | 6147 |
6088 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6148 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6089 | 6149 |
6090 private: | 6150 private: |
6091 bool did_commit_; | 6151 bool did_commit_; |
6092 }; | 6152 }; |
6093 | 6153 |
6094 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6154 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6095 | 6155 |
6096 } // namespace cc | 6156 } // namespace cc |
OLD | NEW |