| 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 | 7 |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/perf/perf_test.h" | 9 #include "testing/perf/perf_test.h" |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 perf_test::PrintResult("invalidation", "", test_name, | 61 perf_test::PrintResult("invalidation", "", test_name, |
| 62 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); | 62 num_runs_ / elapsed_.InSecondsF(), "runs/s", true); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void RunUpdateTilePrioritiesStationaryTest(const std::string& test_name, | 65 void RunUpdateTilePrioritiesStationaryTest(const std::string& test_name, |
| 66 const gfx::Transform& transform) { | 66 const gfx::Transform& transform) { |
| 67 start_time_ = base::TimeTicks(); | 67 start_time_ = base::TimeTicks(); |
| 68 num_runs_ = 0; | 68 num_runs_ = 0; |
| 69 | 69 |
| 70 gfx::Size layer_bounds(50 * 256, 50 * 256); | |
| 71 gfx::Rect viewport_rect(0, 0, 1024, 768); | 70 gfx::Rect viewport_rect(0, 0, 1024, 768); |
| 72 do { | 71 do { |
| 73 picture_layer_tiling_->UpdateTilePriorities( | 72 picture_layer_tiling_->UpdateTilePriorities( |
| 74 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); | 73 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); |
| 75 } while (DidRun()); | 74 } while (DidRun()); |
| 76 | 75 |
| 77 perf_test::PrintResult("update_tile_priorities_stationary", | 76 perf_test::PrintResult("update_tile_priorities_stationary", |
| 78 "", | 77 "", |
| 79 test_name, | 78 test_name, |
| 80 num_runs_ / elapsed_.InSecondsF(), | 79 num_runs_ / elapsed_.InSecondsF(), |
| 81 "runs/s", | 80 "runs/s", |
| 82 true); | 81 true); |
| 83 } | 82 } |
| 84 | 83 |
| 85 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, | 84 void RunUpdateTilePrioritiesScrollingTest(const std::string& test_name, |
| 86 const gfx::Transform& transform) { | 85 const gfx::Transform& transform) { |
| 87 start_time_ = base::TimeTicks(); | 86 start_time_ = base::TimeTicks(); |
| 88 num_runs_ = 0; | 87 num_runs_ = 0; |
| 89 | 88 |
| 90 gfx::Size layer_bounds(50 * 256, 50 * 256); | |
| 91 gfx::Size viewport_size(1024, 768); | 89 gfx::Size viewport_size(1024, 768); |
| 92 gfx::Rect viewport_rect(viewport_size); | 90 gfx::Rect viewport_rect(viewport_size); |
| 93 int xoffsets[] = {10, 0, -10, 0}; | 91 int xoffsets[] = {10, 0, -10, 0}; |
| 94 int yoffsets[] = {0, 10, 0, -10}; | 92 int yoffsets[] = {0, 10, 0, -10}; |
| 95 int offsetIndex = 0; | 93 int offsetIndex = 0; |
| 96 int offsetCount = 0; | 94 int offsetCount = 0; |
| 97 const int maxOffsetCount = 1000; | 95 const int maxOffsetCount = 1000; |
| 98 do { | 96 do { |
| 99 picture_layer_tiling_->UpdateTilePriorities( | 97 picture_layer_tiling_->UpdateTilePriorities( |
| 100 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); | 98 ACTIVE_TREE, viewport_rect, 1.f, num_runs_ + 1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 } while (DidRun()); | 109 } while (DidRun()); |
| 112 | 110 |
| 113 perf_test::PrintResult("update_tile_priorities_scrolling", | 111 perf_test::PrintResult("update_tile_priorities_scrolling", |
| 114 "", | 112 "", |
| 115 test_name, | 113 test_name, |
| 116 num_runs_ / elapsed_.InSecondsF(), | 114 num_runs_ / elapsed_.InSecondsF(), |
| 117 "runs/s", | 115 "runs/s", |
| 118 true); | 116 true); |
| 119 } | 117 } |
| 120 | 118 |
| 119 void RunTilingRasterTileIteratorTest(const std::string& test_name, |
| 120 const gfx::Size& bounds, |
| 121 const gfx::Rect& first_viewport, |
| 122 const gfx::Rect& second_viewport) { |
| 123 start_time_ = base::TimeTicks(); |
| 124 num_runs_ = 0; |
| 125 |
| 126 picture_layer_tiling_ = |
| 127 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 128 gfx::Rect viewports[2] = {first_viewport, second_viewport}; |
| 129 |
| 130 do { |
| 131 picture_layer_tiling_->UpdateTilePriorities( |
| 132 ACTIVE_TREE, viewports[num_runs_ % 2], 1.f, num_runs_ + 1); |
| 133 for (PictureLayerTiling::TilingRasterTileIterator it( |
| 134 picture_layer_tiling_.get()); |
| 135 it; |
| 136 ++it) |
| 137 continue; |
| 138 } while (DidRun()); |
| 139 |
| 140 perf_test::PrintResult("tiling_raster_tile_iterator", |
| 141 "", |
| 142 test_name, |
| 143 num_runs_ / elapsed_.InSecondsF(), |
| 144 "runs/s", |
| 145 true); |
| 146 } |
| 147 |
| 121 private: | 148 private: |
| 122 FakePictureLayerTilingClient picture_layer_tiling_client_; | 149 FakePictureLayerTilingClient picture_layer_tiling_client_; |
| 123 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; | 150 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; |
| 124 | 151 |
| 125 base::TimeTicks start_time_; | 152 base::TimeTicks start_time_; |
| 126 base::TimeDelta elapsed_; | 153 base::TimeDelta elapsed_; |
| 127 int num_runs_; | 154 int num_runs_; |
| 128 }; | 155 }; |
| 129 | 156 |
| 130 TEST_F(PictureLayerTilingPerfTest, Invalidate) { | 157 TEST_F(PictureLayerTilingPerfTest, Invalidate) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 | 178 |
| 152 transform.Rotate(10); | 179 transform.Rotate(10); |
| 153 RunUpdateTilePrioritiesStationaryTest("rotation", transform); | 180 RunUpdateTilePrioritiesStationaryTest("rotation", transform); |
| 154 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 181 RunUpdateTilePrioritiesScrollingTest("rotation", transform); |
| 155 | 182 |
| 156 transform.ApplyPerspectiveDepth(10); | 183 transform.ApplyPerspectiveDepth(10); |
| 157 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 184 RunUpdateTilePrioritiesStationaryTest("perspective", transform); |
| 158 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 185 RunUpdateTilePrioritiesScrollingTest("perspective", transform); |
| 159 } | 186 } |
| 160 | 187 |
| 188 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIterator) { |
| 189 RunTilingRasterTileIteratorTest("1k_bounds_100_vp_stationary", |
| 190 gfx::Size(1000, 1000), |
| 191 gfx::Rect(0, 0, 100, 100), |
| 192 gfx::Rect(0, 0, 100, 100)); |
| 193 RunTilingRasterTileIteratorTest("1k_bounds_100_vp_moving", |
| 194 gfx::Size(1000, 1000), |
| 195 gfx::Rect(0, 0, 100, 100), |
| 196 gfx::Rect(0, 100, 100, 100)); |
| 197 RunTilingRasterTileIteratorTest("1k_bounds_500_vp_stationary", |
| 198 gfx::Size(1000, 1000), |
| 199 gfx::Rect(0, 0, 500, 500), |
| 200 gfx::Rect(0, 0, 500, 500)); |
| 201 RunTilingRasterTileIteratorTest("1k_bounds_500_vp_moving", |
| 202 gfx::Size(1000, 1000), |
| 203 gfx::Rect(0, 0, 500, 500), |
| 204 gfx::Rect(0, 100, 500, 500)); |
| 205 RunTilingRasterTileIteratorTest("2k_bounds_100_vp_stationary", |
| 206 gfx::Size(2000, 2000), |
| 207 gfx::Rect(0, 0, 100, 100), |
| 208 gfx::Rect(0, 0, 100, 100)); |
| 209 RunTilingRasterTileIteratorTest("2k_bounds_100_vp_moving", |
| 210 gfx::Size(2000, 2000), |
| 211 gfx::Rect(0, 0, 100, 100), |
| 212 gfx::Rect(0, 100, 100, 100)); |
| 213 RunTilingRasterTileIteratorTest("2k_bounds_500_vp_stationary", |
| 214 gfx::Size(2000, 2000), |
| 215 gfx::Rect(0, 0, 500, 500), |
| 216 gfx::Rect(0, 0, 500, 500)); |
| 217 RunTilingRasterTileIteratorTest("2k_bounds_500_vp_moving", |
| 218 gfx::Size(2000, 2000), |
| 219 gfx::Rect(0, 0, 500, 500), |
| 220 gfx::Rect(0, 100, 500, 500)); |
| 221 } |
| 222 |
| 161 } // namespace | 223 } // namespace |
| 162 | 224 |
| 163 } // namespace cc | 225 } // namespace cc |
| OLD | NEW |