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

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

Issue 1452943002: cc: Fix overlay damage tracking bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 EXPECT_EQ(1, other_callback_count); 2015 EXPECT_EQ(1, other_callback_count);
2016 } 2016 }
2017 #endif // OS_ANDROID 2017 #endif // OS_ANDROID
2018 2018
2019 class TestOverlayProcessor : public OverlayProcessor { 2019 class TestOverlayProcessor : public OverlayProcessor {
2020 public: 2020 public:
2021 class Strategy : public OverlayProcessor::Strategy { 2021 class Strategy : public OverlayProcessor::Strategy {
2022 public: 2022 public:
2023 Strategy() {} 2023 Strategy() {}
2024 ~Strategy() override {} 2024 ~Strategy() override {}
2025 MOCK_METHOD4(Attempt, 2025 MOCK_METHOD3(Attempt,
2026 bool(ResourceProvider* resource_provider, 2026 bool(ResourceProvider* resource_provider,
2027 RenderPassList* render_passes, 2027 RenderPassList* render_passes,
2028 OverlayCandidateList* candidates, 2028 OverlayCandidateList* candidates));
2029 gfx::Rect* damage_rect));
2030 }; 2029 };
2031 2030
2032 class Validator : public OverlayCandidateValidator { 2031 class Validator : public OverlayCandidateValidator {
2033 public: 2032 public:
2034 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {} 2033 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {}
2035 2034
2036 // Returns true if draw quads can be represented as CALayers (Mac only). 2035 // Returns true if draw quads can be represented as CALayers (Mac only).
2037 MOCK_METHOD0(AllowCALayerOverlays, bool()); 2036 MOCK_METHOD0(AllowCALayerOverlays, bool());
2038 2037
2039 // A list of possible overlay candidates is presented to this function. 2038 // A list of possible overlay candidates is presented to this function.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 viewport_rect, viewport_rect, viewport_rect, resource_id, 2115 viewport_rect, viewport_rect, viewport_rect, resource_id,
2117 premultiplied_alpha, gfx::PointF(0, 0), 2116 premultiplied_alpha, gfx::PointF(0, 0),
2118 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2117 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2119 flipped, nearest_neighbor); 2118 flipped, nearest_neighbor);
2120 2119
2121 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays. 2120 // DirectRenderer::DrawFrame calls into OverlayProcessor::ProcessForOverlays.
2122 // Attempt will be called for each strategy in OverlayProcessor. We have 2121 // Attempt will be called for each strategy in OverlayProcessor. We have
2123 // added a fake strategy, so checking for Attempt calls checks if there was 2122 // added a fake strategy, so checking for Attempt calls checks if there was
2124 // any attempt to overlay, which there shouldn't be. We can't use the quad 2123 // any attempt to overlay, which there shouldn't be. We can't use the quad
2125 // list because the render pass is cleaned up by DrawFrame. 2124 // list because the render pass is cleaned up by DrawFrame.
2126 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0); 2125 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0);
2127 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0); 2126 EXPECT_CALL(*validator, AllowCALayerOverlays()).Times(0);
2128 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2127 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2129 viewport_rect, false); 2128 viewport_rect, false);
2130 Mock::VerifyAndClearExpectations(processor->strategy_); 2129 Mock::VerifyAndClearExpectations(processor->strategy_);
2131 Mock::VerifyAndClearExpectations(validator.get()); 2130 Mock::VerifyAndClearExpectations(validator.get());
2132 2131
2133 // Without a copy request Attempt() should be called once. 2132 // Without a copy request Attempt() should be called once.
2134 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2133 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2135 viewport_rect, gfx::Transform()); 2134 viewport_rect, gfx::Transform());
2136 root_pass->has_transparent_background = false; 2135 root_pass->has_transparent_background = false;
2137 2136
2138 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2137 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2139 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(), 2138 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2140 viewport_rect, viewport_rect, viewport_rect, resource_id, 2139 viewport_rect, viewport_rect, viewport_rect, resource_id,
2141 premultiplied_alpha, gfx::PointF(0, 0), 2140 premultiplied_alpha, gfx::PointF(0, 0),
2142 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2141 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2143 flipped, nearest_neighbor); 2142 flipped, nearest_neighbor);
2144 EXPECT_CALL(*validator, AllowCALayerOverlays()) 2143 EXPECT_CALL(*validator, AllowCALayerOverlays())
2145 .Times(1) 2144 .Times(1)
2146 .WillOnce(::testing::Return(false)); 2145 .WillOnce(::testing::Return(false));
2147 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(1); 2146 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(1);
2148 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2147 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2149 viewport_rect, false); 2148 viewport_rect, false);
2150 2149
2151 // If the CALayerOverlay path is taken, then the ordinary overlay path should 2150 // If the CALayerOverlay path is taken, then the ordinary overlay path should
2152 // not be called. 2151 // not be called.
2153 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0), 2152 root_pass = AddRenderPass(&render_passes_in_draw_order_, RenderPassId(1, 0),
2154 viewport_rect, gfx::Transform()); 2153 viewport_rect, gfx::Transform());
2155 root_pass->has_transparent_background = false; 2154 root_pass->has_transparent_background = false;
2156 2155
2157 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 2156 overlay_quad = root_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
2158 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(), 2157 overlay_quad->SetNew(root_pass->CreateAndAppendSharedQuadState(),
2159 viewport_rect, viewport_rect, viewport_rect, resource_id, 2158 viewport_rect, viewport_rect, viewport_rect, resource_id,
2160 premultiplied_alpha, gfx::PointF(0, 0), 2159 premultiplied_alpha, gfx::PointF(0, 0),
2161 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity, 2160 gfx::PointF(1, 1), SK_ColorTRANSPARENT, vertex_opacity,
2162 flipped, nearest_neighbor); 2161 flipped, nearest_neighbor);
2163 EXPECT_CALL(*validator, AllowCALayerOverlays()) 2162 EXPECT_CALL(*validator, AllowCALayerOverlays())
2164 .Times(1) 2163 .Times(1)
2165 .WillOnce(::testing::Return(true)); 2164 .WillOnce(::testing::Return(true));
2166 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _, _)).Times(0); 2165 EXPECT_CALL(*processor->strategy_, Attempt(_, _, _)).Times(0);
2167 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2166 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2168 viewport_rect, false); 2167 viewport_rect, false);
2169 } 2168 }
2170 2169
2171 class SingleOverlayOnTopProcessor : public OverlayProcessor { 2170 class SingleOverlayOnTopProcessor : public OverlayProcessor {
2172 public: 2171 public:
2173 class SingleOverlayValidator : public OverlayCandidateValidator { 2172 class SingleOverlayValidator : public OverlayCandidateValidator {
2174 public: 2173 public:
2175 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 2174 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
2176 strategies->push_back( 2175 strategies->push_back(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 EXPECT_CALL(overlay_scheduler, 2282 EXPECT_CALL(overlay_scheduler,
2284 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, 2283 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect,
2285 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); 2284 BoundingRect(uv_top_left, uv_bottom_right))).Times(1);
2286 2285
2287 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, 2286 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect,
2288 viewport_rect, false); 2287 viewport_rect, false);
2289 } 2288 }
2290 2289
2291 } // namespace 2290 } // namespace
2292 } // namespace cc 2291 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698