Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: ui/ozone/platform/drm/gpu/screen_manager.cc

Issue 2919533003: ozone/drm: Only reuse ScanoutBuffers with compatible modifiers (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/scanout_buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
361 // If the controller doesn't advertise modifiers, wont have a
362 // modifier either and we can reuse the buffer. Otherwise, check
363 // to see if the controller supports the buffers format
364 // modifier.
365 const auto& modifiers = controller->GetFormatModifiers(fourcc_format);
366 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()
367 return *primary;
368 for (const uint64_t modifier : modifiers) {
Daniele Castagna 2017/06/03 19:53:05 You could use std::find here. I have no preference
369 if (modifier == primary->buffer->GetFormatModifier()) {
Daniele Castagna 2017/06/03 19:53:06 nit: curly braces not needed.
370 return *primary;
371 }
372 }
373 }
357 } 374 }
358 375
359 gfx::BufferFormat format = display::DisplaySnapshot::PrimaryFormat();
360 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); 376 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice();
361 uint32_t fourcc_format = ui::GetFourCCFormatForOpaqueFramebuffer(format);
362 scoped_refptr<ScanoutBuffer> buffer = 377 scoped_refptr<ScanoutBuffer> buffer =
363 buffer_generator_->Create(drm, fourcc_format, bounds.size()); 378 buffer_generator_->Create(drm, fourcc_format, bounds.size());
364 if (!buffer) { 379 if (!buffer) {
365 LOG(ERROR) << "Failed to create scanout buffer"; 380 LOG(ERROR) << "Failed to create scanout buffer";
366 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(), 381 return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(),
367 gfx::RectF()); 382 gfx::RectF());
368 } 383 }
369 384
370 FillModesetBuffer(drm, controller, buffer.get()); 385 FillModesetBuffer(drm, controller, buffer.get());
371 return OverlayPlane(buffer); 386 return OverlayPlane(buffer);
(...skipping 30 matching lines...) Expand all
402 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { 417 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const {
403 for (auto& pair : window_map_) { 418 for (auto& pair : window_map_) {
404 if (pair.second->bounds() == bounds) 419 if (pair.second->bounds() == bounds)
405 return pair.second.get(); 420 return pair.second.get();
406 } 421 }
407 422
408 return nullptr; 423 return nullptr;
409 } 424 }
410 425
411 } // namespace ui 426 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/scanout_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698