Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: cc/trees/layer_sorter.cc

Issue 13285002: cc: Consolidate LayerList types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_sorter.h ('k') | cc/trees/layer_sorter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // invisible and hence returning zero is fine. 252 // invisible and hence returning zero is fine.
253 if (!d) 253 if (!d)
254 return 0.f; 254 return 0.f;
255 255
256 // The intersection point would be given by: 256 // The intersection point would be given by:
257 // p + (n / d) * u but since we are only interested in the 257 // p + (n / d) * u but since we are only interested in the
258 // z coordinate and p's z coord is zero, all we need is the value of n/d. 258 // z coordinate and p's z coord is zero, all we need is the value of n/d.
259 return n / d; 259 return n / d;
260 } 260 }
261 261
262 void LayerSorter::CreateGraphNodes(LayerList::iterator first, 262 void LayerSorter::CreateGraphNodes(LayerImplList::iterator first,
263 LayerList::iterator last) { 263 LayerImplList::iterator last) {
264 DVLOG(2) << "Creating graph nodes:"; 264 DVLOG(2) << "Creating graph nodes:";
265 float min_z = FLT_MAX; 265 float min_z = FLT_MAX;
266 float max_z = -FLT_MAX; 266 float max_z = -FLT_MAX;
267 for (LayerList::const_iterator it = first; it < last; it++) { 267 for (LayerImplList::const_iterator it = first; it < last; it++) {
268 nodes_.push_back(GraphNode(*it)); 268 nodes_.push_back(GraphNode(*it));
269 GraphNode& node = nodes_.at(nodes_.size() - 1); 269 GraphNode& node = nodes_.at(nodes_.size() - 1);
270 RenderSurfaceImpl* render_surface = node.layer->render_surface(); 270 RenderSurfaceImpl* render_surface = node.layer->render_surface();
271 if (!node.layer->DrawsContent() && !render_surface) 271 if (!node.layer->DrawsContent() && !render_surface)
272 continue; 272 continue;
273 273
274 DVLOG(2) << "Layer " << node.layer->id() << 274 DVLOG(2) << "Layer " << node.layer->id() <<
275 " (" << node.layer->bounds().width() << 275 " (" << node.layer->bounds().width() <<
276 " x " << node.layer->bounds().height() << ")"; 276 " x " << node.layer->bounds().height() << ")";
277 277
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // intersection between the triangles and backprojecting those points to the 366 // intersection between the triangles and backprojecting those points to the
367 // plane of the layer to determine the corresponding Z coordinate. The layer 367 // plane of the layer to determine the corresponding Z coordinate. The layer
368 // with the lower Z coordinate (farther from the eye) needs to be rendered 368 // with the lower Z coordinate (farther from the eye) needs to be rendered
369 // first. 369 // first.
370 // 370 //
371 // If the layer projections don't intersect, then no edges (dependencies) are 371 // If the layer projections don't intersect, then no edges (dependencies) are
372 // created between them in the graph. HOWEVER, in this case we still need to 372 // created between them in the graph. HOWEVER, in this case we still need to
373 // preserve the ordering of the original list of layers, since that list should 373 // preserve the ordering of the original list of layers, since that list should
374 // already have proper z-index ordering of layers. 374 // already have proper z-index ordering of layers.
375 // 375 //
376 void LayerSorter::Sort(LayerList::iterator first, LayerList::iterator last) { 376 void LayerSorter::Sort(LayerImplList::iterator first,
377 LayerImplList::iterator last) {
377 DVLOG(2) << "Sorting start ----"; 378 DVLOG(2) << "Sorting start ----";
378 CreateGraphNodes(first, last); 379 CreateGraphNodes(first, last);
379 380
380 CreateGraphEdges(); 381 CreateGraphEdges();
381 382
382 std::vector<GraphNode*> sorted_list; 383 std::vector<GraphNode*> sorted_list;
383 std::deque<GraphNode*> no_incoming_edge_node_list; 384 std::deque<GraphNode*> no_incoming_edge_node_list;
384 385
385 // Find all the nodes that don't have incoming edges. 386 // Find all the nodes that don't have incoming edges.
386 for (NodeList::iterator la = nodes_.begin(); la < nodes_.end(); la++) { 387 for (NodeList::iterator la = nodes_.begin(); la < nodes_.end(); la++) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 no_incoming_edge_node_list.push_back(next_node); 448 no_incoming_edge_node_list.push_back(next_node);
448 DVLOG(2) << "Breaking cycle by cleaning up incoming edges from " << 449 DVLOG(2) << "Breaking cycle by cleaning up incoming edges from " <<
449 next_node->layer->id() << 450 next_node->layer->id() <<
450 " (weight = " << min_incoming_edge_weight << ")"; 451 " (weight = " << min_incoming_edge_weight << ")";
451 } 452 }
452 453
453 // Note: The original elements of the list are in no danger of having their 454 // Note: The original elements of the list are in no danger of having their
454 // ref count go to zero here as they are all nodes of the layer hierarchy and 455 // ref count go to zero here as they are all nodes of the layer hierarchy and
455 // are kept alive by their parent nodes. 456 // are kept alive by their parent nodes.
456 int count = 0; 457 int count = 0;
457 for (LayerList::iterator it = first; it < last; it++) 458 for (LayerImplList::iterator it = first; it < last; it++)
458 *it = sorted_list[count++]->layer; 459 *it = sorted_list[count++]->layer;
459 460
460 DVLOG(2) << "Sorting end ----"; 461 DVLOG(2) << "Sorting end ----";
461 462
462 nodes_.clear(); 463 nodes_.clear();
463 edges_.clear(); 464 edges_.clear();
464 active_edges_.clear(); 465 active_edges_.clear();
465 } 466 }
466 467
467 } // namespace cc 468 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_sorter.h ('k') | cc/trees/layer_sorter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698