| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_sorter.h" | 5 #include "cc/trees/layer_sorter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 continue; | 311 continue; |
| 312 for (size_t nb = na + 1; nb < nodes_.size(); nb++) { | 312 for (size_t nb = na + 1; nb < nodes_.size(); nb++) { |
| 313 GraphNode& node_b = nodes_[nb]; | 313 GraphNode& node_b = nodes_[nb]; |
| 314 if (!node_b.layer->DrawsContent() && !node_b.layer->render_surface()) | 314 if (!node_b.layer->DrawsContent() && !node_b.layer->render_surface()) |
| 315 continue; | 315 continue; |
| 316 float weight = 0.f; | 316 float weight = 0.f; |
| 317 ABCompareResult overlap_result = CheckOverlap(&node_a.shape, | 317 ABCompareResult overlap_result = CheckOverlap(&node_a.shape, |
| 318 &node_b.shape, | 318 &node_b.shape, |
| 319 z_threshold, | 319 z_threshold, |
| 320 &weight); | 320 &weight); |
| 321 GraphNode* start_node = NULL; | 321 GraphNode* start_node = nullptr; |
| 322 GraphNode* end_node = NULL; | 322 GraphNode* end_node = nullptr; |
| 323 if (overlap_result == ABeforeB) { | 323 if (overlap_result == ABeforeB) { |
| 324 start_node = &node_a; | 324 start_node = &node_a; |
| 325 end_node = &node_b; | 325 end_node = &node_b; |
| 326 } else if (overlap_result == BBeforeA) { | 326 } else if (overlap_result == BBeforeA) { |
| 327 start_node = &node_b; | 327 start_node = &node_b; |
| 328 end_node = &node_a; | 328 end_node = &node_a; |
| 329 } | 329 } |
| 330 | 330 |
| 331 if (start_node) { | 331 if (start_node) { |
| 332 DVLOG(2) << start_node->layer->id() << " -> " << end_node->layer->id(); | 332 DVLOG(2) << start_node->layer->id() << " -> " << end_node->layer->id(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 422 |
| 423 if (!active_edges_.size()) | 423 if (!active_edges_.size()) |
| 424 break; | 424 break; |
| 425 | 425 |
| 426 // If there are still active edges but the list of nodes without incoming | 426 // If there are still active edges but the list of nodes without incoming |
| 427 // edges is empty then we have run into a cycle. Break the cycle by finding | 427 // edges is empty then we have run into a cycle. Break the cycle by finding |
| 428 // the node with the smallest overall incoming edge weight and use it. This | 428 // the node with the smallest overall incoming edge weight and use it. This |
| 429 // will favor nodes that have zero-weight incoming edges i.e. layers that | 429 // will favor nodes that have zero-weight incoming edges i.e. layers that |
| 430 // are being occluded by a layer that intersects them. | 430 // are being occluded by a layer that intersects them. |
| 431 float min_incoming_edge_weight = FLT_MAX; | 431 float min_incoming_edge_weight = FLT_MAX; |
| 432 GraphNode* next_node = NULL; | 432 GraphNode* next_node = nullptr; |
| 433 for (size_t i = 0; i < nodes_.size(); i++) { | 433 for (size_t i = 0; i < nodes_.size(); i++) { |
| 434 if (nodes_[i].incoming.size() && | 434 if (nodes_[i].incoming.size() && |
| 435 nodes_[i].incoming_edge_weight < min_incoming_edge_weight) { | 435 nodes_[i].incoming_edge_weight < min_incoming_edge_weight) { |
| 436 min_incoming_edge_weight = nodes_[i].incoming_edge_weight; | 436 min_incoming_edge_weight = nodes_[i].incoming_edge_weight; |
| 437 next_node = &nodes_[i]; | 437 next_node = &nodes_[i]; |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 DCHECK(next_node); | 440 DCHECK(next_node); |
| 441 // Remove all its incoming edges. | 441 // Remove all its incoming edges. |
| 442 for (size_t e = 0; e < next_node->incoming.size(); e++) { | 442 for (size_t e = 0; e < next_node->incoming.size(); e++) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 461 *it = sorted_list[count++]->layer; | 461 *it = sorted_list[count++]->layer; |
| 462 | 462 |
| 463 DVLOG(2) << "Sorting end ----"; | 463 DVLOG(2) << "Sorting end ----"; |
| 464 | 464 |
| 465 nodes_.clear(); | 465 nodes_.clear(); |
| 466 edges_.clear(); | 466 edges_.clear(); |
| 467 active_edges_.clear(); | 467 active_edges_.clear(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 } // namespace cc | 470 } // namespace cc |
| OLD | NEW |