| 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 int num_tiles, |
| 121 const gfx::Rect& viewport) { |
| 122 start_time_ = base::TimeTicks(); |
| 123 num_runs_ = 0; |
| 124 |
| 125 gfx::Size bounds(10000, 10000); |
| 126 picture_layer_tiling_ = |
| 127 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 128 picture_layer_tiling_->UpdateTilePriorities( |
| 129 ACTIVE_TREE, viewport, 1.0f, 1.0); |
| 130 do { |
| 131 int count = num_tiles; |
| 132 for (PictureLayerTiling::TilingRasterTileIterator it( |
| 133 picture_layer_tiling_.get(), ACTIVE_TREE); |
| 134 it && count; |
| 135 ++it) { |
| 136 --count; |
| 137 } |
| 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("32_100x100", 32, gfx::Rect(0, 0, 100, 100)); |
| 190 RunTilingRasterTileIteratorTest("32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 191 RunTilingRasterTileIteratorTest("64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 192 RunTilingRasterTileIteratorTest("64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
| 193 } |
| 194 |
| 161 } // namespace | 195 } // namespace |
| 162 | 196 |
| 163 } // namespace cc | 197 } // namespace cc |
| OLD | NEW |