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

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

Issue 2693023002: Use SwapBuffersWithBounds on Chromecast (Closed)
Patch Set: danakj nits Created 3 years, 9 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
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 renderer_->SetVisible(true); 1618 renderer_->SetVisible(true);
1619 Mock::VerifyAndClearExpectations(output_surface_.get()); 1619 Mock::VerifyAndClearExpectations(output_surface_.get());
1620 } 1620 }
1621 1621
1622 class TestOverlayProcessor : public OverlayProcessor { 1622 class TestOverlayProcessor : public OverlayProcessor {
1623 public: 1623 public:
1624 class Strategy : public OverlayProcessor::Strategy { 1624 class Strategy : public OverlayProcessor::Strategy {
1625 public: 1625 public:
1626 Strategy() {} 1626 Strategy() {}
1627 ~Strategy() override {} 1627 ~Strategy() override {}
1628 MOCK_METHOD3(Attempt, 1628 MOCK_METHOD4(Attempt,
1629 bool(ResourceProvider* resource_provider, 1629 bool(ResourceProvider* resource_provider,
1630 RenderPass* render_pass, 1630 RenderPass* render_pass,
1631 OverlayCandidateList* candidates)); 1631 OverlayCandidateList* candidates,
1632 std::vector<gfx::Rect>* content_bounds));
1632 }; 1633 };
1633 1634
1634 class Validator : public OverlayCandidateValidator { 1635 class Validator : public OverlayCandidateValidator {
1635 public: 1636 public:
1636 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {} 1637 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {}
1637 1638
1638 // Returns true if draw quads can be represented as CALayers (Mac only). 1639 // Returns true if draw quads can be represented as CALayers (Mac only).
1639 MOCK_METHOD0(AllowCALayerOverlays, bool()); 1640 MOCK_METHOD0(AllowCALayerOverlays, bool());
1640 1641
1641 // A list of possible overlay candidates is presented to this function. 1642 // A list of possible overlay candidates is presented to this function.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1719 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1719 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1720 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1720 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1721 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1721 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1722 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1722 1723
1723 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 1724 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
1724 // Attempt will be called for each strategy in OverlayProcessor. We have 1725 // Attempt will be called for each strategy in OverlayProcessor. We have
1725 // added a fake strategy, so checking for Attempt calls checks if there was 1726 // added a fake strategy, so checking for Attempt calls checks if there was
1726 // any attempt to overlay, which there shouldn't be. We can't use the quad 1727 // any attempt to overlay, which there shouldn't be. We can't use the quad
1727 // list because the render pass is cleaned up by DrawFrame. 1728 // list because the render pass is cleaned up by DrawFrame.
1728 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0); 1729 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
1729 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0); 1730 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0);
1730 DrawFrame(&renderer, viewport_size); 1731 DrawFrame(&renderer, viewport_size);
1731 Mock::VerifyAndClearExpectations(processor->strategy_); 1732 Mock::VerifyAndClearExpectations(processor->strategy_);
1732 Mock::VerifyAndClearExpectations(validator.get()); 1733 Mock::VerifyAndClearExpectations(validator.get());
1733 1734
1734 // Without a copy request Attempt() should be called once. 1735 // Without a copy request Attempt() should be called once.
1735 root_pass = 1736 root_pass =
1736 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size), 1737 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size),
1737 gfx::Transform(), FilterOperations()); 1738 gfx::Transform(), FilterOperations());
1738 root_pass->has_transparent_background = false; 1739 root_pass->has_transparent_background = false;
1739 1740
1740 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 1741 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
1741 overlay_quad->SetNew( 1742 overlay_quad->SetNew(
1742 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1743 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1743 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1744 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1744 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1745 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1745 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1746 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1746 EXPECT_CALL(*validator, AllowCALayerOverlays()) 1747 EXPECT_CALL(*validator, AllowCALayerOverlays())
1747 .Times(1) 1748 .Times(1)
1748 .WillOnce(::testing::Return(false)); 1749 .WillOnce(::testing::Return(false));
1749 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(1); 1750 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(1);
1750 DrawFrame(&renderer, viewport_size); 1751 DrawFrame(&renderer, viewport_size);
1751 1752
1752 // If the CALayerOverlay path is taken, then the ordinary overlay path should 1753 // If the CALayerOverlay path is taken, then the ordinary overlay path should
1753 // not be called. 1754 // not be called.
1754 root_pass = 1755 root_pass =
1755 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size), 1756 AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(viewport_size),
1756 gfx::Transform(), FilterOperations()); 1757 gfx::Transform(), FilterOperations());
1757 root_pass->has_transparent_background = false; 1758 root_pass->has_transparent_background = false;
1758 1759
1759 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 1760 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
1760 overlay_quad->SetNew( 1761 overlay_quad->SetNew(
1761 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size), 1762 root_pass->CreateAndAppendSharedQuadState(), gfx::Rect(viewport_size),
1762 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id, 1763 gfx::Rect(viewport_size), gfx::Rect(viewport_size), resource_id,
1763 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1), 1764 premultiplied_alpha, gfx::PointF(0, 0), gfx::PointF(1, 1),
1764 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false); 1765 SK_ColorTRANSPARENT, vertex_opacity, flipped, nearest_neighbor, false);
1765 EXPECT_CALL(*validator, AllowCALayerOverlays()) 1766 EXPECT_CALL(*validator, AllowCALayerOverlays())
1766 .Times(1) 1767 .Times(1)
1767 .WillOnce(::testing::Return(true)); 1768 .WillOnce(::testing::Return(true));
1768 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0); 1769 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
1769 DrawFrame(&renderer, viewport_size); 1770 DrawFrame(&renderer, viewport_size);
1770 } 1771 }
1771 1772
1772 class SingleOverlayOnTopProcessor : public OverlayProcessor { 1773 class SingleOverlayOnTopProcessor : public OverlayProcessor {
1773 public: 1774 public:
1774 class SingleOverlayValidator : public OverlayCandidateValidator { 1775 class SingleOverlayValidator : public OverlayCandidateValidator {
1775 public: 1776 public:
1776 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 1777 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
1777 strategies->push_back(base::MakeUnique<OverlayStrategySingleOnTop>(this)); 1778 strategies->push_back(base::MakeUnique<OverlayStrategySingleOnTop>(this));
1778 strategies->push_back(base::MakeUnique<OverlayStrategyUnderlay>(this)); 1779 strategies->push_back(base::MakeUnique<OverlayStrategyUnderlay>(this));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 renderer_->SetVisible(true); 2023 renderer_->SetVisible(true);
2023 Mock::VerifyAndClearExpectations(context_support_ptr_); 2024 Mock::VerifyAndClearExpectations(context_support_ptr_);
2024 2025
2025 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); 2026 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true));
2026 renderer_->SetVisible(false); 2027 renderer_->SetVisible(false);
2027 Mock::VerifyAndClearExpectations(context_support_ptr_); 2028 Mock::VerifyAndClearExpectations(context_support_ptr_);
2028 } 2029 }
2029 2030
2030 } // namespace 2031 } // namespace
2031 } // namespace cc 2032 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698