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

Side by Side Diff: cc/layer_sorter.cc

Issue 11362024: added fix that deals with precision in layer sorter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | « no previous file | cc/layer_sorter_unittest.cc » ('j') | cc/layer_sorter_unittest.cc » ('J')
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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_sorter.h" 7 #include "cc/layer_sorter.h"
8 8
9 #include <deque> 9 #include <deque>
10 #include <limits> 10 #include <limits>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 r)) 107 r))
108 overlapPoints.push_back(r); 108 overlapPoints.push_back(r);
109 109
110 if (overlapPoints.empty()) 110 if (overlapPoints.empty())
111 return None; 111 return None;
112 112
113 // Check the corresponding layer depth value for all overlap points to deter mine 113 // Check the corresponding layer depth value for all overlap points to deter mine
114 // which layer is in front. 114 // which layer is in front.
115 float maxPositive = 0; 115 float maxPositive = 0;
116 float maxNegative = 0; 116 float maxNegative = 0;
117
118 // flag to tell us if we've computed an accurate (w.r.t. floating point) ans wer
danakj 2012/11/01 20:15:33 All comments should be complete sentences with cap
119 bool accurate = false;
117 for (unsigned o = 0; o < overlapPoints.size(); o++) { 120 for (unsigned o = 0; o < overlapPoints.size(); o++) {
118 float za = a->layerZFromProjectedPoint(overlapPoints[o]); 121 float za = a->layerZFromProjectedPoint(overlapPoints[o]);
119 float zb = b->layerZFromProjectedPoint(overlapPoints[o]); 122 float zb = b->layerZFromProjectedPoint(overlapPoints[o]);
120 123
124 // attempt to avoid issues with layers that are too close together
125 // if we have 2-sided quads that are very close together then we draw th em
enne (OOO) 2012/11/01 20:08:55 style nit: cc code doesn't obey the Chromium 80 co
126 // in the order they arrived in to avoid z-fighting flickering
127 // The correct solution is for the content maker to turn on back-face cu lling
128 // or move the quads apart (if they're not two sides of one object)
129 float absdif = fabsf(zb - za);
130 float absmax = fmax(fabs(zb), fabs(za));
enne (OOO) 2012/11/01 20:08:55 style nit: Can you match the variable style in thi
131 // check to see if we've got a result with a reasonable amount of error
132 if (absdif > 1e-4 * absmax)
enne (OOO) 2012/11/01 20:08:55 Can you pull this constant out into a named variab
133 accurate = true;
134
121 float diff = za - zb; 135 float diff = za - zb;
122 if (diff > maxPositive) 136 if (diff > maxPositive)
123 maxPositive = diff; 137 maxPositive = diff;
124 if (diff < maxNegative) 138 if (diff < maxNegative)
125 maxNegative = diff; 139 maxNegative = diff;
126 } 140 }
127 141
142 // if we can't tell which should come first, use document order
143 if (!accurate)
144 return ABeforeB;
145
128 float maxDiff = (fabsf(maxPositive) > fabsf(maxNegative) ? maxPositive : max Negative); 146 float maxDiff = (fabsf(maxPositive) > fabsf(maxNegative) ? maxPositive : max Negative);
129 147
130 // If the results are inconsistent (and the z difference substantial to rule out 148 // If the results are inconsistent (and the z difference substantial to rule out
131 // numerical errors) then the layers are intersecting. We will still return an 149 // numerical errors) then the layers are intersecting. We will still return an
132 // order based on the maximum depth difference but with an edge weight of ze ro 150 // order based on the maximum depth difference but with an edge weight of ze ro
133 // these layers will get priority if a graph cycle is present and needs to b e broken. 151 // these layers will get priority if a graph cycle is present and needs to b e broken.
134 if (maxPositive > zThreshold && maxNegative < -zThreshold) 152 if (maxPositive > zThreshold && maxNegative < -zThreshold)
135 weight = 0; 153 weight = 0;
136 else 154 else
137 weight = fabsf(maxDiff); 155 weight = fabsf(maxDiff);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 *it = sortedList[count++]->layer; 421 *it = sortedList[count++]->layer;
404 422
405 DVLOG(2) << "Sorting end ----"; 423 DVLOG(2) << "Sorting end ----";
406 424
407 m_nodes.clear(); 425 m_nodes.clear();
408 m_edges.clear(); 426 m_edges.clear();
409 m_activeEdges.clear(); 427 m_activeEdges.clear();
410 } 428 }
411 429
412 } 430 }
OLDNEW
« no previous file with comments | « no previous file | cc/layer_sorter_unittest.cc » ('j') | cc/layer_sorter_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698