Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: cc/surfaces/display_unittest.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: SetPreviousFrame lint Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EXPECT_FALSE(scheduler_->damaged); 189 EXPECT_FALSE(scheduler_->damaged);
190 EXPECT_FALSE(scheduler_->display_resized_); 190 EXPECT_FALSE(scheduler_->display_resized_);
191 EXPECT_TRUE(scheduler_->has_new_root_surface); 191 EXPECT_TRUE(scheduler_->has_new_root_surface);
192 192
193 scheduler_->ResetDamageForTest(); 193 scheduler_->ResetDamageForTest();
194 display_->Resize(gfx::Size(100, 100)); 194 display_->Resize(gfx::Size(100, 100));
195 EXPECT_FALSE(scheduler_->damaged); 195 EXPECT_FALSE(scheduler_->damaged);
196 EXPECT_TRUE(scheduler_->display_resized_); 196 EXPECT_TRUE(scheduler_->display_resized_);
197 EXPECT_FALSE(scheduler_->has_new_root_surface); 197 EXPECT_FALSE(scheduler_->has_new_root_surface);
198 198
199 factory_.Create(local_frame_id);
200
201 // First draw from surface should have full damage. 199 // First draw from surface should have full damage.
202 RenderPassList pass_list; 200 RenderPassList pass_list;
203 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 201 std::unique_ptr<RenderPass> pass = RenderPass::Create();
204 pass->output_rect = gfx::Rect(0, 0, 100, 100); 202 pass->output_rect = gfx::Rect(0, 0, 100, 100);
205 pass->damage_rect = gfx::Rect(10, 10, 1, 1); 203 pass->damage_rect = gfx::Rect(10, 10, 1, 1);
206 pass->id = RenderPassId(1, 1); 204 pass->id = RenderPassId(1, 1);
207 pass_list.push_back(std::move(pass)); 205 pass_list.push_back(std::move(pass));
208 206
209 scheduler_->ResetDamageForTest(); 207 scheduler_->ResetDamageForTest();
210 SubmitCompositorFrame(&pass_list, local_frame_id); 208 SubmitCompositorFrame(&pass_list, local_frame_id);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 scheduler_->swapped = false; 405 scheduler_->swapped = false;
408 display_->DrawAndSwap(); 406 display_->DrawAndSwap();
409 EXPECT_TRUE(scheduler_->swapped); 407 EXPECT_TRUE(scheduler_->swapped);
410 EXPECT_EQ(6u, output_surface_->num_sent_frames()); 408 EXPECT_EQ(6u, output_surface_->num_sent_frames());
411 EXPECT_EQ(gfx::Size(100, 100), 409 EXPECT_EQ(gfx::Size(100, 100),
412 software_output_device_->viewport_pixel_size()); 410 software_output_device_->viewport_pixel_size());
413 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), 411 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
414 software_output_device_->damage_rect()); 412 software_output_device_->damage_rect());
415 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size()); 413 EXPECT_EQ(0u, output_surface_->last_sent_frame()->latency_info.size());
416 } 414 }
417
418 factory_.Destroy(local_frame_id);
419 } 415 }
420 416
421 class MockedContext : public TestWebGraphicsContext3D { 417 class MockedContext : public TestWebGraphicsContext3D {
422 public: 418 public:
423 MOCK_METHOD0(shallowFinishCHROMIUM, void()); 419 MOCK_METHOD0(shallowFinishCHROMIUM, void());
424 }; 420 };
425 421
426 TEST_F(DisplayTest, Finish) { 422 TEST_F(DisplayTest, Finish) {
427 LocalFrameId local_frame_id(id_allocator_.GenerateId()); 423 LocalFrameId local_frame_id(id_allocator_.GenerateId());
428 424
429 RendererSettings settings; 425 RendererSettings settings;
430 settings.partial_swap_enabled = true; 426 settings.partial_swap_enabled = true;
431 settings.finish_rendering_on_resize = true; 427 settings.finish_rendering_on_resize = true;
432 428
433 std::unique_ptr<MockedContext> context(new MockedContext()); 429 std::unique_ptr<MockedContext> context(new MockedContext());
434 MockedContext* context_ptr = context.get(); 430 MockedContext* context_ptr = context.get();
435 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); 431 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0);
436 432
437 SetUpDisplay(settings, std::move(context)); 433 SetUpDisplay(settings, std::move(context));
438 434
439 StubDisplayClient client; 435 StubDisplayClient client;
440 display_->Initialize(&client, &manager_); 436 display_->Initialize(&client, &manager_);
441 437
442 display_->SetLocalFrameId(local_frame_id, 1.f); 438 display_->SetLocalFrameId(local_frame_id, 1.f);
443 439
444 display_->Resize(gfx::Size(100, 100)); 440 display_->Resize(gfx::Size(100, 100));
445 factory_.Create(local_frame_id);
446 441
447 { 442 {
448 RenderPassList pass_list; 443 RenderPassList pass_list;
449 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 444 std::unique_ptr<RenderPass> pass = RenderPass::Create();
450 pass->output_rect = gfx::Rect(0, 0, 100, 100); 445 pass->output_rect = gfx::Rect(0, 0, 100, 100);
451 pass->damage_rect = gfx::Rect(10, 10, 1, 1); 446 pass->damage_rect = gfx::Rect(10, 10, 1, 1);
452 pass->id = RenderPassId(1, 1); 447 pass->id = RenderPassId(1, 1);
453 pass_list.push_back(std::move(pass)); 448 pass_list.push_back(std::move(pass));
454 449
455 SubmitCompositorFrame(&pass_list, local_frame_id); 450 SubmitCompositorFrame(&pass_list, local_frame_id);
(...skipping 25 matching lines...) Expand all
481 SubmitCompositorFrame(&pass_list, local_frame_id); 476 SubmitCompositorFrame(&pass_list, local_frame_id);
482 } 477 }
483 478
484 display_->DrawAndSwap(); 479 display_->DrawAndSwap();
485 480
486 testing::Mock::VerifyAndClearExpectations(context_ptr); 481 testing::Mock::VerifyAndClearExpectations(context_ptr);
487 482
488 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); 483 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM());
489 display_->Resize(gfx::Size(250, 250)); 484 display_->Resize(gfx::Size(250, 250));
490 testing::Mock::VerifyAndClearExpectations(context_ptr); 485 testing::Mock::VerifyAndClearExpectations(context_ptr);
491
492 factory_.Destroy(local_frame_id);
493 } 486 }
494 487
495 class CountLossDisplayClient : public StubDisplayClient { 488 class CountLossDisplayClient : public StubDisplayClient {
496 public: 489 public:
497 CountLossDisplayClient() = default; 490 CountLossDisplayClient() = default;
498 491
499 void DisplayOutputSurfaceLost() override { ++loss_count_; } 492 void DisplayOutputSurfaceLost() override { ++loss_count_; }
500 493
501 int loss_count() const { return loss_count_; } 494 int loss_count() const { return loss_count_; }
502 495
(...skipping 10 matching lines...) Expand all
513 // Verify DidLoseOutputSurface callback is hooked up correctly. 506 // Verify DidLoseOutputSurface callback is hooked up correctly.
514 EXPECT_EQ(0, client.loss_count()); 507 EXPECT_EQ(0, client.loss_count());
515 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( 508 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM(
516 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 509 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
517 output_surface_->context_provider()->ContextGL()->Flush(); 510 output_surface_->context_provider()->ContextGL()->Flush();
518 EXPECT_EQ(1, client.loss_count()); 511 EXPECT_EQ(1, client.loss_count());
519 } 512 }
520 513
521 } // namespace 514 } // namespace
522 } // namespace cc 515 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698