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/test/fake_picture_layer_tiling_client.h" | 7 #include "cc/test/fake_picture_layer_tiling_client.h" |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "testing/perf/perf_test.h" | 10 #include "testing/perf/perf_test.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } while (!timer_.HasTimeLimitExpired()); | 105 } while (!timer_.HasTimeLimitExpired()); |
106 | 106 |
107 perf_test::PrintResult("update_tile_priorities_scrolling", | 107 perf_test::PrintResult("update_tile_priorities_scrolling", |
108 "", | 108 "", |
109 test_name, | 109 test_name, |
110 timer_.LapsPerSecond(), | 110 timer_.LapsPerSecond(), |
111 "runs/s", | 111 "runs/s", |
112 true); | 112 true); |
113 } | 113 } |
114 | 114 |
115 void RunTilingRasterTileIteratorTest(const std::string& test_name, | 115 void RunRasterIteratorConstructTest(const std::string& test_name, |
116 int num_tiles, | 116 const gfx::Rect& viewport) { |
117 const gfx::Rect& viewport) { | 117 gfx::Size bounds(viewport.size()); |
| 118 picture_layer_tiling_ = |
| 119 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
| 120 picture_layer_tiling_->UpdateTilePriorities( |
| 121 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
| 122 |
| 123 timer_.Reset(); |
| 124 do { |
| 125 PictureLayerTiling::TilingRasterTileIterator it( |
| 126 picture_layer_tiling_.get(), ACTIVE_TREE); |
| 127 timer_.NextLap(); |
| 128 } while (!timer_.HasTimeLimitExpired()); |
| 129 |
| 130 perf_test::PrintResult("tiling_raster_tile_iterator_construct", |
| 131 "", |
| 132 test_name, |
| 133 timer_.LapsPerSecond(), |
| 134 "runs/s", |
| 135 true); |
| 136 } |
| 137 |
| 138 void RunRasterIteratorConstructAndIterateTest(const std::string& test_name, |
| 139 int num_tiles, |
| 140 const gfx::Rect& viewport) { |
118 gfx::Size bounds(10000, 10000); | 141 gfx::Size bounds(10000, 10000); |
119 picture_layer_tiling_ = | 142 picture_layer_tiling_ = |
120 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); | 143 PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_); |
121 picture_layer_tiling_->UpdateTilePriorities( | 144 picture_layer_tiling_->UpdateTilePriorities( |
122 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); | 145 ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform()); |
123 | 146 |
124 timer_.Reset(); | 147 timer_.Reset(); |
125 do { | 148 do { |
126 int count = num_tiles; | 149 int count = num_tiles; |
127 for (PictureLayerTiling::TilingRasterTileIterator it( | 150 PictureLayerTiling::TilingRasterTileIterator it( |
128 picture_layer_tiling_.get(), ACTIVE_TREE); | 151 picture_layer_tiling_.get(), ACTIVE_TREE); |
129 it && count; | 152 while (count--) { |
130 ++it) { | 153 ASSERT_TRUE(it) << "count: " << count; |
131 --count; | 154 ASSERT_TRUE(*it != NULL) << "count: " << count; |
| 155 ++it; |
132 } | 156 } |
133 timer_.NextLap(); | 157 timer_.NextLap(); |
134 } while (!timer_.HasTimeLimitExpired()); | 158 } while (!timer_.HasTimeLimitExpired()); |
135 | 159 |
136 perf_test::PrintResult("tiling_raster_tile_iterator", | 160 perf_test::PrintResult("tiling_raster_tile_iterator_construct_and_iterate", |
137 "", | 161 "", |
138 test_name, | 162 test_name, |
139 timer_.LapsPerSecond(), | 163 timer_.LapsPerSecond(), |
140 "runs/s", | 164 "runs/s", |
141 true); | 165 true); |
142 } | 166 } |
143 | 167 |
144 private: | 168 private: |
145 FakePictureLayerTilingClient picture_layer_tiling_client_; | 169 FakePictureLayerTilingClient picture_layer_tiling_client_; |
146 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; | 170 scoped_ptr<PictureLayerTiling> picture_layer_tiling_; |
(...skipping 25 matching lines...) Expand all Loading... |
172 | 196 |
173 transform.Rotate(10); | 197 transform.Rotate(10); |
174 RunUpdateTilePrioritiesStationaryTest("rotation", transform); | 198 RunUpdateTilePrioritiesStationaryTest("rotation", transform); |
175 RunUpdateTilePrioritiesScrollingTest("rotation", transform); | 199 RunUpdateTilePrioritiesScrollingTest("rotation", transform); |
176 | 200 |
177 transform.ApplyPerspectiveDepth(10); | 201 transform.ApplyPerspectiveDepth(10); |
178 RunUpdateTilePrioritiesStationaryTest("perspective", transform); | 202 RunUpdateTilePrioritiesStationaryTest("perspective", transform); |
179 RunUpdateTilePrioritiesScrollingTest("perspective", transform); | 203 RunUpdateTilePrioritiesScrollingTest("perspective", transform); |
180 } | 204 } |
181 | 205 |
182 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIterator) { | 206 TEST_F(PictureLayerTilingPerfTest, TilingRasterTileIteratorConstruct) { |
183 RunTilingRasterTileIteratorTest("32_100x100", 32, gfx::Rect(0, 0, 100, 100)); | 207 RunRasterIteratorConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
184 RunTilingRasterTileIteratorTest("32_500x500", 32, gfx::Rect(0, 0, 500, 500)); | 208 RunRasterIteratorConstructTest("50_0_100x100", gfx::Rect(50, 0, 100, 100)); |
185 RunTilingRasterTileIteratorTest("64_100x100", 64, gfx::Rect(0, 0, 100, 100)); | 209 RunRasterIteratorConstructTest("100_0_100x100", gfx::Rect(100, 0, 100, 100)); |
186 RunTilingRasterTileIteratorTest("64_500x500", 64, gfx::Rect(0, 0, 500, 500)); | 210 RunRasterIteratorConstructTest("150_0_100x100", gfx::Rect(150, 0, 100, 100)); |
| 211 } |
| 212 |
| 213 TEST_F(PictureLayerTilingPerfTest, |
| 214 TilingRasterTileIteratorConstructAndIterate) { |
| 215 RunRasterIteratorConstructAndIterateTest( |
| 216 "32_100x100", 32, gfx::Rect(0, 0, 100, 100)); |
| 217 RunRasterIteratorConstructAndIterateTest( |
| 218 "32_500x500", 32, gfx::Rect(0, 0, 500, 500)); |
| 219 RunRasterIteratorConstructAndIterateTest( |
| 220 "64_100x100", 64, gfx::Rect(0, 0, 100, 100)); |
| 221 RunRasterIteratorConstructAndIterateTest( |
| 222 "64_500x500", 64, gfx::Rect(0, 0, 500, 500)); |
187 } | 223 } |
188 | 224 |
189 } // namespace | 225 } // namespace |
190 | 226 |
191 } // namespace cc | 227 } // namespace cc |
OLD | NEW |