OLD | NEW |
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/debug/test_web_graphics_context_3d.h" | 10 #include "cc/debug/test_web_graphics_context_3d.h" |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 // Software resource. | 613 // Software resource. |
614 scoped_ptr<TextureLayerImpl> impl_layer = | 614 scoped_ptr<TextureLayerImpl> impl_layer = |
615 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 615 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
616 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 616 impl_layer->SetTextureMailbox(test_data_.mailbox3_); |
617 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 617 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
618 } | 618 } |
619 | 619 |
620 { | 620 { |
621 scoped_ptr<TextureLayerImpl> impl_layer = | 621 scoped_ptr<TextureLayerImpl> impl_layer = |
622 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 622 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 623 ContextProvider* context_provider = |
| 624 host_impl_.output_surface()->context_provider(); |
623 unsigned texture = | 625 unsigned texture = |
624 host_impl_.output_surface()->context3d()->createTexture(); | 626 context_provider->Context3d()->createTexture(); |
625 impl_layer->set_texture_id(texture); | 627 impl_layer->set_texture_id(texture); |
626 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 628 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
627 } | 629 } |
628 | 630 |
629 { | 631 { |
630 scoped_ptr<TextureLayerImpl> impl_layer = | 632 scoped_ptr<TextureLayerImpl> impl_layer = |
631 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 633 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
632 impl_layer->set_texture_id(0); | 634 impl_layer->set_texture_id(0); |
633 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); | 635 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); |
634 } | 636 } |
(...skipping 17 matching lines...) Expand all Loading... |
652 // Software resource. | 654 // Software resource. |
653 scoped_ptr<TextureLayerImpl> impl_layer = | 655 scoped_ptr<TextureLayerImpl> impl_layer = |
654 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 656 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
655 impl_layer->SetTextureMailbox(test_data_.mailbox3_); | 657 impl_layer->SetTextureMailbox(test_data_.mailbox3_); |
656 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 658 EXPECT_TRUE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
657 } | 659 } |
658 | 660 |
659 { | 661 { |
660 scoped_ptr<TextureLayerImpl> impl_layer = | 662 scoped_ptr<TextureLayerImpl> impl_layer = |
661 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 663 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 664 ContextProvider* context_provider = |
| 665 host_impl_.output_surface()->context_provider(); |
662 unsigned texture = | 666 unsigned texture = |
663 host_impl_.output_surface()->context3d()->createTexture(); | 667 context_provider->Context3d()->createTexture(); |
664 impl_layer->set_texture_id(texture); | 668 impl_layer->set_texture_id(texture); |
665 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 669 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
666 } | 670 } |
667 | 671 |
668 { | 672 { |
669 scoped_ptr<TextureLayerImpl> impl_layer = | 673 scoped_ptr<TextureLayerImpl> impl_layer = |
670 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 674 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
671 impl_layer->set_texture_id(0); | 675 impl_layer->set_texture_id(0); |
672 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); | 676 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); |
673 } | 677 } |
674 | 678 |
675 // Resourceless software mode. | 679 // Resourceless software mode. |
676 { | 680 { |
677 scoped_ptr<TextureLayerImpl> impl_layer = | 681 scoped_ptr<TextureLayerImpl> impl_layer = |
678 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); | 682 TextureLayerImpl::Create(host_impl_.active_tree(), 1, true); |
679 impl_layer->SetTextureMailbox(test_data_.mailbox1_); | 683 impl_layer->SetTextureMailbox(test_data_.mailbox1_); |
680 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 684 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
681 } | 685 } |
682 | 686 |
683 { | 687 { |
684 scoped_ptr<TextureLayerImpl> impl_layer = | 688 scoped_ptr<TextureLayerImpl> impl_layer = |
685 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); | 689 TextureLayerImpl::Create(host_impl_.active_tree(), 1, false); |
| 690 ContextProvider* context_provider = |
| 691 host_impl_.output_surface()->context_provider(); |
686 unsigned texture = | 692 unsigned texture = |
687 host_impl_.output_surface()->context3d()->createTexture(); | 693 context_provider->Context3d()->createTexture(); |
688 impl_layer->set_texture_id(texture); | 694 impl_layer->set_texture_id(texture); |
689 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); | 695 EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_RESOURCELESS_SOFTWARE)); |
690 } | 696 } |
691 } | 697 } |
692 | 698 |
693 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { | 699 TEST_F(TextureLayerImplWithMailboxTest, TestImplLayerCallbacks) { |
694 host_impl_.CreatePendingTree(); | 700 host_impl_.CreatePendingTree(); |
695 scoped_ptr<TextureLayerImpl> pending_layer; | 701 scoped_ptr<TextureLayerImpl> pending_layer; |
696 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); | 702 pending_layer = TextureLayerImpl::Create(host_impl_.pending_tree(), 1, true); |
697 ASSERT_TRUE(pending_layer); | 703 ASSERT_TRUE(pending_layer); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 commit_count_(0), | 800 commit_count_(0), |
795 expected_used_textures_on_draw_(0), | 801 expected_used_textures_on_draw_(0), |
796 expected_used_textures_on_commit_(0) {} | 802 expected_used_textures_on_commit_(0) {} |
797 | 803 |
798 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) | 804 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) |
799 OVERRIDE { | 805 OVERRIDE { |
800 scoped_ptr<TestWebGraphicsContext3D> context( | 806 scoped_ptr<TestWebGraphicsContext3D> context( |
801 TestWebGraphicsContext3D::Create()); | 807 TestWebGraphicsContext3D::Create()); |
802 context_ = context.get(); | 808 context_ = context.get(); |
803 texture_ = context->createTexture(); | 809 texture_ = context->createTexture(); |
804 return FakeOutputSurface::Create3d( | 810 return FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>(); |
805 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | |
806 } | 811 } |
807 | 812 |
808 virtual unsigned PrepareTexture() OVERRIDE { | 813 virtual unsigned PrepareTexture() OVERRIDE { |
809 return texture_; | 814 return texture_; |
810 } | 815 } |
811 | 816 |
812 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { | 817 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
813 return context_; | 818 return context_; |
814 } | 819 } |
815 | 820 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 int callback_count_; | 1119 int callback_count_; |
1115 scoped_refptr<Layer> root_; | 1120 scoped_refptr<Layer> root_; |
1116 scoped_refptr<TextureLayer> layer_; | 1121 scoped_refptr<TextureLayer> layer_; |
1117 }; | 1122 }; |
1118 | 1123 |
1119 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1124 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1120 TextureLayerWithMailboxImplThreadDeleted); | 1125 TextureLayerWithMailboxImplThreadDeleted); |
1121 | 1126 |
1122 } // namespace | 1127 } // namespace |
1123 } // namespace cc | 1128 } // namespace cc |
OLD | NEW |