| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/test/null_task_runner.h" | 10 #include "base/test/null_task_runner.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 EXPECT_EQ(6u, output_surface_->num_sent_frames()); | 428 EXPECT_EQ(6u, output_surface_->num_sent_frames()); |
| 429 EXPECT_EQ(gfx::Size(100, 100), | 429 EXPECT_EQ(gfx::Size(100, 100), |
| 430 software_output_device_->viewport_pixel_size()); | 430 software_output_device_->viewport_pixel_size()); |
| 431 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), | 431 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 432 software_output_device_->damage_rect()); | 432 software_output_device_->damage_rect()); |
| 433 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size()); | 433 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size()); |
| 434 } | 434 } |
| 435 TearDownDisplay(); | 435 TearDownDisplay(); |
| 436 } | 436 } |
| 437 | 437 |
| 438 // Check LatencyInfo storage is cleaned up if it exceeds the limit. |
| 439 TEST_F(DisplayTest, MaxLatencyInfoCap) { |
| 440 RendererSettings settings; |
| 441 settings.partial_swap_enabled = true; |
| 442 settings.finish_rendering_on_resize = true; |
| 443 SetUpDisplay(settings, nullptr); |
| 444 gfx::ColorSpace color_space_1 = gfx::ColorSpace::CreateXYZD50(); |
| 445 gfx::ColorSpace color_space_2 = gfx::ColorSpace::CreateSCRGBLinear(); |
| 446 |
| 447 StubDisplayClient client; |
| 448 display_->Initialize(&client, &manager_); |
| 449 display_->SetColorSpace(color_space_1, color_space_1); |
| 450 |
| 451 LocalSurfaceId local_surface_id(id_allocator_.GenerateId()); |
| 452 display_->SetLocalSurfaceId(local_surface_id, 1.f); |
| 453 |
| 454 scheduler_->ResetDamageForTest(); |
| 455 display_->Resize(gfx::Size(100, 100)); |
| 456 |
| 457 RenderPassList pass_list; |
| 458 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 459 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 460 pass->damage_rect = gfx::Rect(10, 10, 1, 1); |
| 461 pass->id = 1u; |
| 462 pass_list.push_back(std::move(pass)); |
| 463 |
| 464 scheduler_->ResetDamageForTest(); |
| 465 SubmitCompositorFrame(&pass_list, local_surface_id); |
| 466 |
| 467 display_->DrawAndSwap(); |
| 468 |
| 469 // This is the same as LatencyInfo::kMaxLatencyInfoNumber. |
| 470 const size_t max_latency_info_count = 100; |
| 471 for (size_t i = 0; i <= max_latency_info_count; ++i) { |
| 472 pass = RenderPass::Create(); |
| 473 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| 474 pass->damage_rect = gfx::Rect(10, 10, 0, 0); |
| 475 pass->id = 1u; |
| 476 |
| 477 pass_list.push_back(std::move(pass)); |
| 478 scheduler_->ResetDamageForTest(); |
| 479 |
| 480 CompositorFrame frame = test::MakeCompositorFrame(); |
| 481 pass_list.swap(frame.render_pass_list); |
| 482 frame.metadata.latency_info.push_back(ui::LatencyInfo()); |
| 483 |
| 484 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| 485 |
| 486 display_->DrawAndSwap(); |
| 487 |
| 488 if (i < max_latency_info_count) |
| 489 EXPECT_EQ(i + 1, display_->stored_latency_info_size_for_testing()); |
| 490 else |
| 491 EXPECT_EQ(0u, display_->stored_latency_info_size_for_testing()); |
| 492 } |
| 493 |
| 494 TearDownDisplay(); |
| 495 } |
| 496 |
| 438 class MockedContext : public TestWebGraphicsContext3D { | 497 class MockedContext : public TestWebGraphicsContext3D { |
| 439 public: | 498 public: |
| 440 MOCK_METHOD0(shallowFinishCHROMIUM, void()); | 499 MOCK_METHOD0(shallowFinishCHROMIUM, void()); |
| 441 }; | 500 }; |
| 442 | 501 |
| 443 TEST_F(DisplayTest, Finish) { | 502 TEST_F(DisplayTest, Finish) { |
| 444 LocalSurfaceId local_surface_id1(id_allocator_.GenerateId()); | 503 LocalSurfaceId local_surface_id1(id_allocator_.GenerateId()); |
| 445 LocalSurfaceId local_surface_id2(id_allocator_.GenerateId()); | 504 LocalSurfaceId local_surface_id2(id_allocator_.GenerateId()); |
| 446 | 505 |
| 447 RendererSettings settings; | 506 RendererSettings settings; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 647 |
| 589 // Should have damaged only display_ but not display2. | 648 // Should have damaged only display_ but not display2. |
| 590 EXPECT_TRUE(scheduler_->damaged); | 649 EXPECT_TRUE(scheduler_->damaged); |
| 591 EXPECT_FALSE(scheduler2->damaged); | 650 EXPECT_FALSE(scheduler2->damaged); |
| 592 manager_.UnregisterBeginFrameSource(begin_frame_source2.get()); | 651 manager_.UnregisterBeginFrameSource(begin_frame_source2.get()); |
| 593 TearDownDisplay(); | 652 TearDownDisplay(); |
| 594 } | 653 } |
| 595 | 654 |
| 596 } // namespace | 655 } // namespace |
| 597 } // namespace cc | 656 } // namespace cc |
| OLD | NEW |