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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // if the layers are found to be intesecting (some features are in front and 83 // if the layers are found to be intesecting (some features are in front and
84 // some are behind). 84 // some are behind).
85 LayerSorter::ABCompareResult LayerSorter::CheckOverlap(LayerShape* a, 85 LayerSorter::ABCompareResult LayerSorter::CheckOverlap(LayerShape* a,
86 LayerShape* b, 86 LayerShape* b,
87 float z_threshold, 87 float z_threshold,
88 float* weight) { 88 float* weight) {
89 *weight = 0.f; 89 *weight = 0.f;
90 90
91 // Early out if the projected bounds don't overlap. 91 // Early out if the projected bounds don't overlap.
92 if (!a->projected_bounds.Intersects(b->projected_bounds)) 92 if (!a->projected_bounds.Intersects(b->projected_bounds))
93 return NONE; 93 return None;
94 94
95 gfx::PointF aPoints[4] = { a->projected_quad.p1(), 95 gfx::PointF aPoints[4] = { a->projected_quad.p1(),
96 a->projected_quad.p2(), 96 a->projected_quad.p2(),
97 a->projected_quad.p3(), 97 a->projected_quad.p3(),
98 a->projected_quad.p4() }; 98 a->projected_quad.p4() };
99 gfx::PointF bPoints[4] = { b->projected_quad.p1(), 99 gfx::PointF bPoints[4] = { b->projected_quad.p1(),
100 b->projected_quad.p2(), 100 b->projected_quad.p2(),
101 b->projected_quad.p3(), 101 b->projected_quad.p3(),
102 b->projected_quad.p4() }; 102 b->projected_quad.p4() };
103 103
(...skipping 12 matching lines...) Expand all
116 // edges. 116 // edges.
117 gfx::PointF r; 117 gfx::PointF r;
118 for (int ea = 0; ea < 4; ++ea) 118 for (int ea = 0; ea < 4; ++ea)
119 for (int eb = 0; eb < 4; ++eb) 119 for (int eb = 0; eb < 4; ++eb)
120 if (EdgeEdgeTest(aPoints[ea], aPoints[(ea + 1) % 4], 120 if (EdgeEdgeTest(aPoints[ea], aPoints[(ea + 1) % 4],
121 bPoints[eb], bPoints[(eb + 1) % 4], 121 bPoints[eb], bPoints[(eb + 1) % 4],
122 &r)) 122 &r))
123 overlap_points.push_back(r); 123 overlap_points.push_back(r);
124 124
125 if (overlap_points.empty()) 125 if (overlap_points.empty())
126 return NONE; 126 return None;
127 127
128 // Check the corresponding layer depth value for all overlap points to 128 // Check the corresponding layer depth value for all overlap points to
129 // determine which layer is in front. 129 // determine which layer is in front.
130 float max_positive = 0.f; 130 float max_positive = 0.f;
131 float max_negative = 0.f; 131 float max_negative = 0.f;
132 132
133 // This flag tracks the existance of a numerically accurate seperation 133 // This flag tracks the existance of a numerically accurate seperation
134 // between two layers. If there is no accurate seperation, the layers 134 // between two layers. If there is no accurate seperation, the layers
135 // cannot be effectively sorted. 135 // cannot be effectively sorted.
136 bool accurate = false; 136 bool accurate = false;
(...skipping 13 matching lines...) Expand all
150 150
151 float diff = za - zb; 151 float diff = za - zb;
152 if (diff > max_positive) 152 if (diff > max_positive)
153 max_positive = diff; 153 max_positive = diff;
154 if (diff < max_negative) 154 if (diff < max_negative)
155 max_negative = diff; 155 max_negative = diff;
156 } 156 }
157 157
158 // If we can't tell which should come first, we use document order. 158 // If we can't tell which should come first, we use document order.
159 if (!accurate) 159 if (!accurate)
160 return A_BEFORE_B; 160 return ABeforeB;
161 161
162 float max_diff = 162 float max_diff =
163 std::abs(max_positive) > std::abs(max_negative) ? 163 std::abs(max_positive) > std::abs(max_negative) ?
164 max_positive : max_negative; 164 max_positive : max_negative;
165 165
166 // If the results are inconsistent (and the z difference substantial to rule 166 // If the results are inconsistent (and the z difference substantial to rule
167 // out numerical errors) then the layers are intersecting. We will still 167 // out numerical errors) then the layers are intersecting. We will still
168 // return an order based on the maximum depth difference but with an edge 168 // return an order based on the maximum depth difference but with an edge
169 // weight of zero these layers will get priority if a graph cycle is present 169 // weight of zero these layers will get priority if a graph cycle is present
170 // and needs to be broken. 170 // and needs to be broken.
171 if (max_positive > z_threshold && max_negative < -z_threshold) 171 if (max_positive > z_threshold && max_negative < -z_threshold)
172 *weight = 0.f; 172 *weight = 0.f;
173 else 173 else
174 *weight = std::abs(max_diff); 174 *weight = std::abs(max_diff);
175 175
176 // Maintain relative order if the layers have the same depth at all 176 // Maintain relative order if the layers have the same depth at all
177 // intersection points. 177 // intersection points.
178 if (max_diff <= 0.f) 178 if (max_diff <= 0.f)
179 return A_BEFORE_B; 179 return ABeforeB;
180 180
181 return B_BEFORE_A; 181 return BBeforeA;
182 } 182 }
183 183
184 LayerShape::LayerShape() {} 184 LayerShape::LayerShape() {}
185 185
186 LayerShape::LayerShape(float width, 186 LayerShape::LayerShape(float width,
187 float height, 187 float height,
188 const gfx::Transform& draw_transform) { 188 const gfx::Transform& draw_transform) {
189 gfx::QuadF layer_quad(gfx::RectF(0.f, 0.f, width, height)); 189 gfx::QuadF layer_quad(gfx::RectF(0.f, 0.f, width, height));
190 190
191 // Compute the projection of the layer quad onto the z = 0 plane. 191 // Compute the projection of the layer quad onto the z = 0 plane.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = NULL;
322 GraphNode* end_node = NULL; 322 GraphNode* end_node = NULL;
323 if (overlap_result == A_BEFORE_B) { 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 == B_BEFORE_A) { 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();
333 edges_.push_back(GraphEdge(start_node, end_node, weight)); 333 edges_.push_back(GraphEdge(start_node, end_node, weight));
334 } 334 }
335 } 335 }
336 } 336 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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