| 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 "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "cc/resources/tile.h" | 6 #include "cc/resources/tile.h" |
| 7 #include "cc/resources/tile_priority.h" | 7 #include "cc/resources/tile_priority.h" |
| 8 #include "cc/test/fake_output_surface.h" | 8 #include "cc/test/fake_output_surface.h" |
| 9 #include "cc/test/fake_output_surface_client.h" | 9 #include "cc/test/fake_output_surface_client.h" |
| 10 #include "cc/test/fake_picture_pile_impl.h" | 10 #include "cc/test/fake_picture_pile_impl.h" |
| 11 #include "cc/test/fake_tile_manager.h" | 11 #include "cc/test/fake_tile_manager.h" |
| 12 #include "cc/test/fake_tile_manager_client.h" | 12 #include "cc/test/fake_tile_manager_client.h" |
| 13 #include "cc/test/lap_timer.h" | 13 #include "cc/test/lap_timer.h" |
| 14 #include "cc/test/test_shared_bitmap_manager.h" |
| 14 #include "cc/test/test_tile_priorities.h" | 15 #include "cc/test/test_tile_priorities.h" |
| 15 | 16 |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "testing/perf/perf_test.h" | 18 #include "testing/perf/perf_test.h" |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 static const int kTimeLimitMillis = 2000; | 24 static const int kTimeLimitMillis = 2000; |
| 24 static const int kWarmupRuns = 5; | 25 static const int kWarmupRuns = 5; |
| 25 static const int kTimeCheckInterval = 10; | 26 static const int kTimeCheckInterval = 10; |
| 26 | 27 |
| 27 class TileManagerPerfTest : public testing::Test { | 28 class TileManagerPerfTest : public testing::Test { |
| 28 public: | 29 public: |
| 29 typedef std::vector<std::pair<scoped_refptr<Tile>, ManagedTileBin> > | 30 typedef std::vector<std::pair<scoped_refptr<Tile>, ManagedTileBin> > |
| 30 TileBinVector; | 31 TileBinVector; |
| 31 | 32 |
| 32 TileManagerPerfTest() | 33 TileManagerPerfTest() |
| 33 : timer_(kWarmupRuns, | 34 : timer_(kWarmupRuns, |
| 34 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 35 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 35 kTimeCheckInterval) {} | 36 kTimeCheckInterval) {} |
| 36 | 37 |
| 37 // Overridden from testing::Test: | 38 // Overridden from testing::Test: |
| 38 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() OVERRIDE { |
| 39 output_surface_ = FakeOutputSurface::Create3d(); | 40 output_surface_ = FakeOutputSurface::Create3d(); |
| 40 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 41 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 41 | 42 |
| 42 resource_provider_ = | 43 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 43 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1); | 44 resource_provider_ = ResourceProvider::Create( |
| 45 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1); |
| 44 size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice. | 46 size_t raster_task_limit_bytes = 32 * 1024 * 1024; // 16-64MB in practice. |
| 45 tile_manager_ = | 47 tile_manager_ = |
| 46 make_scoped_ptr(new FakeTileManager(&tile_manager_client_, | 48 make_scoped_ptr(new FakeTileManager(&tile_manager_client_, |
| 47 resource_provider_.get(), | 49 resource_provider_.get(), |
| 48 raster_task_limit_bytes)); | 50 raster_task_limit_bytes)); |
| 49 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); | 51 picture_pile_ = FakePicturePileImpl::CreateInfiniteFilledPile(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 GlobalStateThatImpactsTilePriority GlobalStateForTest() { | 54 GlobalStateThatImpactsTilePriority GlobalStateForTest() { |
| 53 GlobalStateThatImpactsTilePriority state; | 55 GlobalStateThatImpactsTilePriority state; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 165 "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 164 } | 166 } |
| 165 | 167 |
| 166 private: | 168 private: |
| 167 FakeTileManagerClient tile_manager_client_; | 169 FakeTileManagerClient tile_manager_client_; |
| 168 LayerTreeSettings settings_; | 170 LayerTreeSettings settings_; |
| 169 scoped_ptr<FakeTileManager> tile_manager_; | 171 scoped_ptr<FakeTileManager> tile_manager_; |
| 170 scoped_refptr<FakePicturePileImpl> picture_pile_; | 172 scoped_refptr<FakePicturePileImpl> picture_pile_; |
| 171 FakeOutputSurfaceClient output_surface_client_; | 173 FakeOutputSurfaceClient output_surface_client_; |
| 172 scoped_ptr<FakeOutputSurface> output_surface_; | 174 scoped_ptr<FakeOutputSurface> output_surface_; |
| 175 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 173 scoped_ptr<ResourceProvider> resource_provider_; | 176 scoped_ptr<ResourceProvider> resource_provider_; |
| 174 LapTimer timer_; | 177 LapTimer timer_; |
| 175 }; | 178 }; |
| 176 | 179 |
| 177 TEST_F(TileManagerPerfTest, ManageTiles) { | 180 TEST_F(TileManagerPerfTest, ManageTiles) { |
| 178 RunManageTilesTest("100_0", 100, 0); | 181 RunManageTilesTest("100_0", 100, 0); |
| 179 RunManageTilesTest("1000_0", 1000, 0); | 182 RunManageTilesTest("1000_0", 1000, 0); |
| 180 RunManageTilesTest("10000_0", 10000, 0); | 183 RunManageTilesTest("10000_0", 10000, 0); |
| 181 RunManageTilesTest("100_10", 100, 10); | 184 RunManageTilesTest("100_10", 100, 10); |
| 182 RunManageTilesTest("1000_10", 1000, 10); | 185 RunManageTilesTest("1000_10", 1000, 10); |
| 183 RunManageTilesTest("10000_10", 10000, 10); | 186 RunManageTilesTest("10000_10", 10000, 10); |
| 184 RunManageTilesTest("100_100", 100, 100); | 187 RunManageTilesTest("100_100", 100, 100); |
| 185 RunManageTilesTest("1000_100", 1000, 100); | 188 RunManageTilesTest("1000_100", 1000, 100); |
| 186 RunManageTilesTest("10000_100", 10000, 100); | 189 RunManageTilesTest("10000_100", 10000, 100); |
| 187 } | 190 } |
| 188 | 191 |
| 189 } // namespace | 192 } // namespace |
| 190 | 193 |
| 191 } // namespace cc | 194 } // namespace cc |
| OLD | NEW |