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

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

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

Powered by Google App Engine
This is Rietveld 408576698