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

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

Issue 2693023002: Use SwapBuffersWithBounds on Chromecast (Closed)
Patch Set: Address danakj comments on PS1 Created 3 years, 10 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 #include <vector> 10 #include <vector>
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 renderer_->SetVisible(true); 1583 renderer_->SetVisible(true);
1584 Mock::VerifyAndClearExpectations(output_surface_.get()); 1584 Mock::VerifyAndClearExpectations(output_surface_.get());
1585 } 1585 }
1586 1586
1587 class TestOverlayProcessor : public OverlayProcessor { 1587 class TestOverlayProcessor : public OverlayProcessor {
1588 public: 1588 public:
1589 class Strategy : public OverlayProcessor::Strategy { 1589 class Strategy : public OverlayProcessor::Strategy {
1590 public: 1590 public:
1591 Strategy() {} 1591 Strategy() {}
1592 ~Strategy() override {} 1592 ~Strategy() override {}
1593 MOCK_METHOD3(Attempt, 1593 MOCK_METHOD4(Attempt,
1594 bool(ResourceProvider* resource_provider, 1594 bool(ResourceProvider* resource_provider,
1595 RenderPass* render_pass, 1595 RenderPass* render_pass,
1596 OverlayCandidateList* candidates)); 1596 OverlayCandidateList* candidates,
1597 std::vector<gfx::Rect>* content_bounds));
1597 }; 1598 };
1598 1599
1599 class Validator : public OverlayCandidateValidator { 1600 class Validator : public OverlayCandidateValidator {
1600 public: 1601 public:
1601 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {} 1602 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {}
1602 1603
1603 // Returns true if draw quads can be represented as CALayers (Mac only). 1604 // Returns true if draw quads can be represented as CALayers (Mac only).
1604 MOCK_METHOD0(AllowCALayerOverlays, bool()); 1605 MOCK_METHOD0(AllowCALayerOverlays, bool());
1605 1606
1606 // A list of possible overlay candidates is presented to this function. 1607 // A list of possible overlay candidates is presented to this function.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1684 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1684 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1685 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1685 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1686 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1686 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1687 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1687 1688
1688 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 1689 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
1689 // Attempt will be called for each strategy in OverlayProcessor. We have 1690 // Attempt will be called for each strategy in OverlayProcessor. We have
1690 // added a fake strategy, so checking for Attempt calls checks if there was 1691 // added a fake strategy, so checking for Attempt calls checks if there was
1691 // any attempt to overlay, which there shouldn't be. We can't use the quad 1692 // any attempt to overlay, which there shouldn't be. We can't use the quad
1692 // list because the render pass is cleaned up by DrawFrame. 1693 // list because the render pass is cleaned up by DrawFrame.
1693 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0); 1694 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
1694 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0); 1695 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0);
1695 DrawFrame(&renderer, viewport_size); 1696 DrawFrame(&renderer, viewport_size);
1696 Mock::VerifyAndClearExpectations(processor->strategy_); 1697 Mock::VerifyAndClearExpectations(processor->strategy_);
1697 Mock::VerifyAndClearExpectations(validator.get()); 1698 Mock::VerifyAndClearExpectations(validator.get());
1698 1699
1699 // Without a copy request Attempt() should be called once. 1700 // Without a copy request Attempt() should be called once.
1700 root_pass = 1701 root_pass =
1701 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size), 1702 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size),
1702 gfx::Transform(), FilterOperations()); 1703 gfx::Transform(), FilterOperations());
1703 root_pass->has_transparent_background = false; 1704 root_pass->has_transparent_background = false;
1704 1705
1705 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 1706 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
1706 overlay_quad->SetNew( 1707 overlay_quad->SetNew(
1707 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1708 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1708 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1709 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1709 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1710 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1710 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1711 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1711 EXPECT_CALL(*validator, AllowCALayerOverlays()) 1712 EXPECT_CALL(*validator, AllowCALayerOverlays())
1712 .Times(1) 1713 .Times(1)
1713 .WillOnce(::testing::Return(false)); 1714 .WillOnce(::testing::Return(false));
1714 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(1); 1715 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(1);
1715 DrawFrame(&renderer, viewport_size); 1716 DrawFrame(&renderer, viewport_size);
1716 1717
1717 // If the CALayerOverlay path is taken, then the ordinary overlay path should 1718 // If the CALayerOverlay path is taken, then the ordinary overlay path should
1718 // not be called. 1719 // not be called.
1719 root_pass = 1720 root_pass =
1720 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size), 1721 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size),
1721 gfx::Transform(), FilterOperations()); 1722 gfx::Transform(), FilterOperations());
1722 root_pass->has_transparent_background = false; 1723 root_pass->has_transparent_background = false;
1723 1724
1724 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 1725 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
1725 overlay_quad->SetNew( 1726 overlay_quad->SetNew(
1726 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1727 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1727 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1728 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1728 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1729 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1729 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1730 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1730 EXPECT_CALL(*validator, AllowCALayerOverlays()) 1731 EXPECT_CALL(*validator, AllowCALayerOverlays())
1731 .Times(1) 1732 .Times(1)
1732 .WillOnce(::testing::Return(true)); 1733 .WillOnce(::testing::Return(true));
1733 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0); 1734 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
1734 DrawFrame(&renderer, viewport_size); 1735 DrawFrame(&renderer, viewport_size);
1735 } 1736 }
1736 1737
1737 class SingleOverlayOnTopProcessor : public OverlayProcessor { 1738 class SingleOverlayOnTopProcessor : public OverlayProcessor {
1738 public: 1739 public:
1739 class SingleOverlayValidator : public OverlayCandidateValidator { 1740 class SingleOverlayValidator : public OverlayCandidateValidator {
1740 public: 1741 public:
1741 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 1742 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
1742 strategies->push_back(base::MakeUnique<OverlayStrategySingleOnTop>(this)); 1743 strategies->push_back(base::MakeUnique<OverlayStrategySingleOnTop>(this));
1743 strategies->push_back(base::MakeUnique<OverlayStrategyUnderlay>(this)); 1744 strategies->push_back(base::MakeUnique<OverlayStrategyUnderlay>(this));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 renderer_->SetVisible(true); 1988 renderer_->SetVisible(true);
1988 Mock::VerifyAndClearExpectations(context_support_ptr_); 1989 Mock::VerifyAndClearExpectations(context_support_ptr_);
1989 1990
1990 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); 1991 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true));
1991 renderer_->SetVisible(false); 1992 renderer_->SetVisible(false);
1992 Mock::VerifyAndClearExpectations(context_support_ptr_); 1993 Mock::VerifyAndClearExpectations(context_support_ptr_);
1993 } 1994 }
1994 1995
1995 } // namespace 1996 } // namespace
1996 } // namespace cc 1997 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698