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 6060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 EndTest(); | 6071 EndTest(); |
6072 return draw_result; | 6072 return draw_result; |
6073 } | 6073 } |
6074 void AfterTest() override {} | 6074 void AfterTest() override {} |
6075 | 6075 |
6076 FakeContentLayerClient client_; | 6076 FakeContentLayerClient client_; |
6077 }; | 6077 }; |
6078 | 6078 |
6079 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); | 6079 MULTI_THREAD_IMPL_TEST_F(RasterizeWithGpuRasterizationCreatesResources); |
6080 | 6080 |
6081 class SynchronousGpuRasterizationRasterizesVisibleOnly | 6081 class GpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest { |
6082 : public LayerTreeHostTest { | |
6083 protected: | 6082 protected: |
6084 SynchronousGpuRasterizationRasterizesVisibleOnly() | 6083 GpuRasterizationRasterizesBorderTiles() : viewport_size_(1024, 2048) {} |
6085 : viewport_size_(1024, 2048) {} | |
6086 | 6084 |
6087 void InitializeSettings(LayerTreeSettings* settings) override { | 6085 void InitializeSettings(LayerTreeSettings* settings) override { |
6088 settings->impl_side_painting = true; | 6086 settings->impl_side_painting = true; |
6089 settings->gpu_rasterization_enabled = true; | 6087 settings->gpu_rasterization_enabled = true; |
6090 settings->gpu_rasterization_forced = true; | 6088 settings->gpu_rasterization_forced = true; |
6091 settings->threaded_gpu_rasterization_enabled = false; | |
6092 } | 6089 } |
6093 | 6090 |
6094 void SetupTree() override { | 6091 void SetupTree() override { |
6095 client_.set_fill_with_nonsolid_color(true); | |
6096 | |
6097 scoped_ptr<FakePicturePile> pile( | |
6098 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, | |
6099 ImplSidePaintingSettings().default_tile_grid_size)); | |
6100 scoped_refptr<FakePictureLayer> root = | |
6101 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | |
6102 root->SetBounds(gfx::Size(viewport_size_.width(), 10000)); | |
6103 root->SetContentsOpaque(true); | |
6104 | |
6105 layer_tree_host()->SetRootLayer(root); | |
6106 LayerTreeHostTest::SetupTree(); | |
6107 layer_tree_host()->SetViewportSize(viewport_size_); | |
6108 } | |
6109 | |
6110 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
6111 | |
6112 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
6113 LayerTreeHostImpl::FrameData* frame_data, | |
6114 DrawResult draw_result) override { | |
6115 EXPECT_EQ(4u, host_impl->resource_provider()->num_resources()); | |
6116 | |
6117 // Verify which tiles got resources using an eviction iterator, which has to | |
6118 // return all tiles that have resources. | |
6119 scoped_ptr<EvictionTilePriorityQueue> eviction_queue( | |
6120 host_impl->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); | |
6121 int tile_count = 0; | |
6122 for (; !eviction_queue->IsEmpty(); eviction_queue->Pop()) { | |
6123 Tile* tile = eviction_queue->Top(); | |
6124 // Ensure this tile is within the viewport. | |
6125 EXPECT_TRUE(tile->content_rect().Intersects(gfx::Rect(viewport_size_))); | |
6126 // Ensure that the tile is 1/4 of the viewport tall (plus padding). | |
6127 EXPECT_EQ(tile->content_rect().height(), | |
6128 (viewport_size_.height() / 4) + 2); | |
6129 ++tile_count; | |
6130 } | |
6131 EXPECT_EQ(4, tile_count); | |
6132 EndTest(); | |
6133 return draw_result; | |
6134 } | |
6135 | |
6136 void AfterTest() override {} | |
6137 | |
6138 private: | |
6139 FakeContentLayerClient client_; | |
6140 gfx::Size viewport_size_; | |
6141 }; | |
6142 | |
6143 MULTI_THREAD_IMPL_TEST_F(SynchronousGpuRasterizationRasterizesVisibleOnly); | |
6144 | |
6145 class ThreadedGpuRasterizationRasterizesBorderTiles : public LayerTreeHostTest { | |
6146 protected: | |
6147 ThreadedGpuRasterizationRasterizesBorderTiles() | |
6148 : viewport_size_(1024, 2048) {} | |
6149 | |
6150 void InitializeSettings(LayerTreeSettings* settings) override { | |
6151 settings->impl_side_painting = true; | |
6152 settings->gpu_rasterization_enabled = true; | |
6153 settings->gpu_rasterization_forced = true; | |
6154 settings->threaded_gpu_rasterization_enabled = true; | |
6155 } | |
6156 | |
6157 void SetupTree() override { | |
6158 client_.set_fill_with_nonsolid_color(true); | 6092 client_.set_fill_with_nonsolid_color(true); |
6159 | 6093 |
6160 scoped_ptr<FakePicturePile> pile( | 6094 scoped_ptr<FakePicturePile> pile( |
6161 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, | 6095 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
6162 ImplSidePaintingSettings().default_tile_grid_size)); | 6096 ImplSidePaintingSettings().default_tile_grid_size)); |
6163 scoped_refptr<FakePictureLayer> root = | 6097 scoped_refptr<FakePictureLayer> root = |
6164 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 6098 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
6165 root->SetBounds(gfx::Size(10000, 10000)); | 6099 root->SetBounds(gfx::Size(10000, 10000)); |
6166 root->SetContentsOpaque(true); | 6100 root->SetContentsOpaque(true); |
6167 | 6101 |
(...skipping 12 matching lines...) Expand all Loading... |
6180 return draw_result; | 6114 return draw_result; |
6181 } | 6115 } |
6182 | 6116 |
6183 void AfterTest() override {} | 6117 void AfterTest() override {} |
6184 | 6118 |
6185 private: | 6119 private: |
6186 FakeContentLayerClient client_; | 6120 FakeContentLayerClient client_; |
6187 gfx::Size viewport_size_; | 6121 gfx::Size viewport_size_; |
6188 }; | 6122 }; |
6189 | 6123 |
6190 MULTI_THREAD_IMPL_TEST_F(ThreadedGpuRasterizationRasterizesBorderTiles); | 6124 MULTI_THREAD_IMPL_TEST_F(GpuRasterizationRasterizesBorderTiles); |
6191 | 6125 |
6192 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles | 6126 class LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles |
6193 : public LayerTreeHostTest { | 6127 : public LayerTreeHostTest { |
6194 protected: | 6128 protected: |
6195 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() | 6129 LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles() |
6196 : playback_allowed_event_(true, true) {} | 6130 : playback_allowed_event_(true, true) {} |
6197 | 6131 |
6198 void InitializeSettings(LayerTreeSettings* settings) override { | 6132 void InitializeSettings(LayerTreeSettings* settings) override { |
6199 settings->impl_side_painting = true; | 6133 settings->impl_side_painting = true; |
6200 } | 6134 } |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6664 | 6598 |
6665 void AfterTest() override {} | 6599 void AfterTest() override {} |
6666 | 6600 |
6667 private: | 6601 private: |
6668 scoped_refptr<Layer> child_; | 6602 scoped_refptr<Layer> child_; |
6669 }; | 6603 }; |
6670 | 6604 |
6671 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); | 6605 SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
6672 | 6606 |
6673 } // namespace cc | 6607 } // namespace cc |
OLD | NEW |