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

Side by Side Diff: cc/layer_sorter_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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/layer_sorter.cc ('k') | cc/layer_tree_host.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/layer_sorter.h" 5 #include "cc/layer_sorter.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 #include "cc/math_util.h" 8 #include "cc/math_util.h"
9 #include "cc/single_thread_proxy.h" 9 #include "cc/single_thread_proxy.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Expected output: [3, 4, 1, 2, 5]. 205 // Expected output: [3, 4, 1, 2, 5].
206 // - 1, 2, and 5 do not have a 3d z difference, and therefore their 206 // - 1, 2, and 5 do not have a 3d z difference, and therefore their
207 // relative ordering should be retained. 207 // relative ordering should be retained.
208 // - 3 and 4 do not have a 3d z difference, and therefore their relative 208 // - 3 and 4 do not have a 3d z difference, and therefore their relative
209 // ordering should be retained. 209 // ordering should be retained.
210 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. 210 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5.
211 211
212 FakeImplProxy proxy; 212 FakeImplProxy proxy;
213 FakeLayerTreeHostImpl host_impl(&proxy); 213 FakeLayerTreeHostImpl host_impl(&proxy);
214 214
215 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(host_impl.activeTree(), 1); 215 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.activeTree(), 1);
216 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(host_impl.activeTree(), 2); 216 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.activeTree(), 2);
217 scoped_ptr<LayerImpl> layer3 = LayerImpl::create(host_impl.activeTree(), 3); 217 scoped_ptr<LayerImpl> layer3 = LayerImpl::Create(host_impl.activeTree(), 3);
218 scoped_ptr<LayerImpl> layer4 = LayerImpl::create(host_impl.activeTree(), 4); 218 scoped_ptr<LayerImpl> layer4 = LayerImpl::Create(host_impl.activeTree(), 4);
219 scoped_ptr<LayerImpl> layer5 = LayerImpl::create(host_impl.activeTree(), 5); 219 scoped_ptr<LayerImpl> layer5 = LayerImpl::Create(host_impl.activeTree(), 5);
220 220
221 gfx::Transform BehindMatrix; 221 gfx::Transform BehindMatrix;
222 BehindMatrix.Translate3d(0.0, 0.0, 2.0); 222 BehindMatrix.Translate3d(0.0, 0.0, 2.0);
223 gfx::Transform FrontMatrix; 223 gfx::Transform FrontMatrix;
224 FrontMatrix.Translate3d(0.0, 0.0, 1.0); 224 FrontMatrix.Translate3d(0.0, 0.0, 1.0);
225 225
226 layer1->setBounds(gfx::Size(10, 10)); 226 layer1->SetBounds(gfx::Size(10, 10));
227 layer1->setContentBounds(gfx::Size(10, 10)); 227 layer1->SetContentBounds(gfx::Size(10, 10));
228 layer1->drawProperties().target_space_transform = BehindMatrix; 228 layer1->draw_properties().target_space_transform = BehindMatrix;
229 layer1->setDrawsContent(true); 229 layer1->SetDrawsContent(true);
230 230
231 layer2->setBounds(gfx::Size(20, 20)); 231 layer2->SetBounds(gfx::Size(20, 20));
232 layer2->setContentBounds(gfx::Size(20, 20)); 232 layer2->SetContentBounds(gfx::Size(20, 20));
233 layer2->drawProperties().target_space_transform = BehindMatrix; 233 layer2->draw_properties().target_space_transform = BehindMatrix;
234 layer2->setDrawsContent(true); 234 layer2->SetDrawsContent(true);
235 235
236 layer3->setBounds(gfx::Size(30, 30)); 236 layer3->SetBounds(gfx::Size(30, 30));
237 layer3->setContentBounds(gfx::Size(30, 30)); 237 layer3->SetContentBounds(gfx::Size(30, 30));
238 layer3->drawProperties().target_space_transform = FrontMatrix; 238 layer3->draw_properties().target_space_transform = FrontMatrix;
239 layer3->setDrawsContent(true); 239 layer3->SetDrawsContent(true);
240 240
241 layer4->setBounds(gfx::Size(40, 40)); 241 layer4->SetBounds(gfx::Size(40, 40));
242 layer4->setContentBounds(gfx::Size(40, 40)); 242 layer4->SetContentBounds(gfx::Size(40, 40));
243 layer4->drawProperties().target_space_transform = FrontMatrix; 243 layer4->draw_properties().target_space_transform = FrontMatrix;
244 layer4->setDrawsContent(true); 244 layer4->SetDrawsContent(true);
245 245
246 layer5->setBounds(gfx::Size(50, 50)); 246 layer5->SetBounds(gfx::Size(50, 50));
247 layer5->setContentBounds(gfx::Size(50, 50)); 247 layer5->SetContentBounds(gfx::Size(50, 50));
248 layer5->drawProperties().target_space_transform = BehindMatrix; 248 layer5->draw_properties().target_space_transform = BehindMatrix;
249 layer5->setDrawsContent(true); 249 layer5->SetDrawsContent(true);
250 250
251 std::vector<LayerImpl*> layer_list; 251 std::vector<LayerImpl*> layer_list;
252 layer_list.push_back(layer1.get()); 252 layer_list.push_back(layer1.get());
253 layer_list.push_back(layer2.get()); 253 layer_list.push_back(layer2.get());
254 layer_list.push_back(layer3.get()); 254 layer_list.push_back(layer3.get());
255 layer_list.push_back(layer4.get()); 255 layer_list.push_back(layer4.get());
256 layer_list.push_back(layer5.get()); 256 layer_list.push_back(layer5.get());
257 257
258 ASSERT_EQ(5u, layer_list.size()); 258 ASSERT_EQ(5u, layer_list.size());
259 EXPECT_EQ(1, layer_list[0]->id()); 259 EXPECT_EQ(1, layer_list[0]->id());
(...skipping 10 matching lines...) Expand all
270 EXPECT_EQ(4, layer_list[1]->id()); 270 EXPECT_EQ(4, layer_list[1]->id());
271 EXPECT_EQ(1, layer_list[2]->id()); 271 EXPECT_EQ(1, layer_list[2]->id());
272 EXPECT_EQ(2, layer_list[3]->id()); 272 EXPECT_EQ(2, layer_list[3]->id());
273 EXPECT_EQ(5, layer_list[4]->id()); 273 EXPECT_EQ(5, layer_list[4]->id());
274 } 274 }
275 275
276 TEST(LayerSorterTest, VerifyConcidentLayerPrecisionLossResultsInDocumentOrder) { 276 TEST(LayerSorterTest, VerifyConcidentLayerPrecisionLossResultsInDocumentOrder) {
277 FakeImplProxy proxy; 277 FakeImplProxy proxy;
278 FakeLayerTreeHostImpl host_impl(&proxy); 278 FakeLayerTreeHostImpl host_impl(&proxy);
279 279
280 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(host_impl.activeTree(), 1); 280 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.activeTree(), 1);
281 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(host_impl.activeTree(), 2); 281 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.activeTree(), 2);
282 282
283 // Layer 1 should occur before layer 2 in paint. However, due to numeric 283 // Layer 1 should occur before layer 2 in paint. However, due to numeric
284 // issues in the sorter, it will put the layers in the wrong order 284 // issues in the sorter, it will put the layers in the wrong order
285 // in some situations. Here we test a patch that results in document 285 // in some situations. Here we test a patch that results in document
286 // order rather than calculated order when numeric percision is suspect 286 // order rather than calculated order when numeric percision is suspect
287 // in calculated order. 287 // in calculated order.
288 288
289 gfx::Transform BehindMatrix; 289 gfx::Transform BehindMatrix;
290 BehindMatrix.Translate3d(0.0, 0.0, 0.999999); 290 BehindMatrix.Translate3d(0.0, 0.0, 0.999999);
291 BehindMatrix.RotateAboutXAxis(38.5); 291 BehindMatrix.RotateAboutXAxis(38.5);
292 BehindMatrix.RotateAboutYAxis(77.0); 292 BehindMatrix.RotateAboutYAxis(77.0);
293 gfx::Transform FrontMatrix; 293 gfx::Transform FrontMatrix;
294 FrontMatrix.Translate3d(0, 0, 1.0); 294 FrontMatrix.Translate3d(0, 0, 1.0);
295 FrontMatrix.RotateAboutXAxis(38.5); 295 FrontMatrix.RotateAboutXAxis(38.5);
296 FrontMatrix.RotateAboutYAxis(77.0); 296 FrontMatrix.RotateAboutYAxis(77.0);
297 297
298 layer1->setBounds(gfx::Size(10, 10)); 298 layer1->SetBounds(gfx::Size(10, 10));
299 layer1->setContentBounds(gfx::Size(10, 10)); 299 layer1->SetContentBounds(gfx::Size(10, 10));
300 layer1->drawProperties().target_space_transform = BehindMatrix; 300 layer1->draw_properties().target_space_transform = BehindMatrix;
301 layer1->setDrawsContent(true); 301 layer1->SetDrawsContent(true);
302 302
303 layer2->setBounds(gfx::Size(10, 10)); 303 layer2->SetBounds(gfx::Size(10, 10));
304 layer2->setContentBounds(gfx::Size(10, 10)); 304 layer2->SetContentBounds(gfx::Size(10, 10));
305 layer2->drawProperties().target_space_transform = FrontMatrix; 305 layer2->draw_properties().target_space_transform = FrontMatrix;
306 layer2->setDrawsContent(true); 306 layer2->SetDrawsContent(true);
307 307
308 std::vector<LayerImpl*> layer_list; 308 std::vector<LayerImpl*> layer_list;
309 layer_list.push_back(layer1.get()); 309 layer_list.push_back(layer1.get());
310 layer_list.push_back(layer2.get()); 310 layer_list.push_back(layer2.get());
311 311
312 ASSERT_EQ(2u, layer_list.size()); 312 ASSERT_EQ(2u, layer_list.size());
313 EXPECT_EQ(1, layer_list[0]->id()); 313 EXPECT_EQ(1, layer_list[0]->id());
314 EXPECT_EQ(2, layer_list[1]->id()); 314 EXPECT_EQ(2, layer_list[1]->id());
315 315
316 LayerSorter layer_sorter; 316 LayerSorter layer_sorter;
317 layer_sorter.Sort(layer_list.begin(), layer_list.end()); 317 layer_sorter.Sort(layer_list.begin(), layer_list.end());
318 318
319 ASSERT_EQ(2u, layer_list.size()); 319 ASSERT_EQ(2u, layer_list.size());
320 EXPECT_EQ(1, layer_list[0]->id()); 320 EXPECT_EQ(1, layer_list[0]->id());
321 EXPECT_EQ(2, layer_list[1]->id()); 321 EXPECT_EQ(2, layer_list[1]->id());
322 } 322 }
323 323
324 } // namespace 324 } // namespace
325 } // namespace cc 325 } // namespace cc
326 326
OLDNEW
« no previous file with comments | « cc/layer_sorter.cc ('k') | cc/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698