| 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 "ui/ozone/platform/drm/gpu/screen_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 6 | 6 |
| 7 #include <xf86drmMode.h> | 7 #include <xf86drmMode.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ScreenManager::~ScreenManager() { | 88 ScreenManager::~ScreenManager() { |
| 89 DCHECK(window_map_.empty()); | 89 DCHECK(window_map_.empty()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void ScreenManager::AddDisplayController(const scoped_refptr<DrmDevice>& drm, | 92 void ScreenManager::AddDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 93 uint32_t crtc, | 93 uint32_t crtc, |
| 94 uint32_t connector) { | 94 uint32_t connector) { |
| 95 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); | 95 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); |
| 96 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is | 96 // TODO(dnicoara): Turn this into a DCHECK when async display configuration is |
| 97 // properly supported. (When there can't be a race between forcing initial | 97 // properly supported. (When there can't be a race between forcing initial |
| 98 // display configuration in ScreenManager and NativeDisplayDelegate creating | 98 // display configuration in ScreenManager and display::NativeDisplayDelegate |
| 99 // the display controllers.) | 99 // creating the display controllers.) |
| 100 if (it != controllers_.end()) { | 100 if (it != controllers_.end()) { |
| 101 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present."; | 101 LOG(WARNING) << "Display controller (crtc=" << crtc << ") already present."; |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 | 104 |
| 105 controllers_.push_back(base::MakeUnique<HardwareDisplayController>( | 105 controllers_.push_back(base::MakeUnique<HardwareDisplayController>( |
| 106 std::unique_ptr<CrtcController>(new CrtcController(drm, crtc, connector)), | 106 std::unique_ptr<CrtcController>(new CrtcController(drm, crtc, connector)), |
| 107 gfx::Point())); | 107 gfx::Point())); |
| 108 } | 108 } |
| 109 | 109 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 const gfx::Rect& bounds) { | 336 const gfx::Rect& bounds) { |
| 337 DrmWindow* window = FindWindowAt(bounds); | 337 DrmWindow* window = FindWindowAt(bounds); |
| 338 if (window) { | 338 if (window) { |
| 339 const OverlayPlane* primary = window->GetLastModesetBuffer(); | 339 const OverlayPlane* primary = window->GetLastModesetBuffer(); |
| 340 const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); | 340 const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); |
| 341 if (primary && primary->buffer->GetSize() == bounds.size() && | 341 if (primary && primary->buffer->GetSize() == bounds.size() && |
| 342 primary->buffer->GetDrmDevice() == drm) | 342 primary->buffer->GetDrmDevice() == drm) |
| 343 return *primary; | 343 return *primary; |
| 344 } | 344 } |
| 345 | 345 |
| 346 gfx::BufferFormat format = ui::DisplaySnapshot::PrimaryFormat(); | 346 gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat(); |
| 347 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); | 347 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); |
| 348 uint32_t fourcc_format = ui::GetFourCCFormatForFramebuffer(format); | 348 uint32_t fourcc_format = ui::GetFourCCFormatForFramebuffer(format); |
| 349 scoped_refptr<ScanoutBuffer> buffer = | 349 scoped_refptr<ScanoutBuffer> buffer = |
| 350 buffer_generator_->Create(drm, fourcc_format, bounds.size()); | 350 buffer_generator_->Create(drm, fourcc_format, bounds.size()); |
| 351 if (!buffer) { | 351 if (!buffer) { |
| 352 LOG(ERROR) << "Failed to create scanout buffer"; | 352 LOG(ERROR) << "Failed to create scanout buffer"; |
| 353 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(), | 353 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(), |
| 354 gfx::RectF()); | 354 gfx::RectF()); |
| 355 } | 355 } |
| 356 | 356 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { | 389 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { |
| 390 for (auto& pair : window_map_) { | 390 for (auto& pair : window_map_) { |
| 391 if (pair.second->bounds() == bounds) | 391 if (pair.second->bounds() == bounds) |
| 392 return pair.second.get(); | 392 return pair.second.get(); |
| 393 } | 393 } |
| 394 | 394 |
| 395 return nullptr; | 395 return nullptr; |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace ui | 398 } // namespace ui |
| OLD | NEW |