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

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

Issue 16211002: Skip drawing unsupported layers in forced software mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on r203584 Created 7 years, 6 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
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/layers/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "cc/base/thread.h" 10 #include "cc/base/thread.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 virtual void SetUp() { 414 virtual void SetUp() {
415 TextureLayerTest::SetUp(); 415 TextureLayerTest::SetUp();
416 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); 416 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_));
417 EXPECT_TRUE(host_impl_.InitializeRenderer(CreateFakeOutputSurface())); 417 EXPECT_TRUE(host_impl_.InitializeRenderer(CreateFakeOutputSurface()));
418 } 418 }
419 419
420 CommonMailboxObjects test_data_; 420 CommonMailboxObjects test_data_;
421 FakeLayerTreeHostClient fake_client_; 421 FakeLayerTreeHostClient fake_client_;
422 }; 422 };
423 423
424 // Test conditions for results of TextureLayerImpl::WillDraw under
425 // different configurations of different mailbox, texture_id, and draw_mode.
426 TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) {
427 // Hardware mode.
428 {
429 scoped_ptr<TextureLayerImpl> impl_layer =
430 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true);
431 impl_layer->SetTextureMailbox(test_data_.mailbox1_);
432 impl_layer->DidBecomeActive();
433 EXPECT_TRUE(impl_layer->WillDraw(
434 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
435 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
436 }
437
438 {
439 scoped_ptr<TextureLayerImpl> impl_layer =
440 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true);
441 impl_layer->SetTextureMailbox(test_data_.mailbox1_);
442 EXPECT_FALSE(impl_layer->WillDraw(
443 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
444 }
445
446 {
447 scoped_ptr<TextureLayerImpl> impl_layer =
448 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
449 unsigned texture =
450 host_impl_.output_surface()->context3d()->createTexture();
451 impl_layer->set_texture_id(texture);
452 EXPECT_TRUE(impl_layer->WillDraw(
453 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
454 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
455 }
456
457 {
458 scoped_ptr<TextureLayerImpl> impl_layer =
459 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
460 impl_layer->set_texture_id(0);
461 EXPECT_FALSE(impl_layer->WillDraw(
462 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
463 }
464
465 // Resourceless software mode.
466 {
467 scoped_ptr<TextureLayerImpl> impl_layer =
468 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true);
469 impl_layer->SetTextureMailbox(test_data_.mailbox1_);
470 impl_layer->DidBecomeActive();
471 EXPECT_FALSE(
472 impl_layer->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE,
473 host_impl_.active_tree()->resource_provider()));
474 }
475
476 {
477 scoped_ptr<TextureLayerImpl> impl_layer =
478 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false);
479 unsigned texture =
480 host_impl_.output_surface()->context3d()->createTexture();
481 impl_layer->set_texture_id(texture);
482 EXPECT_FALSE(
483 impl_layer->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE,
484 host_impl_.active_tree()->resource_provider()));
485 }
486 }
487
424 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { 488 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) {
425 host_impl_.CreatePendingTree(); 489 host_impl_.CreatePendingTree();
426 scoped_ptr<TextureLayerImpl> pending_layer; 490 scoped_ptr<TextureLayerImpl> pending_layer;
427 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); 491 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true);
428 ASSERT_TRUE(pending_layer); 492 ASSERT_TRUE(pending_layer);
429 493
430 scoped_ptr<LayerImpl> active_layer( 494 scoped_ptr<LayerImpl> active_layer(
431 pending_layer->CreateLayerImpl(host_impl_.active_tree())); 495 pending_layer->CreateLayerImpl(host_impl_.active_tree()));
432 ASSERT_TRUE(active_layer); 496 ASSERT_TRUE(active_layer);
433 497
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 TEST_F(TextureLayerImplWithMailboxTest, 542 TEST_F(TextureLayerImplWithMailboxTest,
479 TestDestructorCallbackOnCreatedResource) { 543 TestDestructorCallbackOnCreatedResource) {
480 scoped_ptr<TextureLayerImpl> impl_layer; 544 scoped_ptr<TextureLayerImpl> impl_layer;
481 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); 545 impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1, true);
482 ASSERT_TRUE(impl_layer); 546 ASSERT_TRUE(impl_layer);
483 547
484 EXPECT_CALL(test_data_.mock_callback_, 548 EXPECT_CALL(test_data_.mock_callback_,
485 Release(test_data_.mailbox_name1_, _, false)) 549 Release(test_data_.mailbox_name1_, _, false))
486 .Times(1); 550 .Times(1);
487 impl_layer->SetTextureMailbox(test_data_.mailbox1_); 551 impl_layer->SetTextureMailbox(test_data_.mailbox1_);
488 impl_layer->WillDraw(host_impl_.active_tree()->resource_provider()); 552 impl_layer->DidBecomeActive();
553 EXPECT_TRUE(impl_layer->WillDraw(
554 DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider()));
489 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider()); 555 impl_layer->DidDraw(host_impl_.active_tree()->resource_provider());
490 impl_layer->SetTextureMailbox(TextureMailbox()); 556 impl_layer->SetTextureMailbox(TextureMailbox());
491 } 557 }
492 558
493 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) { 559 TEST_F(TextureLayerImplWithMailboxTest, TestCallbackOnInUseResource) {
494 ResourceProvider* provider = host_impl_.active_tree()->resource_provider(); 560 ResourceProvider* provider = host_impl_.active_tree()->resource_provider();
495 ResourceProvider::ResourceId id = 561 ResourceProvider::ResourceId id =
496 provider->CreateResourceFromTextureMailbox(test_data_.mailbox1_); 562 provider->CreateResourceFromTextureMailbox(test_data_.mailbox1_);
497 provider->AllocateForTesting(id); 563 provider->AllocateForTesting(id);
498 564
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 base::Lock lock_; 689 base::Lock lock_;
624 unsigned expected_used_textures_on_commit_; 690 unsigned expected_used_textures_on_commit_;
625 }; 691 };
626 692
627 // The TextureLayerClient does not use mailboxes, so can't use a delegating 693 // The TextureLayerClient does not use mailboxes, so can't use a delegating
628 // renderer. 694 // renderer.
629 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerClientTest); 695 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerClientTest);
630 696
631 } // namespace 697 } // namespace
632 } // namespace cc 698 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698