| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/surfaces/display.h" | 5 #include "cc/surfaces/display.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/test/null_task_runner.h" | 9 #include "base/test/null_task_runner.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); | 125 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); |
| 126 } | 126 } |
| 127 output_surface_ = output_surface.get(); | 127 output_surface_ = output_surface.get(); |
| 128 | 128 |
| 129 std::unique_ptr<TestDisplayScheduler> scheduler( | 129 std::unique_ptr<TestDisplayScheduler> scheduler( |
| 130 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); | 130 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); |
| 131 scheduler_ = scheduler.get(); | 131 scheduler_ = scheduler.get(); |
| 132 | 132 |
| 133 display_ = base::MakeUnique<Display>( | 133 display_ = base::MakeUnique<Display>( |
| 134 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, | 134 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, |
| 135 settings, std::move(begin_frame_source), std::move(output_surface), | 135 settings, kArbitraryFrameSinkId, std::move(begin_frame_source), |
| 136 std::move(scheduler), | 136 std::move(output_surface), std::move(scheduler), |
| 137 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); | 137 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); |
| 138 display_->SetVisible(true); | 138 display_->SetVisible(true); |
| 139 } | 139 } |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 void SubmitCompositorFrame(RenderPassList* pass_list, | 142 void SubmitCompositorFrame(RenderPassList* pass_list, |
| 143 const LocalFrameId& local_frame_id) { | 143 const LocalFrameId& local_frame_id) { |
| 144 CompositorFrame frame; | 144 CompositorFrame frame; |
| 145 pass_list->swap(frame.render_pass_list); | 145 pass_list->swap(frame.render_pass_list); |
| 146 | 146 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Check that frame is damaged and swapped only under correct conditions. | 175 // Check that frame is damaged and swapped only under correct conditions. |
| 176 TEST_F(DisplayTest, DisplayDamaged) { | 176 TEST_F(DisplayTest, DisplayDamaged) { |
| 177 RendererSettings settings; | 177 RendererSettings settings; |
| 178 settings.partial_swap_enabled = true; | 178 settings.partial_swap_enabled = true; |
| 179 settings.finish_rendering_on_resize = true; | 179 settings.finish_rendering_on_resize = true; |
| 180 SetUpDisplay(settings, nullptr); | 180 SetUpDisplay(settings, nullptr); |
| 181 | 181 |
| 182 StubDisplayClient client; | 182 StubDisplayClient client; |
| 183 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); | 183 display_->Initialize(&client, &manager_); |
| 184 | 184 |
| 185 LocalFrameId local_frame_id(id_allocator_.GenerateId()); | 185 LocalFrameId local_frame_id(id_allocator_.GenerateId()); |
| 186 SurfaceId surface_id(factory_.frame_sink_id(), local_frame_id); | |
| 187 EXPECT_FALSE(scheduler_->damaged); | 186 EXPECT_FALSE(scheduler_->damaged); |
| 188 EXPECT_FALSE(scheduler_->has_new_root_surface); | 187 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 189 display_->SetSurfaceId(surface_id, 1.f); | 188 display_->SetLocalFrameId(local_frame_id, 1.f); |
| 190 EXPECT_FALSE(scheduler_->damaged); | 189 EXPECT_FALSE(scheduler_->damaged); |
| 191 EXPECT_FALSE(scheduler_->display_resized_); | 190 EXPECT_FALSE(scheduler_->display_resized_); |
| 192 EXPECT_TRUE(scheduler_->has_new_root_surface); | 191 EXPECT_TRUE(scheduler_->has_new_root_surface); |
| 193 | 192 |
| 194 scheduler_->ResetDamageForTest(); | 193 scheduler_->ResetDamageForTest(); |
| 195 display_->Resize(gfx::Size(100, 100)); | 194 display_->Resize(gfx::Size(100, 100)); |
| 196 EXPECT_FALSE(scheduler_->damaged); | 195 EXPECT_FALSE(scheduler_->damaged); |
| 197 EXPECT_TRUE(scheduler_->display_resized_); | 196 EXPECT_TRUE(scheduler_->display_resized_); |
| 198 EXPECT_FALSE(scheduler_->has_new_root_surface); | 197 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 199 | 198 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 factory_.Destroy(local_frame_id); | 418 factory_.Destroy(local_frame_id); |
| 420 } | 419 } |
| 421 | 420 |
| 422 class MockedContext : public TestWebGraphicsContext3D { | 421 class MockedContext : public TestWebGraphicsContext3D { |
| 423 public: | 422 public: |
| 424 MOCK_METHOD0(shallowFinishCHROMIUM, void()); | 423 MOCK_METHOD0(shallowFinishCHROMIUM, void()); |
| 425 }; | 424 }; |
| 426 | 425 |
| 427 TEST_F(DisplayTest, Finish) { | 426 TEST_F(DisplayTest, Finish) { |
| 428 LocalFrameId local_frame_id(id_allocator_.GenerateId()); | 427 LocalFrameId local_frame_id(id_allocator_.GenerateId()); |
| 429 SurfaceId surface_id(factory_.frame_sink_id(), local_frame_id); | |
| 430 | 428 |
| 431 RendererSettings settings; | 429 RendererSettings settings; |
| 432 settings.partial_swap_enabled = true; | 430 settings.partial_swap_enabled = true; |
| 433 settings.finish_rendering_on_resize = true; | 431 settings.finish_rendering_on_resize = true; |
| 434 | 432 |
| 435 std::unique_ptr<MockedContext> context(new MockedContext()); | 433 std::unique_ptr<MockedContext> context(new MockedContext()); |
| 436 MockedContext* context_ptr = context.get(); | 434 MockedContext* context_ptr = context.get(); |
| 437 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 435 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 438 | 436 |
| 439 SetUpDisplay(settings, std::move(context)); | 437 SetUpDisplay(settings, std::move(context)); |
| 440 | 438 |
| 441 StubDisplayClient client; | 439 StubDisplayClient client; |
| 442 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); | 440 display_->Initialize(&client, &manager_); |
| 443 | 441 |
| 444 display_->SetSurfaceId(surface_id, 1.f); | 442 display_->SetLocalFrameId(local_frame_id, 1.f); |
| 445 | 443 |
| 446 display_->Resize(gfx::Size(100, 100)); | 444 display_->Resize(gfx::Size(100, 100)); |
| 447 factory_.Create(local_frame_id); | 445 factory_.Create(local_frame_id); |
| 448 | 446 |
| 449 { | 447 { |
| 450 RenderPassList pass_list; | 448 RenderPassList pass_list; |
| 451 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 449 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 452 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 450 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 453 pass->damage_rect = gfx::Rect(10, 10, 1, 1); | 451 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 454 pass->id = RenderPassId(1, 1); | 452 pass->id = RenderPassId(1, 1); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 int loss_count() const { return loss_count_; } | 501 int loss_count() const { return loss_count_; } |
| 504 | 502 |
| 505 private: | 503 private: |
| 506 int loss_count_ = 0; | 504 int loss_count_ = 0; |
| 507 }; | 505 }; |
| 508 | 506 |
| 509 TEST_F(DisplayTest, ContextLossInformsClient) { | 507 TEST_F(DisplayTest, ContextLossInformsClient) { |
| 510 SetUpDisplay(RendererSettings(), TestWebGraphicsContext3D::Create()); | 508 SetUpDisplay(RendererSettings(), TestWebGraphicsContext3D::Create()); |
| 511 | 509 |
| 512 CountLossDisplayClient client; | 510 CountLossDisplayClient client; |
| 513 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); | 511 display_->Initialize(&client, &manager_); |
| 514 | 512 |
| 515 // Verify DidLoseOutputSurface callback is hooked up correctly. | 513 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 516 EXPECT_EQ(0, client.loss_count()); | 514 EXPECT_EQ(0, client.loss_count()); |
| 517 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( | 515 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( |
| 518 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 516 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 519 output_surface_->context_provider()->ContextGL()->Flush(); | 517 output_surface_->context_provider()->ContextGL()->Flush(); |
| 520 EXPECT_EQ(1, client.loss_count()); | 518 EXPECT_EQ(1, client.loss_count()); |
| 521 } | 519 } |
| 522 | 520 |
| 523 } // namespace | 521 } // namespace |
| 524 } // namespace cc | 522 } // namespace cc |
| OLD | NEW |