OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 2540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2551 virtual ~FakeVideoFrame() { } | 2551 virtual ~FakeVideoFrame() { } |
2552 | 2552 |
2553 virtual Format format() const { NOTREACHED(); return FormatInvalid; } | 2553 virtual Format format() const { NOTREACHED(); return FormatInvalid; } |
2554 virtual unsigned width() const { NOTREACHED(); return 0; } | 2554 virtual unsigned width() const { NOTREACHED(); return 0; } |
2555 virtual unsigned height() const { NOTREACHED(); return 0; } | 2555 virtual unsigned height() const { NOTREACHED(); return 0; } |
2556 virtual unsigned planes() const { NOTREACHED(); return 0; } | 2556 virtual unsigned planes() const { NOTREACHED(); return 0; } |
2557 virtual int stride(unsigned plane) const { NOTREACHED(); return 0; } | 2557 virtual int stride(unsigned plane) const { NOTREACHED(); return 0; } |
2558 virtual const void* data(unsigned plane) const { NOTREACHED(); return NULL;
} | 2558 virtual const void* data(unsigned plane) const { NOTREACHED(); return NULL;
} |
2559 virtual unsigned textureId() const { NOTREACHED(); return 0; } | 2559 virtual unsigned textureId() const { NOTREACHED(); return 0; } |
2560 virtual unsigned textureTarget() const { NOTREACHED(); return 0; } | 2560 virtual unsigned textureTarget() const { NOTREACHED(); return 0; } |
| 2561 virtual WebKit::WebRect visibleRect() const { NOTREACHED(); return WebKit::W
ebRect(0, 0, 0, 0); } |
| 2562 virtual WebKit::WebSize textureSize() const { NOTREACHED(); return WebKit::W
ebSize(4, 4); } |
2561 | 2563 |
2562 static VideoFrame* toVideoFrame(WebVideoFrame* web_video_frame) { | 2564 static VideoFrame* toVideoFrame(WebVideoFrame* web_video_frame) { |
2563 FakeVideoFrame* wrapped_frame = | 2565 FakeVideoFrame* wrapped_frame = |
2564 static_cast<FakeVideoFrame*>(web_video_frame); | 2566 static_cast<FakeVideoFrame*>(web_video_frame); |
2565 if (wrapped_frame) | 2567 if (wrapped_frame) |
2566 return wrapped_frame->m_frame.get(); | 2568 return wrapped_frame->m_frame.get(); |
2567 return NULL; | 2569 return NULL; |
2568 } | 2570 } |
2569 | 2571 |
2570 private: | 2572 private: |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 FakeVideoFrameProvider provider; | 2723 FakeVideoFrameProvider provider; |
2722 provider.setFrame(&videoFrame); | 2724 provider.setFrame(&videoFrame); |
2723 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider, unwrapper); | 2725 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider, unwrapper); |
2724 videoLayer->setBounds(gfx::Size(10, 10)); | 2726 videoLayer->setBounds(gfx::Size(10, 10)); |
2725 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2727 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2726 videoLayer->setContentBounds(gfx::Size(10, 10)); | 2728 videoLayer->setContentBounds(gfx::Size(10, 10)); |
2727 videoLayer->setDrawsContent(true); | 2729 videoLayer->setDrawsContent(true); |
2728 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2730 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2729 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2731 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2730 | 2732 |
| 2733 FakeVideoFrameProvider providerScaled; |
| 2734 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(layerId
++, &providerScaled, unwrapper); |
| 2735 videoLayerScaled->setBounds(gfx::Size(10, 10)); |
| 2736 videoLayerScaled->setAnchorPoint(gfx::PointF(0, 0)); |
| 2737 videoLayerScaled->setContentBounds(gfx::Size(10, 10)); |
| 2738 videoLayerScaled->setDrawsContent(true); |
| 2739 videoLayerScaled->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2740 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); |
| 2741 |
2731 FakeVideoFrameProvider hwProvider; | 2742 FakeVideoFrameProvider hwProvider; |
2732 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++,
&hwProvider, unwrapper); | 2743 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++,
&hwProvider, unwrapper); |
2733 hwVideoLayer->setBounds(gfx::Size(10, 10)); | 2744 hwVideoLayer->setBounds(gfx::Size(10, 10)); |
2734 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2745 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2735 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); | 2746 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); |
2736 hwVideoLayer->setDrawsContent(true); | 2747 hwVideoLayer->setDrawsContent(true); |
2737 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2748 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2738 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2749 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
2739 | 2750 |
2740 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l
ayerId++); | 2751 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l
ayerId++); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 EXPECT_TRUE(passList.isEmpty()); | 2784 EXPECT_TRUE(passList.isEmpty()); |
2774 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2785 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2775 | 2786 |
2776 // Use a context that supports IOSurfaces | 2787 // Use a context that supports IOSurfaces |
2777 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); | 2788 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); |
2778 | 2789 |
2779 FakeVideoFrame hwVideoFrame( | 2790 FakeVideoFrame hwVideoFrame( |
2780 VideoFrame::WrapNativeTexture( | 2791 VideoFrame::WrapNativeTexture( |
2781 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2792 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
2782 GL_TEXTURE_2D, | 2793 GL_TEXTURE_2D, |
2783 gfx::Size(4, 4), gfx::Size(4, 4), base::TimeDelta(), | 2794 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), |
2784 VideoFrame::ReadPixelsCB(), base::Closure())); | 2795 VideoFrame::ReadPixelsCB(), base::Closure())); |
2785 hwProvider.setFrame(&hwVideoFrame); | 2796 hwProvider.setFrame(&hwVideoFrame); |
2786 | 2797 |
| 2798 FakeVideoFrame videoFrameScaled( |
| 2799 VideoFrame::WrapNativeTexture( |
| 2800 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
| 2801 GL_TEXTURE_2D, |
| 2802 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD
elta(), |
| 2803 VideoFrame::ReadPixelsCB(), base::Closure())); |
| 2804 providerScaled.setFrame(&videoFrameScaled); |
| 2805 |
2787 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2806 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2788 | 2807 |
2789 LayerTreeHostImpl::FrameData frame; | 2808 LayerTreeHostImpl::FrameData frame; |
2790 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2809 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2791 m_hostImpl->drawLayers(frame); | 2810 m_hostImpl->drawLayers(frame); |
2792 m_hostImpl->didDrawAllLayers(frame); | 2811 m_hostImpl->didDrawAllLayers(frame); |
2793 m_hostImpl->swapBuffers(); | 2812 m_hostImpl->swapBuffers(); |
2794 | 2813 |
2795 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2814 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
2796 | 2815 |
2797 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, | 2816 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, |
2798 // that will warn if any resource from the previous context gets used. | 2817 // that will warn if any resource from the previous context gets used. |
2799 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface))
.PassAs<GraphicsContext>()); | 2818 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface))
.PassAs<GraphicsContext>()); |
2800 | 2819 |
2801 // Create dummy resources so that looking up an old resource will get an | 2820 // Create dummy resources so that looking up an old resource will get an |
2802 // invalid texture id mapping. | 2821 // invalid texture id mapping. |
2803 for (unsigned i = 0; i < numResources; ++i) | 2822 for (unsigned i = 0; i < numResources; ++i) |
2804 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(1); | 2823 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(1); |
2805 | 2824 |
2806 // The WebVideoFrameProvider is expected to recreate its textures after a | 2825 // The WebVideoFrameProvider is expected to recreate its textures after a |
2807 // lost context (or not serve a frame). | 2826 // lost context (or not serve a frame). |
2808 hwProvider.setFrame(0); | 2827 hwProvider.setFrame(0); |
| 2828 providerScaled.setFrame(0); |
2809 | 2829 |
2810 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2830 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2811 m_hostImpl->drawLayers(frame); | 2831 m_hostImpl->drawLayers(frame); |
2812 m_hostImpl->didDrawAllLayers(frame); | 2832 m_hostImpl->didDrawAllLayers(frame); |
2813 m_hostImpl->swapBuffers(); | 2833 m_hostImpl->swapBuffers(); |
2814 | 2834 |
2815 FakeVideoFrame hwVideoFrame2( | 2835 FakeVideoFrame hwVideoFrame2( |
2816 VideoFrame::WrapNativeTexture( | 2836 VideoFrame::WrapNativeTexture( |
2817 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2837 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
2818 GL_TEXTURE_2D, | 2838 GL_TEXTURE_2D, |
2819 gfx::Size(4, 4), gfx::Size(4, 4), base::TimeDelta(), | 2839 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), |
2820 VideoFrame::ReadPixelsCB(), base::Closure())); | 2840 VideoFrame::ReadPixelsCB(), base::Closure())); |
2821 hwProvider.setFrame(&hwVideoFrame2); | 2841 hwProvider.setFrame(&hwVideoFrame2); |
2822 | 2842 |
2823 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2843 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2824 m_hostImpl->drawLayers(frame); | 2844 m_hostImpl->drawLayers(frame); |
2825 m_hostImpl->didDrawAllLayers(frame); | 2845 m_hostImpl->didDrawAllLayers(frame); |
2826 m_hostImpl->swapBuffers(); | 2846 m_hostImpl->swapBuffers(); |
2827 } | 2847 } |
2828 | 2848 |
2829 // Fake WebGraphicsContext3D that tracks the number of textures in use. | 2849 // Fake WebGraphicsContext3D that tracks the number of textures in use. |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4408 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4428 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4409 testCaseIndex++; | 4429 testCaseIndex++; |
4410 } | 4430 } |
4411 } | 4431 } |
4412 | 4432 |
4413 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4433 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4414 LayerTreeHostImplTest, | 4434 LayerTreeHostImplTest, |
4415 ::testing::Values(false, true)); | 4435 ::testing::Values(false, true)); |
4416 | 4436 |
4417 } // anonymous namespace | 4437 } // anonymous namespace |
OLD | NEW |