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

Side by Side Diff: cc/layers/picture_layer_unittest.cc

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase Created 4 years, 3 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/layers/picture_layer.cc ('k') | cc/layers/surface_layer_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 FakeLayerTreeHostClient host_client; 235 FakeLayerTreeHostClient host_client;
236 TestTaskGraphRunner task_graph_runner; 236 TestTaskGraphRunner task_graph_runner;
237 std::unique_ptr<FakeLayerTreeHost> host = 237 std::unique_ptr<FakeLayerTreeHost> host =
238 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); 238 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
239 host->GetLayerTree()->SetRootLayer(layer); 239 host->GetLayerTree()->SetRootLayer(layer);
240 layer->SetIsDrawable(true); 240 layer->SetIsDrawable(true);
241 layer->SavePaintProperties(); 241 layer->SavePaintProperties();
242 layer->Update(); 242 layer->Update();
243 243
244 EXPECT_EQ(0, host->source_frame_number()); 244 EXPECT_EQ(0, host->SourceFrameNumber());
245 host->CommitComplete(); 245 host->CommitComplete();
246 EXPECT_EQ(1, host->source_frame_number()); 246 EXPECT_EQ(1, host->SourceFrameNumber());
247 247
248 layer->SetBounds(gfx::Size(0, 0)); 248 layer->SetBounds(gfx::Size(0, 0));
249 layer->SavePaintProperties(); 249 layer->SavePaintProperties();
250 // Intentionally skipping Update since it would normally be skipped on 250 // Intentionally skipping Update since it would normally be skipped on
251 // a layer with empty bounds. 251 // a layer with empty bounds.
252 252
253 FakeImplTaskRunnerProvider impl_task_runner_provider; 253 FakeImplTaskRunnerProvider impl_task_runner_provider;
254 254
255 TestSharedBitmapManager shared_bitmap_manager; 255 TestSharedBitmapManager shared_bitmap_manager;
256 std::unique_ptr<FakeOutputSurface> output_surface = 256 std::unique_ptr<FakeOutputSurface> output_surface =
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 FakeLayerTreeHostClient host_client; 370 FakeLayerTreeHostClient host_client;
371 TestTaskGraphRunner task_graph_runner; 371 TestTaskGraphRunner task_graph_runner;
372 std::unique_ptr<FakeLayerTreeHost> host = 372 std::unique_ptr<FakeLayerTreeHost> host =
373 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); 373 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
374 host->GetLayerTree()->SetRootLayer(layer); 374 host->GetLayerTree()->SetRootLayer(layer);
375 layer->SetIsDrawable(true); 375 layer->SetIsDrawable(true);
376 layer->SavePaintProperties(); 376 layer->SavePaintProperties();
377 layer->Update(); 377 layer->Update();
378 378
379 EXPECT_EQ(0, host->source_frame_number()); 379 EXPECT_EQ(0, host->SourceFrameNumber());
380 host->CommitComplete(); 380 host->CommitComplete();
381 EXPECT_EQ(1, host->source_frame_number()); 381 EXPECT_EQ(1, host->SourceFrameNumber());
382 382
383 layer->SavePaintProperties(); 383 layer->SavePaintProperties();
384 layer->Update(); 384 layer->Update();
385 385
386 FakeImplTaskRunnerProvider impl_task_runner_provider; 386 FakeImplTaskRunnerProvider impl_task_runner_provider;
387 387
388 TestSharedBitmapManager shared_bitmap_manager; 388 TestSharedBitmapManager shared_bitmap_manager;
389 std::unique_ptr<OutputSurface> output_surface( 389 std::unique_ptr<OutputSurface> output_surface(
390 FakeOutputSurface::CreateDelegating3d()); 390 FakeOutputSurface::CreateDelegating3d());
391 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting(); 391 LayerTreeSettings layer_tree_settings = LayerTreeSettingsForTesting();
392 layer_tree_settings.image_decode_tasks_enabled = true; 392 layer_tree_settings.image_decode_tasks_enabled = true;
393 FakeLayerTreeHostImpl host_impl(layer_tree_settings, 393 FakeLayerTreeHostImpl host_impl(layer_tree_settings,
394 &impl_task_runner_provider, 394 &impl_task_runner_provider,
395 &shared_bitmap_manager, &task_graph_runner); 395 &shared_bitmap_manager, &task_graph_runner);
396 host_impl.SetVisible(true); 396 host_impl.SetVisible(true);
397 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 397 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get()));
398 398
399 host_impl.CreatePendingTree(); 399 host_impl.CreatePendingTree();
400 host_impl.pending_tree()->SetRootLayerForTesting( 400 host_impl.pending_tree()->SetRootLayerForTesting(
401 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1)); 401 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1));
402 host_impl.pending_tree()->BuildLayerListForTesting(); 402 host_impl.pending_tree()->BuildLayerListForTesting();
403 403
404 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>( 404 FakePictureLayerImpl* layer_impl = static_cast<FakePictureLayerImpl*>(
405 host_impl.pending_tree()->root_layer_for_testing()); 405 host_impl.pending_tree()->root_layer_for_testing());
406 406
407 layer->PushPropertiesTo(layer_impl); 407 layer->PushPropertiesTo(layer_impl);
408 408
409 host->CommitComplete(); 409 host->CommitComplete();
410 EXPECT_EQ(2, host->source_frame_number()); 410 EXPECT_EQ(2, host->SourceFrameNumber());
411 411
412 host_impl.ActivateSyncTree(); 412 host_impl.ActivateSyncTree();
413 413
414 // By updating the draw proprties on the active tree, we will set the viewport 414 // By updating the draw proprties on the active tree, we will set the viewport
415 // rect for tile priorities to something non-empty. 415 // rect for tile priorities to something non-empty.
416 const bool can_use_lcd_text = false; 416 const bool can_use_lcd_text = false;
417 host_impl.active_tree()->BuildPropertyTreesForTesting(); 417 host_impl.active_tree()->BuildPropertyTreesForTesting();
418 host_impl.active_tree()->UpdateDrawProperties(can_use_lcd_text); 418 host_impl.active_tree()->UpdateDrawProperties(can_use_lcd_text);
419 419
420 layer->SetBounds(gfx::Size(11, 11)); 420 layer->SetBounds(gfx::Size(11, 11));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 host2->SetVisible(true); 524 host2->SetVisible(true);
525 host_client2.SetLayerTreeHost(host2.get()); 525 host_client2.SetLayerTreeHost(host2.get());
526 526
527 // The PictureLayer is put in one LayerTreeHost. 527 // The PictureLayer is put in one LayerTreeHost.
528 host1->GetLayerTree()->SetRootLayer(layer); 528 host1->GetLayerTree()->SetRootLayer(layer);
529 // Do a main frame, record the picture layers. 529 // Do a main frame, record the picture layers.
530 EXPECT_EQ(0, layer->update_count()); 530 EXPECT_EQ(0, layer->update_count());
531 layer->SetNeedsDisplay(); 531 layer->SetNeedsDisplay();
532 host1->Composite(base::TimeTicks::Now()); 532 host1->Composite(base::TimeTicks::Now());
533 EXPECT_EQ(1, layer->update_count()); 533 EXPECT_EQ(1, layer->update_count());
534 EXPECT_EQ(1, host1->source_frame_number()); 534 EXPECT_EQ(1, host1->SourceFrameNumber());
535 535
536 // The source frame number in |host1| is now higher than host2. 536 // The source frame number in |host1| is now higher than host2.
537 layer->SetNeedsDisplay(); 537 layer->SetNeedsDisplay();
538 host1->Composite(base::TimeTicks::Now()); 538 host1->Composite(base::TimeTicks::Now());
539 EXPECT_EQ(2, layer->update_count()); 539 EXPECT_EQ(2, layer->update_count());
540 EXPECT_EQ(2, host1->source_frame_number()); 540 EXPECT_EQ(2, host1->SourceFrameNumber());
541 541
542 // Then moved to another LayerTreeHost. 542 // Then moved to another LayerTreeHost.
543 host1->GetLayerTree()->SetRootLayer(nullptr); 543 host1->GetLayerTree()->SetRootLayer(nullptr);
544 host2->GetLayerTree()->SetRootLayer(layer); 544 host2->GetLayerTree()->SetRootLayer(layer);
545 545
546 // Do a main frame, record the picture layers. The frame number has changed 546 // Do a main frame, record the picture layers. The frame number has changed
547 // non-monotonically. 547 // non-monotonically.
548 layer->SetNeedsDisplay(); 548 layer->SetNeedsDisplay();
549 host2->Composite(base::TimeTicks::Now()); 549 host2->Composite(base::TimeTicks::Now());
550 EXPECT_EQ(3, layer->update_count()); 550 EXPECT_EQ(3, layer->update_count());
551 EXPECT_EQ(1, host2->source_frame_number()); 551 EXPECT_EQ(1, host2->SourceFrameNumber());
552 } 552 }
553 553
554 } // namespace 554 } // namespace
555 } // namespace cc 555 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/layers/surface_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698