| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 2517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 ADD_FAILURE() << "Trying to bind texture id " << id; | 2528 ADD_FAILURE() << "Trying to bind texture id " << id; |
| 2529 } | 2529 } |
| 2530 | 2530 |
| 2531 private: | 2531 private: |
| 2532 base::hash_set<unsigned> m_allocatedTextureIds; | 2532 base::hash_set<unsigned> m_allocatedTextureIds; |
| 2533 }; | 2533 }; |
| 2534 | 2534 |
| 2535 // Fake video frame that represents a 4x4 YUV video frame. | 2535 // Fake video frame that represents a 4x4 YUV video frame. |
| 2536 class FakeVideoFrame: public WebVideoFrame { | 2536 class FakeVideoFrame: public WebVideoFrame { |
| 2537 public: | 2537 public: |
| 2538 FakeVideoFrame() : m_textureId(0) { memset(m_data, 0x80, sizeof(m_data)); } | 2538 FakeVideoFrame() |
| 2539 : m_textureId(0) |
| 2540 , m_visibleRect(0, 0, 4, 4) |
| 2541 { |
| 2542 memset(m_data, 0x80, sizeof(m_data)); |
| 2543 } |
| 2539 virtual ~FakeVideoFrame() { } | 2544 virtual ~FakeVideoFrame() { } |
| 2540 virtual Format format() const { return m_textureId ? FormatNativeTexture : F
ormatYV12; } | 2545 virtual Format format() const { return m_textureId ? FormatNativeTexture : F
ormatYV12; } |
| 2541 virtual unsigned width() const { return 4; } | |
| 2542 virtual unsigned height() const { return 4; } | |
| 2543 virtual unsigned planes() const { return m_textureId ? 0 : 3; } | 2546 virtual unsigned planes() const { return m_textureId ? 0 : 3; } |
| 2544 virtual int stride(unsigned plane) const { return 4; } | 2547 virtual int stride(unsigned plane) const { return 16; } |
| 2545 virtual const void* data(unsigned plane) const { return m_data; } | 2548 virtual const void* data(unsigned plane) const { return m_data; } |
| 2546 virtual unsigned textureId() const { return m_textureId; } | 2549 virtual unsigned textureId() const { return m_textureId; } |
| 2547 virtual unsigned textureTarget() const { return m_textureId ? GL_TEXTURE_2D
: 0; } | 2550 virtual unsigned textureTarget() const { return m_textureId ? GL_TEXTURE_2D
: 0; } |
| 2551 virtual WebKit::WebRect visibleRect() const { return m_visibleRect; } |
| 2552 virtual WebKit::WebSize textureSize() const { return WebKit::WebSize(4, 4);
} |
| 2548 | 2553 |
| 2554 void setVisibleRect(const WebKit::WebRect& visibleRect) { m_visibleRect = vi
sibleRect; } |
| 2549 void setTextureId(unsigned id) { m_textureId = id; } | 2555 void setTextureId(unsigned id) { m_textureId = id; } |
| 2550 | 2556 |
| 2551 private: | 2557 private: |
| 2552 char m_data[16]; | 2558 char m_data[64]; |
| 2553 unsigned m_textureId; | 2559 unsigned m_textureId; |
| 2560 WebKit::WebRect m_visibleRect; |
| 2554 }; | 2561 }; |
| 2555 | 2562 |
| 2556 // Fake video frame provider that always provides the same FakeVideoFrame. | 2563 // Fake video frame provider that always provides the same FakeVideoFrame. |
| 2557 class FakeVideoFrameProvider: public WebVideoFrameProvider { | 2564 class FakeVideoFrameProvider: public WebVideoFrameProvider { |
| 2558 public: | 2565 public: |
| 2559 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } | 2566 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } |
| 2560 virtual ~FakeVideoFrameProvider() | 2567 virtual ~FakeVideoFrameProvider() |
| 2561 { | 2568 { |
| 2562 if (m_client) | 2569 if (m_client) |
| 2563 m_client->stopUsingProvider(); | 2570 m_client->stopUsingProvider(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2699 FakeVideoFrameProvider provider; | 2706 FakeVideoFrameProvider provider; |
| 2700 provider.setFrame(&videoFrame); | 2707 provider.setFrame(&videoFrame); |
| 2701 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider); | 2708 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p
rovider); |
| 2702 videoLayer->setBounds(IntSize(10, 10)); | 2709 videoLayer->setBounds(IntSize(10, 10)); |
| 2703 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2710 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2704 videoLayer->setContentBounds(IntSize(10, 10)); | 2711 videoLayer->setContentBounds(IntSize(10, 10)); |
| 2705 videoLayer->setDrawsContent(true); | 2712 videoLayer->setDrawsContent(true); |
| 2706 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2713 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2707 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2714 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
| 2708 | 2715 |
| 2716 FakeVideoFrame videoFrameScaled; |
| 2717 FakeVideoFrameProvider providerScaled; |
| 2718 providerScaled.setFrame(&videoFrameScaled); |
| 2719 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(layerId
++, &providerScaled); |
| 2720 videoLayerScaled->setBounds(IntSize(10, 10)); |
| 2721 videoLayerScaled->setAnchorPoint(FloatPoint(0, 0)); |
| 2722 videoLayerScaled->setContentBounds(IntSize(10, 10)); |
| 2723 videoLayerScaled->setDrawsContent(true); |
| 2724 videoLayerScaled->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2725 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); |
| 2726 |
| 2709 FakeVideoFrame hwVideoFrame; | 2727 FakeVideoFrame hwVideoFrame; |
| 2710 FakeVideoFrameProvider hwProvider; | 2728 FakeVideoFrameProvider hwProvider; |
| 2711 hwProvider.setFrame(&hwVideoFrame); | 2729 hwProvider.setFrame(&hwVideoFrame); |
| 2712 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++,
&hwProvider); | 2730 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++,
&hwProvider); |
| 2713 hwVideoLayer->setBounds(IntSize(10, 10)); | 2731 hwVideoLayer->setBounds(IntSize(10, 10)); |
| 2714 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2732 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); |
| 2715 hwVideoLayer->setContentBounds(IntSize(10, 10)); | 2733 hwVideoLayer->setContentBounds(IntSize(10, 10)); |
| 2716 hwVideoLayer->setDrawsContent(true); | 2734 hwVideoLayer->setDrawsContent(true); |
| 2717 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2735 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2718 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2736 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2749 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2767 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2750 ScopedPtrVector<RenderPass> passList; | 2768 ScopedPtrVector<RenderPass> passList; |
| 2751 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2769 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
| 2752 delegatedRendererLayer->setRenderPasses(passList); | 2770 delegatedRendererLayer->setRenderPasses(passList); |
| 2753 EXPECT_TRUE(passList.isEmpty()); | 2771 EXPECT_TRUE(passList.isEmpty()); |
| 2754 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2772 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
| 2755 | 2773 |
| 2756 // Use a context that supports IOSurfaces | 2774 // Use a context that supports IOSurfaces |
| 2757 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); | 2775 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); |
| 2758 | 2776 |
| 2777 videoFrameScaled.setVisibleRect(WebKit::WebRect(0, 0, 3, 2)); |
| 2759 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D(
)->createTexture()); | 2778 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D(
)->createTexture()); |
| 2760 | 2779 |
| 2761 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2780 m_hostImpl->setRootLayer(rootLayer.Pass()); |
| 2762 | 2781 |
| 2763 LayerTreeHostImpl::FrameData frame; | 2782 LayerTreeHostImpl::FrameData frame; |
| 2764 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2783 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2765 m_hostImpl->drawLayers(frame); | 2784 m_hostImpl->drawLayers(frame); |
| 2766 m_hostImpl->didDrawAllLayers(frame); | 2785 m_hostImpl->didDrawAllLayers(frame); |
| 2767 m_hostImpl->swapBuffers(); | 2786 m_hostImpl->swapBuffers(); |
| 2768 | 2787 |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4375 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4394 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
| 4376 testCaseIndex++; | 4395 testCaseIndex++; |
| 4377 } | 4396 } |
| 4378 } | 4397 } |
| 4379 | 4398 |
| 4380 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4399 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4381 LayerTreeHostImplTest, | 4400 LayerTreeHostImplTest, |
| 4382 ::testing::Values(false, true)); | 4401 ::testing::Values(false, true)); |
| 4383 | 4402 |
| 4384 } // namespace | 4403 } // namespace |
| OLD | NEW |