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

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

Issue 1372103005: Refactor OverlayStrategySandwich and OverlayStrategyCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SolidColor
Patch Set: Delete OverlayStrategyCommon Created 5 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 <set> 7 #include <set>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 EXPECT_EQ(1, other_callback_count); 2000 EXPECT_EQ(1, other_callback_count);
2001 } 2001 }
2002 #endif // OS_ANDROID 2002 #endif // OS_ANDROID
2003 2003
2004 class TestOverlayProcessor : public OverlayProcessor { 2004 class TestOverlayProcessor : public OverlayProcessor {
2005 public: 2005 public:
2006 class Strategy : public OverlayProcessor::Strategy { 2006 class Strategy : public OverlayProcessor::Strategy {
2007 public: 2007 public:
2008 Strategy() {} 2008 Strategy() {}
2009 ~Strategy() override {} 2009 ~Strategy() override {}
2010 MOCK_METHOD3(Attempt, 2010 MOCK_METHOD2(Attempt,
2011 bool(RenderPassList* render_passes_in_draw_order, 2011 bool(RenderPassList* render_passes,
2012 OverlayCandidateList* candidates, 2012 OverlayCandidateList* candidates));
2013 float device_scale_factor));
2014 }; 2013 };
2015 2014
2016 explicit TestOverlayProcessor(OutputSurface* surface) 2015 explicit TestOverlayProcessor(OutputSurface* surface)
2017 : OverlayProcessor(surface) {} 2016 : OverlayProcessor(surface) {}
2018 ~TestOverlayProcessor() override {} 2017 ~TestOverlayProcessor() override {}
2019 void Initialize() override { 2018 void Initialize() override {
2020 strategy_ = new Strategy(); 2019 strategy_ = new Strategy();
2021 strategies_.push_back(scoped_ptr<OverlayProcessor::Strategy>(strategy_)); 2020 strategies_.push_back(make_scoped_ptr(strategy_));
2022 } 2021 }
2023 2022
2024 Strategy* strategy_; 2023 Strategy* strategy_;
2025 }; 2024 };
2026 2025
2027 void MailboxReleased(unsigned sync_point, 2026 void MailboxReleased(unsigned sync_point,
2028 bool lost_resource, 2027 bool lost_resource,
2029 BlockingTaskRunner* main_thread_task_runner) { 2028 BlockingTaskRunner* main_thread_task_runner) {
2030 } 2029 }
2031 2030
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 premultiplied_alpha, gfx::PointF(0, 0), 2082 premultiplied_alpha, gfx::PointF(0, 0),
2084 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2083 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2085 flipped, nearest_neighbor); 2084 flipped, nearest_neighbor);
2086 overlay_quad->set_allow_overlay(true); 2085 overlay_quad->set_allow_overlay(true);
2087 2086
2088 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 2087 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
2089 // Attempt will be called for each strategy in OverlayProcessor. We have 2088 // Attempt will be called for each strategy in OverlayProcessor. We have
2090 // added a fake strategy, so checking for Attempt calls checks if there was 2089 // added a fake strategy, so checking for Attempt calls checks if there was
2091 // any attempt to overlay, which there shouldn't be. We can't use the quad 2090 // any attempt to overlay, which there shouldn't be. We can't use the quad
2092 // list because the render pass is cleaned up by DrawFrame. 2091 // list because the render pass is cleaned up by DrawFrame.
2093 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0); 2092 EXPECT_CALL(*processor->strategy_, Attempt(_, _)).Times(0);
2094 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2093 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2095 viewport_rect, false); 2094 viewport_rect, false);
2096 Mock::VerifyAndClearExpectations(processor->strategy_); 2095 Mock::VerifyAndClearExpectations(processor->strategy_);
2097 2096
2098 // Without a copy request Attempt() should be called once. 2097 // Without a copy request Attempt() should be called once.
2099 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2098 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2100 viewport_rect, gfx::Transform()); 2099 viewport_rect, gfx::Transform());
2101 root_pass->has_transparent_background = false; 2100 root_pass->has_transparent_background = false;
2102 2101
2103 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2102 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2104 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(), 2103 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2105 viewport_rect, viewport_rect, viewport_rect, resource_id, 2104 viewport_rect, viewport_rect, viewport_rect, resource_id,
2106 premultiplied_alpha, gfx::PointF(0, 0), 2105 premultiplied_alpha, gfx::PointF(0, 0),
2107 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2106 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2108 flipped, nearest_neighbor); 2107 flipped, nearest_neighbor);
2109 2108
2110 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(1); 2109 EXPECT_CALL(*processor->strategy_, Attempt(_, _)).Times(1);
2111 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2110 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2112 viewport_rect, false); 2111 viewport_rect, false);
2113 } 2112 }
2114 2113
2115 class SingleOverlayOnTopProcessor : public OverlayProcessor { 2114 class SingleOverlayOnTopProcessor : public OverlayProcessor {
2116 public: 2115 public:
2117 class SingleOverlayValidator : public OverlayCandidateValidator { 2116 class SingleOverlayValidator : public OverlayCandidateValidator {
2118 public: 2117 public:
2119 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 2118 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
2120 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>( 2119 strategies->push_back(
2121 new OverlayStrategyCommon(this, new OverlayStrategySingleOnTop))); 2120 make_scoped_ptr(new OverlayStrategySingleOnTop(this)));
2122 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>( 2121 strategies->push_back(make_scoped_ptr(new OverlayStrategyUnderlay(this)));
2123 new OverlayStrategyCommon(this, new OverlayStrategyUnderlay)));
2124 } 2122 }
2125 2123
2126 void CheckOverlaySupport(OverlayCandidateList* surfaces) override { 2124 void CheckOverlaySupport(OverlayCandidateList* surfaces) override {
2127 ASSERT_EQ(1U, surfaces->size()); 2125 ASSERT_EQ(1U, surfaces->size());
2128 OverlayCandidate& candidate = surfaces->back(); 2126 OverlayCandidate& candidate = surfaces->back();
2129 candidate.overlay_handled = true; 2127 candidate.overlay_handled = true;
2130 } 2128 }
2131 }; 2129 };
2132 2130
2133 explicit SingleOverlayOnTopProcessor(OutputSurface* surface) 2131 explicit SingleOverlayOnTopProcessor(OutputSurface* surface)
2134 : OverlayProcessor(surface) {} 2132 : OverlayProcessor(surface) {}
2135 2133
2136 void Initialize() override { 2134 void Initialize() override {
2137 strategies_.push_back(scoped_ptr<Strategy>(new OverlayStrategyCommon( 2135 strategies_.push_back(
2138 &validator_, new OverlayStrategySingleOnTop))); 2136 make_scoped_ptr(new OverlayStrategySingleOnTop(&validator_)));
2139 } 2137 }
2140 2138
2141 SingleOverlayValidator validator_; 2139 SingleOverlayValidator validator_;
2142 }; 2140 };
2143 2141
2144 class WaitSyncPointCountingContext : public TestWebGraphicsContext3D { 2142 class WaitSyncPointCountingContext : public TestWebGraphicsContext3D {
2145 public: 2143 public:
2146 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); 2144 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point));
2147 }; 2145 };
2148 2146
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 EXPECT_CALL(overlay_scheduler, 2224 EXPECT_CALL(overlay_scheduler,
2227 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2225 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2228 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2226 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2229 2227
2230 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2228 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2231 viewport_rect, false); 2229 viewport_rect, false);
2232 } 2230 }
2233 2231
2234 } // namespace 2232 } // namespace
2235 } // namespace cc 2233 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698