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

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

Issue 1430813002: cc: Fork OverlayCandidate to CALayerOverlay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master1
Patch Set: Rebase Created 5 years, 1 month 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/overlay_candidate_validator.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"
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 public: 2014 public:
2015 Strategy() {} 2015 Strategy() {}
2016 ~Strategy() override {} 2016 ~Strategy() override {}
2017 MOCK_METHOD4(Attempt, 2017 MOCK_METHOD4(Attempt,
2018 bool(ResourceProvider* resource_provider, 2018 bool(ResourceProvider* resource_provider,
2019 RenderPassList* render_passes, 2019 RenderPassList* render_passes,
2020 OverlayCandidateList* candidates, 2020 OverlayCandidateList* candidates,
2021 gfx::Rect* damage_rect)); 2021 gfx::Rect* damage_rect));
2022 }; 2022 };
2023 2023
2024 class Validator : public OverlayCandidateValidator {
2025 public:
2026 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {}
2027
2028 // Returns true if draw quads can be represented as CALayers (Mac only).
2029 MOCK_METHOD0(AllowCALayerOverlays, bool());
2030
2031 // A list of possible overlay candidates is presented to this function.
2032 // The expected result is that those candidates that can be in a separate
2033 // plane are marked with |overlay_handled| set to true, otherwise they are
2034 // to be traditionally composited. Candidates with |overlay_handled| set to
2035 // true must also have their |display_rect| converted to integer
2036 // coordinates if necessary.
2037 void CheckOverlaySupport(OverlayCandidateList* surfaces) {}
2038 };
2039
2024 explicit TestOverlayProcessor(OutputSurface* surface) 2040 explicit TestOverlayProcessor(OutputSurface* surface)
2025 : OverlayProcessor(surface) {} 2041 : OverlayProcessor(surface) {}
2026 ~TestOverlayProcessor() override {} 2042 ~TestOverlayProcessor() override {}
2027 void Initialize() override { 2043 void Initialize() override {
2028 strategy_ = new Strategy(); 2044 strategy_ = new Strategy();
2029 strategies_.push_back(make_scoped_ptr(strategy_)); 2045 strategies_.push_back(make_scoped_ptr(strategy_));
2030 } 2046 }
2031 2047
2032 Strategy* strategy_; 2048 Strategy* strategy_;
2033 }; 2049 };
2034 2050
2035 void MailboxReleased(const gpu::SyncToken& sync_token, 2051 void MailboxReleased(const gpu::SyncToken& sync_token,
2036 bool lost_resource, 2052 bool lost_resource,
2037 BlockingTaskRunner* main_thread_task_runner) {} 2053 BlockingTaskRunner* main_thread_task_runner) {}
2038 2054
2039 void IgnoreCopyResult(scoped_ptr<CopyOutputResult> result) { 2055 void IgnoreCopyResult(scoped_ptr<CopyOutputResult> result) {
2040 } 2056 }
2041 2057
2042 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) { 2058 TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
2043 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext); 2059 scoped_ptr<DiscardCheckingContext> context_owned(new DiscardCheckingContext);
2044 FakeOutputSurfaceClient output_surface_client; 2060 FakeOutputSurfaceClient output_surface_client;
2045 scoped_ptr<OutputSurface> output_surface( 2061 scoped_ptr<FakeOutputSurface> output_surface(
2046 FakeOutputSurface::Create3d(context_owned.Pass())); 2062 FakeOutputSurface::Create3d(context_owned.Pass()));
2047 CHECK(output_surface->BindToClient(&output_surface_client)); 2063 CHECK(output_surface->BindToClient(&output_surface_client));
2048 2064
2049 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 2065 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
2050 new TestSharedBitmapManager()); 2066 new TestSharedBitmapManager());
2051 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create( 2067 scoped_ptr<ResourceProvider> resource_provider = FakeResourceProvider::Create(
2052 output_surface.get(), shared_bitmap_manager.get()); 2068 output_surface.get(), shared_bitmap_manager.get());
2053 scoped_ptr<TextureMailboxDeleter> mailbox_deleter( 2069 scoped_ptr<TextureMailboxDeleter> mailbox_deleter(
2054 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())); 2070 new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get()));
2055 2071
2056 RendererSettings settings; 2072 RendererSettings settings;
2057 FakeRendererClient renderer_client; 2073 FakeRendererClient renderer_client;
2058 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(), 2074 FakeRendererGL renderer(&renderer_client, &settings, output_surface.get(),
2059 resource_provider.get(), mailbox_deleter.get()); 2075 resource_provider.get(), mailbox_deleter.get());
2060 2076
2061 TestOverlayProcessor* processor = 2077 TestOverlayProcessor* processor =
2062 new TestOverlayProcessor(output_surface.get()); 2078 new TestOverlayProcessor(output_surface.get());
2063 processor->Initialize(); 2079 processor->Initialize();
2064 renderer.SetOverlayProcessor(processor); 2080 renderer.SetOverlayProcessor(processor);
2081 scoped_ptr<TestOverlayProcessor::Validator> validator(
2082 new TestOverlayProcessor::Validator);
2083 output_surface->SetOverlayCandidateValidator(validator.get());
2065 2084
2066 gfx::Rect viewport_rect(1, 1); 2085 gfx::Rect viewport_rect(1, 1);
2067 RenderPass* root_pass = 2086 RenderPass* root_pass =
2068 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2087 AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2069 viewport_rect, gfx::Transform()); 2088 viewport_rect, gfx::Transform());
2070 root_pass->has_transparent_background = false; 2089 root_pass->has_transparent_background = false;
2071 root_pass->copy_requests.push_back( 2090 root_pass->copy_requests.push_back(
2072 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult))); 2091 CopyOutputRequest::CreateRequest(base::Bind(&IgnoreCopyResult)));
2073 2092
2074 TextureMailbox mailbox = 2093 TextureMailbox mailbox =
(...skipping 15 matching lines...) Expand all
2090 premultiplied_alpha, gfx::PointF(0, 0), 2109 premultiplied_alpha, gfx::PointF(0, 0),
2091 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2110 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2092 flipped, nearest_neighbor); 2111 flipped, nearest_neighbor);
2093 2112
2094 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 2113 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
2095 // Attempt will be called for each strategy in OverlayProcessor. We have 2114 // Attempt will be called for each strategy in OverlayProcessor. We have
2096 // added a fake strategy, so checking for Attempt calls checks if there was 2115 // added a fake strategy, so checking for Attempt calls checks if there was
2097 // any attempt to overlay, which there shouldn't be. We can't use the quad 2116 // any attempt to overlay, which there shouldn't be. We can't use the quad
2098 // list because the render pass is cleaned up by DrawFrame. 2117 // list because the render pass is cleaned up by DrawFrame.
2099 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0); 2118 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
2119 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0);
2100 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2120 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2101 viewport_rect, false); 2121 viewport_rect, false);
2102 Mock::VerifyAndClearExpectations(processor->strategy_); 2122 Mock::VerifyAndClearExpectations(processor->strategy_);
2123 Mock::VerifyAndClearExpectations(validator.get());
2103 2124
2104 // Without a copy request Attempt() should be called once. 2125 // Without a copy request Attempt() should be called once.
2105 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2126 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2106 viewport_rect, gfx::Transform()); 2127 viewport_rect, gfx::Transform());
2107 root_pass->has_transparent_background = false; 2128 root_pass->has_transparent_background = false;
2108 2129
2109 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2130 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2110 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(), 2131 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2111 viewport_rect, viewport_rect, viewport_rect, resource_id, 2132 viewport_rect, viewport_rect, viewport_rect, resource_id,
2112 premultiplied_alpha, gfx::PointF(0, 0), 2133 premultiplied_alpha, gfx::PointF(0, 0),
2113 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2134 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2114 flipped, nearest_neighbor); 2135 flipped, nearest_neighbor);
2136 EXPECT_CALL(*validator, AllowCALayerOverlays())
2137 .Times(1)
2138 .WillOnce(::testing::Return(false));
2139 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(1);
2140 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2141 viewport_rect, false);
2115 2142
2116 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(1); 2143 // If the CALayerOverlay path is taken, then the ordinary overlay path should
2144 // not be called.
2145 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2146 viewport_rect, gfx::Transform());
2147 root_pass->has_transparent_background = false;
2148
2149 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2150 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2151 viewport_rect, viewport_rect, viewport_rect, resource_id,
2152 premultiplied_alpha, gfx::PointF(0, 0),
2153 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2154 flipped, nearest_neighbor);
2155 EXPECT_CALL(*validator, AllowCALayerOverlays())
2156 .Times(1)
2157 .WillOnce(::testing::Return(true));
2158 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0);
2117 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2159 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2118 viewport_rect, false); 2160 viewport_rect, false);
2119 } 2161 }
2120 2162
2121 class SingleOverlayOnTopProcessor : public OverlayProcessor { 2163 class SingleOverlayOnTopProcessor : public OverlayProcessor {
2122 public: 2164 public:
2123 class SingleOverlayValidator : public OverlayCandidateValidator { 2165 class SingleOverlayValidator : public OverlayCandidateValidator {
2124 public: 2166 public:
2125 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 2167 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
2126 strategies->push_back( 2168 strategies->push_back(
2127 make_scoped_ptr(new OverlayStrategySingleOnTop(this))); 2169 make_scoped_ptr(new OverlayStrategySingleOnTop(this)));
2128 strategies->push_back(make_scoped_ptr(new OverlayStrategyUnderlay(this))); 2170 strategies->push_back(make_scoped_ptr(new OverlayStrategyUnderlay(this)));
2129 } 2171 }
2130 2172
2173 bool AllowCALayerOverlays() override { return false; }
2174
2131 void CheckOverlaySupport(OverlayCandidateList* surfaces) override { 2175 void CheckOverlaySupport(OverlayCandidateList* surfaces) override {
2132 ASSERT_EQ(1U, surfaces->size()); 2176 ASSERT_EQ(1U, surfaces->size());
2133 OverlayCandidate& candidate = surfaces->back(); 2177 OverlayCandidate& candidate = surfaces->back();
2134 candidate.overlay_handled = true; 2178 candidate.overlay_handled = true;
2135 } 2179 }
2136 }; 2180 };
2137 2181
2138 explicit SingleOverlayOnTopProcessor(OutputSurface* surface) 2182 explicit SingleOverlayOnTopProcessor(OutputSurface* surface)
2139 : OverlayProcessor(surface) {} 2183 : OverlayProcessor(surface) {}
2140 2184
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 EXPECT_CALL(overlay_scheduler, 2275 EXPECT_CALL(overlay_scheduler,
2232 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2276 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2233 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2277 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2234 2278
2235 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2279 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2236 viewport_rect, false); 2280 viewport_rect, false);
2237 } 2281 }
2238 2282
2239 } // namespace 2283 } // namespace
2240 } // namespace cc 2284 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/overlay_candidate_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698