| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_pile.h" | 5 #include "cc/resources/picture_pile.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 std::vector<gfx::Rect> invalid_tiles_vertical = invalid_tiles; | 109 std::vector<gfx::Rect> invalid_tiles_vertical = invalid_tiles; |
| 110 std::sort(invalid_tiles_vertical.begin(), | 110 std::sort(invalid_tiles_vertical.begin(), |
| 111 invalid_tiles_vertical.end(), | 111 invalid_tiles_vertical.end(), |
| 112 rect_sort_y); | 112 rect_sort_y); |
| 113 | 113 |
| 114 float vertical_density; | 114 float vertical_density; |
| 115 std::vector<gfx::Rect> vertical_clustering; | 115 std::vector<gfx::Rect> vertical_clustering; |
| 116 vertical_density = PerformClustering(invalid_tiles_vertical, | 116 vertical_density = PerformClustering(invalid_tiles_vertical, |
| 117 &vertical_clustering); | 117 &vertical_clustering); |
| 118 | 118 |
| 119 // If vertical density is optimal, then we can return early. |
| 120 if (vertical_density == 1.f) { |
| 121 *record_rects = vertical_clustering; |
| 122 return vertical_density; |
| 123 } |
| 124 |
| 119 // Now try again with a horizontal sort, see which one is best | 125 // Now try again with a horizontal sort, see which one is best |
| 120 // TODO(humper): Heuristics for skipping this step? | |
| 121 std::vector<gfx::Rect> invalid_tiles_horizontal = invalid_tiles; | 126 std::vector<gfx::Rect> invalid_tiles_horizontal = invalid_tiles; |
| 122 std::sort(invalid_tiles_vertical.begin(), | 127 std::sort(invalid_tiles_horizontal.begin(), |
| 123 invalid_tiles_vertical.end(), | 128 invalid_tiles_horizontal.end(), |
| 124 rect_sort_x); | 129 rect_sort_x); |
| 125 | 130 |
| 126 float horizontal_density; | 131 float horizontal_density; |
| 127 std::vector<gfx::Rect> horizontal_clustering; | 132 std::vector<gfx::Rect> horizontal_clustering; |
| 128 horizontal_density = PerformClustering(invalid_tiles_vertical, | 133 horizontal_density = PerformClustering(invalid_tiles_horizontal, |
| 129 &horizontal_clustering); | 134 &horizontal_clustering); |
| 130 | 135 |
| 131 if (vertical_density < horizontal_density) { | 136 if (vertical_density < horizontal_density) { |
| 132 *record_rects = horizontal_clustering; | 137 *record_rects = horizontal_clustering; |
| 133 return horizontal_density; | 138 return horizontal_density; |
| 134 } | 139 } |
| 135 | 140 |
| 136 *record_rects = vertical_clustering; | 141 *record_rects = vertical_clustering; |
| 137 return vertical_density; | 142 return vertical_density; |
| 138 } | 143 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 309 } |
| 305 DCHECK(found_tile_for_recorded_picture); | 310 DCHECK(found_tile_for_recorded_picture); |
| 306 } | 311 } |
| 307 | 312 |
| 308 has_any_recordings_ = true; | 313 has_any_recordings_ = true; |
| 309 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 314 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
| 310 return true; | 315 return true; |
| 311 } | 316 } |
| 312 | 317 |
| 313 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |