Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: cc/output/gl_renderer_unittest.cc

Issue 2352963002: cc: Make most of cc::OutputSurface abstract. (Closed)
Patch Set: outputsurface-cleanup: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 MOCK_METHOD0(DiscardBackbuffer, void()); 1602 MOCK_METHOD0(DiscardBackbuffer, void());
1603 MOCK_METHOD4(Reshape, 1603 MOCK_METHOD4(Reshape,
1604 void(const gfx::Size& size, 1604 void(const gfx::Size& size,
1605 float scale_factor, 1605 float scale_factor,
1606 const gfx::ColorSpace& color_space, 1606 const gfx::ColorSpace& color_space,
1607 bool has_alpha)); 1607 bool has_alpha));
1608 MOCK_METHOD0(BindFramebuffer, void()); 1608 MOCK_METHOD0(BindFramebuffer, void());
1609 MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum()); 1609 MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum());
1610 MOCK_METHOD1(SwapBuffers_, void(CompositorFrame& frame)); // NOLINT 1610 MOCK_METHOD1(SwapBuffers_, void(CompositorFrame& frame)); // NOLINT
1611 void SwapBuffers(CompositorFrame frame) override { SwapBuffers_(frame); } 1611 void SwapBuffers(CompositorFrame frame) override { SwapBuffers_(frame); }
1612 MOCK_CONST_METHOD0(GetOverlayCandidateValidator,
1613 OverlayCandidateValidator*());
1614 MOCK_CONST_METHOD0(IsDisplayedAsOverlayPlane, bool());
1615 MOCK_CONST_METHOD0(GetOverlayTextureId, unsigned());
1616 MOCK_CONST_METHOD0(SurfaceIsSuspendForRecycle, bool());
1617 MOCK_CONST_METHOD0(HasExternalStencilTest, bool());
1618 MOCK_METHOD0(ApplyExternalStencil, void());
1612 }; 1619 };
1613 1620
1614 class MockOutputSurfaceTest : public GLRendererTest { 1621 class MockOutputSurfaceTest : public GLRendererTest {
1615 protected: 1622 protected:
1616 virtual void SetUp() { 1623 virtual void SetUp() {
1617 FakeOutputSurfaceClient output_surface_client_; 1624 FakeOutputSurfaceClient output_surface_client_;
1618 CHECK(output_surface_.BindToClient(&output_surface_client_)); 1625 CHECK(output_surface_.BindToClient(&output_surface_client_));
1619 1626
1620 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 1627 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
1621 resource_provider_ = FakeResourceProvider::Create( 1628 resource_provider_ = FakeResourceProvider::Create(
1622 output_surface_.context_provider(), shared_bitmap_manager_.get()); 1629 output_surface_.context_provider(), shared_bitmap_manager_.get());
1623 1630
1624 renderer_.reset(new FakeRendererGL(&settings_, &output_surface_, 1631 renderer_.reset(new FakeRendererGL(&settings_, &output_surface_,
1625 resource_provider_.get())); 1632 resource_provider_.get()));
1633 EXPECT_CALL(output_surface_, GetOverlayCandidateValidator()).Times(1);
1626 renderer_->Initialize(); 1634 renderer_->Initialize();
1627 1635
1628 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1); 1636 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1);
1629 renderer_->SetVisible(true); 1637 renderer_->SetVisible(true);
1638 Mock::VerifyAndClearExpectations(&output_surface_);
1630 } 1639 }
1631 1640
1632 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); } 1641 void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); }
1633 1642
1634 void DrawFrame(float device_scale_factor, 1643 void DrawFrame(float device_scale_factor,
1635 const gfx::Rect& device_viewport_rect, 1644 const gfx::Rect& device_viewport_rect,
1636 bool transparent) { 1645 bool transparent) {
1637 RenderPassId render_pass_id(1, 0); 1646 RenderPassId render_pass_id(1, 0);
1638 RenderPass* render_pass = 1647 RenderPass* render_pass =
1639 AddRenderPass(&render_passes_in_draw_order_, render_pass_id, 1648 AddRenderPass(&render_passes_in_draw_order_, render_pass_id,
(...skipping 29 matching lines...) Expand all
1669 StrictMock<MockOutputSurface> output_surface_; 1678 StrictMock<MockOutputSurface> output_surface_;
1670 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_; 1679 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager_;
1671 std::unique_ptr<ResourceProvider> resource_provider_; 1680 std::unique_ptr<ResourceProvider> resource_provider_;
1672 std::unique_ptr<FakeRendererGL> renderer_; 1681 std::unique_ptr<FakeRendererGL> renderer_;
1673 }; 1682 };
1674 1683
1675 TEST_F(MockOutputSurfaceTest, BackbufferDiscard) { 1684 TEST_F(MockOutputSurfaceTest, BackbufferDiscard) {
1676 // Drop backbuffer on hide. 1685 // Drop backbuffer on hide.
1677 EXPECT_CALL(output_surface_, DiscardBackbuffer()).Times(1); 1686 EXPECT_CALL(output_surface_, DiscardBackbuffer()).Times(1);
1678 renderer_->SetVisible(false); 1687 renderer_->SetVisible(false);
1688 Mock::VerifyAndClearExpectations(&output_surface_);
1689
1679 // Restore backbuffer on show. 1690 // Restore backbuffer on show.
1680 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1); 1691 EXPECT_CALL(output_surface_, EnsureBackbuffer()).Times(1);
1681 renderer_->SetVisible(true); 1692 renderer_->SetVisible(true);
1682 } 1693 Mock::VerifyAndClearExpectations(&output_surface_);
1683
1684 TEST_F(MockOutputSurfaceTest, DrawFrameAndSwap) {
1685 gfx::Rect device_viewport_rect(1, 1);
1686 DrawFrame(1.f, device_viewport_rect, true);
1687
1688 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1689 renderer_->SwapBuffers(CompositorFrameMetadata());
1690 }
1691
1692 TEST_F(MockOutputSurfaceTest, DrawOpaqueFrameAndSwap) {
1693 gfx::Rect device_viewport_rect(1, 1);
1694 DrawFrame(1.f, device_viewport_rect, false);
1695
1696 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1697 renderer_->SwapBuffers(CompositorFrameMetadata());
1698 }
1699
1700 TEST_F(MockOutputSurfaceTest, DrawFrameAndResizeAndSwap) {
1701 gfx::Rect device_viewport_rect(1, 1);
1702
1703 DrawFrame(1.f, device_viewport_rect, true);
1704 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1705 renderer_->SwapBuffers(CompositorFrameMetadata());
1706
1707 device_viewport_rect = gfx::Rect(2, 2);
1708
1709 DrawFrame(2.f, device_viewport_rect, true);
1710 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1711 renderer_->SwapBuffers(CompositorFrameMetadata());
1712
1713 DrawFrame(2.f, device_viewport_rect, true);
1714 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1715 renderer_->SwapBuffers(CompositorFrameMetadata());
1716
1717 device_viewport_rect = gfx::Rect(1, 1);
1718
1719 DrawFrame(1.f, device_viewport_rect, true);
1720 EXPECT_CALL(output_surface_, SwapBuffers_(_)).Times(1);
1721 renderer_->SwapBuffers(CompositorFrameMetadata());
1722 } 1694 }
1723 1695
1724 class TestOverlayProcessor : public OverlayProcessor { 1696 class TestOverlayProcessor : public OverlayProcessor {
1725 public: 1697 public:
1726 class Strategy : public OverlayProcessor::Strategy { 1698 class Strategy : public OverlayProcessor::Strategy {
1727 public: 1699 public:
1728 Strategy() {} 1700 Strategy() {}
1729 ~Strategy() override {} 1701 ~Strategy() override {}
1730 MOCK_METHOD3(Attempt, 1702 MOCK_METHOD3(Attempt,
1731 bool(ResourceProvider* resource_provider, 1703 bool(ResourceProvider* resource_provider,
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 renderer_->SetVisible(true); 2085 renderer_->SetVisible(true);
2114 Mock::VerifyAndClearExpectations(context_support_ptr_); 2086 Mock::VerifyAndClearExpectations(context_support_ptr_);
2115 2087
2116 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); 2088 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true));
2117 renderer_->SetVisible(false); 2089 renderer_->SetVisible(false);
2118 Mock::VerifyAndClearExpectations(context_support_ptr_); 2090 Mock::VerifyAndClearExpectations(context_support_ptr_);
2119 } 2091 }
2120 2092
2121 } // namespace 2093 } // namespace
2122 } // namespace cc 2094 } // namespace cc
OLDNEW
« no previous file with comments | « blimp/client/support/compositor/blimp_embedder_compositor.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698