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

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

Issue 475633008: cc: Use impl-side painting in LTH context lost tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update tests to use PictureLayers along with Content. Created 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/delegated_frame_provider.h" 9 #include "cc/layers/delegated_frame_provider.h"
10 #include "cc/layers/delegated_frame_resource_collection.h" 10 #include "cc/layers/delegated_frame_resource_collection.h"
11 #include "cc/layers/heads_up_display_layer.h" 11 #include "cc/layers/heads_up_display_layer.h"
12 #include "cc/layers/io_surface_layer.h" 12 #include "cc/layers/io_surface_layer.h"
13 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
14 #include "cc/layers/painted_scrollbar_layer.h" 14 #include "cc/layers/painted_scrollbar_layer.h"
15 #include "cc/layers/picture_layer.h" 15 #include "cc/layers/picture_layer.h"
16 #include "cc/layers/texture_layer.h" 16 #include "cc/layers/texture_layer.h"
17 #include "cc/layers/texture_layer_impl.h" 17 #include "cc/layers/texture_layer_impl.h"
18 #include "cc/layers/video_layer.h" 18 #include "cc/layers/video_layer.h"
19 #include "cc/layers/video_layer_impl.h" 19 #include "cc/layers/video_layer_impl.h"
20 #include "cc/output/filter_operations.h" 20 #include "cc/output/filter_operations.h"
21 #include "cc/test/fake_content_layer.h" 21 #include "cc/test/fake_content_layer.h"
22 #include "cc/test/fake_content_layer_client.h" 22 #include "cc/test/fake_content_layer_client.h"
23 #include "cc/test/fake_content_layer_impl.h" 23 #include "cc/test/fake_content_layer_impl.h"
24 #include "cc/test/fake_delegated_renderer_layer.h" 24 #include "cc/test/fake_delegated_renderer_layer.h"
25 #include "cc/test/fake_delegated_renderer_layer_impl.h" 25 #include "cc/test/fake_delegated_renderer_layer_impl.h"
26 #include "cc/test/fake_layer_tree_host_client.h" 26 #include "cc/test/fake_layer_tree_host_client.h"
27 #include "cc/test/fake_output_surface.h" 27 #include "cc/test/fake_output_surface.h"
28 #include "cc/test/fake_output_surface_client.h" 28 #include "cc/test/fake_output_surface_client.h"
29 #include "cc/test/fake_painted_scrollbar_layer.h" 29 #include "cc/test/fake_painted_scrollbar_layer.h"
30 #include "cc/test/fake_picture_layer.h"
31 #include "cc/test/fake_picture_layer_impl.h"
30 #include "cc/test/fake_scoped_ui_resource.h" 32 #include "cc/test/fake_scoped_ui_resource.h"
31 #include "cc/test/fake_scrollbar.h" 33 #include "cc/test/fake_scrollbar.h"
32 #include "cc/test/fake_video_frame_provider.h" 34 #include "cc/test/fake_video_frame_provider.h"
33 #include "cc/test/layer_tree_test.h" 35 #include "cc/test/layer_tree_test.h"
34 #include "cc/test/render_pass_test_common.h" 36 #include "cc/test/render_pass_test_common.h"
35 #include "cc/test/test_context_provider.h" 37 #include "cc/test/test_context_provider.h"
36 #include "cc/test/test_shared_bitmap_manager.h" 38 #include "cc/test/test_shared_bitmap_manager.h"
37 #include "cc/test/test_web_graphics_context_3d.h" 39 #include "cc/test/test_web_graphics_context_3d.h"
38 #include "cc/trees/layer_tree_host_impl.h" 40 #include "cc/trees/layer_tree_host_impl.h"
39 #include "cc/trees/layer_tree_impl.h" 41 #include "cc/trees/layer_tree_impl.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 309
308 virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); } 310 virtual void DidInitializeOutputSurface() OVERRIDE { EXPECT_TRUE(false); }
309 311
310 virtual void AfterTest() OVERRIDE { 312 virtual void AfterTest() OVERRIDE {
311 } 313 }
312 }; 314 };
313 315
314 SINGLE_AND_MULTI_THREAD_TEST_F( 316 SINGLE_AND_MULTI_THREAD_TEST_F(
315 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); 317 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
316 318
317 class LayerTreeHostContextTestLostContextSucceedsWithContent 319 class LayerTreeHostContextTestLostContextSucceedsWithContentAndImpl
danakj 2014/08/26 18:54:41 leave the test name
sohanjg 2014/08/27 06:59:50 Done.
318 : public LayerTreeHostContextTestLostContextSucceeds { 320 : public LayerTreeHostContextTestLostContextSucceeds {
319 public: 321 public:
320 virtual void SetupTree() OVERRIDE { 322 virtual void SetupTree() OVERRIDE {
321 root_ = Layer::Create(); 323 root_ = Layer::Create();
322 root_->SetBounds(gfx::Size(10, 10)); 324 root_->SetBounds(gfx::Size(10, 10));
323 root_->SetIsDrawable(true); 325 root_->SetIsDrawable(true);
324 326
325 content_ = FakeContentLayer::Create(&client_); 327 if (layer_tree_host()->settings().impl_side_painting)
326 content_->SetBounds(gfx::Size(10, 10)); 328 layer_ = PictureLayer::Create(&client_);
danakj 2014/08/26 18:54:41 FakePictureLayer
sohanjg 2014/08/27 06:59:50 Done.
327 content_->SetIsDrawable(true); 329 else
330 layer_ = ContentLayer::Create(&client_);
danakj 2014/08/26 18:54:41 You mean FakeContentLayer
sohanjg 2014/08/27 06:59:49 Done.
331 layer_->SetBounds(gfx::Size(10, 10));
332 layer_->SetIsDrawable(true);
328 333
329 root_->AddChild(content_); 334 root_->AddChild(layer_);
330 335
331 layer_tree_host()->SetRootLayer(root_); 336 layer_tree_host()->SetRootLayer(root_);
332 LayerTreeHostContextTest::SetupTree(); 337 LayerTreeHostContextTest::SetupTree();
333 } 338 }
334 339
335 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { 340 virtual void InvalidateAndSetNeedsCommit() OVERRIDE {
336 // Invalidate the render surface so we don't try to use a cached copy of the 341 // Invalidate the render surface so we don't try to use a cached copy of the
337 // surface. We want to make sure to test the drawing paths for drawing to 342 // surface. We want to make sure to test the drawing paths for drawing to
338 // a child surface. 343 // a child surface.
339 content_->SetNeedsDisplay(); 344 layer_->SetNeedsDisplay();
340 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); 345 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit();
341 } 346 }
342 347
343 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 348 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
344 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( 349 if (layer_tree_host()->settings().impl_side_painting) {
345 host_impl->active_tree()->root_layer()->children()[0]); 350 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>(
346 // Even though the context was lost, we should have a resource. The 351 host_impl->active_tree()->root_layer()->children()[0]);
347 // TestWebGraphicsContext3D ensures that this resource is created with 352 // Even though the context was lost, we should have valid tile
348 // the active context. 353 // priorities.
349 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); 354 EXPECT_TRUE(picture_impl->HasValidTilePriorities());
sohanjg 2014/08/26 09:36:47 hope this is the closest to having resource for ti
danakj 2014/08/26 18:54:40 picture_impl->HighResTiling()->TileAt(0, 0)->HasRe
sohanjg 2014/08/27 06:59:50 yea! but i think for impl-side paint, can we be su
danakj 2014/08/27 12:59:26 It should not activate and draw without a resource
sohanjg 2014/08/27 13:33:01 Hmm. picture_impl->HighResTiling()->TileAt(0, 0)->
danakj 2014/08/27 13:49:32 That sounds wrong, does it do this every time it d
sohanjg 2014/08/27 14:13:34 DrawLayersOnThread is always having no resource, i
sohanjg 2014/09/01 10:51:28 Sorry for the late response. For tests we use soli
danakj 2014/09/03 19:51:40 Oh, maybe we need to make the client_ draw somethi
355 } else {
356 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>(
357 host_impl->active_tree()->root_layer()->children()[0]);
358 // Even though the context was lost, we should have a resource. The
359 // TestWebGraphicsContext3D ensures that this resource is created with
360 // the active context.
361 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0));
362 }
350 } 363 }
351 364
352 protected: 365 protected:
353 FakeContentLayerClient client_; 366 FakeContentLayerClient client_;
354 scoped_refptr<Layer> root_; 367 scoped_refptr<Layer> root_;
355 scoped_refptr<ContentLayer> content_; 368 scoped_refptr<Layer> layer_;
356 }; 369 };
357 370
358 // This test uses TiledLayer to check for a working context. 371 // This test uses TiledLayer and PictureLayer to check for a working context.
359 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( 372 SINGLE_AND_MULTI_THREAD_TEST_F(
360 LayerTreeHostContextTestLostContextSucceedsWithContent); 373 LayerTreeHostContextTestLostContextSucceedsWithContentAndImpl);
361 374
362 class LayerTreeHostContextTestCreateOutputSurfaceFails 375 class LayerTreeHostContextTestCreateOutputSurfaceFails
363 : public LayerTreeHostContextTest { 376 : public LayerTreeHostContextTest {
364 public: 377 public:
365 // Run a test that initially fails OutputSurface creation |times_to_fail| 378 // Run a test that initially fails OutputSurface creation |times_to_fail|
366 // times. If |expect_fallback_attempt| is |true|, an attempt to create a 379 // times. If |expect_fallback_attempt| is |true|, an attempt to create a
367 // fallback/software OutputSurface is expected to occur. 380 // fallback/software OutputSurface is expected to occur.
368 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, 381 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail,
369 bool expect_fallback_attempt) 382 bool expect_fallback_attempt)
370 : times_to_fail_(times_to_fail), 383 : times_to_fail_(times_to_fail),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 }; 442 };
430 443
431 SINGLE_AND_MULTI_THREAD_TEST_F( 444 SINGLE_AND_MULTI_THREAD_TEST_F(
432 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback); 445 LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback);
433 446
434 class LayerTreeHostContextTestLostContextAndEvictTextures 447 class LayerTreeHostContextTestLostContextAndEvictTextures
435 : public LayerTreeHostContextTest { 448 : public LayerTreeHostContextTest {
436 public: 449 public:
437 LayerTreeHostContextTestLostContextAndEvictTextures() 450 LayerTreeHostContextTestLostContextAndEvictTextures()
438 : LayerTreeHostContextTest(), 451 : LayerTreeHostContextTest(),
439 layer_(FakeContentLayer::Create(&client_)),
440 impl_host_(0), 452 impl_host_(0),
441 num_commits_(0) {} 453 num_commits_(0) {}
442 454
443 virtual void SetupTree() OVERRIDE { 455 virtual void SetupTree() OVERRIDE {
456 if (layer_tree_host()->settings().impl_side_painting)
457 layer_ = PictureLayer::Create(&client_);
danakj 2014/08/26 18:54:40 FakePictureLayer
sohanjg 2014/08/27 06:59:49 Done.
458 else
459 layer_ = FakeContentLayer::Create(&client_);
444 layer_->SetBounds(gfx::Size(10, 20)); 460 layer_->SetBounds(gfx::Size(10, 20));
445 layer_tree_host()->SetRootLayer(layer_); 461 layer_tree_host()->SetRootLayer(layer_);
446 LayerTreeHostContextTest::SetupTree(); 462 LayerTreeHostContextTest::SetupTree();
447 } 463 }
448 464
449 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 465 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
450 466
451 void PostEvictTextures() { 467 void PostEvictTextures() {
452 if (HasImplThread()) { 468 if (HasImplThread()) {
453 ImplThreadTaskRunner()->PostTask( 469 ImplThreadTaskRunner()->PostTask(
454 FROM_HERE, 470 FROM_HERE,
455 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures:: 471 base::Bind(&LayerTreeHostContextTestLostContextAndEvictTextures::
456 EvictTexturesOnImplThread, 472 EvictTexturesOnImplThread,
457 base::Unretained(this))); 473 base::Unretained(this)));
458 } else { 474 } else {
459 DebugScopedSetImplThread impl(proxy()); 475 DebugScopedSetImplThread impl(proxy());
460 EvictTexturesOnImplThread(); 476 EvictTexturesOnImplThread();
461 } 477 }
462 } 478 }
463 479
464 void EvictTexturesOnImplThread() { 480 void EvictTexturesOnImplThread() {
465 impl_host_->EvictTexturesForTesting(); 481 impl_host_->EvictTexturesForTesting();
466 if (lose_after_evict_) 482 if (lose_after_evict_)
467 LoseContext(); 483 LoseContext();
468 } 484 }
469 485
470 virtual void DidCommitAndDrawFrame() OVERRIDE { 486 virtual void DidCommitAndDrawFrame() OVERRIDE {
471 if (num_commits_ > 1) 487 if (num_commits_ > 1)
472 return; 488 return;
473 EXPECT_TRUE(layer_->HaveBackingAt(0, 0));
sohanjg 2014/08/26 09:36:47 if we use impl-side painting, this test cant be us
danakj 2014/08/26 18:54:40 we can't check this here on the main thread with i
sohanjg 2014/08/27 06:59:50 Done.
474 PostEvictTextures(); 489 PostEvictTextures();
475 } 490 }
476 491
477 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 492 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
danakj 2014/08/26 18:54:40 Change this to DrawLayersOnThread
sohanjg 2014/08/27 06:59:49 Done.
478 LayerTreeHostContextTest::CommitCompleteOnThread(impl); 493 LayerTreeHostContextTest::CommitCompleteOnThread(impl);
479 if (num_commits_ > 1) 494 if (num_commits_ > 1)
480 return; 495 return;
481 ++num_commits_; 496 ++num_commits_;
danakj 2014/08/26 18:54:40 when impl painting, check the picture layer has a
sohanjg 2014/08/27 06:59:50 Done.
482 if (!lose_after_evict_) 497 if (!lose_after_evict_)
483 LoseContext(); 498 LoseContext();
484 impl_host_ = impl; 499 impl_host_ = impl;
485 } 500 }
486 501
487 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); } 502 virtual void DidInitializeOutputSurface() OVERRIDE { EndTest(); }
488 503
489 virtual void AfterTest() OVERRIDE {} 504 virtual void AfterTest() OVERRIDE {}
490 505
491 protected: 506 protected:
492 bool lose_after_evict_; 507 bool lose_after_evict_;
493 FakeContentLayerClient client_; 508 FakeContentLayerClient client_;
494 scoped_refptr<FakeContentLayer> layer_; 509 scoped_refptr<Layer> layer_;
495 LayerTreeHostImpl* impl_host_; 510 LayerTreeHostImpl* impl_host_;
496 int num_commits_; 511 int num_commits_;
497 }; 512 };
498 513
499 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 514 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
500 LoseAfterEvict_SingleThread_DirectRenderer) { 515 LoseAfterEvict_SingleThread_DirectRenderer) {
501 lose_after_evict_ = true; 516 lose_after_evict_ = true;
502 RunTest(false, false, false); 517 RunTest(false, false, false);
503 } 518 }
504 519
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 575 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
561 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) { 576 LoseBeforeEvict_MultiThread_DelegatingRenderer_ImplSidePaint) {
562 lose_after_evict_ = false; 577 lose_after_evict_ = false;
563 RunTest(true, true, true); 578 RunTest(true, true, true);
564 } 579 }
565 580
566 class LayerTreeHostContextTestLostContextWhileUpdatingResources 581 class LayerTreeHostContextTestLostContextWhileUpdatingResources
567 : public LayerTreeHostContextTest { 582 : public LayerTreeHostContextTest {
568 public: 583 public:
569 LayerTreeHostContextTestLostContextWhileUpdatingResources() 584 LayerTreeHostContextTestLostContextWhileUpdatingResources()
570 : parent_(FakeContentLayer::Create(&client_)), 585 : num_children_(50), times_to_lose_on_end_query_(3) {}
571 num_children_(50),
572 times_to_lose_on_end_query_(3) {}
573 586
574 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { 587 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE {
575 scoped_ptr<TestWebGraphicsContext3D> context = 588 scoped_ptr<TestWebGraphicsContext3D> context =
576 LayerTreeHostContextTest::CreateContext3d(); 589 LayerTreeHostContextTest::CreateContext3d();
577 if (times_to_lose_on_end_query_) { 590 if (times_to_lose_on_end_query_) {
578 --times_to_lose_on_end_query_; 591 --times_to_lose_on_end_query_;
579 context->set_times_end_query_succeeds(5); 592 context->set_times_end_query_succeeds(5);
580 } 593 }
581 return context.Pass(); 594 return context.Pass();
582 } 595 }
583 596
584 virtual void SetupTree() OVERRIDE { 597 virtual void SetupTree() OVERRIDE {
598 if (layer_tree_host()->settings().impl_side_painting)
599 parent_ = PictureLayer::Create(&client_);
600 else
601 parent_ = FakeContentLayer::Create(&client_);
602
585 parent_->SetBounds(gfx::Size(num_children_, 1)); 603 parent_->SetBounds(gfx::Size(num_children_, 1));
586 604
587 for (int i = 0; i < num_children_; i++) { 605 for (int i = 0; i < num_children_; i++) {
588 scoped_refptr<FakeContentLayer> child = 606 scoped_refptr<Layer> child;
589 FakeContentLayer::Create(&client_); 607 if (layer_tree_host()->settings().impl_side_painting)
608 child = PictureLayer::Create(&client_);
609 else
610 child = FakeContentLayer::Create(&client_);
590 child->SetPosition(gfx::PointF(i, 0.f)); 611 child->SetPosition(gfx::PointF(i, 0.f));
591 child->SetBounds(gfx::Size(1, 1)); 612 child->SetBounds(gfx::Size(1, 1));
592 parent_->AddChild(child); 613 parent_->AddChild(child);
593 } 614 }
594 615
595 layer_tree_host()->SetRootLayer(parent_); 616 layer_tree_host()->SetRootLayer(parent_);
596 LayerTreeHostContextTest::SetupTree(); 617 LayerTreeHostContextTest::SetupTree();
597 } 618 }
598 619
599 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 620 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
600 621
601 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 622 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
602 EXPECT_EQ(0, times_to_lose_on_end_query_); 623 EXPECT_EQ(0, times_to_lose_on_end_query_);
603 EndTest(); 624 EndTest();
604 } 625 }
605 626
606 virtual void AfterTest() OVERRIDE { 627 virtual void AfterTest() OVERRIDE {
607 EXPECT_EQ(0, times_to_lose_on_end_query_); 628 EXPECT_EQ(0, times_to_lose_on_end_query_);
608 } 629 }
609 630
610 private: 631 private:
611 FakeContentLayerClient client_; 632 FakeContentLayerClient client_;
612 scoped_refptr<FakeContentLayer> parent_; 633 scoped_refptr<Layer> parent_;
613 int num_children_; 634 int num_children_;
614 int times_to_lose_on_end_query_; 635 int times_to_lose_on_end_query_;
615 }; 636 };
616 637
617 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( 638 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
618 LayerTreeHostContextTestLostContextWhileUpdatingResources); 639 LayerTreeHostContextTestLostContextWhileUpdatingResources);
619 640
620 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { 641 class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest {
621 public: 642 public:
622 LayerTreeHostContextTestLayersNotified() 643 LayerTreeHostContextTestLayersNotified()
623 : LayerTreeHostContextTest(), num_commits_(0) {} 644 : LayerTreeHostContextTest(), num_commits_(0) {}
624 645
625 virtual void SetupTree() OVERRIDE { 646 virtual void SetupTree() OVERRIDE {
626 root_ = FakeContentLayer::Create(&client_); 647 if (layer_tree_host()->settings().impl_side_painting) {
627 child_ = FakeContentLayer::Create(&client_); 648 root_ = PictureLayer::Create(&client_);
danakj 2014/08/26 18:54:41 FakePictureLayers, or you can't cast the impl to a
sohanjg 2014/08/27 06:59:49 Done.
628 grandchild_ = FakeContentLayer::Create(&client_); 649 child_ = PictureLayer::Create(&client_);
650 grandchild_ = PictureLayer::Create(&client_);
651 } else {
652 root_ = FakeContentLayer::Create(&client_);
653 child_ = FakeContentLayer::Create(&client_);
654 grandchild_ = FakeContentLayer::Create(&client_);
655 }
629 656
630 root_->AddChild(child_); 657 root_->AddChild(child_);
631 child_->AddChild(grandchild_); 658 child_->AddChild(grandchild_);
632 659
633 layer_tree_host()->SetRootLayer(root_); 660 layer_tree_host()->SetRootLayer(root_);
634 LayerTreeHostContextTest::SetupTree(); 661 LayerTreeHostContextTest::SetupTree();
635 } 662 }
636 663
637 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 664 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
638 665
639 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 666 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
640 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); 667 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl);
641 668
642 FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( 669 LayerImpl* root;
643 host_impl->active_tree()->root_layer()); 670 LayerImpl* child;
644 FakeContentLayerImpl* child = 671 LayerImpl* grandchild;
645 static_cast<FakeContentLayerImpl*>(root->children()[0]); 672
646 FakeContentLayerImpl* grandchild = 673 if (layer_tree_host()->settings().impl_side_painting) {
647 static_cast<FakeContentLayerImpl*>(child->children()[0]); 674 root = static_cast<FakePictureLayerImpl*>(
675 host_impl->active_tree()->root_layer());
676 child = static_cast<FakePictureLayerImpl*>(root->children()[0]);
677 grandchild = static_cast<FakePictureLayerImpl*>(child->children()[0]);
678
679 } else {
680 root = static_cast<FakeContentLayerImpl*>(
681 host_impl->active_tree()->root_layer());
682 child = static_cast<FakeContentLayerImpl*>(root->children()[0]);
683 grandchild = static_cast<FakeContentLayerImpl*>(child->children()[0]);
684 }
648 685
649 ++num_commits_; 686 ++num_commits_;
650 switch (num_commits_) { 687 switch (num_commits_) {
651 case 1: 688 case 1:
652 EXPECT_EQ(0u, root->lost_output_surface_count());
653 EXPECT_EQ(0u, child->lost_output_surface_count());
654 EXPECT_EQ(0u, grandchild->lost_output_surface_count());
sohanjg 2014/08/26 09:36:47 if we use impl-side, these test cant be used, are
sohanjg 2014/08/26 10:56:26 can we check something like LayerPropertyChanged ?
danakj 2014/08/26 18:54:40 add this to FakePictureLayerImpl. https://code.go
sohanjg 2014/08/27 06:59:50 Done.
655 // Lose the context and struggle to recreate it. 689 // Lose the context and struggle to recreate it.
656 LoseContext(); 690 LoseContext();
657 times_to_fail_create_ = 1; 691 times_to_fail_create_ = 1;
658 break; 692 break;
659 case 2: 693 case 2:
660 EXPECT_GE(1u, root->lost_output_surface_count());
661 EXPECT_GE(1u, child->lost_output_surface_count());
662 EXPECT_GE(1u, grandchild->lost_output_surface_count());
sohanjg 2014/08/26 09:36:47 if we use impl-side, these test cant be used, are
663 EndTest(); 694 EndTest();
664 break; 695 break;
665 default: 696 default:
666 NOTREACHED(); 697 NOTREACHED();
667 } 698 }
668 } 699 }
669 700
670 virtual void AfterTest() OVERRIDE {} 701 virtual void AfterTest() OVERRIDE {}
671 702
672 private: 703 private:
673 int num_commits_; 704 int num_commits_;
674 705
675 FakeContentLayerClient client_; 706 FakeContentLayerClient client_;
676 scoped_refptr<FakeContentLayer> root_; 707 scoped_refptr<Layer> root_;
677 scoped_refptr<FakeContentLayer> child_; 708 scoped_refptr<Layer> child_;
678 scoped_refptr<FakeContentLayer> grandchild_; 709 scoped_refptr<Layer> grandchild_;
679 }; 710 };
680 711
681 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); 712 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified);
682 713
683 class LayerTreeHostContextTestDontUseLostResources 714 class LayerTreeHostContextTestDontUseLostResources
684 : public LayerTreeHostContextTest { 715 : public LayerTreeHostContextTest {
685 public: 716 public:
686 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) { 717 LayerTreeHostContextTestDontUseLostResources() : lost_context_(false) {
687 context_should_support_io_surface_ = true; 718 context_should_support_io_surface_ = true;
688 719
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 scoped_refptr<Layer> root = Layer::Create(); 772 scoped_refptr<Layer> root = Layer::Create();
742 root->SetBounds(gfx::Size(10, 10)); 773 root->SetBounds(gfx::Size(10, 10));
743 root->SetIsDrawable(true); 774 root->SetIsDrawable(true);
744 775
745 scoped_refptr<FakeDelegatedRendererLayer> delegated = 776 scoped_refptr<FakeDelegatedRendererLayer> delegated =
746 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get()); 777 FakeDelegatedRendererLayer::Create(delegated_frame_provider_.get());
747 delegated->SetBounds(gfx::Size(10, 10)); 778 delegated->SetBounds(gfx::Size(10, 10));
748 delegated->SetIsDrawable(true); 779 delegated->SetIsDrawable(true);
749 root->AddChild(delegated); 780 root->AddChild(delegated);
750 781
751 scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_); 782 scoped_refptr<Layer> layer;
752 content->SetBounds(gfx::Size(10, 10)); 783 if (layer_tree_host()->settings().impl_side_painting)
753 content->SetIsDrawable(true); 784 layer = PictureLayer::Create(&client_);
754 root->AddChild(content); 785 else
786 layer = ContentLayer::Create(&client_);
787 layer->SetBounds(gfx::Size(10, 10));
788 layer->SetIsDrawable(true);
789 root->AddChild(layer);
755 790
756 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); 791 scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL);
757 texture->SetBounds(gfx::Size(10, 10)); 792 texture->SetBounds(gfx::Size(10, 10));
758 texture->SetIsDrawable(true); 793 texture->SetIsDrawable(true);
759 texture->SetTextureMailbox( 794 texture->SetTextureMailbox(
760 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), 795 TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
761 SingleReleaseCallback::Create( 796 SingleReleaseCallback::Create(
762 base::Bind(&LayerTreeHostContextTestDontUseLostResources:: 797 base::Bind(&LayerTreeHostContextTestDontUseLostResources::
763 EmptyReleaseCallback))); 798 EmptyReleaseCallback)));
764 root->AddChild(texture); 799 root->AddChild(texture);
765 800
766 scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); 801 scoped_refptr<Layer> mask;
802 if (layer_tree_host()->settings().impl_side_painting)
803 mask = PictureLayer::Create(&client_);
804 else
805 mask = ContentLayer::Create(&client_);
767 mask->SetBounds(gfx::Size(10, 10)); 806 mask->SetBounds(gfx::Size(10, 10));
768 807
769 scoped_refptr<ContentLayer> content_with_mask = 808 scoped_refptr<Layer> layer_with_mask;
770 ContentLayer::Create(&client_); 809 if (layer_tree_host()->settings().impl_side_painting)
771 content_with_mask->SetBounds(gfx::Size(10, 10)); 810 layer_with_mask = PictureLayer::Create(&client_);
772 content_with_mask->SetIsDrawable(true); 811 else
773 content_with_mask->SetMaskLayer(mask.get()); 812 layer_with_mask = ContentLayer::Create(&client_);
774 root->AddChild(content_with_mask); 813 layer_with_mask->SetBounds(gfx::Size(10, 10));
814 layer_with_mask->SetIsDrawable(true);
815 layer_with_mask->SetMaskLayer(mask.get());
816 root->AddChild(layer_with_mask);
775 817
776 scoped_refptr<VideoLayer> video_color = 818 scoped_refptr<VideoLayer> video_color =
777 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); 819 VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0);
778 video_color->SetBounds(gfx::Size(10, 10)); 820 video_color->SetBounds(gfx::Size(10, 10));
779 video_color->SetIsDrawable(true); 821 video_color->SetIsDrawable(true);
780 root->AddChild(video_color); 822 root->AddChild(video_color);
781 823
782 scoped_refptr<VideoLayer> video_hw = 824 scoped_refptr<VideoLayer> video_hw =
783 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0); 825 VideoLayer::Create(&hw_frame_provider_, media::VIDEO_ROTATION_0);
784 video_hw->SetBounds(gfx::Size(10, 10)); 826 video_hw->SetBounds(gfx::Size(10, 10));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 root->AddChild(io_surface); 867 root->AddChild(io_surface);
826 } 868 }
827 869
828 // Enable the hud. 870 // Enable the hud.
829 LayerTreeDebugState debug_state; 871 LayerTreeDebugState debug_state;
830 debug_state.show_property_changed_rects = true; 872 debug_state.show_property_changed_rects = true;
831 layer_tree_host()->SetDebugState(debug_state); 873 layer_tree_host()->SetDebugState(debug_state);
832 874
833 scoped_refptr<PaintedScrollbarLayer> scrollbar = 875 scoped_refptr<PaintedScrollbarLayer> scrollbar =
834 PaintedScrollbarLayer::Create( 876 PaintedScrollbarLayer::Create(
835 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id()); 877 scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id());
836 scrollbar->SetBounds(gfx::Size(10, 10)); 878 scrollbar->SetBounds(gfx::Size(10, 10));
837 scrollbar->SetIsDrawable(true); 879 scrollbar->SetIsDrawable(true);
838 root->AddChild(scrollbar); 880 root->AddChild(scrollbar);
839 881
840 layer_tree_host()->SetRootLayer(root); 882 layer_tree_host()->SetRootLayer(root);
841 LayerTreeHostContextTest::SetupTree(); 883 LayerTreeHostContextTest::SetupTree();
842 } 884 }
843 885
844 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 886 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
845 887
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1440 }
1399 } 1441 }
1400 }; 1442 };
1401 1443
1402 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); 1444 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction);
1403 1445
1404 class LayerTreeHostContextTestSurfaceCreateCallback 1446 class LayerTreeHostContextTestSurfaceCreateCallback
1405 : public LayerTreeHostContextTest { 1447 : public LayerTreeHostContextTest {
1406 public: 1448 public:
1407 LayerTreeHostContextTestSurfaceCreateCallback() 1449 LayerTreeHostContextTestSurfaceCreateCallback()
1408 : LayerTreeHostContextTest(), 1450 : LayerTreeHostContextTest() {}
1409 layer_(FakeContentLayer::Create(&client_)) {}
1410 1451
1411 virtual void SetupTree() OVERRIDE { 1452 virtual void SetupTree() OVERRIDE {
1453 if (layer_tree_host()->settings().impl_side_painting)
1454 layer_ = PictureLayer::Create(&client_);
1455 else
1456 layer_ = FakeContentLayer::Create(&client_);
1412 layer_->SetBounds(gfx::Size(10, 20)); 1457 layer_->SetBounds(gfx::Size(10, 20));
1413 layer_tree_host()->SetRootLayer(layer_); 1458 layer_tree_host()->SetRootLayer(layer_);
1414 LayerTreeHostContextTest::SetupTree(); 1459 LayerTreeHostContextTest::SetupTree();
1415 } 1460 }
1416 1461
1417 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1462 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
1418 1463
1419 virtual void DidCommit() OVERRIDE { 1464 virtual void DidCommit() OVERRIDE {
1420 switch (layer_tree_host()->source_frame_number()) { 1465 switch (layer_tree_host()->source_frame_number()) {
1421 case 1: 1466 case 1:
1422 EXPECT_EQ(1u, layer_->output_surface_created_count());
sohanjg 2014/08/26 09:36:47 this seems to be the only thing this test checks,
sohanjg 2014/08/26 10:56:26 like LayerTreeHostContextTestLayersNotified test,
danakj 2014/08/26 18:54:40 Add this to FakePictureLayer. https://code.google
sohanjg 2014/08/27 06:59:50 Done.
1423 layer_tree_host()->SetNeedsCommit(); 1467 layer_tree_host()->SetNeedsCommit();
1424 break; 1468 break;
1425 case 2: 1469 case 2:
1426 EXPECT_EQ(1u, layer_->output_surface_created_count());
1427 layer_tree_host()->SetNeedsCommit(); 1470 layer_tree_host()->SetNeedsCommit();
1428 break; 1471 break;
1429 case 3: 1472 case 3:
1430 EXPECT_EQ(1u, layer_->output_surface_created_count());
1431 break; 1473 break;
1432 case 4: 1474 case 4:
1433 EXPECT_EQ(2u, layer_->output_surface_created_count());
1434 layer_tree_host()->SetNeedsCommit(); 1475 layer_tree_host()->SetNeedsCommit();
1435 break; 1476 break;
1436 } 1477 }
1437 } 1478 }
1438 1479
1439 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1480 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1440 LayerTreeHostContextTest::CommitCompleteOnThread(impl); 1481 LayerTreeHostContextTest::CommitCompleteOnThread(impl);
1441 switch (LastCommittedSourceFrameNumber(impl)) { 1482 switch (LastCommittedSourceFrameNumber(impl)) {
1442 case 0: 1483 case 0:
1443 break; 1484 break;
1444 case 1: 1485 case 1:
1445 break; 1486 break;
1446 case 2: 1487 case 2:
1447 LoseContext(); 1488 LoseContext();
1448 break; 1489 break;
1449 case 3: 1490 case 3:
1450 EndTest(); 1491 EndTest();
1451 break; 1492 break;
1452 } 1493 }
1453 } 1494 }
1454 1495
1455 virtual void AfterTest() OVERRIDE {} 1496 virtual void AfterTest() OVERRIDE {}
1456 1497
1457 protected: 1498 protected:
1458 FakeContentLayerClient client_; 1499 FakeContentLayerClient client_;
1459 scoped_refptr<FakeContentLayer> layer_; 1500 scoped_refptr<Layer> layer_;
1460 }; 1501 };
1461 1502
1462 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); 1503 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
1463 1504
1464 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame 1505 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
1465 : public LayerTreeHostContextTest { 1506 : public LayerTreeHostContextTest {
1466 protected: 1507 protected:
1467 virtual void BeginTest() OVERRIDE { 1508 virtual void BeginTest() OVERRIDE {
1468 deferred_ = false; 1509 deferred_ = false;
1469 PostSetNeedsCommitToMainThread(); 1510 PostSetNeedsCommitToMainThread();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 virtual void AfterTest() OVERRIDE {} 1556 virtual void AfterTest() OVERRIDE {}
1516 1557
1517 bool deferred_; 1558 bool deferred_;
1518 }; 1559 };
1519 1560
1520 SINGLE_AND_MULTI_THREAD_TEST_F( 1561 SINGLE_AND_MULTI_THREAD_TEST_F(
1521 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); 1562 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
1522 1563
1523 } // namespace 1564 } // namespace
1524 } // namespace cc 1565 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698