| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 mask_->setAnchorPoint(gfx::PointF()); | 570 mask_->setAnchorPoint(gfx::PointF()); |
| 572 | 571 |
| 573 scoped_refptr<ContentLayer> content_with_mask_ = | 572 scoped_refptr<ContentLayer> content_with_mask_ = |
| 574 ContentLayer::create(&client_); | 573 ContentLayer::create(&client_); |
| 575 content_with_mask_->setBounds(gfx::Size(10, 10)); | 574 content_with_mask_->setBounds(gfx::Size(10, 10)); |
| 576 content_with_mask_->setAnchorPoint(gfx::PointF()); | 575 content_with_mask_->setAnchorPoint(gfx::PointF()); |
| 577 content_with_mask_->setIsDrawable(true); | 576 content_with_mask_->setIsDrawable(true); |
| 578 content_with_mask_->setMaskLayer(mask_.get()); | 577 content_with_mask_->setMaskLayer(mask_.get()); |
| 579 root_->addChild(content_with_mask_); | 578 root_->addChild(content_with_mask_); |
| 580 | 579 |
| 581 VideoLayerImpl::FrameUnwrapper unwrapper = | |
| 582 base::Bind(FakeVideoFrame::ToVideoFrame); | |
| 583 | |
| 584 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( | 580 scoped_refptr<VideoLayer> video_color_ = VideoLayer::create( |
| 585 &color_frame_provider_, unwrapper); | 581 &color_frame_provider_); |
| 586 video_color_->setBounds(gfx::Size(10, 10)); | 582 video_color_->setBounds(gfx::Size(10, 10)); |
| 587 video_color_->setAnchorPoint(gfx::PointF()); | 583 video_color_->setAnchorPoint(gfx::PointF()); |
| 588 video_color_->setIsDrawable(true); | 584 video_color_->setIsDrawable(true); |
| 589 root_->addChild(video_color_); | 585 root_->addChild(video_color_); |
| 590 | 586 |
| 591 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( | 587 scoped_refptr<VideoLayer> video_hw_ = VideoLayer::create( |
| 592 &hw_frame_provider_, unwrapper); | 588 &hw_frame_provider_); |
| 593 video_hw_->setBounds(gfx::Size(10, 10)); | 589 video_hw_->setBounds(gfx::Size(10, 10)); |
| 594 video_hw_->setAnchorPoint(gfx::PointF()); | 590 video_hw_->setAnchorPoint(gfx::PointF()); |
| 595 video_hw_->setIsDrawable(true); | 591 video_hw_->setIsDrawable(true); |
| 596 root_->addChild(video_hw_); | 592 root_->addChild(video_hw_); |
| 597 | 593 |
| 598 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( | 594 scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::create( |
| 599 &scaled_hw_frame_provider_, unwrapper); | 595 &scaled_hw_frame_provider_); |
| 600 video_scaled_hw_->setBounds(gfx::Size(10, 10)); | 596 video_scaled_hw_->setBounds(gfx::Size(10, 10)); |
| 601 video_scaled_hw_->setAnchorPoint(gfx::PointF()); | 597 video_scaled_hw_->setAnchorPoint(gfx::PointF()); |
| 602 video_scaled_hw_->setIsDrawable(true); | 598 video_scaled_hw_->setIsDrawable(true); |
| 603 root_->addChild(video_scaled_hw_); | 599 root_->addChild(video_scaled_hw_); |
| 604 | 600 |
| 605 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); | 601 scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::create(); |
| 606 io_surface_->setBounds(gfx::Size(10, 10)); | 602 io_surface_->setBounds(gfx::Size(10, 10)); |
| 607 io_surface_->setAnchorPoint(gfx::PointF()); | 603 io_surface_->setAnchorPoint(gfx::PointF()); |
| 608 io_surface_->setIsDrawable(true); | 604 io_surface_->setIsDrawable(true); |
| 609 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 605 io_surface_->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 pass_list.append(pass_for_quad.PassAs<RenderPass>()); | 663 pass_list.append(pass_for_quad.PassAs<RenderPass>()); |
| 668 pass_list.append(pass.PassAs<RenderPass>()); | 664 pass_list.append(pass.PassAs<RenderPass>()); |
| 669 | 665 |
| 670 // First child is the delegated layer. | 666 // First child is the delegated layer. |
| 671 DelegatedRendererLayerImpl* delegated_impl = | 667 DelegatedRendererLayerImpl* delegated_impl = |
| 672 static_cast<DelegatedRendererLayerImpl*>( | 668 static_cast<DelegatedRendererLayerImpl*>( |
| 673 host_impl->rootLayer()->children()[0]); | 669 host_impl->rootLayer()->children()[0]); |
| 674 delegated_impl->setRenderPasses(pass_list); | 670 delegated_impl->setRenderPasses(pass_list); |
| 675 EXPECT_TRUE(pass_list.isEmpty()); | 671 EXPECT_TRUE(pass_list.isEmpty()); |
| 676 | 672 |
| 677 color_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 673 color_video_frame_ = VideoFrame::CreateColorFrame( |
| 678 VideoFrame::CreateColorFrame( | 674 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 679 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()))); | 675 hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 680 hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 676 resource_provider->graphicsContext3D()->createTexture(), |
| 681 VideoFrame::WrapNativeTexture( | 677 GL_TEXTURE_2D, |
| 682 resource_provider->graphicsContext3D()->createTexture(), | 678 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), |
| 683 GL_TEXTURE_2D, | 679 base::TimeDelta(), |
| 684 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), | 680 VideoFrame::ReadPixelsCB(), |
| 685 base::TimeDelta(), | 681 base::Closure()); |
| 686 VideoFrame::ReadPixelsCB(), | 682 scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( |
| 687 base::Closure()))); | 683 resource_provider->graphicsContext3D()->createTexture(), |
| 688 scaled_hw_video_frame_ = make_scoped_ptr(new FakeVideoFrame( | 684 GL_TEXTURE_2D, |
| 689 VideoFrame::WrapNativeTexture( | 685 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), |
| 690 resource_provider->graphicsContext3D()->createTexture(), | 686 base::TimeDelta(), |
| 691 GL_TEXTURE_2D, | 687 VideoFrame::ReadPixelsCB(), |
| 692 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), | 688 base::Closure()); |
| 693 base::TimeDelta(), | |
| 694 VideoFrame::ReadPixelsCB(), | |
| 695 base::Closure()))); | |
| 696 | 689 |
| 697 color_frame_provider_.set_frame(color_video_frame_.get()); | 690 color_frame_provider_.set_frame(color_video_frame_); |
| 698 hw_frame_provider_.set_frame(hw_video_frame_.get()); | 691 hw_frame_provider_.set_frame(hw_video_frame_); |
| 699 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_.get()); | 692 scaled_hw_frame_provider_.set_frame(scaled_hw_video_frame_); |
| 700 return; | 693 return; |
| 701 } | 694 } |
| 702 | 695 |
| 703 if (host_impl->activeTree()->source_frame_number() == 3) { | 696 if (host_impl->activeTree()->source_frame_number() == 3) { |
| 704 // On the third commit we're recovering from context loss. Hardware | 697 // On the third commit we're recovering from context loss. Hardware |
| 705 // video frames should not be reused by the VideoFrameProvider, but | 698 // video frames should not be reused by the VideoFrameProvider, but |
| 706 // software frames can be. | 699 // software frames can be. |
| 707 hw_frame_provider_.set_frame(NULL); | 700 hw_frame_provider_.set_frame(NULL); |
| 708 scaled_hw_frame_provider_.set_frame(NULL); | 701 scaled_hw_frame_provider_.set_frame(NULL); |
| 709 } | 702 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 736 scoped_refptr<TextureLayer> texture_; | 729 scoped_refptr<TextureLayer> texture_; |
| 737 scoped_refptr<ContentLayer> mask_; | 730 scoped_refptr<ContentLayer> mask_; |
| 738 scoped_refptr<ContentLayer> content_with_mask_; | 731 scoped_refptr<ContentLayer> content_with_mask_; |
| 739 scoped_refptr<VideoLayer> video_color_; | 732 scoped_refptr<VideoLayer> video_color_; |
| 740 scoped_refptr<VideoLayer> video_hw_; | 733 scoped_refptr<VideoLayer> video_hw_; |
| 741 scoped_refptr<VideoLayer> video_scaled_hw_; | 734 scoped_refptr<VideoLayer> video_scaled_hw_; |
| 742 scoped_refptr<IOSurfaceLayer> io_surface_; | 735 scoped_refptr<IOSurfaceLayer> io_surface_; |
| 743 scoped_refptr<HeadsUpDisplayLayer> hud_; | 736 scoped_refptr<HeadsUpDisplayLayer> hud_; |
| 744 scoped_refptr<ScrollbarLayer> scrollbar_; | 737 scoped_refptr<ScrollbarLayer> scrollbar_; |
| 745 | 738 |
| 746 scoped_ptr<FakeVideoFrame> color_video_frame_; | 739 scoped_refptr<VideoFrame> color_video_frame_; |
| 747 scoped_ptr<FakeVideoFrame> hw_video_frame_; | 740 scoped_refptr<VideoFrame> hw_video_frame_; |
| 748 scoped_ptr<FakeVideoFrame> scaled_hw_video_frame_; | 741 scoped_refptr<VideoFrame> scaled_hw_video_frame_; |
| 749 | 742 |
| 750 FakeVideoFrameProvider color_frame_provider_; | 743 FakeVideoFrameProvider color_frame_provider_; |
| 751 FakeVideoFrameProvider hw_frame_provider_; | 744 FakeVideoFrameProvider hw_frame_provider_; |
| 752 FakeVideoFrameProvider scaled_hw_frame_provider_; | 745 FakeVideoFrameProvider scaled_hw_frame_provider_; |
| 753 }; | 746 }; |
| 754 | 747 |
| 755 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) | 748 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources) |
| 756 | 749 |
| 757 } // namespace | 750 } // namespace |
| 758 } // namespace cc | 751 } // namespace cc |
| OLD | NEW |