| 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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
| 6 #include "cc/test/fake_picture_layer_tiling_client.h" | 6 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 7 #include "cc/test/fake_tile_manager.h" | |
| 8 #include "cc/test/fake_tile_manager_client.h" | |
| 9 | 7 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/perf/perf_test.h" | 9 #include "testing/perf/perf_test.h" |
| 12 | 10 |
| 13 namespace cc { | 11 namespace cc { |
| 14 | 12 |
| 15 namespace { | 13 namespace { |
| 16 | 14 |
| 17 static const int kTimeLimitMillis = 2000; | 15 static const int kTimeLimitMillis = 2000; |
| 18 static const int kWarmupRuns = 5; | 16 static const int kWarmupRuns = 5; |
| 19 static const int kTimeCheckInterval = 10; | 17 static const int kTimeCheckInterval = 10; |
| 20 | 18 |
| 21 class PictureLayerTilingPerfTest : public testing::Test { | 19 class PictureLayerTilingPerfTest : public testing::Test { |
| 22 public: | 20 public: |
| 23 PictureLayerTilingPerfTest() : num_runs_(0) { | 21 PictureLayerTilingPerfTest() : num_runs_(0) {} |
| 24 tile_manager_ = make_scoped_ptr(new FakeTileManager(&tile_manager_client_)); | |
| 25 picture_layer_tiling_client_ = | |
| 26 make_scoped_ptr(new FakePictureLayerTilingClient(tile_manager_.get())); | |
| 27 } | |
| 28 | 22 |
| 29 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() OVERRIDE { |
| 30 picture_layer_tiling_client_->SetTileSize(gfx::Size(256, 256)); | 24 picture_layer_tiling_client_.SetTileSize(gfx::Size(256, 256)); |
| 31 picture_layer_tiling_ = PictureLayerTiling::Create( | 25 picture_layer_tiling_ = PictureLayerTiling::Create( |
| 32 1, gfx::Size(256 * 50, 256 * 50), picture_layer_tiling_client_.get()); | 26 1, gfx::Size(256 * 50, 256 * 50), &picture_layer_tiling_client_); |
| 33 picture_layer_tiling_->CreateTilesForTesting(PENDING_TREE); | 27 picture_layer_tiling_->CreateAllTilesForTesting(); |
| 34 } | 28 } |
| 35 | 29 |
| 36 virtual void TearDown() OVERRIDE { | 30 virtual void TearDown() OVERRIDE { |
| 37 picture_layer_tiling_.reset(NULL); | 31 picture_layer_tiling_.reset(NULL); |
| 38 } | 32 } |
| 39 | 33 |
| 40 void EndTest() { | 34 void EndTest() { |
| 41 elapsed_ = base::TimeTicks::HighResNow() - start_time_; | 35 elapsed_ = base::TimeTicks::HighResNow() - start_time_; |
| 42 } | 36 } |
| 43 | 37 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 | 63 |
| 70 void RunUpdateTilePrioritiesStationaryTest( | 64 void RunUpdateTilePrioritiesStationaryTest( |
| 71 const std::string& test_name, | 65 const std::string& test_name, |
| 72 const gfx::Transform& transform) { | 66 const gfx::Transform& transform) { |
| 73 start_time_ = base::TimeTicks(); | 67 start_time_ = base::TimeTicks(); |
| 74 num_runs_ = 0; | 68 num_runs_ = 0; |
| 75 | 69 |
| 76 gfx::Size layer_bounds(50 * 256, 50 * 256); | 70 gfx::Size layer_bounds(50 * 256, 50 * 256); |
| 77 do { | 71 do { |
| 78 picture_layer_tiling_->UpdateTilePriorities( | 72 picture_layer_tiling_->UpdateTilePriorities( |
| 79 PENDING_TREE, | 73 ACTIVE_TREE, |
| 80 layer_bounds, | 74 layer_bounds, |
| 81 gfx::Rect(layer_bounds), | 75 gfx::Rect(layer_bounds), |
| 82 gfx::Rect(layer_bounds), | 76 gfx::Rect(layer_bounds), |
| 83 layer_bounds, | 77 layer_bounds, |
| 84 layer_bounds, | 78 layer_bounds, |
| 85 1.f, | 79 1.f, |
| 86 1.f, | 80 1.f, |
| 87 transform, | 81 transform, |
| 88 transform, | 82 transform, |
| 89 num_runs_ + 1, | 83 num_runs_ + 1, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 103 gfx::Size layer_bounds(50 * 256, 50 * 256); | 97 gfx::Size layer_bounds(50 * 256, 50 * 256); |
| 104 gfx::Size viewport_size(1024, 768); | 98 gfx::Size viewport_size(1024, 768); |
| 105 gfx::Rect viewport_rect(viewport_size); | 99 gfx::Rect viewport_rect(viewport_size); |
| 106 int xoffsets[] = {10, 0, -10, 0}; | 100 int xoffsets[] = {10, 0, -10, 0}; |
| 107 int yoffsets[] = {0, 10, 0, -10}; | 101 int yoffsets[] = {0, 10, 0, -10}; |
| 108 int offsetIndex = 0; | 102 int offsetIndex = 0; |
| 109 int offsetCount = 0; | 103 int offsetCount = 0; |
| 110 const int maxOffsetCount = 1000; | 104 const int maxOffsetCount = 1000; |
| 111 do { | 105 do { |
| 112 picture_layer_tiling_->UpdateTilePriorities( | 106 picture_layer_tiling_->UpdateTilePriorities( |
| 113 PENDING_TREE, | 107 ACTIVE_TREE, |
| 114 viewport_size, | 108 viewport_size, |
| 115 viewport_rect, | 109 viewport_rect, |
| 116 gfx::Rect(layer_bounds), | 110 gfx::Rect(layer_bounds), |
| 117 layer_bounds, | 111 layer_bounds, |
| 118 layer_bounds, | 112 layer_bounds, |
| 119 1.f, | 113 1.f, |
| 120 1.f, | 114 1.f, |
| 121 transform, | 115 transform, |
| 122 transform, | 116 transform, |
| 123 num_runs_ + 1, | 117 num_runs_ + 1, |
| 124 250); | 118 250); |
| 125 | 119 |
| 126 viewport_rect = gfx::Rect( | 120 viewport_rect = gfx::Rect( |
| 127 viewport_rect.x() + xoffsets[offsetIndex], | 121 viewport_rect.x() + xoffsets[offsetIndex], |
| 128 viewport_rect.y() + yoffsets[offsetIndex], | 122 viewport_rect.y() + yoffsets[offsetIndex], |
| 129 viewport_rect.width(), | 123 viewport_rect.width(), |
| 130 viewport_rect.height()); | 124 viewport_rect.height()); |
| 131 | 125 |
| 132 if (++offsetCount > maxOffsetCount) { | 126 if (++offsetCount > maxOffsetCount) { |
| 133 offsetCount = 0; | 127 offsetCount = 0; |
| 134 offsetIndex = (offsetIndex + 1) % 4; | 128 offsetIndex = (offsetIndex + 1) % 4; |
| 135 } | 129 } |
| 136 } while (DidRun()); | 130 } while (DidRun()); |
| 137 | 131 |
| 138 perf_test::PrintResult("update_tile_priorities_scrolling", "", test_name, | 132 perf_test::PrintResult("update_tile_priorities_scrolling", "", test_name, |
| 139 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); | 133 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); |
| 140 } | 134 } |
| 141 | 135 |
| 142 private: | 136 private: |
| 143 FakeTileManagerClient tile_manager_client_; | 137 FakePictureLayerTilingClient picture_layer_tiling_client_; |
| 144 scoped_ptr<FakeTileManager> tile_manager_; | |
| 145 scoped_ptr<FakePictureLayerTilingClient> picture_layer_tiling_client_; | |
| 146 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; | 138 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; |
| 147 | 139 |
| 148 base::TimeTicks start_time_; | 140 base::TimeTicks start_time_; |
| 149 base::TimeDelta elapsed_; | 141 base::TimeDelta elapsed_; |
| 150 int num_runs_; | 142 int num_runs_; |
| 151 }; | 143 }; |
| 152 | 144 |
| 153 TEST_F(PictureLayerTilingPerfTest, Invalidate) { | 145 TEST_F(PictureLayerTilingPerfTest, Invalidate) { |
| 154 Region one_tile(gfx::Rect(256, 256)); | 146 Region one_tile(gfx::Rect(256, 256)); |
| 155 RunInvalidateTest("1x1", one_tile); | 147 RunInvalidateTest("1x1", one_tile); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 176 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 168 RunUpdateTilePrioritiesScrollingTest("rotation", transform); |
| 177 | 169 |
| 178 transform.ApplyPerspectiveDepth(10); | 170 transform.ApplyPerspectiveDepth(10); |
| 179 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 171 RunUpdateTilePrioritiesStationaryTest("perspective", transform); |
| 180 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 172 RunUpdateTilePrioritiesScrollingTest("perspective", transform); |
| 181 } | 173 } |
| 182 | 174 |
| 183 } // namespace | 175 } // namespace |
| 184 | 176 |
| 185 } // namespace cc | 177 } // namespace cc |
| OLD | NEW |