| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 if (should_enable) { | 341 if (should_enable) { |
| 342 EnableController(controller); | 342 EnableController(controller); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 OverlayPlane ScreenManager::GetModesetBuffer( | 347 OverlayPlane ScreenManager::GetModesetBuffer( |
| 348 HardwareDisplayController* controller, | 348 HardwareDisplayController* controller, |
| 349 const gfx::Rect& bounds) { | 349 const gfx::Rect& bounds) { |
| 350 DrmWindow* window = FindWindowAt(bounds); | 350 DrmWindow* window = FindWindowAt(bounds); |
| 351 |
| 352 gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat(); |
| 353 uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(format); |
| 354 |
| 351 if (window) { | 355 if (window) { |
| 352 const OverlayPlane* primary = window->GetLastModesetBuffer(); | 356 const OverlayPlane* primary = window->GetLastModesetBuffer(); |
| 353 const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); | 357 const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); |
| 354 if (primary && primary->buffer->GetSize() == bounds.size() && | 358 if (primary && primary->buffer->GetSize() == bounds.size() && |
| 355 primary->buffer->GetDrmDevice() == drm) | 359 primary->buffer->GetDrmDevice() == drm) { |
| 356 return *primary; | 360 // If the controller doesn't advertise modifiers, wont have a |
| 361 // modifier either and we can reuse the buffer. Otherwise, check |
| 362 // to see if the controller supports the buffers format |
| 363 // modifier. |
| 364 const auto& modifiers = controller->GetFormatModifiers(fourcc_format); |
| 365 if (modifiers.empty()) |
| 366 return *primary; |
| 367 for (const uint64_t modifier : modifiers) { |
| 368 if (modifier == primary->buffer->GetFormatModifier()) |
| 369 return *primary; |
| 370 } |
| 371 } |
| 357 } | 372 } |
| 358 | 373 |
| 359 gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat(); | |
| 360 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); | 374 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); |
| 361 uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(format); | |
| 362 scoped_refptr<ScanoutBuffer> buffer = | 375 scoped_refptr<ScanoutBuffer> buffer = |
| 363 buffer_generator_->Create(drm, fourcc_format, bounds.size()); | 376 buffer_generator_->Create(drm, fourcc_format, bounds.size()); |
| 364 if (!buffer) { | 377 if (!buffer) { |
| 365 LOG(ERROR) << "Failed to create scanout buffer"; | 378 LOG(ERROR) << "Failed to create scanout buffer"; |
| 366 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(), | 379 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(), |
| 367 gfx::RectF()); | 380 gfx::RectF()); |
| 368 } | 381 } |
| 369 | 382 |
| 370 FillModesetBuffer(drm, controller, buffer.get()); | 383 FillModesetBuffer(drm, controller, buffer.get()); |
| 371 return OverlayPlane(buffer); | 384 return OverlayPlane(buffer); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 402 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { | 415 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { |
| 403 for (auto& pair : window_map_) { | 416 for (auto& pair : window_map_) { |
| 404 if (pair.second->bounds() == bounds) | 417 if (pair.second->bounds() == bounds) |
| 405 return pair.second.get(); | 418 return pair.second.get(); |
| 406 } | 419 } |
| 407 | 420 |
| 408 return nullptr; | 421 return nullptr; |
| 409 } | 422 } |
| 410 | 423 |
| 411 } // namespace ui | 424 } // namespace ui |
| OLD | NEW |