| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tiles/raster_tile_priority_queue_all.h" | 5 #include "cc/tiles/raster_tile_priority_queue_all.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/tiles/tiling_set_raster_queue_all.h" | 8 #include "cc/tiles/tiling_set_raster_queue_all.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class RasterOrderComparator { | 14 class RasterOrderComparator { |
| 15 public: | 15 public: |
| 16 explicit RasterOrderComparator(TreePriority tree_priority) | 16 explicit RasterOrderComparator(TreePriority tree_priority) |
| 17 : tree_priority_(tree_priority) {} | 17 : tree_priority_(tree_priority) {} |
| 18 | 18 |
| 19 // Note that in this function, we have to return true if and only if |
| 20 // a is strictly lower priority than b. |
| 19 bool operator()( | 21 bool operator()( |
| 20 const std::unique_ptr<TilingSetRasterQueueAll>& a_queue, | 22 const std::unique_ptr<TilingSetRasterQueueAll>& a_queue, |
| 21 const std::unique_ptr<TilingSetRasterQueueAll>& b_queue) const { | 23 const std::unique_ptr<TilingSetRasterQueueAll>& b_queue) const { |
| 22 // Note that in this function, we have to return true if and only if | |
| 23 // a is strictly lower priority than b. | |
| 24 const TilePriority& a_priority = a_queue->Top().priority(); | 24 const TilePriority& a_priority = a_queue->Top().priority(); |
| 25 const TilePriority& b_priority = b_queue->Top().priority(); | 25 const TilePriority& b_priority = b_queue->Top().priority(); |
| 26 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; | 26 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; |
| 27 | 27 |
| 28 // If the priority bin is the same but one of the tiles is from a |
| 29 // non-drawing layer, then the drawing layer has a higher priority. |
| 30 if (b_priority.priority_bin == a_priority.priority_bin && |
| 31 b_queue->is_drawing_layer() != a_queue->is_drawing_layer()) { |
| 32 return b_queue->is_drawing_layer(); |
| 33 } |
| 34 |
| 28 // If the bin is the same but the resolution is not, then the order will be | 35 // If the bin is the same but the resolution is not, then the order will be |
| 29 // determined by whether we prioritize low res or not. | 36 // determined by whether we prioritize low res or not. |
| 30 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile | 37 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile |
| 31 // class but instead produced by the iterators. | 38 // class but instead produced by the iterators. |
| 32 if (b_priority.priority_bin == a_priority.priority_bin && | 39 if (b_priority.priority_bin == a_priority.priority_bin && |
| 33 b_priority.resolution != a_priority.resolution) { | 40 b_priority.resolution != a_priority.resolution) { |
| 34 // Non ideal resolution should be sorted lower than other resolutions. | 41 // Non ideal resolution should be sorted lower than other resolutions. |
| 35 if (a_priority.resolution == NON_IDEAL_RESOLUTION) | 42 if (a_priority.resolution == NON_IDEAL_RESOLUTION) |
| 36 return true; | 43 return true; |
| 37 | 44 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 std::vector<std::unique_ptr<TilingSetRasterQueueAll>>* queues) { | 63 std::vector<std::unique_ptr<TilingSetRasterQueueAll>>* queues) { |
| 57 DCHECK(queues->empty()); | 64 DCHECK(queues->empty()); |
| 58 | 65 |
| 59 for (auto* layer : layers) { | 66 for (auto* layer : layers) { |
| 60 if (!layer->HasValidTilePriorities()) | 67 if (!layer->HasValidTilePriorities()) |
| 61 continue; | 68 continue; |
| 62 | 69 |
| 63 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); | 70 PictureLayerTilingSet* tiling_set = layer->picture_layer_tiling_set(); |
| 64 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; | 71 bool prioritize_low_res = tree_priority == SMOOTHNESS_TAKES_PRIORITY; |
| 65 std::unique_ptr<TilingSetRasterQueueAll> tiling_set_queue = | 72 std::unique_ptr<TilingSetRasterQueueAll> tiling_set_queue = |
| 66 base::MakeUnique<TilingSetRasterQueueAll>(tiling_set, | 73 base::MakeUnique<TilingSetRasterQueueAll>( |
| 67 prioritize_low_res); | 74 tiling_set, prioritize_low_res, |
| 75 layer->contributes_to_drawn_render_surface()); |
| 68 // Queues will only contain non empty tiling sets. | 76 // Queues will only contain non empty tiling sets. |
| 69 if (!tiling_set_queue->IsEmpty()) | 77 if (!tiling_set_queue->IsEmpty()) |
| 70 queues->push_back(std::move(tiling_set_queue)); | 78 queues->push_back(std::move(tiling_set_queue)); |
| 71 } | 79 } |
| 72 std::make_heap(queues->begin(), queues->end(), | 80 std::make_heap(queues->begin(), queues->end(), |
| 73 RasterOrderComparator(tree_priority)); | 81 RasterOrderComparator(tree_priority)); |
| 74 } | 82 } |
| 75 | 83 |
| 76 } // namespace | 84 } // namespace |
| 77 | 85 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return active_queues_; | 181 return active_queues_; |
| 174 return pending_queues_; | 182 return pending_queues_; |
| 175 } | 183 } |
| 176 default: | 184 default: |
| 177 NOTREACHED(); | 185 NOTREACHED(); |
| 178 return active_queues_; | 186 return active_queues_; |
| 179 } | 187 } |
| 180 } | 188 } |
| 181 | 189 |
| 182 } // namespace cc | 190 } // namespace cc |
| OLD | NEW |