Chromium Code Reviews| Index: ui/ozone/platform/drm/gpu/screen_manager.cc |
| diff --git a/ui/ozone/platform/drm/gpu/screen_manager.cc b/ui/ozone/platform/drm/gpu/screen_manager.cc |
| index 5dd26663881c04668e11dd0a4af17bb746c38dfb..ee58fa406dd8af12fae8c794a1f9a40744388fe9 100644 |
| --- a/ui/ozone/platform/drm/gpu/screen_manager.cc |
| +++ b/ui/ozone/platform/drm/gpu/screen_manager.cc |
| @@ -348,17 +348,32 @@ OverlayPlane ScreenManager::GetModesetBuffer( |
| HardwareDisplayController* controller, |
| const gfx::Rect& bounds) { |
| DrmWindow* window = FindWindowAt(bounds); |
| + |
| + gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat(); |
| + uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(format); |
| + |
| if (window) { |
| const OverlayPlane* primary = window->GetLastModesetBuffer(); |
| const DrmDevice* drm = controller->GetAllocationDrmDevice().get(); |
| if (primary && primary->buffer->GetSize() == bounds.size() && |
| - primary->buffer->GetDrmDevice() == drm) |
| - return *primary; |
| + primary->buffer->GetDrmDevice() == drm) { |
| + |
| + // If the controller doesn't advertise modifiers, wont have a |
| + // modifier either and we can reuse the buffer. Otherwise, check |
| + // to see if the controller supports the buffers format |
| + // modifier. |
| + const auto& modifiers = controller->GetFormatModifiers(fourcc_format); |
| + if (modifiers.size() == 0) |
|
Daniele Castagna
2017/06/03 19:53:06
nit: !modifiers.size()
dnicoara
2017/06/05 15:54:58
Actually, use: modifiers.empty()
|
| + return *primary; |
| + for (const uint64_t modifier : modifiers) { |
|
Daniele Castagna
2017/06/03 19:53:05
You could use std::find here. I have no preference
|
| + if (modifier == primary->buffer->GetFormatModifier()) { |
|
Daniele Castagna
2017/06/03 19:53:06
nit: curly braces not needed.
|
| + return *primary; |
| + } |
| + } |
| + } |
| } |
| - gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat(); |
| scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); |
| - uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(format); |
| scoped_refptr<ScanoutBuffer> buffer = |
| buffer_generator_->Create(drm, fourcc_format, bounds.size()); |
| if (!buffer) { |