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

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: 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 #if defined(OZONE_USE_ATOMIC)
dnicoara 2015/03/16 21:14:11 move #ifdef include block after the normal include
23 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
24 #endif
22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" 25 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h"
23 26
24 namespace ui { 27 namespace ui {
25 28
26 namespace { 29 namespace {
27 30
28 struct PageFlipPayload { 31 struct PageFlipPayload {
29 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner, 32 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner,
30 const DrmDevice::PageFlipCallback& callback) 33 const DrmDevice::PageFlipCallback& callback)
31 : task_runner(task_runner), callback(callback) {} 34 : task_runner(task_runner), callback(callback) {}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 195 }
193 196
194 bool DrmDevice::Initialize() { 197 bool DrmDevice::Initialize() {
195 // Ignore devices that cannot perform modesetting. 198 // Ignore devices that cannot perform modesetting.
196 if (!CanQueryForResources(file_.GetPlatformFile())) { 199 if (!CanQueryForResources(file_.GetPlatformFile())) {
197 VLOG(2) << "Cannot query for resources for '" << device_path_.value() 200 VLOG(2) << "Cannot query for resources for '" << device_path_.value()
198 << "'"; 201 << "'";
199 return false; 202 return false;
200 } 203 }
201 204
205 #if defined(OZONE_USE_ATOMIC)
206 plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic());
207 #else
202 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); 208 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy());
209 #endif
203 if (!plane_manager_->Initialize(this)) { 210 if (!plane_manager_->Initialize(this)) {
204 LOG(ERROR) << "Failed to initialize the plane manager for " 211 LOG(ERROR) << "Failed to initialize the plane manager for "
205 << device_path_.value(); 212 << device_path_.value();
206 plane_manager_.reset(); 213 plane_manager_.reset();
207 return false; 214 return false;
208 } 215 }
209 216
210 return true; 217 return true;
211 } 218 }
212 219
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info, 439 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info,
433 uint32_t handle, 440 uint32_t handle,
434 uint32_t stride, 441 uint32_t stride,
435 void* pixels) { 442 void* pixels) {
436 DCHECK(file_.IsValid()); 443 DCHECK(file_.IsValid());
437 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle); 444 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle);
438 munmap(pixels, info.getSafeSize(stride)); 445 munmap(pixels, info.getSafeSize(stride));
439 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle); 446 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle);
440 } 447 }
441 448
449 bool DrmDevice::CommitProperties(drmModePropertySet* properties,
450 uint32_t flags,
451 const PageFlipCallback& callback) {
452 #if defined(OZONE_USE_ATOMIC)
453 scoped_ptr<PageFlipPayload> payload(
454 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback));
455 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(),
456 properties)) {
457 // If successful the payload will be removed by the event
458 ignore_result(payload.release());
459 return true;
460 }
461 return false;
462 #else
463 return false;
464 #endif
465 }
466
442 bool DrmDevice::SetMaster() { 467 bool DrmDevice::SetMaster() {
443 DCHECK(file_.IsValid()); 468 DCHECK(file_.IsValid());
444 return (drmSetMaster(file_.GetPlatformFile()) == 0); 469 return (drmSetMaster(file_.GetPlatformFile()) == 0);
445 } 470 }
446 471
447 bool DrmDevice::DropMaster() { 472 bool DrmDevice::DropMaster() {
448 DCHECK(file_.IsValid()); 473 DCHECK(file_.IsValid());
449 return (drmDropMaster(file_.GetPlatformFile()) == 0); 474 return (drmDropMaster(file_.GetPlatformFile()) == 0);
450 } 475 }
451 476
452 } // namespace ui 477 } // 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