| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 screen_manager_->GetDisplayController(GetSecondaryBounds()); | 372 screen_manager_->GetDisplayController(GetSecondaryBounds()); |
| 373 | 373 |
| 374 EXPECT_NE(controller1, controller2); | 374 EXPECT_NE(controller1, controller2); |
| 375 EXPECT_EQ(drm_, controller1->crtc_controllers()[0]->drm()); | 375 EXPECT_EQ(drm_, controller1->crtc_controllers()[0]->drm()); |
| 376 EXPECT_EQ(drm2, controller2->crtc_controllers()[0]->drm()); | 376 EXPECT_EQ(drm2, controller2->crtc_controllers()[0]->drm()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 TEST_F(ScreenManagerTest, CheckControllerToWindowMappingWithSameBounds) { | 379 TEST_F(ScreenManagerTest, CheckControllerToWindowMappingWithSameBounds) { |
| 380 scoped_ptr<ui::DrmWindow> window( | 380 scoped_ptr<ui::DrmWindow> window( |
| 381 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); | 381 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); |
| 382 window->Initialize(); | 382 window->Initialize(buffer_generator_.get()); |
| 383 window->SetBounds(GetPrimaryBounds()); | 383 window->SetBounds(GetPrimaryBounds()); |
| 384 screen_manager_->AddWindow(1, std::move(window)); | 384 screen_manager_->AddWindow(1, std::move(window)); |
| 385 | 385 |
| 386 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 386 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 387 screen_manager_->ConfigureDisplayController( | 387 screen_manager_->ConfigureDisplayController( |
| 388 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 388 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 389 kDefaultMode); | 389 kDefaultMode); |
| 390 | 390 |
| 391 EXPECT_TRUE(screen_manager_->GetWindow(1)->GetController()); | 391 EXPECT_TRUE(screen_manager_->GetWindow(1)->GetController()); |
| 392 | 392 |
| 393 window = screen_manager_->RemoveWindow(1); | 393 window = screen_manager_->RemoveWindow(1); |
| 394 window->Shutdown(); | 394 window->Shutdown(); |
| 395 } | 395 } |
| 396 | 396 |
| 397 TEST_F(ScreenManagerTest, CheckControllerToWindowMappingWithDifferentBounds) { | 397 TEST_F(ScreenManagerTest, CheckControllerToWindowMappingWithDifferentBounds) { |
| 398 scoped_ptr<ui::DrmWindow> window( | 398 scoped_ptr<ui::DrmWindow> window( |
| 399 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); | 399 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); |
| 400 window->Initialize(); | 400 window->Initialize(buffer_generator_.get()); |
| 401 gfx::Rect new_bounds = GetPrimaryBounds(); | 401 gfx::Rect new_bounds = GetPrimaryBounds(); |
| 402 new_bounds.Inset(0, 0, 1, 1); | 402 new_bounds.Inset(0, 0, 1, 1); |
| 403 window->SetBounds(new_bounds); | 403 window->SetBounds(new_bounds); |
| 404 screen_manager_->AddWindow(1, std::move(window)); | 404 screen_manager_->AddWindow(1, std::move(window)); |
| 405 | 405 |
| 406 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 406 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 407 screen_manager_->ConfigureDisplayController( | 407 screen_manager_->ConfigureDisplayController( |
| 408 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 408 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 409 kDefaultMode); | 409 kDefaultMode); |
| 410 | 410 |
| 411 EXPECT_FALSE(screen_manager_->GetWindow(1)->GetController()); | 411 EXPECT_FALSE(screen_manager_->GetWindow(1)->GetController()); |
| 412 | 412 |
| 413 window = screen_manager_->RemoveWindow(1); | 413 window = screen_manager_->RemoveWindow(1); |
| 414 window->Shutdown(); | 414 window->Shutdown(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 TEST_F(ScreenManagerTest, | 417 TEST_F(ScreenManagerTest, |
| 418 CheckControllerToWindowMappingWithOverlappingWindows) { | 418 CheckControllerToWindowMappingWithOverlappingWindows) { |
| 419 const size_t kWindowCount = 2; | 419 const size_t kWindowCount = 2; |
| 420 for (size_t i = 1; i < kWindowCount + 1; ++i) { | 420 for (size_t i = 1; i < kWindowCount + 1; ++i) { |
| 421 scoped_ptr<ui::DrmWindow> window( | 421 scoped_ptr<ui::DrmWindow> window( |
| 422 new ui::DrmWindow(i, device_manager_.get(), screen_manager_.get())); | 422 new ui::DrmWindow(i, device_manager_.get(), screen_manager_.get())); |
| 423 window->Initialize(); | 423 window->Initialize(buffer_generator_.get()); |
| 424 window->SetBounds(GetPrimaryBounds()); | 424 window->SetBounds(GetPrimaryBounds()); |
| 425 screen_manager_->AddWindow(i, std::move(window)); | 425 screen_manager_->AddWindow(i, std::move(window)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 428 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 429 screen_manager_->ConfigureDisplayController( | 429 screen_manager_->ConfigureDisplayController( |
| 430 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 430 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 431 kDefaultMode); | 431 kDefaultMode); |
| 432 | 432 |
| 433 bool window1_has_controller = screen_manager_->GetWindow(1)->GetController(); | 433 bool window1_has_controller = screen_manager_->GetWindow(1)->GetController(); |
| 434 bool window2_has_controller = screen_manager_->GetWindow(2)->GetController(); | 434 bool window2_has_controller = screen_manager_->GetWindow(2)->GetController(); |
| 435 // Only one of the windows can have a controller. | 435 // Only one of the windows can have a controller. |
| 436 EXPECT_TRUE(window1_has_controller ^ window2_has_controller); | 436 EXPECT_TRUE(window1_has_controller ^ window2_has_controller); |
| 437 | 437 |
| 438 for (size_t i = 1; i < kWindowCount + 1; ++i) { | 438 for (size_t i = 1; i < kWindowCount + 1; ++i) { |
| 439 scoped_ptr<ui::DrmWindow> window = screen_manager_->RemoveWindow(i); | 439 scoped_ptr<ui::DrmWindow> window = screen_manager_->RemoveWindow(i); |
| 440 window->Shutdown(); | 440 window->Shutdown(); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 TEST_F(ScreenManagerTest, ShouldDissociateWindowOnControllerRemoval) { | 444 TEST_F(ScreenManagerTest, ShouldDissociateWindowOnControllerRemoval) { |
| 445 gfx::AcceleratedWidget window_id = 1; | 445 gfx::AcceleratedWidget window_id = 1; |
| 446 scoped_ptr<ui::DrmWindow> window(new ui::DrmWindow( | 446 scoped_ptr<ui::DrmWindow> window(new ui::DrmWindow( |
| 447 window_id, device_manager_.get(), screen_manager_.get())); | 447 window_id, device_manager_.get(), screen_manager_.get())); |
| 448 window->Initialize(); | 448 window->Initialize(buffer_generator_.get()); |
| 449 window->SetBounds(GetPrimaryBounds()); | 449 window->SetBounds(GetPrimaryBounds()); |
| 450 screen_manager_->AddWindow(window_id, std::move(window)); | 450 screen_manager_->AddWindow(window_id, std::move(window)); |
| 451 | 451 |
| 452 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 452 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 453 screen_manager_->ConfigureDisplayController( | 453 screen_manager_->ConfigureDisplayController( |
| 454 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 454 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 455 kDefaultMode); | 455 kDefaultMode); |
| 456 | 456 |
| 457 EXPECT_TRUE(screen_manager_->GetWindow(window_id)->GetController()); | 457 EXPECT_TRUE(screen_manager_->GetWindow(window_id)->GetController()); |
| 458 | 458 |
| 459 screen_manager_->RemoveDisplayController(drm_, kPrimaryCrtc); | 459 screen_manager_->RemoveDisplayController(drm_, kPrimaryCrtc); |
| 460 | 460 |
| 461 EXPECT_FALSE(screen_manager_->GetWindow(window_id)->GetController()); | 461 EXPECT_FALSE(screen_manager_->GetWindow(window_id)->GetController()); |
| 462 | 462 |
| 463 window = screen_manager_->RemoveWindow(1); | 463 window = screen_manager_->RemoveWindow(1); |
| 464 window->Shutdown(); | 464 window->Shutdown(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasNoBuffer) { | 467 TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasNoBuffer) { |
| 468 scoped_ptr<ui::DrmWindow> window( | 468 scoped_ptr<ui::DrmWindow> window( |
| 469 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); | 469 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); |
| 470 window->Initialize(); | 470 window->Initialize(buffer_generator_.get()); |
| 471 window->SetBounds(GetPrimaryBounds()); | 471 window->SetBounds(GetPrimaryBounds()); |
| 472 screen_manager_->AddWindow(1, std::move(window)); | 472 screen_manager_->AddWindow(1, std::move(window)); |
| 473 | 473 |
| 474 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 474 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 475 screen_manager_->ConfigureDisplayController( | 475 screen_manager_->ConfigureDisplayController( |
| 476 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 476 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 477 kDefaultMode); | 477 kDefaultMode); |
| 478 | 478 |
| 479 EXPECT_TRUE(screen_manager_->GetWindow(1)->GetController()); | 479 EXPECT_TRUE(screen_manager_->GetWindow(1)->GetController()); |
| 480 // There is a buffer after initial config. | 480 // There is a buffer after initial config. |
| 481 uint32_t framebuffer = drm_->current_framebuffer(); | 481 uint32_t framebuffer = drm_->current_framebuffer(); |
| 482 EXPECT_NE(0U, framebuffer); | 482 EXPECT_NE(0U, framebuffer); |
| 483 | 483 |
| 484 screen_manager_->ConfigureDisplayController( | 484 screen_manager_->ConfigureDisplayController( |
| 485 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 485 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 486 kDefaultMode); | 486 kDefaultMode); |
| 487 | 487 |
| 488 // There is a new buffer after we configured with the same mode but no | 488 // There is a new buffer after we configured with the same mode but no |
| 489 // pending frames on the window. | 489 // pending frames on the window. |
| 490 EXPECT_NE(framebuffer, drm_->current_framebuffer()); | 490 EXPECT_NE(framebuffer, drm_->current_framebuffer()); |
| 491 | 491 |
| 492 window = screen_manager_->RemoveWindow(1); | 492 window = screen_manager_->RemoveWindow(1); |
| 493 window->Shutdown(); | 493 window->Shutdown(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasBuffer) { | 496 TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasBuffer) { |
| 497 scoped_ptr<ui::DrmWindow> window( | 497 scoped_ptr<ui::DrmWindow> window( |
| 498 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); | 498 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); |
| 499 window->Initialize(); | 499 window->Initialize(buffer_generator_.get()); |
| 500 window->SetBounds(GetPrimaryBounds()); | 500 window->SetBounds(GetPrimaryBounds()); |
| 501 scoped_refptr<ui::ScanoutBuffer> buffer = buffer_generator_->Create( | 501 scoped_refptr<ui::ScanoutBuffer> buffer = buffer_generator_->Create( |
| 502 drm_, gfx::BufferFormat::BGRA_8888, GetPrimaryBounds().size()); | 502 drm_, gfx::BufferFormat::BGRA_8888, GetPrimaryBounds().size()); |
| 503 window->SchedulePageFlip( | 503 window->SchedulePageFlip( |
| 504 std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(buffer)), | 504 std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(buffer)), |
| 505 base::Bind(&EmptySwapCallback)); | 505 base::Bind(&EmptySwapCallback)); |
| 506 screen_manager_->AddWindow(1, std::move(window)); | 506 screen_manager_->AddWindow(1, std::move(window)); |
| 507 | 507 |
| 508 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 508 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 509 screen_manager_->ConfigureDisplayController( | 509 screen_manager_->ConfigureDisplayController( |
| 510 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 510 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 511 kDefaultMode); | 511 kDefaultMode); |
| 512 | 512 |
| 513 EXPECT_EQ(buffer->GetFramebufferId(), drm_->current_framebuffer()); | 513 EXPECT_EQ(buffer->GetFramebufferId(), drm_->current_framebuffer()); |
| 514 | 514 |
| 515 window = screen_manager_->RemoveWindow(1); | 515 window = screen_manager_->RemoveWindow(1); |
| 516 window->Shutdown(); | 516 window->Shutdown(); |
| 517 } | 517 } |
| OLD | NEW |