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

Side by Side Diff: cc/layer_sorter.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
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 "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerSorter.h" 7 #include "CCLayerSorter.h"
8 8
9 #include "CCMathUtil.h" 9 #include "CCMathUtil.h"
10 #include "CCRenderSurface.h" 10 #include "CCRenderSurface.h"
11 #include <limits.h> 11 #include <limits.h>
12 #include <public/WebTransformationMatrix.h> 12 #include <public/WebTransformationMatrix.h>
13 #include <deque> 13 #include <deque>
14 #include <vector> 14 #include <vector>
15 15
16 using namespace std; 16 using namespace std;
17 using WebKit::WebTransformationMatrix; 17 using WebKit::WebTransformationMatrix;
18 18
19 #define LOG_CHANNEL_PREFIX Log 19 #define LOG_CHANNEL_PREFIX Log
20 #define SHOW_DEBUG_LOG 0 20 #define SHOW_DEBUG_LOG 0
21 21
22 #if !defined( NDEBUG ) 22 #if !defined( NDEBUG )
23 #if SHOW_DEBUG_LOG 23 #if SHOW_DEBUG_LOG
24 static WTFLogChannel LogCCLayerSorter = { 0x00000000, "", WTFLogChannelOn }; 24 static WTFLogChannel LogLayerSorter = { 0x00000000, "", WTFLogChannelOn };
25 #else 25 #else
26 static WTFLogChannel LogCCLayerSorter = { 0x00000000, "", WTFLogChannelOff }; 26 static WTFLogChannel LogLayerSorter = { 0x00000000, "", WTFLogChannelOff };
27 #endif 27 #endif
28 #endif 28 #endif
29 29
30 namespace cc { 30 namespace cc {
31 31
32 inline static float perpProduct(const FloatSize& u, const FloatSize& v) 32 inline static float perpProduct(const FloatSize& u, const FloatSize& v)
33 { 33 {
34 return u.width() * v.height() - u.height() * v.width(); 34 return u.width() * v.height() - u.height() * v.width();
35 } 35 }
36 36
(...skipping 19 matching lines...) Expand all
56 56
57 float t = perpProduct(u, w) / denom; 57 float t = perpProduct(u, w) / denom;
58 if (t < 0 || t > 1) 58 if (t < 0 || t > 1)
59 return false; 59 return false;
60 60
61 u.scale(s); 61 u.scale(s);
62 r = a + u; 62 r = a + u;
63 return true; 63 return true;
64 } 64 }
65 65
66 GraphNode::GraphNode(CCLayerImpl* cclayer) 66 GraphNode::GraphNode(LayerImpl* layerImpl)
67 : layer(cclayer) 67 : layer(layerImpl)
68 , incomingEdgeWeight(0) 68 , incomingEdgeWeight(0)
69 { 69 {
70 } 70 }
71 71
72 GraphNode::~GraphNode() 72 GraphNode::~GraphNode()
73 { 73 {
74 } 74 }
75 75
76 CCLayerSorter::CCLayerSorter() 76 LayerSorter::LayerSorter()
77 : m_zRange(0) 77 : m_zRange(0)
78 { 78 {
79 } 79 }
80 80
81 CCLayerSorter::~CCLayerSorter() 81 LayerSorter::~LayerSorter()
82 { 82 {
83 } 83 }
84 84
85 // Checks whether layer "a" draws on top of layer "b". The weight value returned is an indication of 85 // Checks whether layer "a" draws on top of layer "b". The weight value returned is an indication of
86 // the maximum z-depth difference between the layers or zero if the layers are f ound to be intesecting 86 // the maximum z-depth difference between the layers or zero if the layers are f ound to be intesecting
87 // (some features are in front and some are behind). 87 // (some features are in front and some are behind).
88 CCLayerSorter::ABCompareResult CCLayerSorter::checkOverlap(LayerShape* a, LayerS hape* b, float zThreshold, float& weight) 88 LayerSorter::ABCompareResult LayerSorter::checkOverlap(LayerShape* a, LayerShape * b, float zThreshold, float& weight)
89 { 89 {
90 weight = 0; 90 weight = 0;
91 91
92 // Early out if the projected bounds don't overlap. 92 // Early out if the projected bounds don't overlap.
93 if (!a->projectedBounds.intersects(b->projectedBounds)) 93 if (!a->projectedBounds.intersects(b->projectedBounds))
94 return None; 94 return None;
95 95
96 FloatPoint aPoints[4] = {a->projectedQuad.p1(), a->projectedQuad.p2(), a->pr ojectedQuad.p3(), a->projectedQuad.p4() }; 96 FloatPoint aPoints[4] = {a->projectedQuad.p1(), a->projectedQuad.p2(), a->pr ojectedQuad.p3(), a->projectedQuad.p4() };
97 FloatPoint bPoints[4] = {b->projectedQuad.p1(), b->projectedQuad.p2(), b->pr ojectedQuad.p3(), b->projectedQuad.p4() }; 97 FloatPoint bPoints[4] = {b->projectedQuad.p1(), b->projectedQuad.p2(), b->pr ojectedQuad.p3(), b->projectedQuad.p4() };
98 98
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 LayerShape::LayerShape(float width, float height, const WebTransformationMatrix& drawTransform) 159 LayerShape::LayerShape(float width, float height, const WebTransformationMatrix& drawTransform)
160 { 160 {
161 FloatQuad layerQuad(FloatRect(0, 0, width, height)); 161 FloatQuad layerQuad(FloatRect(0, 0, width, height));
162 162
163 // Compute the projection of the layer quad onto the z = 0 plane. 163 // Compute the projection of the layer quad onto the z = 0 plane.
164 164
165 FloatPoint clippedQuad[8]; 165 FloatPoint clippedQuad[8];
166 int numVerticesInClippedQuad; 166 int numVerticesInClippedQuad;
167 CCMathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVertice sInClippedQuad); 167 MathUtil::mapClippedQuad(drawTransform, layerQuad, clippedQuad, numVerticesI nClippedQuad);
168 168
169 if (numVerticesInClippedQuad < 3) { 169 if (numVerticesInClippedQuad < 3) {
170 projectedBounds = FloatRect(); 170 projectedBounds = FloatRect();
171 return; 171 return;
172 } 172 }
173 173
174 projectedBounds = CCMathUtil::computeEnclosingRectOfVertices(clippedQuad, nu mVerticesInClippedQuad); 174 projectedBounds = MathUtil::computeEnclosingRectOfVertices(clippedQuad, numV erticesInClippedQuad);
175 175
176 // NOTE: it will require very significant refactoring and overhead to deal w ith 176 // NOTE: it will require very significant refactoring and overhead to deal w ith
177 // generalized polygons or multiple quads per layer here. For the sake of la yer 177 // generalized polygons or multiple quads per layer here. For the sake of la yer
178 // sorting it is equally correct to take a subsection of the polygon that ca n be made 178 // sorting it is equally correct to take a subsection of the polygon that ca n be made
179 // into a quad. This will only be incorrect in the case of intersecting laye rs, which 179 // into a quad. This will only be incorrect in the case of intersecting laye rs, which
180 // are not supported yet anyway. 180 // are not supported yet anyway.
181 projectedQuad.setP1(clippedQuad[0]); 181 projectedQuad.setP1(clippedQuad[0]);
182 projectedQuad.setP2(clippedQuad[1]); 182 projectedQuad.setP2(clippedQuad[1]);
183 projectedQuad.setP3(clippedQuad[2]); 183 projectedQuad.setP3(clippedQuad[2]);
184 if (numVerticesInClippedQuad >= 4) 184 if (numVerticesInClippedQuad >= 4)
185 projectedQuad.setP4(clippedQuad[3]); 185 projectedQuad.setP4(clippedQuad[3]);
186 else 186 else
187 projectedQuad.setP4(clippedQuad[2]); // this will be a degenerate quad t hat is actually a triangle. 187 projectedQuad.setP4(clippedQuad[2]); // this will be a degenerate quad t hat is actually a triangle.
188 188
189 // Compute the normal of the layer's plane. 189 // Compute the normal of the layer's plane.
190 bool clipped = false; 190 bool clipped = false;
191 FloatPoint3D c1 = CCMathUtil::mapPoint(drawTransform, FloatPoint3D(0, 0, 0), clipped); 191 FloatPoint3D c1 = MathUtil::mapPoint(drawTransform, FloatPoint3D(0, 0, 0), c lipped);
192 FloatPoint3D c2 = CCMathUtil::mapPoint(drawTransform, FloatPoint3D(0, 1, 0), clipped); 192 FloatPoint3D c2 = MathUtil::mapPoint(drawTransform, FloatPoint3D(0, 1, 0), c lipped);
193 FloatPoint3D c3 = CCMathUtil::mapPoint(drawTransform, FloatPoint3D(1, 0, 0), clipped); 193 FloatPoint3D c3 = MathUtil::mapPoint(drawTransform, FloatPoint3D(1, 0, 0), c lipped);
194 // FIXME: Deal with clipping. 194 // FIXME: Deal with clipping.
195 FloatPoint3D c12 = c2 - c1; 195 FloatPoint3D c12 = c2 - c1;
196 FloatPoint3D c13 = c3 - c1; 196 FloatPoint3D c13 = c3 - c1;
197 layerNormal = c13.cross(c12); 197 layerNormal = c13.cross(c12);
198 198
199 transformOrigin = c1; 199 transformOrigin = c1;
200 } 200 }
201 201
202 // Returns the Z coordinate of a point on the layer that projects 202 // Returns the Z coordinate of a point on the layer that projects
203 // to point p which lies on the z = 0 plane. It does it by computing the 203 // to point p which lies on the z = 0 plane. It does it by computing the
(...skipping 11 matching lines...) Expand all
215 // invisible and hence returning zero is fine. 215 // invisible and hence returning zero is fine.
216 if (!d) 216 if (!d)
217 return 0; 217 return 0;
218 218
219 // The intersection point would be given by: 219 // The intersection point would be given by:
220 // p + (n / d) * u but since we are only interested in the 220 // p + (n / d) * u but since we are only interested in the
221 // z coordinate and p's z coord is zero, all we need is the value of n/d. 221 // z coordinate and p's z coord is zero, all we need is the value of n/d.
222 return n / d; 222 return n / d;
223 } 223 }
224 224
225 void CCLayerSorter::createGraphNodes(LayerList::iterator first, LayerList::itera tor last) 225 void LayerSorter::createGraphNodes(LayerList::iterator first, LayerList::iterato r last)
226 { 226 {
227 #if !defined( NDEBUG ) 227 #if !defined( NDEBUG )
228 LOG(CCLayerSorter, "Creating graph nodes:\n"); 228 LOG(LayerSorter, "Creating graph nodes:\n");
229 #endif 229 #endif
230 float minZ = FLT_MAX; 230 float minZ = FLT_MAX;
231 float maxZ = -FLT_MAX; 231 float maxZ = -FLT_MAX;
232 for (LayerList::const_iterator it = first; it < last; it++) { 232 for (LayerList::const_iterator it = first; it < last; it++) {
233 m_nodes.push_back(GraphNode(*it)); 233 m_nodes.push_back(GraphNode(*it));
234 GraphNode& node = m_nodes.at(m_nodes.size() - 1); 234 GraphNode& node = m_nodes.at(m_nodes.size() - 1);
235 CCRenderSurface* renderSurface = node.layer->renderSurface(); 235 RenderSurfaceImpl* renderSurface = node.layer->renderSurface();
236 if (!node.layer->drawsContent() && !renderSurface) 236 if (!node.layer->drawsContent() && !renderSurface)
237 continue; 237 continue;
238 238
239 #if !defined( NDEBUG ) 239 #if !defined( NDEBUG )
240 LOG(CCLayerSorter, "Layer %d (%d x %d)\n", node.layer->id(), node.layer- >bounds().width(), node.layer->bounds().height()); 240 LOG(LayerSorter, "Layer %d (%d x %d)\n", node.layer->id(), node.layer->b ounds().width(), node.layer->bounds().height());
241 #endif 241 #endif
242 242
243 WebTransformationMatrix drawTransform; 243 WebTransformationMatrix drawTransform;
244 float layerWidth, layerHeight; 244 float layerWidth, layerHeight;
245 if (renderSurface) { 245 if (renderSurface) {
246 drawTransform = renderSurface->drawTransform(); 246 drawTransform = renderSurface->drawTransform();
247 layerWidth = renderSurface->contentRect().width(); 247 layerWidth = renderSurface->contentRect().width();
248 layerHeight = renderSurface->contentRect().height(); 248 layerHeight = renderSurface->contentRect().height();
249 } else { 249 } else {
250 drawTransform = node.layer->drawTransform(); 250 drawTransform = node.layer->drawTransform();
251 layerWidth = node.layer->contentBounds().width(); 251 layerWidth = node.layer->contentBounds().width();
252 layerHeight = node.layer->contentBounds().height(); 252 layerHeight = node.layer->contentBounds().height();
253 } 253 }
254 254
255 node.shape = LayerShape(layerWidth, layerHeight, drawTransform); 255 node.shape = LayerShape(layerWidth, layerHeight, drawTransform);
256 256
257 maxZ = max(maxZ, node.shape.transformOrigin.z()); 257 maxZ = max(maxZ, node.shape.transformOrigin.z());
258 minZ = min(minZ, node.shape.transformOrigin.z()); 258 minZ = min(minZ, node.shape.transformOrigin.z());
259 } 259 }
260 260
261 m_zRange = fabsf(maxZ - minZ); 261 m_zRange = fabsf(maxZ - minZ);
262 } 262 }
263 263
264 void CCLayerSorter::createGraphEdges() 264 void LayerSorter::createGraphEdges()
265 { 265 {
266 #if !defined( NDEBUG ) 266 #if !defined( NDEBUG )
267 LOG(CCLayerSorter, "Edges:\n"); 267 LOG(LayerSorter, "Edges:\n");
268 #endif 268 #endif
269 // Fraction of the total zRange below which z differences 269 // Fraction of the total zRange below which z differences
270 // are not considered reliable. 270 // are not considered reliable.
271 const float zThresholdFactor = 0.01f; 271 const float zThresholdFactor = 0.01f;
272 float zThreshold = m_zRange * zThresholdFactor; 272 float zThreshold = m_zRange * zThresholdFactor;
273 273
274 for (unsigned na = 0; na < m_nodes.size(); na++) { 274 for (unsigned na = 0; na < m_nodes.size(); na++) {
275 GraphNode& nodeA = m_nodes[na]; 275 GraphNode& nodeA = m_nodes[na];
276 if (!nodeA.layer->drawsContent() && !nodeA.layer->renderSurface()) 276 if (!nodeA.layer->drawsContent() && !nodeA.layer->renderSurface())
277 continue; 277 continue;
278 for (unsigned nb = na + 1; nb < m_nodes.size(); nb++) { 278 for (unsigned nb = na + 1; nb < m_nodes.size(); nb++) {
279 GraphNode& nodeB = m_nodes[nb]; 279 GraphNode& nodeB = m_nodes[nb];
280 if (!nodeB.layer->drawsContent() && !nodeB.layer->renderSurface()) 280 if (!nodeB.layer->drawsContent() && !nodeB.layer->renderSurface())
281 continue; 281 continue;
282 float weight = 0; 282 float weight = 0;
283 ABCompareResult overlapResult = checkOverlap(&nodeA.shape, &nodeB.sh ape, zThreshold, weight); 283 ABCompareResult overlapResult = checkOverlap(&nodeA.shape, &nodeB.sh ape, zThreshold, weight);
284 GraphNode* startNode = 0; 284 GraphNode* startNode = 0;
285 GraphNode* endNode = 0; 285 GraphNode* endNode = 0;
286 if (overlapResult == ABeforeB) { 286 if (overlapResult == ABeforeB) {
287 startNode = &nodeA; 287 startNode = &nodeA;
288 endNode = &nodeB; 288 endNode = &nodeB;
289 } else if (overlapResult == BBeforeA) { 289 } else if (overlapResult == BBeforeA) {
290 startNode = &nodeB; 290 startNode = &nodeB;
291 endNode = &nodeA; 291 endNode = &nodeA;
292 } 292 }
293 293
294 if (startNode) { 294 if (startNode) {
295 #if !defined( NDEBUG ) 295 #if !defined( NDEBUG )
296 LOG(CCLayerSorter, "%d -> %d\n", startNode->layer->id(), endNode ->layer->id()); 296 LOG(LayerSorter, "%d -> %d\n", startNode->layer->id(), endNode-> layer->id());
297 #endif 297 #endif
298 m_edges.push_back(GraphEdge(startNode, endNode, weight)); 298 m_edges.push_back(GraphEdge(startNode, endNode, weight));
299 } 299 }
300 } 300 }
301 } 301 }
302 302
303 for (unsigned i = 0; i < m_edges.size(); i++) { 303 for (unsigned i = 0; i < m_edges.size(); i++) {
304 GraphEdge& edge = m_edges[i]; 304 GraphEdge& edge = m_edges[i];
305 m_activeEdges[&edge] = &edge; 305 m_activeEdges[&edge] = &edge;
306 edge.from->outgoing.push_back(&edge); 306 edge.from->outgoing.push_back(&edge);
307 edge.to->incoming.push_back(&edge); 307 edge.to->incoming.push_back(&edge);
308 edge.to->incomingEdgeWeight += edge.weight; 308 edge.to->incomingEdgeWeight += edge.weight;
309 } 309 }
310 } 310 }
311 311
312 // Finds and removes an edge from the list by doing a swap with the 312 // Finds and removes an edge from the list by doing a swap with the
313 // last element of the list. 313 // last element of the list.
314 void CCLayerSorter::removeEdgeFromList(GraphEdge* edge, std::vector<GraphEdge*>& list) 314 void LayerSorter::removeEdgeFromList(GraphEdge* edge, std::vector<GraphEdge*>& l ist)
315 { 315 {
316 std::vector<GraphEdge*>::iterator iter = std::find(list.begin(), list.end(), edge); 316 std::vector<GraphEdge*>::iterator iter = std::find(list.begin(), list.end(), edge);
317 ASSERT(iter != list.end()); 317 ASSERT(iter != list.end());
318 list.erase(iter); 318 list.erase(iter);
319 } 319 }
320 320
321 // Sorts the given list of layers such that they can be painted in a back-to-fro nt 321 // Sorts the given list of layers such that they can be painted in a back-to-fro nt
322 // order. Sorting produces correct results for non-intersecting layers that don' t have 322 // order. Sorting produces correct results for non-intersecting layers that don' t have
323 // cyclical order dependencies. Cycles and intersections are broken (somewhat) a ribtrarily. 323 // cyclical order dependencies. Cycles and intersections are broken (somewhat) a ribtrarily.
324 // Sorting of layers is done via a topological sort of a directed graph whose no des are 324 // Sorting of layers is done via a topological sort of a directed graph whose no des are
325 // the layers themselves. An edge from node A to node B signifies that layer A n eeds to 325 // the layers themselves. An edge from node A to node B signifies that layer A n eeds to
326 // be drawn before layer B. If A and B have no dependency between each other, th en we 326 // be drawn before layer B. If A and B have no dependency between each other, th en we
327 // preserve the ordering of those layers as they were in the original list. 327 // preserve the ordering of those layers as they were in the original list.
328 // 328 //
329 // The draw order between two layers is determined by projecting the two triangl es making 329 // The draw order between two layers is determined by projecting the two triangl es making
330 // up each layer quad to the Z = 0 plane, finding points of intersection between the triangles 330 // up each layer quad to the Z = 0 plane, finding points of intersection between the triangles
331 // and backprojecting those points to the plane of the layer to determine the co rresponding Z 331 // and backprojecting those points to the plane of the layer to determine the co rresponding Z
332 // coordinate. The layer with the lower Z coordinate (farther from the eye) need s to be rendered 332 // coordinate. The layer with the lower Z coordinate (farther from the eye) need s to be rendered
333 // first. 333 // first.
334 // 334 //
335 // If the layer projections don't intersect, then no edges (dependencies) are cr eated 335 // If the layer projections don't intersect, then no edges (dependencies) are cr eated
336 // between them in the graph. HOWEVER, in this case we still need to preserve th e ordering 336 // between them in the graph. HOWEVER, in this case we still need to preserve th e ordering
337 // of the original list of layers, since that list should already have proper z- index 337 // of the original list of layers, since that list should already have proper z- index
338 // ordering of layers. 338 // ordering of layers.
339 // 339 //
340 void CCLayerSorter::sort(LayerList::iterator first, LayerList::iterator last) 340 void LayerSorter::sort(LayerList::iterator first, LayerList::iterator last)
341 { 341 {
342 #if !defined( NDEBUG ) 342 #if !defined( NDEBUG )
343 LOG(CCLayerSorter, "Sorting start ----\n"); 343 LOG(LayerSorter, "Sorting start ----\n");
344 #endif 344 #endif
345 createGraphNodes(first, last); 345 createGraphNodes(first, last);
346 346
347 createGraphEdges(); 347 createGraphEdges();
348 348
349 std::vector<GraphNode*> sortedList; 349 std::vector<GraphNode*> sortedList;
350 std::deque<GraphNode*> noIncomingEdgeNodeList; 350 std::deque<GraphNode*> noIncomingEdgeNodeList;
351 351
352 // Find all the nodes that don't have incoming edges. 352 // Find all the nodes that don't have incoming edges.
353 for (NodeList::iterator la = m_nodes.begin(); la < m_nodes.end(); la++) { 353 for (NodeList::iterator la = m_nodes.begin(); la < m_nodes.end(); la++) {
354 if (!la->incoming.size()) 354 if (!la->incoming.size())
355 noIncomingEdgeNodeList.push_back(&(*la)); 355 noIncomingEdgeNodeList.push_back(&(*la));
356 } 356 }
357 357
358 #if !defined( NDEBUG ) 358 #if !defined( NDEBUG )
359 LOG(CCLayerSorter, "Sorted list: "); 359 LOG(LayerSorter, "Sorted list: ");
360 #endif 360 #endif
361 while (m_activeEdges.size() || noIncomingEdgeNodeList.size()) { 361 while (m_activeEdges.size() || noIncomingEdgeNodeList.size()) {
362 while (noIncomingEdgeNodeList.size()) { 362 while (noIncomingEdgeNodeList.size()) {
363 363
364 // It is necessary to preserve the existing ordering of layers, when there are 364 // It is necessary to preserve the existing ordering of layers, when there are
365 // no explicit dependencies (because this existing ordering has corr ect 365 // no explicit dependencies (because this existing ordering has corr ect
366 // z-index/layout ordering). To preserve this ordering, we process N odes in 366 // z-index/layout ordering). To preserve this ordering, we process N odes in
367 // the same order that they were added to the list. 367 // the same order that they were added to the list.
368 GraphNode* fromNode = noIncomingEdgeNodeList.front(); 368 GraphNode* fromNode = noIncomingEdgeNodeList.front();
369 noIncomingEdgeNodeList.pop_front(); 369 noIncomingEdgeNodeList.pop_front();
370 370
371 // Add it to the final list. 371 // Add it to the final list.
372 sortedList.push_back(fromNode); 372 sortedList.push_back(fromNode);
373 373
374 #if !defined( NDEBUG ) 374 #if !defined( NDEBUG )
375 LOG(CCLayerSorter, "%d, ", fromNode->layer->id()); 375 LOG(LayerSorter, "%d, ", fromNode->layer->id());
376 #endif 376 #endif
377 377
378 // Remove all its outgoing edges from the graph. 378 // Remove all its outgoing edges from the graph.
379 for (unsigned i = 0; i < fromNode->outgoing.size(); i++) { 379 for (unsigned i = 0; i < fromNode->outgoing.size(); i++) {
380 GraphEdge* outgoingEdge = fromNode->outgoing[i]; 380 GraphEdge* outgoingEdge = fromNode->outgoing[i];
381 381
382 m_activeEdges.erase(outgoingEdge); 382 m_activeEdges.erase(outgoingEdge);
383 removeEdgeFromList(outgoingEdge, outgoingEdge->to->incoming); 383 removeEdgeFromList(outgoingEdge, outgoingEdge->to->incoming);
384 outgoingEdge->to->incomingEdgeWeight -= outgoingEdge->weight; 384 outgoingEdge->to->incomingEdgeWeight -= outgoingEdge->weight;
385 385
(...skipping 24 matching lines...) Expand all
410 for (unsigned e = 0; e < nextNode->incoming.size(); e++) { 410 for (unsigned e = 0; e < nextNode->incoming.size(); e++) {
411 GraphEdge* incomingEdge = nextNode->incoming[e]; 411 GraphEdge* incomingEdge = nextNode->incoming[e];
412 412
413 m_activeEdges.erase(incomingEdge); 413 m_activeEdges.erase(incomingEdge);
414 removeEdgeFromList(incomingEdge, incomingEdge->from->outgoing); 414 removeEdgeFromList(incomingEdge, incomingEdge->from->outgoing);
415 } 415 }
416 nextNode->incoming.clear(); 416 nextNode->incoming.clear();
417 nextNode->incomingEdgeWeight = 0; 417 nextNode->incomingEdgeWeight = 0;
418 noIncomingEdgeNodeList.push_back(nextNode); 418 noIncomingEdgeNodeList.push_back(nextNode);
419 #if !defined( NDEBUG ) 419 #if !defined( NDEBUG )
420 LOG(CCLayerSorter, "Breaking cycle by cleaning up incoming edges from %d (weight = %f)\n", nextNode->layer->id(), minIncomingEdgeWeight); 420 LOG(LayerSorter, "Breaking cycle by cleaning up incoming edges from %d ( weight = %f)\n", nextNode->layer->id(), minIncomingEdgeWeight);
421 #endif 421 #endif
422 } 422 }
423 423
424 // Note: The original elements of the list are in no danger of having their ref count go to zero 424 // Note: The original elements of the list are in no danger of having their ref count go to zero
425 // here as they are all nodes of the layer hierarchy and are kept alive by t heir parent nodes. 425 // here as they are all nodes of the layer hierarchy and are kept alive by t heir parent nodes.
426 int count = 0; 426 int count = 0;
427 for (LayerList::iterator it = first; it < last; it++) 427 for (LayerList::iterator it = first; it < last; it++)
428 *it = sortedList[count++]->layer; 428 *it = sortedList[count++]->layer;
429 429
430 #if !defined( NDEBUG ) 430 #if !defined( NDEBUG )
431 LOG(CCLayerSorter, "Sorting end ----\n"); 431 LOG(LayerSorter, "Sorting end ----\n");
432 #endif 432 #endif
433 433
434 m_nodes.clear(); 434 m_nodes.clear();
435 m_edges.clear(); 435 m_edges.clear();
436 m_activeEdges.clear(); 436 m_activeEdges.clear();
437 } 437 }
438 438
439 } 439 }
OLDNEW
« cc/active_animation.h ('K') | « cc/layer_sorter.h ('k') | cc/layer_sorter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698