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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/content_layer.h" | 8 #include "cc/content_layer.h" |
9 #include "cc/delegated_renderer_layer.h" | 9 #include "cc/delegated_renderer_layer.h" |
10 #include "cc/delegated_renderer_layer_impl.h" | 10 #include "cc/delegated_renderer_layer_impl.h" |
11 #include "cc/heads_up_display_layer.h" | 11 #include "cc/heads_up_display_layer.h" |
12 #include "cc/io_surface_layer.h" | 12 #include "cc/io_surface_layer.h" |
13 #include "cc/layer_impl.h" | 13 #include "cc/layer_impl.h" |
14 #include "cc/layer_tree_host_impl.h" | 14 #include "cc/layer_tree_host_impl.h" |
15 #include "cc/layer_tree_impl.h" | 15 #include "cc/layer_tree_impl.h" |
16 #include "cc/scrollbar_layer.h" | 16 #include "cc/scrollbar_layer.h" |
17 #include "cc/single_thread_proxy.h" | 17 #include "cc/single_thread_proxy.h" |
18 #include "cc/test/fake_content_layer.h" | 18 #include "cc/test/fake_content_layer.h" |
19 #include "cc/test/fake_content_layer_client.h" | 19 #include "cc/test/fake_content_layer_client.h" |
20 #include "cc/test/fake_content_layer_impl.h" | 20 #include "cc/test/fake_content_layer_impl.h" |
21 #include "cc/test/fake_output_surface.h" | 21 #include "cc/test/fake_output_surface.h" |
22 #include "cc/test/fake_scrollbar_theme_painter.h" | 22 #include "cc/test/fake_scrollbar_theme_painter.h" |
23 #include "cc/test/fake_video_frame.h" | |
24 #include "cc/test/fake_video_frame_provider.h" | 23 #include "cc/test/fake_video_frame_provider.h" |
25 #include "cc/test/fake_web_graphics_context_3d.h" | 24 #include "cc/test/fake_web_graphics_context_3d.h" |
26 #include "cc/test/fake_web_scrollbar.h" | 25 #include "cc/test/fake_web_scrollbar.h" |
27 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 26 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
28 #include "cc/test/layer_tree_test_common.h" | 27 #include "cc/test/layer_tree_test_common.h" |
29 #include "cc/test/render_pass_test_common.h" | 28 #include "cc/test/render_pass_test_common.h" |
30 #include "cc/texture_layer.h" | 29 #include "cc/texture_layer.h" |
31 #include "cc/video_layer.h" | 30 #include "cc/video_layer.h" |
32 #include "cc/video_layer_impl.h" | 31 #include "cc/video_layer_impl.h" |
33 #include "media/base/media.h" | 32 #include "media/base/media.h" |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 mask_->setAnchorPoint(gfx::PointF()); | 603 mask_->setAnchorPoint(gfx::PointF()); |
605 | 604 |
606 scoped_refptr<ContentLayer> content_with_mask_ = | 605 scoped_refptr<ContentLayer> content_with_mask_ = |
607 ContentLayer::create(&client_); | 606 ContentLayer::create(&client_); |
608 content_with_mask_->setBounds(gfx::Size(10, 10)); | 607 content_with_mask_->setBounds(gfx::Size(10, 10)); |
609 content_with_mask_->setAnchorPoint(gfx::PointF()); | 608 content_with_mask_->setAnchorPoint(gfx::PointF()); |
610 content_with_mask_->setIsDrawable(true); | 609 content_with_mask_->setIsDrawable(true); |
611 content_with_mask_->setMaskLayer(mask_.get()); | 610 content_with_mask_->setMaskLayer(mask_.get()); |
612 root_->addChild(content_with_mask_); | 611 root_->addChild(content_with_mask_); |
613 | 612 |
614 VideoLayerImpl::FrameUnwrapper unwrapper = | |
615 base::Bind(FakeVideoFrame::ToVideoFrame); | |
616 | |
617 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( | 613 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( |
618 &color_frame_provider_, unwrapper); | 614 &color_frame_provider_); |
619 video_color_->setBounds(gfx::Size(10, 10)); | 615 video_color_->setBounds(gfx::Size(10, 10)); |
620 video_color_->setAnchorPoint(gfx::PointF()); | 616 video_color_->setAnchorPoint(gfx::PointF()); |
621 video_color_->setIsDrawable(true); | 617 video_color_->setIsDrawable(true); |
622 root_->addChild(video_color_); | 618 root_->addChild(video_color_); |
623 | 619 |
624 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( | 620 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( |
625 &hw_frame_provider_, unwrapper); | 621 &hw_frame_provider_); |
626 video_hw_->setBounds(gfx::Size(10, 10)); | 622 video_hw_->setBounds(gfx::Size(10, 10)); |
627 video_hw_->setAnchorPoint(gfx::PointF()); | 623 video_hw_->setAnchorPoint(gfx::PointF()); |
628 video_hw_->setIsDrawable(true); | 624 video_hw_->setIsDrawable(true); |
629 root_->addChild(video_hw_); | 625 root_->addChild(video_hw_); |
630 | 626 |
631 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( | 627 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( |
632 &scaled_hw_frame_provider_, unwrapper); | 628 &scaled_hw_frame_provider_); |
633 video_scaled_hw_->setBounds(gfx::Size(10, 10)); | 629 video_scaled_hw_->setBounds(gfx::Size(10, 10)); |
634 video_scaled_hw_->setAnchorPoint(gfx::PointF()); | 630 video_scaled_hw_->setAnchorPoint(gfx::PointF()); |
635 video_scaled_hw_->setIsDrawable(true); | 631 video_scaled_hw_->setIsDrawable(true); |
636 root_->addChild(video_scaled_hw_); | 632 root_->addChild(video_scaled_hw_); |
637 | 633 |
638 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); | 634 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); |
639 io_surface_->setBounds(gfx::Size(10, 10)); | 635 io_surface_->setBounds(gfx::Size(10, 10)); |
640 io_surface_->setAnchorPoint(gfx::PointF()); | 636 io_surface_->setAnchorPoint(gfx::PointF()); |
641 io_surface_->setIsDrawable(true); | 637 io_surface_->setIsDrawable(true); |
642 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 638 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 pass_list.append(pass_for_quad.PassAs<RenderPass>()); | 696 pass_list.append(pass_for_quad.PassAs<RenderPass>()); |
701 pass_list.append(pass.PassAs<RenderPass>()); | 697 pass_list.append(pass.PassAs<RenderPass>()); |
702 | 698 |
703 // First child is the delegated layer. | 699 // First child is the delegated layer. |
704 DelegatedRendererLayerImpl* delegated_impl = | 700 DelegatedRendererLayerImpl* delegated_impl = |
705 static_cast<DelegatedRendererLayerImpl*>( | 701 static_cast<DelegatedRendererLayerImpl*>( |
706 host_impl->rootLayer()->children()[0]); | 702 host_impl->rootLayer()->children()[0]); |
707 delegated_impl->setRenderPasses(pass_list); | 703 delegated_impl->setRenderPasses(pass_list); |
708 EXPECT_TRUE(pass_list.isEmpty()); | 704 EXPECT_TRUE(pass_list.isEmpty()); |
709 | 705 |
710 color_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 706 color_video_frame_ = VideoFrame::CreateColorFrame( |
711 VideoFrame::CreateColorFrame( | 707 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
712 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()))); | 708 hw_video_frame_ = VideoFrame::WrapNativeTexture( |
713 hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 709 resource_provider->graphicsContext3D()->createTexture(), |
714 VideoFrame::WrapNativeTexture( | 710 GL_TEXTURE_2D, |
715 resource_provider->graphicsContext3D()->createTexture(), | 711 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), |
716 GL_TEXTURE_2D, | 712 base::TimeDelta(), |
717 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), | 713 VideoFrame::ReadPixelsCB(), |
718 base::TimeDelta(), | 714 base::Closure()); |
719 VideoFrame::ReadPixelsCB(), | 715 scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( |
720 base::Closure()))); | 716 resource_provider->graphicsContext3D()->createTexture(), |
721 scaled_hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 717 GL_TEXTURE_2D, |
722 VideoFrame::WrapNativeTexture( | 718 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), |
723 resource_provider->graphicsContext3D()->createTexture(), | 719 base::TimeDelta(), |
724 GL_TEXTURE_2D, | 720 VideoFrame::ReadPixelsCB(), |
725 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), | 721 base::Closure()); |
726 base::TimeDelta(), | |
727 VideoFrame::ReadPixelsCB(), | |
728 base::Closure()))); | |
729 | 722 |
730 color_frame_provider_.set_frame(color_video_frame_.get()); | 723 color_frame_provider_.set_frame(color_video_frame_); |
731 hw_frame_provider_.set_frame(hw_video_frame_.get()); | 724 hw_frame_provider_.set_frame(hw_video_frame_); |
732 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_.get()); | 725 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); |
733 return; | 726 return; |
734 } | 727 } |
735 | 728 |
736 if (host_impl->activeTree()->source_frame_number() == 3) { | 729 if (host_impl->activeTree()->source_frame_number() == 3) { |
737 // On the third commit we're recovering from context loss. Hardware | 730 // On the third commit we're recovering from context loss. Hardware |
738 // video frames should not be reused by the VideoFrameProvider, but | 731 // video frames should not be reused by the VideoFrameProvider, but |
739 // software frames can be. | 732 // software frames can be. |
740 hw_frame_provider_.set_frame(NULL); | 733 hw_frame_provider_.set_frame(NULL); |
741 scaled_hw_frame_provider_.set_frame(NULL); | 734 scaled_hw_frame_provider_.set_frame(NULL); |
742 } | 735 } |
(...skipping 26 matching lines...) Expand all Loading... |
769 scoped_refptr<TextureLayer> texture_; | 762 scoped_refptr<TextureLayer> texture_; |
770 scoped_refptr<ContentLayer> mask_; | 763 scoped_refptr<ContentLayer> mask_; |
771 scoped_refptr<ContentLayer> content_with_mask_; | 764 scoped_refptr<ContentLayer> content_with_mask_; |
772 scoped_refptr<VideoLayer> video_color_; | 765 scoped_refptr<VideoLayer> video_color_; |
773 scoped_refptr<VideoLayer> video_hw_; | 766 scoped_refptr<VideoLayer> video_hw_; |
774 scoped_refptr<VideoLayer> video_scaled_hw_; | 767 scoped_refptr<VideoLayer> video_scaled_hw_; |
775 scoped_refptr<IOSurfaceLayer> io_surface_; | 768 scoped_refptr<IOSurfaceLayer> io_surface_; |
776 scoped_refptr<HeadsUpDisplayLayer> hud_; | 769 scoped_refptr<HeadsUpDisplayLayer> hud_; |
777 scoped_refptr<ScrollbarLayer> scrollbar_; | 770 scoped_refptr<ScrollbarLayer> scrollbar_; |
778 | 771 |
779 scoped_ptr<FakeVideoFrame> color_video_frame_; | 772 scoped_refptr<VideoFrame> color_video_frame_; |
780 scoped_ptr<FakeVideoFrame> hw_video_frame_; | 773 scoped_refptr<VideoFrame> hw_video_frame_; |
781 scoped_ptr<FakeVideoFrame> scaled_hw_video_frame_; | 774 scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
782 | 775 |
783 FakeVideoFrameProvider color_frame_provider_; | 776 FakeVideoFrameProvider color_frame_provider_; |
784 FakeVideoFrameProvider hw_frame_provider_; | 777 FakeVideoFrameProvider hw_frame_provider_; |
785 FakeVideoFrameProvider scaled_hw_frame_provider_; | 778 FakeVideoFrameProvider scaled_hw_frame_provider_; |
786 }; | 779 }; |
787 | 780 |
788 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) | 781 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) |
789 | 782 |
790 } // namespace | 783 } // namespace |
791 } // namespace cc | 784 } // namespace cc |
OLD | NEW |