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 6044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6055 EndTest(); | 6055 EndTest(); |
6056 return draw_result; | 6056 return draw_result; |
6057 } | 6057 } |
6058 void AfterTest() override {} | 6058 void AfterTest() override {} |
6059 | 6059 |
6060 FakeContentLayerClient client_; | 6060 FakeContentLayerClient client_; |
6061 }; | 6061 }; |
6062 | 6062 |
6063 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); | 6063 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); |
6064 | 6064 |
6065 class SynchronousGpuRasterizationRasterizesVisibleOnly | 6065 class GpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest { |
6066 : public LayerTreeHostTest { | |
6067 protected: | 6066 protected: |
6068 SynchronousGpuRasterizationRasterizesVisibleOnly() | 6067 GpuRasterizationRasterizesBorderTiles() : viewport_size_(1024, 2048) {} |
6069 : viewport_size_(1024, 2048) {} | |
6070 | 6068 |
6071 void InitializeSettings(LayerTreeSettings* settings) override { | 6069 void InitializeSettings(LayerTreeSettings* settings) override { |
6072 settings->impl_side_painting = true; | 6070 settings->impl_side_painting = true; |
6073 settings->gpu_rasterization_enabled = true; | 6071 settings->gpu_rasterization_enabled = true; |
6074 settings->gpu_rasterization_forced = true; | 6072 settings->gpu_rasterization_forced = true; |
6075 settings->threaded_gpu_rasterization_enabled = false; | |
6076 } | 6073 } |
6077 | 6074 |
6078 void SetupTree() override { | 6075 void SetupTree() override { |
6079 client_.set_fill_with_nonsolid_color(true); | |
6080 | |
6081 scoped_ptr<FakePicturePile> pile( | |
6082 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, | |
6083 ImplSidePaintingSettings().default_tile_grid_size)); | |
6084 scoped_refptr<FakePictureLayer> root = | |
6085 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | |
6086 root->SetBounds(gfx::Size(viewport_size_.width(), 10000)); | |
6087 root->SetContentsOpaque(true); | |
6088 | |
6089 layer_tree_host()->SetRootLayer(root); | |
6090 LayerTreeHostTest::SetupTree(); | |
6091 layer_tree_host()->SetViewportSize(viewport_size_); | |
6092 } | |
6093 | |
6094 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
6095 | |
6096 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
6097 LayerTreeHostImpl::FrameData* frame_data, | |
6098 DrawResult draw_result) override { | |
6099 EXPECT_EQ(4u, host_impl->resource_provider()->num_resources()); | |
6100 | |
6101 // Verify which tiles got resources using an eviction iterator, which has to | |
6102 // return all tiles that have resources. | |
6103 scoped_ptr<EvictionTilePriorityQueue> eviction_queue( | |
6104 host_impl->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); | |
6105 int tile_count = 0; | |
6106 for (; !eviction_queue->IsEmpty(); eviction_queue->Pop()) { | |
6107 Tile* tile = eviction_queue->Top(); | |
6108 // Ensure this tile is within the viewport. | |
6109 EXPECT_TRUE(tile->content_rect().Intersects(gfx::Rect(viewport_size_))); | |
6110 // Ensure that the tile is 1/4 of the viewport tall (plus padding). | |
6111 EXPECT_EQ(tile->content_rect().height(), | |
6112 (viewport_size_.height() / 4) + 2); | |
6113 ++tile_count; | |
6114 } | |
6115 EXPECT_EQ(4, tile_count); | |
6116 EndTest(); | |
6117 return draw_result; | |
6118 } | |
6119 | |
6120 void AfterTest() override {} | |
6121 | |
6122 private: | |
6123 FakeContentLayerClient client_; | |
6124 gfx::Size viewport_size_; | |
6125 }; | |
6126 | |
6127 MULTI_THREAD_IMPL_TEST_F(SynchronousGpuRasterizationRasterizesVisibleOnly); | |
6128 | |
6129 class ThreadedGpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest { | |
6130 protected: | |
6131 ThreadedGpuRasterizationRasterizesBorderTiles() | |
6132 : viewport_size_(1024, 2048) {} | |
6133 | |
6134 void InitializeSettings(LayerTreeSettings* settings) override { | |
6135 settings->impl_side_painting = true; | |
6136 settings->gpu_rasterization_enabled = true; | |
6137 settings->gpu_rasterization_forced = true; | |
6138 settings->threaded_gpu_rasterization_enabled = true; | |
6139 } | |
6140 | |
6141 void SetupTree() override { | |
6142 client_.set_fill_with_nonsolid_color(true); | 6076 client_.set_fill_with_nonsolid_color(true); |
6143 | 6077 |
6144 scoped_ptr<FakePicturePile> pile( | 6078 scoped_ptr<FakePicturePile> pile( |
6145 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, | 6079 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
6146 ImplSidePaintingSettings().default_tile_grid_size)); | 6080 ImplSidePaintingSettings().default_tile_grid_size)); |
6147 scoped_refptr<FakePictureLayer> root = | 6081 scoped_refptr<FakePictureLayer> root = |
6148 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 6082 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
6149 root->SetBounds(gfx::Size(10000, 10000)); | 6083 root->SetBounds(gfx::Size(10000, 10000)); |
6150 root->SetContentsOpaque(true); | 6084 root->SetContentsOpaque(true); |
6151 | 6085 |
(...skipping 12 matching lines...) Expand all Loading... |
6164 return draw_result; | 6098 return draw_result; |
6165 } | 6099 } |
6166 | 6100 |
6167 void AfterTest() override {} | 6101 void AfterTest() override {} |
6168 | 6102 |
6169 private: | 6103 private: |
6170 FakeContentLayerClient client_; | 6104 FakeContentLayerClient client_; |
6171 gfx::Size viewport_size_; | 6105 gfx::Size viewport_size_; |
6172 }; | 6106 }; |
6173 | 6107 |
6174 MULTI_THREAD_IMPL_TEST_F(ThreadedGpuRasterizationRasterizesBorderTiles); | 6108 MULTI_THREAD_IMPL_TEST_F(GpuRasterizationRasterizesBorderTiles); |
6175 | 6109 |
6176 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 6110 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
6177 : public LayerTreeHostTest { | 6111 : public LayerTreeHostTest { |
6178 protected: | 6112 protected: |
6179 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 6113 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
6180 : playback_allowed_event_(true, true) {} | 6114 : playback_allowed_event_(true, true) {} |
6181 | 6115 |
6182 void InitializeSettings(LayerTreeSettings* settings) override { | 6116 void InitializeSettings(LayerTreeSettings* settings) override { |
6183 settings->impl_side_painting = true; | 6117 settings->impl_side_painting = true; |
6184 } | 6118 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6629 | 6563 |
6630 void AfterTest() override {} | 6564 void AfterTest() override {} |
6631 | 6565 |
6632 private: | 6566 private: |
6633 scoped_refptr<Layer> child_; | 6567 scoped_refptr<Layer> child_; |
6634 }; | 6568 }; |
6635 | 6569 |
6636 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); | 6570 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
6637 | 6571 |
6638 } // namespace cc | 6572 } // namespace cc |
OLD | NEW |