| 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 <drm_fourcc.h> | 5 #include <drm_fourcc.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" | 13 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
| 14 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 15 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 15 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 16 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 16 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 17 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 17 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
| 18 #include "ui/ozone/platform/drm/gpu/mock_drm_device.h" | 18 #include "ui/ozone/platform/drm/gpu/mock_drm_device.h" |
| 19 #include "ui/ozone/platform/drm/gpu/mock_dumb_buffer_generator.h" | 19 #include "ui/ozone/platform/drm/gpu/mock_scanout_buffer_generator.h" |
| 20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 void EmptySwapCallback(gfx::SwapResult) { | 24 void EmptySwapCallback(gfx::SwapResult) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Create a basic mode for a 6x4 screen. | 27 // Create a basic mode for a 6x4 screen. |
| 28 const drmModeModeInfo kDefaultMode = | 28 const drmModeModeInfo kDefaultMode = |
| 29 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; | 29 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 return gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); | 44 return gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Secondary is in extended mode, right-of primary. | 47 // Secondary is in extended mode, right-of primary. |
| 48 gfx::Rect GetSecondaryBounds() const { | 48 gfx::Rect GetSecondaryBounds() const { |
| 49 return gfx::Rect(kDefaultMode.hdisplay, 0, kDefaultMode.hdisplay, | 49 return gfx::Rect(kDefaultMode.hdisplay, 0, kDefaultMode.hdisplay, |
| 50 kDefaultMode.vdisplay); | 50 kDefaultMode.vdisplay); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SetUp() override { | 53 void SetUp() override { |
| 54 drm_ = new ui::MockDrmDevice(); | 54 drm_ = new ui::MockDrmDevice(false, std::vector<uint32_t>(1, kPrimaryCrtc), |
| 55 4 /* planes per crtc */); |
| 55 device_manager_.reset(new ui::DrmDeviceManager(nullptr)); | 56 device_manager_.reset(new ui::DrmDeviceManager(nullptr)); |
| 56 buffer_generator_.reset(new ui::MockDumbBufferGenerator()); | 57 buffer_generator_.reset(new ui::MockScanoutBufferGenerator()); |
| 57 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get())); | 58 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get())); |
| 58 } | 59 } |
| 59 void TearDown() override { | 60 void TearDown() override { |
| 60 screen_manager_.reset(); | 61 screen_manager_.reset(); |
| 61 drm_ = nullptr; | 62 drm_ = nullptr; |
| 62 } | 63 } |
| 63 | 64 |
| 64 protected: | 65 protected: |
| 65 scoped_refptr<ui::MockDrmDevice> drm_; | 66 scoped_refptr<ui::MockDrmDevice> drm_; |
| 66 std::unique_ptr<ui::DrmDeviceManager> device_manager_; | 67 std::unique_ptr<ui::DrmDeviceManager> device_manager_; |
| 67 std::unique_ptr<ui::MockDumbBufferGenerator> buffer_generator_; | 68 std::unique_ptr<ui::MockScanoutBufferGenerator> buffer_generator_; |
| 68 std::unique_ptr<ui::ScreenManager> screen_manager_; | 69 std::unique_ptr<ui::ScreenManager> screen_manager_; |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); | 72 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 TEST_F(ScreenManagerTest, CheckWithNoControllers) { | 75 TEST_F(ScreenManagerTest, CheckWithNoControllers) { |
| 75 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 76 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 76 } | 77 } |
| 77 | 78 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); | 510 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 510 screen_manager_->ConfigureDisplayController( | 511 screen_manager_->ConfigureDisplayController( |
| 511 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), | 512 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 512 kDefaultMode); | 513 kDefaultMode); |
| 513 | 514 |
| 514 EXPECT_EQ(buffer->GetFramebufferId(), drm_->current_framebuffer()); | 515 EXPECT_EQ(buffer->GetFramebufferId(), drm_->current_framebuffer()); |
| 515 | 516 |
| 516 window = screen_manager_->RemoveWindow(1); | 517 window = screen_manager_->RemoveWindow(1); |
| 517 window->Shutdown(); | 518 window->Shutdown(); |
| 518 } | 519 } |
| 520 |
| 521 TEST_F(ScreenManagerTest, RejectBufferWithIncompatibleModifiers) { |
| 522 std::unique_ptr<ui::DrmWindow> window( |
| 523 new ui::DrmWindow(1, device_manager_.get(), screen_manager_.get())); |
| 524 window->Initialize(buffer_generator_.get()); |
| 525 window->SetBounds(GetPrimaryBounds()); |
| 526 scoped_refptr<ui::ScanoutBuffer> buffer = |
| 527 buffer_generator_->CreateWithModifier(drm_, DRM_FORMAT_XRGB8888, |
| 528 I915_FORMAT_MOD_X_TILED, |
| 529 GetPrimaryBounds().size()); |
| 530 |
| 531 window->SchedulePageFlip( |
| 532 std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(buffer)), |
| 533 base::Bind(&EmptySwapCallback)); |
| 534 screen_manager_->AddWindow(1, std::move(window)); |
| 535 |
| 536 screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector); |
| 537 screen_manager_->ConfigureDisplayController( |
| 538 drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), |
| 539 kDefaultMode); |
| 540 |
| 541 // ScreenManager::GetModesetBuffer (called to get a buffer to |
| 542 // modeset the new controller) should reject the buffer with |
| 543 // I915_FORMAT_MOD_X_TILED modifier we created above and the two |
| 544 // framebuffer IDs should be different. |
| 545 EXPECT_NE(buffer->GetFramebufferId(), drm_->current_framebuffer()); |
| 546 |
| 547 window = screen_manager_->RemoveWindow(1); |
| 548 window->Shutdown(); |
| 549 } |
| OLD | NEW |