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