Chromium Code Reviews| 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. | |
|
tdresser
2017/07/04 16:41:04
kMaxLA -> kMaxLa
Navid Zolghadr
2017/07/04 17:16:28
Done.
| |
| 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 EXPECT_EQ(i < max_latency_info_count ? (i + 1) : 0, | |
| 488 display_->stored_latency_info_size_for_testing()); | |
|
tdresser
2017/07/04 16:41:04
I think this would be a bit easier to read if you
Navid Zolghadr
2017/07/04 17:16:28
Done.
| |
| 489 } | |
| 490 | |
| 491 TearDownDisplay(); | |
| 492 } | |
| 493 | |
| 438 class MockedContext : public TestWebGraphicsContext3D { | 494 class MockedContext : public TestWebGraphicsContext3D { |
| 439 public: | 495 public: |
| 440 MOCK_METHOD0(shallowFinishCHROMIUM, void()); | 496 MOCK_METHOD0(shallowFinishCHROMIUM, void()); |
| 441 }; | 497 }; |
| 442 | 498 |
| 443 TEST_F(DisplayTest, Finish) { | 499 TEST_F(DisplayTest, Finish) { |
| 444 LocalSurfaceId local_surface_id1(id_allocator_.GenerateId()); | 500 LocalSurfaceId local_surface_id1(id_allocator_.GenerateId()); |
| 445 LocalSurfaceId local_surface_id2(id_allocator_.GenerateId()); | 501 LocalSurfaceId local_surface_id2(id_allocator_.GenerateId()); |
| 446 | 502 |
| 447 RendererSettings settings; | 503 RendererSettings settings; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 | 644 |
| 589 // Should have damaged only display_ but not display2. | 645 // Should have damaged only display_ but not display2. |
| 590 EXPECT_TRUE(scheduler_->damaged); | 646 EXPECT_TRUE(scheduler_->damaged); |
| 591 EXPECT_FALSE(scheduler2->damaged); | 647 EXPECT_FALSE(scheduler2->damaged); |
| 592 manager_.UnregisterBeginFrameSource(begin_frame_source2.get()); | 648 manager_.UnregisterBeginFrameSource(begin_frame_source2.get()); |
| 593 TearDownDisplay(); | 649 TearDownDisplay(); |
| 594 } | 650 } |
| 595 | 651 |
| 596 } // namespace | 652 } // namespace |
| 597 } // namespace cc | 653 } // namespace cc |
| OLD | NEW |