Chromium Code Reviews| Index: cc/layer_sorter.cc |
| diff --git a/cc/layer_sorter.cc b/cc/layer_sorter.cc |
| index ef347dbe55b41f6ead7b16d804cda08d461477ed..8603b96c94db4b0ff0321616bf33fcfad6a0e31c 100644 |
| --- a/cc/layer_sorter.cc |
| +++ b/cc/layer_sorter.cc |
| @@ -114,10 +114,24 @@ LayerSorter::ABCompareResult LayerSorter::checkOverlap(LayerShape* a, LayerShape |
| // which layer is in front. |
| float maxPositive = 0; |
| float maxNegative = 0; |
| + |
| + // flag to tell us if we've computed an accurate (w.r.t. floating point) answer |
|
danakj
2012/11/01 20:15:33
All comments should be complete sentences with cap
|
| + bool accurate = false; |
| for (unsigned o = 0; o < overlapPoints.size(); o++) { |
| float za = a->layerZFromProjectedPoint(overlapPoints[o]); |
| float zb = b->layerZFromProjectedPoint(overlapPoints[o]); |
| + // attempt to avoid issues with layers that are too close together |
| + // if we have 2-sided quads that are very close together then we draw them |
|
enne (OOO)
2012/11/01 20:08:55
style nit: cc code doesn't obey the Chromium 80 co
|
| + // in the order they arrived in to avoid z-fighting flickering |
| + // The correct solution is for the content maker to turn on back-face culling |
| + // or move the quads apart (if they're not two sides of one object) |
| + float absdif = fabsf(zb - za); |
| + 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
|
| + // check to see if we've got a result with a reasonable amount of error |
| + if (absdif > 1e-4 * absmax) |
|
enne (OOO)
2012/11/01 20:08:55
Can you pull this constant out into a named variab
|
| + accurate = true; |
| + |
| float diff = za - zb; |
| if (diff > maxPositive) |
| maxPositive = diff; |
| @@ -125,6 +139,10 @@ LayerSorter::ABCompareResult LayerSorter::checkOverlap(LayerShape* a, LayerShape |
| maxNegative = diff; |
| } |
| + // if we can't tell which should come first, use document order |
| + if (!accurate) |
| + return ABeforeB; |
| + |
| float maxDiff = (fabsf(maxPositive) > fabsf(maxNegative) ? maxPositive : maxNegative); |
| // If the results are inconsistent (and the z difference substantial to rule out |