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

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

Issue 994503004: Preliminary atomic patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change gyp var Created 5 years, 9 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
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/drm_device.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
11 #include <xf86drmMode.h> 11 #include <xf86drmMode.h>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/task_runner.h" 17 #include "base/task_runner.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
20 #include "third_party/skia/include/core/SkImageInfo.h" 20 #include "third_party/skia/include/core/SkImageInfo.h"
21 #include "ui/ozone/platform/drm/gpu/drm_util.h" 21 #include "ui/ozone/platform/drm/gpu/drm_util.h"
22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h"
23 23
24 #if defined(USE_DRM_ATOMIC)
25 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
26 #endif
27
24 namespace ui { 28 namespace ui {
25 29
26 namespace { 30 namespace {
27 31
28 struct PageFlipPayload { 32 struct PageFlipPayload {
29 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner, 33 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner,
30 const DrmDevice::PageFlipCallback& callback) 34 const DrmDevice::PageFlipCallback& callback)
31 : task_runner(task_runner), callback(callback) {} 35 : task_runner(task_runner), callback(callback) {}
32 36
33 // Task runner for the thread scheduling the page flip event. This is used to 37 // Task runner for the thread scheduling the page flip event. This is used to
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 197 }
194 198
195 bool DrmDevice::Initialize() { 199 bool DrmDevice::Initialize() {
196 // Ignore devices that cannot perform modesetting. 200 // Ignore devices that cannot perform modesetting.
197 if (!CanQueryForResources(file_.GetPlatformFile())) { 201 if (!CanQueryForResources(file_.GetPlatformFile())) {
198 VLOG(2) << "Cannot query for resources for '" << device_path_.value() 202 VLOG(2) << "Cannot query for resources for '" << device_path_.value()
199 << "'"; 203 << "'";
200 return false; 204 return false;
201 } 205 }
202 206
207 #if defined(USE_DRM_ATOMIC)
208 plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic());
209 #else
203 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); 210 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy());
211 #endif // defined(USE_DRM_ATOMIC)
204 if (!plane_manager_->Initialize(this)) { 212 if (!plane_manager_->Initialize(this)) {
205 LOG(ERROR) << "Failed to initialize the plane manager for " 213 LOG(ERROR) << "Failed to initialize the plane manager for "
206 << device_path_.value(); 214 << device_path_.value();
207 plane_manager_.reset(); 215 plane_manager_.reset();
208 return false; 216 return false;
209 } 217 }
210 218
211 return true; 219 return true;
212 } 220 }
213 221
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info, 441 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info,
434 uint32_t handle, 442 uint32_t handle,
435 uint32_t stride, 443 uint32_t stride,
436 void* pixels) { 444 void* pixels) {
437 DCHECK(file_.IsValid()); 445 DCHECK(file_.IsValid());
438 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle); 446 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle);
439 munmap(pixels, info.getSafeSize(stride)); 447 munmap(pixels, info.getSafeSize(stride));
440 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle); 448 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle);
441 } 449 }
442 450
451 bool DrmDevice::CommitProperties(drmModePropertySet* properties,
452 uint32_t flags,
453 const PageFlipCallback& callback) {
454 #if defined(USE_DRM_ATOMIC)
455 scoped_ptr<PageFlipPayload> payload(
456 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback));
457 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(),
458 properties)) {
459 // If successful the payload will be removed by the event
460 ignore_result(payload.release());
461 return true;
462 }
463 return false;
464 #else
465 return false;
466 #endif // defined(USE_DRM_ATOMIC)
467 }
468
443 bool DrmDevice::SetMaster() { 469 bool DrmDevice::SetMaster() {
444 DCHECK(file_.IsValid()); 470 DCHECK(file_.IsValid());
445 return (drmSetMaster(file_.GetPlatformFile()) == 0); 471 return (drmSetMaster(file_.GetPlatformFile()) == 0);
446 } 472 }
447 473
448 bool DrmDevice::DropMaster() { 474 bool DrmDevice::DropMaster() {
449 DCHECK(file_.IsValid()); 475 DCHECK(file_.IsValid());
450 return (drmDropMaster(file_.GetPlatformFile()) == 0); 476 return (drmDropMaster(file_.GetPlatformFile()) == 0);
451 } 477 }
452 478
453 } // namespace ui 479 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_device.h ('k') | ui/ozone/platform/drm/gpu/hardware_display_plane.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698