Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/debug/lap_timer.h" | 5 #include "cc/debug/lap_timer.h" |
| 6 #include "cc/resources/picture_layer_tiling.h" | 6 #include "cc/resources/picture_layer_tiling.h" |
| 7 #include "cc/resources/resource_provider.h" | 7 #include "cc/resources/resource_provider.h" |
| 8 #include "cc/resources/scoped_resource.h" | 8 #include "cc/resources/scoped_resource.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| 11 #include "cc/test/fake_picture_layer_tiling_client.h" | 11 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 12 #include "cc/test/test_context_provider.h" | 12 #include "cc/test/test_context_provider.h" |
| 13 #include "cc/test/test_shared_bitmap_manager.h" | 13 #include "cc/test/test_shared_bitmap_manager.h" |
| 14 | 14 |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/perf/perf_test.h" | 16 #include "testing/perf/perf_test.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const int kTimeLimitMillis = 2000; | 22 static const int kTimeLimitMillis = 2000; |
| 23 static const int kWarmupRuns = 5; | 23 static const int kWarmupRuns = 5; |
| 24 static const int kTimeCheckInterval = 10; | 24 static const int kTimeCheckInterval = 10; |
| 25 | 25 |
| 26 const size_t kMaxTilesForInterestArea = 250; | |
|
danakj
2014/12/02 21:58:37
Maybe these should be defaults in LayerTreeSetting
| |
| 27 const float kSkewportTargetTimeInSeconds = 1.0f; | |
| 28 const int kSkewportExtrapolationLimitInContentPixels = 2000; | |
| 29 | |
| 26 class PictureLayerTilingPerfTest : public testing::Test { | 30 class PictureLayerTilingPerfTest : public testing::Test { |
| 27 public: | 31 public: |
| 28 PictureLayerTilingPerfTest() | 32 PictureLayerTilingPerfTest() |
| 29 : timer_(kWarmupRuns, | 33 : timer_(kWarmupRuns, |
| 30 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 34 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 31 kTimeCheckInterval), | 35 kTimeCheckInterval), |
| 32 context_provider_(TestContextProvider::Create()) { | 36 context_provider_(TestContextProvider::Create()) { |
| 33 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 37 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 34 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 38 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 35 | 39 |
| 36 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 40 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 37 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 41 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 38 shared_bitmap_manager_.get(), | 42 shared_bitmap_manager_.get(), |
| 39 NULL, | 43 NULL, |
| 40 NULL, | 44 NULL, |
| 41 0, | 45 0, |
| 42 false, | 46 false, |
| 43 1).Pass(); | 47 1).Pass(); |
| 44 } | 48 } |
| 45 | 49 |
| 46 void SetUp() override { | 50 void SetUp() override { |
| 47 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); | 51 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
| 48 picture_layer_tiling_client_.set_max_tiles_for_interest_area(250); | |
| 49 picture_layer_tiling_client_.set_tree(PENDING_TREE); | 52 picture_layer_tiling_client_.set_tree(PENDING_TREE); |
| 50 picture_layer_tiling_ = PictureLayerTiling::Create( | 53 picture_layer_tiling_ = PictureLayerTiling::Create( |
| 51 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); | 54 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_, |
| 55 kMaxTilesForInterestArea, kSkewportTargetTimeInSeconds, | |
| 56 kSkewportExtrapolationLimitInContentPixels); | |
| 52 picture_layer_tiling_->CreateAllTilesForTesting(); | 57 picture_layer_tiling_->CreateAllTilesForTesting(); |
| 53 } | 58 } |
| 54 | 59 |
| 55 void TearDown() override { picture_layer_tiling_.reset(NULL); } | 60 void TearDown() override { picture_layer_tiling_.reset(NULL); } |
| 56 | 61 |
| 57 void RunInvalidateTest(const std::string& test_name, const Region& region) { | 62 void RunInvalidateTest(const std::string& test_name, const Region& region) { |
| 58 timer_.Reset(); | 63 timer_.Reset(); |
| 59 do { | 64 do { |
| 60 picture_layer_tiling_->UpdateTilesToCurrentRasterSource( | 65 picture_layer_tiling_->UpdateTilesToCurrentRasterSource( |
| 61 picture_layer_tiling_client_.raster_source(), region, | 66 picture_layer_tiling_client_.raster_source(), region, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 "", | 124 "", |
| 120 test_name, | 125 test_name, |
| 121 timer_.LapsPerSecond(), | 126 timer_.LapsPerSecond(), |
| 122 "runs/s", | 127 "runs/s", |
| 123 true); | 128 true); |
| 124 } | 129 } |
| 125 | 130 |
| 126 void RunRasterIteratorConstructTest(const std::string& test_name, | 131 void RunRasterIteratorConstructTest(const std::string& test_name, |
| 127 const gfx::Rect& viewport) { | 132 const gfx::Rect& viewport) { |
| 128 gfx::Size bounds(viewport.size()); | 133 gfx::Size bounds(viewport.size()); |
| 129 picture_layer_tiling_ = | 134 picture_layer_tiling_ = PictureLayerTiling::Create( |
| 130 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 135 1, bounds, &picture_layer_tiling_client_, kMaxTilesForInterestArea, |
| 136 kSkewportTargetTimeInSeconds, | |
| 137 kSkewportExtrapolationLimitInContentPixels); | |
| 131 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 138 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 132 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 139 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 133 Occlusion()); | 140 Occlusion()); |
| 134 | 141 |
| 135 timer_.Reset(); | 142 timer_.Reset(); |
| 136 do { | 143 do { |
| 137 PictureLayerTiling::TilingRasterTileIterator it( | 144 PictureLayerTiling::TilingRasterTileIterator it( |
| 138 picture_layer_tiling_.get()); | 145 picture_layer_tiling_.get()); |
| 139 timer_.NextLap(); | 146 timer_.NextLap(); |
| 140 } while (!timer_.HasTimeLimitExpired()); | 147 } while (!timer_.HasTimeLimitExpired()); |
| 141 | 148 |
| 142 perf_test::PrintResult("tiling_raster_tile_iterator_construct", | 149 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
| 143 "", | 150 "", |
| 144 test_name, | 151 test_name, |
| 145 timer_.LapsPerSecond(), | 152 timer_.LapsPerSecond(), |
| 146 "runs/s", | 153 "runs/s", |
| 147 true); | 154 true); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, | 157 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
| 151 int num_tiles, | 158 int num_tiles, |
| 152 const gfx::Rect& viewport) { | 159 const gfx::Rect& viewport) { |
| 153 gfx::Size bounds(10000, 10000); | 160 gfx::Size bounds(10000, 10000); |
| 154 picture_layer_tiling_ = | 161 picture_layer_tiling_ = PictureLayerTiling::Create( |
| 155 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 162 1, bounds, &picture_layer_tiling_client_, kMaxTilesForInterestArea, |
| 163 kSkewportTargetTimeInSeconds, | |
| 164 kSkewportExtrapolationLimitInContentPixels); | |
| 156 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); | 165 picture_layer_tiling_client_.set_tree(ACTIVE_TREE); |
| 157 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 166 picture_layer_tiling_->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 158 Occlusion()); | 167 Occlusion()); |
| 159 | 168 |
| 160 timer_.Reset(); | 169 timer_.Reset(); |
| 161 do { | 170 do { |
| 162 int count = num_tiles; | 171 int count = num_tiles; |
| 163 PictureLayerTiling::TilingRasterTileIterator it( | 172 PictureLayerTiling::TilingRasterTileIterator it( |
| 164 picture_layer_tiling_.get()); | 173 picture_layer_tiling_.get()); |
| 165 while (count--) { | 174 while (count--) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 246 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 238 RunRasterIteratorConstructAndIterateTest( | 247 RunRasterIteratorConstructAndIterateTest( |
| 239 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 248 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 240 RunRasterIteratorConstructAndIterateTest( | 249 RunRasterIteratorConstructAndIterateTest( |
| 241 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 250 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| 242 } | 251 } |
| 243 | 252 |
| 244 } // namespace | 253 } // namespace |
| 245 | 254 |
| 246 } // namespace cc | 255 } // namespace cc |
| OLD | NEW |