| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 mask_->setAnchorPoint(gfx::PointF()); | 557 mask_->setAnchorPoint(gfx::PointF()); |
| 559 | 558 |
| 560 scoped_refptr<ContentLayer> content_with_mask_ = | 559 scoped_refptr<ContentLayer> content_with_mask_ = |
| 561 ContentLayer::create(&client_); | 560 ContentLayer::create(&client_); |
| 562 content_with_mask_->setBounds(gfx::Size(10, 10)); | 561 content_with_mask_->setBounds(gfx::Size(10, 10)); |
| 563 content_with_mask_->setAnchorPoint(gfx::PointF()); | 562 content_with_mask_->setAnchorPoint(gfx::PointF()); |
| 564 content_with_mask_->setIsDrawable(true); | 563 content_with_mask_->setIsDrawable(true); |
| 565 content_with_mask_->setMaskLayer(mask_.get()); | 564 content_with_mask_->setMaskLayer(mask_.get()); |
| 566 root_->addChild(content_with_mask_); | 565 root_->addChild(content_with_mask_); |
| 567 | 566 |
| 568 VideoLayerImpl::FrameUnwrapper unwrapper = | |
| 569 base::Bind(FakeVideoFrame::ToVideoFrame); | |
| 570 | |
| 571 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( | 567 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( |
| 572 &color_frame_provider_, unwrapper); | 568 &color_frame_provider_); |
| 573 video_color_->setBounds(gfx::Size(10, 10)); | 569 video_color_->setBounds(gfx::Size(10, 10)); |
| 574 video_color_->setAnchorPoint(gfx::PointF()); | 570 video_color_->setAnchorPoint(gfx::PointF()); |
| 575 video_color_->setIsDrawable(true); | 571 video_color_->setIsDrawable(true); |
| 576 root_->addChild(video_color_); | 572 root_->addChild(video_color_); |
| 577 | 573 |
| 578 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( | 574 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( |
| 579 &hw_frame_provider_, unwrapper); | 575 &hw_frame_provider_); |
| 580 video_hw_->setBounds(gfx::Size(10, 10)); | 576 video_hw_->setBounds(gfx::Size(10, 10)); |
| 581 video_hw_->setAnchorPoint(gfx::PointF()); | 577 video_hw_->setAnchorPoint(gfx::PointF()); |
| 582 video_hw_->setIsDrawable(true); | 578 video_hw_->setIsDrawable(true); |
| 583 root_->addChild(video_hw_); | 579 root_->addChild(video_hw_); |
| 584 | 580 |
| 585 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( | 581 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( |
| 586 &scaled_hw_frame_provider_, unwrapper); | 582 &scaled_hw_frame_provider_); |
| 587 video_scaled_hw_->setBounds(gfx::Size(10, 10)); | 583 video_scaled_hw_->setBounds(gfx::Size(10, 10)); |
| 588 video_scaled_hw_->setAnchorPoint(gfx::PointF()); | 584 video_scaled_hw_->setAnchorPoint(gfx::PointF()); |
| 589 video_scaled_hw_->setIsDrawable(true); | 585 video_scaled_hw_->setIsDrawable(true); |
| 590 root_->addChild(video_scaled_hw_); | 586 root_->addChild(video_scaled_hw_); |
| 591 | 587 |
| 592 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); | 588 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); |
| 593 io_surface_->setBounds(gfx::Size(10, 10)); | 589 io_surface_->setBounds(gfx::Size(10, 10)); |
| 594 io_surface_->setAnchorPoint(gfx::PointF()); | 590 io_surface_->setAnchorPoint(gfx::PointF()); |
| 595 io_surface_->setIsDrawable(true); | 591 io_surface_->setIsDrawable(true); |
| 596 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 592 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 pass_list.append(pass_for_quad.PassAs<RenderPass>()); | 650 pass_list.append(pass_for_quad.PassAs<RenderPass>()); |
| 655 pass_list.append(pass.PassAs<RenderPass>()); | 651 pass_list.append(pass.PassAs<RenderPass>()); |
| 656 | 652 |
| 657 // First child is the delegated layer. | 653 // First child is the delegated layer. |
| 658 DelegatedRendererLayerImpl* delegated_impl = | 654 DelegatedRendererLayerImpl* delegated_impl = |
| 659 static_cast<DelegatedRendererLayerImpl*>( | 655 static_cast<DelegatedRendererLayerImpl*>( |
| 660 host_impl->rootLayer()->children()[0]); | 656 host_impl->rootLayer()->children()[0]); |
| 661 delegated_impl->setRenderPasses(pass_list); | 657 delegated_impl->setRenderPasses(pass_list); |
| 662 EXPECT_TRUE(pass_list.isEmpty()); | 658 EXPECT_TRUE(pass_list.isEmpty()); |
| 663 | 659 |
| 664 color_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 660 color_video_frame_ = VideoFrame::CreateColorFrame( |
| 665 VideoFrame::CreateColorFrame( | 661 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 666 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()))); | 662 hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 667 hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 663 resource_provider->graphicsContext3D()->createTexture(), |
| 668 VideoFrame::WrapNativeTexture( | 664 GL_TEXTURE_2D, |
| 669 resource_provider->graphicsContext3D()->createTexture(), | 665 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), |
| 670 GL_TEXTURE_2D, | 666 base::TimeDelta(), |
| 671 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), | 667 VideoFrame::ReadPixelsCB(), |
| 672 base::TimeDelta(), | 668 base::Closure()); |
| 673 VideoFrame::ReadPixelsCB(), | 669 scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 674 base::Closure()))); | 670 resource_provider->graphicsContext3D()->createTexture(), |
| 675 scaled_hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 671 GL_TEXTURE_2D, |
| 676 VideoFrame::WrapNativeTexture( | 672 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), |
| 677 resource_provider->graphicsContext3D()->createTexture(), | 673 base::TimeDelta(), |
| 678 GL_TEXTURE_2D, | 674 VideoFrame::ReadPixelsCB(), |
| 679 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), | 675 base::Closure()); |
| 680 base::TimeDelta(), | |
| 681 VideoFrame::ReadPixelsCB(), | |
| 682 base::Closure()))); | |
| 683 | 676 |
| 684 color_frame_provider_.set_frame(color_video_frame_.get()); | 677 color_frame_provider_.set_frame(color_video_frame_); |
| 685 hw_frame_provider_.set_frame(hw_video_frame_.get()); | 678 hw_frame_provider_.set_frame(hw_video_frame_); |
| 686 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_.get()); | 679 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); |
| 687 return; | 680 return; |
| 688 } | 681 } |
| 689 | 682 |
| 690 if (host_impl->activeTree()->source_frame_number() == 3) { | 683 if (host_impl->activeTree()->source_frame_number() == 3) { |
| 691 // On the third commit we're recovering from context loss. Hardware | 684 // On the third commit we're recovering from context loss. Hardware |
| 692 // video frames should not be reused by the VideoFrameProvider, but | 685 // video frames should not be reused by the VideoFrameProvider, but |
| 693 // software frames can be. | 686 // software frames can be. |
| 694 hw_frame_provider_.set_frame(NULL); | 687 hw_frame_provider_.set_frame(NULL); |
| 695 scaled_hw_frame_provider_.set_frame(NULL); | 688 scaled_hw_frame_provider_.set_frame(NULL); |
| 696 } | 689 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 723 scoped_refptr<TextureLayer> texture_; | 716 scoped_refptr<TextureLayer> texture_; |
| 724 scoped_refptr<ContentLayer> mask_; | 717 scoped_refptr<ContentLayer> mask_; |
| 725 scoped_refptr<ContentLayer> content_with_mask_; | 718 scoped_refptr<ContentLayer> content_with_mask_; |
| 726 scoped_refptr<VideoLayer> video_color_; | 719 scoped_refptr<VideoLayer> video_color_; |
| 727 scoped_refptr<VideoLayer> video_hw_; | 720 scoped_refptr<VideoLayer> video_hw_; |
| 728 scoped_refptr<VideoLayer> video_scaled_hw_; | 721 scoped_refptr<VideoLayer> video_scaled_hw_; |
| 729 scoped_refptr<IOSurfaceLayer> io_surface_; | 722 scoped_refptr<IOSurfaceLayer> io_surface_; |
| 730 scoped_refptr<HeadsUpDisplayLayer> hud_; | 723 scoped_refptr<HeadsUpDisplayLayer> hud_; |
| 731 scoped_refptr<ScrollbarLayer> scrollbar_; | 724 scoped_refptr<ScrollbarLayer> scrollbar_; |
| 732 | 725 |
| 733 scoped_ptr<FakeVideoFrame> color_video_frame_; | 726 scoped_refptr<VideoFrame> color_video_frame_; |
| 734 scoped_ptr<FakeVideoFrame> hw_video_frame_; | 727 scoped_refptr<VideoFrame> hw_video_frame_; |
| 735 scoped_ptr<FakeVideoFrame> scaled_hw_video_frame_; | 728 scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
| 736 | 729 |
| 737 FakeVideoFrameProvider color_frame_provider_; | 730 FakeVideoFrameProvider color_frame_provider_; |
| 738 FakeVideoFrameProvider hw_frame_provider_; | 731 FakeVideoFrameProvider hw_frame_provider_; |
| 739 FakeVideoFrameProvider scaled_hw_frame_provider_; | 732 FakeVideoFrameProvider scaled_hw_frame_provider_; |
| 740 }; | 733 }; |
| 741 | 734 |
| 742 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) | 735 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) |
| 743 | 736 |
| 744 } // namespace | 737 } // namespace |
| 745 } // namespace cc | 738 } // namespace cc |
| OLD | NEW |