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() : m_textureId(0), m_visibleRect(0, 0, 4, 4) { memset(m_data , 0x80, sizeof(m_data)); } |
2539 virtual ~FakeVideoFrame() { } | 2539 virtual ~FakeVideoFrame() { } |
2540 virtual Format format() const { return m_textureId ? FormatNativeTexture : F ormatYV12; } | 2540 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; } | 2541 virtual unsigned planes() const { return m_textureId ? 0 : 3; } |
2544 virtual int stride(unsigned plane) const { return 4; } | 2542 virtual int stride(unsigned plane) const { return 4; } |
Ami GONE FROM CHROMIUM
2012/10/25 17:13:34
16?
sheu
2012/10/25 21:44:13
I guess for FormatNativeTexture that makes sense.
| |
2545 virtual const void* data(unsigned plane) const { return m_data; } | 2543 virtual const void* data(unsigned plane) const { return m_data; } |
2546 virtual unsigned textureId() const { return m_textureId; } | 2544 virtual unsigned textureId() const { return m_textureId; } |
2547 virtual unsigned textureTarget() const { return m_textureId ? GL_TEXTURE_2D : 0; } | 2545 virtual unsigned textureTarget() const { return m_textureId ? GL_TEXTURE_2D : 0; } |
2546 virtual WebKit::WebRect visibleRect() const { visibleRect; } | |
Ami GONE FROM CHROMIUM
2012/10/25 17:13:34
missing m_?
(how is this compiling? :))
sheu
2012/10/25 21:44:13
Aha. Looks like I have -build_tests -autotest in
| |
2547 virtual WebKit::WebRect textureSize() const { return WebKit::WebSize(4, 4); } | |
2548 | 2548 |
2549 void setVisibleRect(const WebKit::WebRect& visibleRect) { m_visibleRect = vi sibleRect; } | |
2549 void setTextureId(unsigned id) { m_textureId = id; } | 2550 void setTextureId(unsigned id) { m_textureId = id; } |
2550 | 2551 |
2551 private: | 2552 private: |
2552 char m_data[16]; | 2553 char m_data[16]; |
2553 unsigned m_textureId; | 2554 unsigned m_textureId; |
2555 WebKit::WebRect m_visibleRect; | |
2554 }; | 2556 }; |
2555 | 2557 |
2556 // Fake video frame provider that always provides the same FakeVideoFrame. | 2558 // Fake video frame provider that always provides the same FakeVideoFrame. |
2557 class FakeVideoFrameProvider: public WebVideoFrameProvider { | 2559 class FakeVideoFrameProvider: public WebVideoFrameProvider { |
2558 public: | 2560 public: |
2559 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } | 2561 FakeVideoFrameProvider() : m_frame(0), m_client(0) { } |
2560 virtual ~FakeVideoFrameProvider() | 2562 virtual ~FakeVideoFrameProvider() |
2561 { | 2563 { |
2562 if (m_client) | 2564 if (m_client) |
2563 m_client->stopUsingProvider(); | 2565 m_client->stopUsingProvider(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2699 FakeVideoFrameProvider provider; | 2701 FakeVideoFrameProvider provider; |
2700 provider.setFrame(&videoFrame); | 2702 provider.setFrame(&videoFrame); |
2701 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider); | 2703 scoped_ptr<VideoLayerImpl> videoLayer = VideoLayerImpl::create(layerId++, &p rovider); |
2702 videoLayer->setBounds(IntSize(10, 10)); | 2704 videoLayer->setBounds(IntSize(10, 10)); |
2703 videoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2705 videoLayer->setAnchorPoint(FloatPoint(0, 0)); |
2704 videoLayer->setContentBounds(IntSize(10, 10)); | 2706 videoLayer->setContentBounds(IntSize(10, 10)); |
2705 videoLayer->setDrawsContent(true); | 2707 videoLayer->setDrawsContent(true); |
2706 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2708 videoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2707 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); | 2709 rootLayer->addChild(videoLayer.PassAs<LayerImpl>()); |
2708 | 2710 |
2711 FakeVideoFrame videoFrameScaled; | |
2712 FakeVideoFrameProvider providerScaled; | |
2713 providerScaled.setFrame(&videoFrameScaled); | |
2714 scoped_ptr<VideoLayerImpl> videoLayerScaled = VideoLayerImpl::create(layerId ++, &providerScaled); | |
2715 videoLayerScaled->setBounds(IntSize(10, 10)); | |
2716 videoLayerScaled->setAnchorPoint(FloatPoint(0, 0)); | |
2717 videoLayerScaled->setContentBounds(IntSize(10, 10)); | |
2718 videoLayerScaled->setDrawsContent(true); | |
2719 videoLayerScaled->setLayerTreeHostImpl(m_hostImpl.get()); | |
2720 rootLayer->addChild(videoLayerScaled.PassAs<LayerImpl>()); | |
2721 | |
2709 FakeVideoFrame hwVideoFrame; | 2722 FakeVideoFrame hwVideoFrame; |
2710 FakeVideoFrameProvider hwProvider; | 2723 FakeVideoFrameProvider hwProvider; |
2711 hwProvider.setFrame(&hwVideoFrame); | 2724 hwProvider.setFrame(&hwVideoFrame); |
2712 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider); | 2725 scoped_ptr<VideoLayerImpl> hwVideoLayer = VideoLayerImpl::create(layerId++, &hwProvider); |
2713 hwVideoLayer->setBounds(IntSize(10, 10)); | 2726 hwVideoLayer->setBounds(IntSize(10, 10)); |
2714 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); | 2727 hwVideoLayer->setAnchorPoint(FloatPoint(0, 0)); |
2715 hwVideoLayer->setContentBounds(IntSize(10, 10)); | 2728 hwVideoLayer->setContentBounds(IntSize(10, 10)); |
2716 hwVideoLayer->setDrawsContent(true); | 2729 hwVideoLayer->setDrawsContent(true); |
2717 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2730 hwVideoLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2718 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); | 2731 rootLayer->addChild(hwVideoLayer.PassAs<LayerImpl>()); |
(...skipping 30 matching lines...) Expand all Loading... | |
2749 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2762 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2750 ScopedPtrVector<RenderPass> passList; | 2763 ScopedPtrVector<RenderPass> passList; |
2751 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); | 2764 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); |
2752 delegatedRendererLayer->setRenderPasses(passList); | 2765 delegatedRendererLayer->setRenderPasses(passList); |
2753 EXPECT_TRUE(passList.isEmpty()); | 2766 EXPECT_TRUE(passList.isEmpty()); |
2754 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2767 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2755 | 2768 |
2756 // Use a context that supports IOSurfaces | 2769 // Use a context that supports IOSurfaces |
2757 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>()); | 2770 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<GraphicsContext>()); |
2758 | 2771 |
2772 videoFrameScaled.setVisibleRect(WebKit::WebRect(0, 0, 3, 2)); | |
2759 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture()); | 2773 hwVideoFrame.setTextureId(m_hostImpl->resourceProvider()->graphicsContext3D( )->createTexture()); |
2760 | 2774 |
2761 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2775 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2762 | 2776 |
2763 LayerTreeHostImpl::FrameData frame; | 2777 LayerTreeHostImpl::FrameData frame; |
2764 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2778 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2765 m_hostImpl->drawLayers(frame); | 2779 m_hostImpl->drawLayers(frame); |
2766 m_hostImpl->didDrawAllLayers(frame); | 2780 m_hostImpl->didDrawAllLayers(frame); |
2767 m_hostImpl->swapBuffers(); | 2781 m_hostImpl->swapBuffers(); |
2768 | 2782 |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4375 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); | 4389 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); |
4376 testCaseIndex++; | 4390 testCaseIndex++; |
4377 } | 4391 } |
4378 } | 4392 } |
4379 | 4393 |
4380 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4394 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4381 LayerTreeHostImplTest, | 4395 LayerTreeHostImplTest, |
4382 ::testing::Values(false, true)); | 4396 ::testing::Values(false, true)); |
4383 | 4397 |
4384 } // namespace | 4398 } // namespace |
OLD | NEW |