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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1925 gfx::Rect layerRect(0, 0, 0, 0); | 1925 gfx::Rect layerRect(0, 0, 0, 0); |
1926 child->setPosition(layerRect.origin()); | 1926 child->setPosition(layerRect.origin()); |
1927 child->setBounds(layerRect.size()); | 1927 child->setBounds(layerRect.size()); |
1928 child->setContentBounds(layerRect.size()); | 1928 child->setContentBounds(layerRect.size()); |
1929 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1929 child->setQuadRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1930 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); | 1930 child->setQuadVisibleRect(gfx::Rect(gfx::Point(), layerRect.size())); |
1931 | 1931 |
1932 LayerTreeHostImpl::FrameData frame; | 1932 LayerTreeHostImpl::FrameData frame; |
1933 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1933 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
1934 ASSERT_EQ(1u, frame.renderPasses.size()); | 1934 ASSERT_EQ(1u, frame.renderPasses.size()); |
1935 m_hostImpl->didDrawAllLayers(frame); | |
danakj
2012/12/06 19:12:10
don't we need this to avoid "in between willdraw a
enne (OOO)
2012/12/06 19:25:42
You shouldn't call didDrawAllLayers twice. See li
danakj
2012/12/06 19:32:20
Ah!
| |
1936 | 1935 |
1937 size_t numGutterQuads = 0; | 1936 size_t numGutterQuads = 0; |
1938 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) | 1937 for (size_t i = 0; i < frame.renderPasses[0]->quad_list.size(); ++i) |
1939 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material == DrawQuad::SOLID_COLOR) ? 1 : 0; | 1938 numGutterQuads += (frame.renderPasses[0]->quad_list[i]->material == DrawQuad::SOLID_COLOR) ? 1 : 0; |
1940 EXPECT_EQ(1u, numGutterQuads); | 1939 EXPECT_EQ(1u, numGutterQuads); |
1941 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); | 1940 EXPECT_EQ(1u, frame.renderPasses[0]->quad_list.size()); |
1942 | 1941 |
1943 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect( gfx::Point(), viewportSize)); | 1942 verifyQuadsExactlyCoverRect(frame.renderPasses[0]->quad_list, gfx::Rect( gfx::Point(), viewportSize)); |
1944 m_hostImpl->didDrawAllLayers(frame); | 1943 m_hostImpl->didDrawAllLayers(frame); |
1945 } | 1944 } |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2834 base::TimeDelta())); | 2833 base::TimeDelta())); |
2835 VideoLayerImpl::FrameUnwrapper unwrapper = | 2834 VideoLayerImpl::FrameUnwrapper unwrapper = |
2836 base::Bind(FakeVideoFrame::toVideoFrame); | 2835 base::Bind(FakeVideoFrame::toVideoFrame); |
2837 FakeVideoFrameProvider provider; | 2836 FakeVideoFrameProvider provider; |
2838 provider.setFrame(&videoFrame); | 2837 provider.setFrame(&videoFrame); |
2839 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider, unwrapper); | 2838 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider, unwrapper); |
2840 videoLayer->setBounds(gfx::Size(10, 10)); | 2839 videoLayer->setBounds(gfx::Size(10, 10)); |
2841 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2840 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2842 videoLayer->setContentBounds(gfx::Size(10, 10)); | 2841 videoLayer->setContentBounds(gfx::Size(10, 10)); |
2843 videoLayer->setDrawsContent(true); | 2842 videoLayer->setDrawsContent(true); |
2844 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2845 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2843 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2846 | 2844 |
2847 FakeVideoFrameProvider providerScaled; | 2845 FakeVideoFrameProvider providerScaled; |
2848 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(layerId ++, &providerScaled, unwrapper); | 2846 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(layerId ++, &providerScaled, unwrapper); |
2849 videoLayerScaled->setBounds(gfx::Size(10, 10)); | 2847 videoLayerScaled->setBounds(gfx::Size(10, 10)); |
2850 videoLayerScaled->setAnchorPoint(gfx::PointF(0, 0)); | 2848 videoLayerScaled->setAnchorPoint(gfx::PointF(0, 0)); |
2851 videoLayerScaled->setContentBounds(gfx::Size(10, 10)); | 2849 videoLayerScaled->setContentBounds(gfx::Size(10, 10)); |
2852 videoLayerScaled->setDrawsContent(true); | 2850 videoLayerScaled->setDrawsContent(true); |
2853 videoLayerScaled->setLayerTreeHostImpl(m_hostImpl.get()); | |
2854 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); | 2851 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); |
2855 | 2852 |
2856 FakeVideoFrameProvider hwProvider; | 2853 FakeVideoFrameProvider hwProvider; |
2857 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider, unwrapper); | 2854 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider, unwrapper); |
2858 hwVideoLayer->setBounds(gfx::Size(10, 10)); | 2855 hwVideoLayer->setBounds(gfx::Size(10, 10)); |
2859 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2856 hwVideoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2860 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); | 2857 hwVideoLayer->setContentBounds(gfx::Size(10, 10)); |
2861 hwVideoLayer->setDrawsContent(true); | 2858 hwVideoLayer->setDrawsContent(true); |
2862 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2863 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2859 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
2864 | 2860 |
2865 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l ayerId++); | 2861 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(l ayerId++); |
2866 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 2862 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
2867 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2863 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2868 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 2864 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
2869 ioSurfaceLayer->setDrawsContent(true); | 2865 ioSurfaceLayer->setDrawsContent(true); |
2870 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 2866 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
2871 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2872 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 2867 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
2873 | 2868 |
2874 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea te(layerId++); | 2869 scoped_ptr<HeadsUpDisplayLayerImpl> hudLayer = HeadsUpDisplayLayerImpl::crea te(layerId++); |
2875 hudLayer->setBounds(gfx::Size(10, 10)); | 2870 hudLayer->setBounds(gfx::Size(10, 10)); |
2876 hudLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2871 hudLayer->setAnchorPoint(gfx::PointF(0, 0)); |
2877 hudLayer->setContentBounds(gfx::Size(10, 10)); | 2872 hudLayer->setContentBounds(gfx::Size(10, 10)); |
2878 hudLayer->setDrawsContent(true); | 2873 hudLayer->setDrawsContent(true); |
2879 hudLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2880 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); | 2874 rootLayer->addChild(hudLayer.PassAs<LayerImpl>()); |
2881 | 2875 |
2882 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++)); | 2876 scoped_ptr<FakeScrollbarLayerImpl> scrollbarLayer(FakeScrollbarLayerImpl::cr eate(layerId++)); |
2883 scrollbarLayer->setBounds(gfx::Size(10, 10)); | 2877 scrollbarLayer->setBounds(gfx::Size(10, 10)); |
2884 scrollbarLayer->setContentBounds(gfx::Size(10, 10)); | 2878 scrollbarLayer->setContentBounds(gfx::Size(10, 10)); |
2885 scrollbarLayer->setDrawsContent(true); | 2879 scrollbarLayer->setDrawsContent(true); |
2886 scrollbarLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2887 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); | 2880 scrollbarLayer->createResources(m_hostImpl->resourceProvider()); |
2888 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); | 2881 rootLayer->addChild(scrollbarLayer.PassAs<LayerImpl>()); |
2889 | 2882 |
2890 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende rerLayerImpl::create(layerId++)); | 2883 scoped_ptr<DelegatedRendererLayerImpl> delegatedRendererLayer(DelegatedRende rerLayerImpl::create(layerId++)); |
2891 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); | 2884 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); |
2892 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); | 2885 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); |
2893 delegatedRendererLayer->setDrawsContent(true); | 2886 delegatedRendererLayer->setDrawsContent(true); |
2894 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
2895 ScopedPtrVector<RenderPass> passList; | 2887 ScopedPtrVector<RenderPass> passList; |
2896 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); | 2888 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); |
2897 delegatedRendererLayer->setRenderPasses(passList); | 2889 delegatedRendererLayer->setRenderPasses(passList); |
2898 EXPECT_TRUE(passList.isEmpty()); | 2890 EXPECT_TRUE(passList.isEmpty()); |
2899 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2891 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2900 | 2892 |
2901 // Use a context that supports IOSurfaces | 2893 // Use a context that supports IOSurfaces |
2902 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>()); | 2894 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>()); |
2903 | 2895 |
2904 FakeVideoFrame hwVideoFrame( | 2896 FakeVideoFrame hwVideoFrame( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3028 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); | 3020 rootLayer->addChild(textureLayer.PassAs<LayerImpl>()); |
3029 | 3021 |
3030 VideoLayerImpl::FrameUnwrapper unwrapper = | 3022 VideoLayerImpl::FrameUnwrapper unwrapper = |
3031 base::Bind(FakeVideoFrame::toVideoFrame); | 3023 base::Bind(FakeVideoFrame::toVideoFrame); |
3032 FakeVideoFrameProvider provider; | 3024 FakeVideoFrameProvider provider; |
3033 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider, unwrapper); | 3025 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(4, &provider, unwrapper); |
3034 videoLayer->setBounds(gfx::Size(10, 10)); | 3026 videoLayer->setBounds(gfx::Size(10, 10)); |
3035 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3027 videoLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3036 videoLayer->setContentBounds(gfx::Size(10, 10)); | 3028 videoLayer->setContentBounds(gfx::Size(10, 10)); |
3037 videoLayer->setDrawsContent(true); | 3029 videoLayer->setDrawsContent(true); |
3038 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
3039 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 3030 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
3040 | 3031 |
3041 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5 ); | 3032 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5 ); |
3042 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 3033 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
3043 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3034 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3044 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 3035 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
3045 ioSurfaceLayer->setDrawsContent(true); | 3036 ioSurfaceLayer->setDrawsContent(true); |
3046 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 3037 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
3047 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | |
3048 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 3038 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
3049 | 3039 |
3050 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of). | 3040 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the LayerTreeHostImpl takes ownership of). |
3051 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)) ); | 3041 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)) ); |
3052 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(outputSurface->context3D()); | 3042 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track ingWebGraphicsContext3D*>(outputSurface->context3D()); |
3053 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 3043 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
3054 | 3044 |
3055 m_hostImpl->setRootLayer(rootLayer.Pass()); | 3045 m_hostImpl->setRootLayer(rootLayer.Pass()); |
3056 | 3046 |
3057 LayerTreeHostImpl::FrameData frame; | 3047 LayerTreeHostImpl::FrameData frame; |
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4895 { | 4885 { |
4896 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4886 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4897 } | 4887 } |
4898 | 4888 |
4899 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4889 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4900 LayerTreeHostImplTest, | 4890 LayerTreeHostImplTest, |
4901 ::testing::Values(false, true)); | 4891 ::testing::Values(false, true)); |
4902 | 4892 |
4903 } // namespace | 4893 } // namespace |
4904 } // namespace cc | 4894 } // namespace cc |
OLD | NEW |