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

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

Issue 1304303002: Mac Overlays: Add sandwich strategy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@overlay_debug
Patch Set: incorporate review feedback Created 5 years, 3 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.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 <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"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
13 #include "cc/output/compositor_frame_metadata.h" 13 #include "cc/output/compositor_frame_metadata.h"
14 #include "cc/output/copy_output_request.h" 14 #include "cc/output/copy_output_request.h"
15 #include "cc/output/copy_output_result.h" 15 #include "cc/output/copy_output_result.h"
16 #include "cc/output/overlay_strategy_single_on_top.h" 16 #include "cc/output/overlay_strategy_single_on_top.h"
17 #include "cc/output/overlay_strategy_underlay.h"
17 #include "cc/output/texture_mailbox_deleter.h" 18 #include "cc/output/texture_mailbox_deleter.h"
18 #include "cc/quads/texture_draw_quad.h" 19 #include "cc/quads/texture_draw_quad.h"
19 #include "cc/resources/resource_provider.h" 20 #include "cc/resources/resource_provider.h"
20 #include "cc/test/fake_impl_proxy.h" 21 #include "cc/test/fake_impl_proxy.h"
21 #include "cc/test/fake_layer_tree_host_impl.h" 22 #include "cc/test/fake_layer_tree_host_impl.h"
22 #include "cc/test/fake_output_surface.h" 23 #include "cc/test/fake_output_surface.h"
23 #include "cc/test/fake_output_surface_client.h" 24 #include "cc/test/fake_output_surface_client.h"
24 #include "cc/test/fake_renderer_client.h" 25 #include "cc/test/fake_renderer_client.h"
25 #include "cc/test/fake_resource_provider.h" 26 #include "cc/test/fake_resource_provider.h"
26 #include "cc/test/pixel_test.h" 27 #include "cc/test/pixel_test.h"
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 EXPECT_EQ(1, other_callback_count); 1999 EXPECT_EQ(1, other_callback_count);
1999 } 2000 }
2000 #endif // OS_ANDROID 2001 #endif // OS_ANDROID
2001 2002
2002 class TestOverlayProcessor : public OverlayProcessor { 2003 class TestOverlayProcessor : public OverlayProcessor {
2003 public: 2004 public:
2004 class Strategy : public OverlayProcessor::Strategy { 2005 class Strategy : public OverlayProcessor::Strategy {
2005 public: 2006 public:
2006 Strategy() {} 2007 Strategy() {}
2007 ~Strategy() override {} 2008 ~Strategy() override {}
2008 MOCK_METHOD2(Attempt, 2009 MOCK_METHOD3(Attempt,
2009 bool(RenderPassList* render_passes_in_draw_order, 2010 bool(RenderPassList* render_passes_in_draw_order,
2010 OverlayCandidateList* candidates)); 2011 OverlayCandidateList* candidates,
2012 float device_scale_factor));
2011 }; 2013 };
2012 2014
2013 explicit TestOverlayProcessor(OutputSurface* surface) 2015 explicit TestOverlayProcessor(OutputSurface* surface)
2014 : OverlayProcessor(surface) {} 2016 : OverlayProcessor(surface) {}
2015 ~TestOverlayProcessor() override {} 2017 ~TestOverlayProcessor() override {}
2016 void Initialize() override { 2018 void Initialize() override {
2017 strategy_ = new Strategy(); 2019 strategy_ = new Strategy();
2018 strategies_.push_back(scoped_ptr<OverlayProcessor::Strategy>(strategy_)); 2020 strategies_.push_back(scoped_ptr<OverlayProcessor::Strategy>(strategy_));
2019 } 2021 }
2020 2022
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 premultiplied_alpha, gfx::PointF(0, 0), 2082 premultiplied_alpha, gfx::PointF(0, 0),
2081 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2083 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2082 flipped, nearest_neighbor); 2084 flipped, nearest_neighbor);
2083 overlay_quad->set_allow_overlay(true); 2085 overlay_quad->set_allow_overlay(true);
2084 2086
2085 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 2087 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
2086 // Attempt will be called for each strategy in OverlayProcessor. We have 2088 // Attempt will be called for each strategy in OverlayProcessor. We have
2087 // 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
2088 // 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
2089 // list because the render pass is cleaned up by DrawFrame. 2091 // list because the render pass is cleaned up by DrawFrame.
2090 EXPECT_CALL(*processor->strategy_, Attempt(_, _)).Times(0); 2092 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0);
2091 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2093 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2092 viewport_rect, false); 2094 viewport_rect, false);
2093 Mock::VerifyAndClearExpectations(processor->strategy_); 2095 Mock::VerifyAndClearExpectations(processor->strategy_);
2094 2096
2095 // Without a copy request Attempt() should be called once. 2097 // Without a copy request Attempt() should be called once.
2096 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2098 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2097 viewport_rect, gfx::Transform()); 2099 viewport_rect, gfx::Transform());
2098 root_pass->has_transparent_background = false; 2100 root_pass->has_transparent_background = false;
2099 2101
2100 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2102 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2101 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(), 2103 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2102 viewport_rect, viewport_rect, viewport_rect, resource_id, 2104 viewport_rect, viewport_rect, viewport_rect, resource_id,
2103 premultiplied_alpha, gfx::PointF(0, 0), 2105 premultiplied_alpha, gfx::PointF(0, 0),
2104 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2106 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2105 flipped, nearest_neighbor); 2107 flipped, nearest_neighbor);
2106 2108
2107 EXPECT_CALL(*processor->strategy_, Attempt(_, _)).Times(1); 2109 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(1);
2108 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2110 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2109 viewport_rect, false); 2111 viewport_rect, false);
2110 } 2112 }
2111 2113
2112 class SingleOverlayOnTopProcessor : public OverlayProcessor { 2114 class SingleOverlayOnTopProcessor : public OverlayProcessor {
2113 public: 2115 public:
2114 class SingleOverlayValidator : public OverlayCandidateValidator { 2116 class SingleOverlayValidator : public OverlayCandidateValidator {
2115 public: 2117 public:
2118 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
2119 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>(
2120 new OverlayStrategyCommon(this, new OverlayStrategySingleOnTop)));
2121 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>(
2122 new OverlayStrategyCommon(this, new OverlayStrategyUnderlay)));
2123 }
2124
2116 void CheckOverlaySupport(OverlayCandidateList* surfaces) override { 2125 void CheckOverlaySupport(OverlayCandidateList* surfaces) override {
2117 ASSERT_EQ(2U, surfaces->size()); 2126 ASSERT_EQ(2U, surfaces->size());
2118 OverlayCandidate& candidate = surfaces->back(); 2127 OverlayCandidate& candidate = surfaces->back();
2119 candidate.overlay_handled = true; 2128 candidate.overlay_handled = true;
2120 } 2129 }
2121 }; 2130 };
2122 2131
2123 explicit SingleOverlayOnTopProcessor(OutputSurface* surface) 2132 explicit SingleOverlayOnTopProcessor(OutputSurface* surface)
2124 : OverlayProcessor(surface) {} 2133 : OverlayProcessor(surface) {}
2125 2134
2126 void Initialize() override { 2135 void Initialize() override {
2127 strategies_.push_back( 2136 strategies_.push_back(scoped_ptr<Strategy>(new OverlayStrategyCommon(
2128 scoped_ptr<Strategy>(new OverlayStrategySingleOnTop(&validator_))); 2137 &validator_, new OverlayStrategySingleOnTop)));
2129 } 2138 }
2130 2139
2131 SingleOverlayValidator validator_; 2140 SingleOverlayValidator validator_;
2132 }; 2141 };
2133 2142
2134 class WaitSyncPointCountingContext : public TestWebGraphicsContext3D { 2143 class WaitSyncPointCountingContext : public TestWebGraphicsContext3D {
2135 public: 2144 public:
2136 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); 2145 MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point));
2137 }; 2146 };
2138 2147
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 EXPECT_CALL(overlay_scheduler, 2225 EXPECT_CALL(overlay_scheduler,
2217 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2226 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2218 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2227 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2219 2228
2220 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2229 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2221 viewport_rect, false); 2230 viewport_rect, false);
2222 } 2231 }
2223 2232
2224 } // namespace 2233 } // namespace
2225 } // namespace cc 2234 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698