| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 class OverlayOutputSurface : public OutputSurface { | 150 class OverlayOutputSurface : public OutputSurface { |
| 151 public: | 151 public: |
| 152 explicit OverlayOutputSurface( | 152 explicit OverlayOutputSurface( |
| 153 scoped_refptr<TestContextProvider> context_provider) | 153 scoped_refptr<TestContextProvider> context_provider) |
| 154 : OutputSurface(std::move(context_provider)) { | 154 : OutputSurface(std::move(context_provider)) { |
| 155 is_displayed_as_overlay_plane_ = true; | 155 is_displayed_as_overlay_plane_ = true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 // OutputSurface implementation. | 158 // OutputSurface implementation. |
| 159 void BindToClient(OutputSurfaceClient* client) override {} |
| 159 void EnsureBackbuffer() override {} | 160 void EnsureBackbuffer() override {} |
| 160 void DiscardBackbuffer() override {} | 161 void DiscardBackbuffer() override {} |
| 161 void BindFramebuffer() override { | 162 void BindFramebuffer() override { |
| 162 bind_framebuffer_count_ += 1; | 163 bind_framebuffer_count_ += 1; |
| 163 } | 164 } |
| 164 void Reshape(const gfx::Size& size, | 165 void Reshape(const gfx::Size& size, |
| 165 float device_scale_factor, | 166 float device_scale_factor, |
| 166 const gfx::ColorSpace& color_space, | 167 const gfx::ColorSpace& color_space, |
| 167 bool has_alpha) override {} | 168 bool has_alpha) override {} |
| 168 void SwapBuffers(OutputSurfaceFrame frame) override {} | 169 void SwapBuffers(OutputSurfaceFrame frame) override {} |
| 169 uint32_t GetFramebufferCopyTextureFormat() override { | 170 uint32_t GetFramebufferCopyTextureFormat() override { |
| 170 // TestContextProvider has no real framebuffer, just use RGB. | 171 // TestContextProvider has no real framebuffer, just use RGB. |
| 171 return GL_RGB; | 172 return GL_RGB; |
| 172 } | 173 } |
| 173 bool HasExternalStencilTest() const override { return false; } | 174 bool HasExternalStencilTest() const override { return false; } |
| 174 void ApplyExternalStencil() override {} | 175 void ApplyExternalStencil() override {} |
| 175 OverlayCandidateValidator* GetOverlayCandidateValidator() const override { | 176 OverlayCandidateValidator* GetOverlayCandidateValidator() const override { |
| 176 return overlay_candidate_validator_.get(); | 177 return overlay_candidate_validator_.get(); |
| 177 } | 178 } |
| 178 bool IsDisplayedAsOverlayPlane() const override { | 179 bool IsDisplayedAsOverlayPlane() const override { |
| 179 return is_displayed_as_overlay_plane_; | 180 return is_displayed_as_overlay_plane_; |
| 180 } | 181 } |
| 181 unsigned GetOverlayTextureId() const override { return 10000; } | 182 unsigned GetOverlayTextureId() const override { return 10000; } |
| 182 bool SurfaceIsSuspendForRecycle() const override { return false; } | 183 bool SurfaceIsSuspendForRecycle() const override { return false; } |
| 183 | 184 |
| 184 void OnSwapBuffersComplete() { client_->DidReceiveSwapBuffersAck(); } | |
| 185 | |
| 186 void set_is_displayed_as_overlay_plane(bool value) { | 185 void set_is_displayed_as_overlay_plane(bool value) { |
| 187 is_displayed_as_overlay_plane_ = value; | 186 is_displayed_as_overlay_plane_ = value; |
| 188 } | 187 } |
| 189 | 188 |
| 190 void SetOverlayCandidateValidator(OverlayCandidateValidator* validator) { | 189 void SetOverlayCandidateValidator(OverlayCandidateValidator* validator) { |
| 191 overlay_candidate_validator_.reset(validator); | 190 overlay_candidate_validator_.reset(validator); |
| 192 } | 191 } |
| 193 | 192 |
| 194 unsigned bind_framebuffer_count() const { return bind_framebuffer_count_; } | 193 unsigned bind_framebuffer_count() const { return bind_framebuffer_count_; } |
| 195 | 194 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 act_iter->shared_quad_state->quad_layer_bounds.ToString()); | 344 act_iter->shared_quad_state->quad_layer_bounds.ToString()); |
| 346 } | 345 } |
| 347 } | 346 } |
| 348 } | 347 } |
| 349 | 348 |
| 350 template <typename OverlayCandidateValidatorType> | 349 template <typename OverlayCandidateValidatorType> |
| 351 class OverlayTest : public testing::Test { | 350 class OverlayTest : public testing::Test { |
| 352 protected: | 351 protected: |
| 353 void SetUp() override { | 352 void SetUp() override { |
| 354 provider_ = TestContextProvider::Create(); | 353 provider_ = TestContextProvider::Create(); |
| 354 provider_->BindToCurrentThread(); |
| 355 output_surface_.reset(new OverlayOutputSurface(provider_)); | 355 output_surface_.reset(new OverlayOutputSurface(provider_)); |
| 356 EXPECT_TRUE(output_surface_->BindToClient(&client_)); | 356 output_surface_->BindToClient(&client_); |
| 357 output_surface_->SetOverlayCandidateValidator( | 357 output_surface_->SetOverlayCandidateValidator( |
| 358 new OverlayCandidateValidatorType); | 358 new OverlayCandidateValidatorType); |
| 359 | 359 |
| 360 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 360 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 361 resource_provider_ = FakeResourceProvider::Create( | 361 resource_provider_ = FakeResourceProvider::Create( |
| 362 provider_.get(), shared_bitmap_manager_.get()); | 362 provider_.get(), shared_bitmap_manager_.get()); |
| 363 | 363 |
| 364 overlay_processor_.reset(new OverlayProcessor(output_surface_.get())); | 364 overlay_processor_.reset(new OverlayProcessor(output_surface_.get())); |
| 365 overlay_processor_->Initialize(); | 365 overlay_processor_->Initialize(); |
| 366 } | 366 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 383 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); | 383 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); |
| 384 OverlayOutputSurface output_surface(provider); | 384 OverlayOutputSurface output_surface(provider); |
| 385 EXPECT_EQ(NULL, output_surface.GetOverlayCandidateValidator()); | 385 EXPECT_EQ(NULL, output_surface.GetOverlayCandidateValidator()); |
| 386 | 386 |
| 387 output_surface.SetOverlayCandidateValidator(new SingleOverlayValidator); | 387 output_surface.SetOverlayCandidateValidator(new SingleOverlayValidator); |
| 388 EXPECT_TRUE(output_surface.GetOverlayCandidateValidator() != NULL); | 388 EXPECT_TRUE(output_surface.GetOverlayCandidateValidator() != NULL); |
| 389 } | 389 } |
| 390 | 390 |
| 391 TEST(OverlayTest, OverlaysProcessorHasStrategy) { | 391 TEST(OverlayTest, OverlaysProcessorHasStrategy) { |
| 392 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); | 392 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); |
| 393 provider->BindToCurrentThread(); |
| 393 OverlayOutputSurface output_surface(provider); | 394 OverlayOutputSurface output_surface(provider); |
| 394 FakeOutputSurfaceClient client; | 395 FakeOutputSurfaceClient client; |
| 395 EXPECT_TRUE(output_surface.BindToClient(&client)); | 396 output_surface.BindToClient(&client); |
| 396 output_surface.SetOverlayCandidateValidator(new SingleOverlayValidator); | 397 output_surface.SetOverlayCandidateValidator(new SingleOverlayValidator); |
| 397 | 398 |
| 398 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( | 399 std::unique_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 399 new TestSharedBitmapManager()); | 400 new TestSharedBitmapManager()); |
| 400 std::unique_ptr<ResourceProvider> resource_provider = | 401 std::unique_ptr<ResourceProvider> resource_provider = |
| 401 FakeResourceProvider::Create(provider.get(), shared_bitmap_manager.get()); | 402 FakeResourceProvider::Create(provider.get(), shared_bitmap_manager.get()); |
| 402 | 403 |
| 403 std::unique_ptr<DefaultOverlayProcessor> overlay_processor( | 404 std::unique_ptr<DefaultOverlayProcessor> overlay_processor( |
| 404 new DefaultOverlayProcessor(&output_surface)); | 405 new DefaultOverlayProcessor(&output_surface)); |
| 405 overlay_processor->Initialize(); | 406 overlay_processor->Initialize(); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 gfx::OverlayTransform plane_transform, | 1305 gfx::OverlayTransform plane_transform, |
| 1305 unsigned overlay_texture_id, | 1306 unsigned overlay_texture_id, |
| 1306 const gfx::Rect& display_bounds, | 1307 const gfx::Rect& display_bounds, |
| 1307 const gfx::RectF& uv_rect)); | 1308 const gfx::RectF& uv_rect)); |
| 1308 }; | 1309 }; |
| 1309 | 1310 |
| 1310 class GLRendererWithOverlaysTest : public testing::Test { | 1311 class GLRendererWithOverlaysTest : public testing::Test { |
| 1311 protected: | 1312 protected: |
| 1312 GLRendererWithOverlaysTest() { | 1313 GLRendererWithOverlaysTest() { |
| 1313 provider_ = TestContextProvider::Create(); | 1314 provider_ = TestContextProvider::Create(); |
| 1315 provider_->BindToCurrentThread(); |
| 1314 output_surface_.reset(new OverlayOutputSurface(provider_)); | 1316 output_surface_.reset(new OverlayOutputSurface(provider_)); |
| 1315 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 1317 output_surface_->BindToClient(&output_surface_client_); |
| 1316 resource_provider_ = FakeResourceProvider::Create(provider_.get(), nullptr); | 1318 resource_provider_ = FakeResourceProvider::Create(provider_.get(), nullptr); |
| 1317 | 1319 |
| 1318 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( | 1320 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( |
| 1319 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); | 1321 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); |
| 1320 } | 1322 } |
| 1321 | 1323 |
| 1322 void Init(bool use_validator) { | 1324 void Init(bool use_validator) { |
| 1323 if (use_validator) | 1325 if (use_validator) |
| 1324 output_surface_->SetOverlayCandidateValidator(new SingleOverlayValidator); | 1326 output_surface_->SetOverlayCandidateValidator(new SingleOverlayValidator); |
| 1325 | 1327 |
| 1326 renderer_ = base::MakeUnique<OverlayInfoRendererGL>( | 1328 renderer_ = base::MakeUnique<OverlayInfoRendererGL>( |
| 1327 &settings_, output_surface_.get(), resource_provider_.get()); | 1329 &settings_, output_surface_.get(), resource_provider_.get()); |
| 1328 renderer_->Initialize(); | 1330 renderer_->Initialize(); |
| 1329 renderer_->SetVisible(true); | 1331 renderer_->SetVisible(true); |
| 1330 } | 1332 } |
| 1331 | 1333 |
| 1332 void DrawFrame(RenderPassList* pass_list, const gfx::Size& viewport_size) { | 1334 void DrawFrame(RenderPassList* pass_list, const gfx::Size& viewport_size) { |
| 1333 renderer_->DrawFrame(pass_list, 1.f, gfx::ColorSpace(), viewport_size); | 1335 renderer_->DrawFrame(pass_list, 1.f, gfx::ColorSpace(), viewport_size); |
| 1334 } | 1336 } |
| 1335 void SwapBuffers() { | 1337 void SwapBuffers() { |
| 1336 renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); | 1338 renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); |
| 1337 output_surface_->OnSwapBuffersComplete(); | |
| 1338 renderer_->SwapBuffersComplete(); | 1339 renderer_->SwapBuffersComplete(); |
| 1339 } | 1340 } |
| 1340 void SwapBuffersWithoutComplete() { | 1341 void SwapBuffersWithoutComplete() { |
| 1341 renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); | 1342 renderer_->SwapBuffers(std::vector<ui::LatencyInfo>()); |
| 1342 } | 1343 } |
| 1343 void SwapBuffersComplete() { | 1344 void SwapBuffersComplete() { |
| 1344 output_surface_->OnSwapBuffersComplete(); | |
| 1345 renderer_->SwapBuffersComplete(); | 1345 renderer_->SwapBuffersComplete(); |
| 1346 } | 1346 } |
| 1347 void ReturnResourceInUseQuery(ResourceId id) { | 1347 void ReturnResourceInUseQuery(ResourceId id) { |
| 1348 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), id); | 1348 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), id); |
| 1349 gpu::TextureInUseResponse response; | 1349 gpu::TextureInUseResponse response; |
| 1350 response.texture = lock.texture_id(); | 1350 response.texture = lock.texture_id(); |
| 1351 response.in_use = false; | 1351 response.in_use = false; |
| 1352 gpu::TextureInUseResponses responses; | 1352 gpu::TextureInUseResponses responses; |
| 1353 responses.push_back(response); | 1353 responses.push_back(response); |
| 1354 renderer_->DidReceiveTextureInUseResponses(responses); | 1354 renderer_->DidReceiveTextureInUseResponses(responses); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 gfx::Size(), filters_, gfx::Vector2dF(1, 1), gfx::PointF(), | 1897 gfx::Size(), filters_, gfx::Vector2dF(1, 1), gfx::PointF(), |
| 1898 background_filters_); | 1898 background_filters_); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 ProcessForOverlays(); | 1901 ProcessForOverlays(); |
| 1902 EXPECT_EQ(0U, ca_layer_list_.size()); | 1902 EXPECT_EQ(0U, ca_layer_list_.size()); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 } // namespace | 1905 } // namespace |
| 1906 } // namespace cc | 1906 } // namespace cc |
| OLD | NEW |