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/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> |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 bool DrmDevice::CloseBufferHandle(uint32_t handle) { | 481 bool DrmDevice::CloseBufferHandle(uint32_t handle) { |
482 struct drm_gem_close close_request; | 482 struct drm_gem_close close_request; |
483 memset(&close_request, 0, sizeof(close_request)); | 483 memset(&close_request, 0, sizeof(close_request)); |
484 close_request.handle = handle; | 484 close_request.handle = handle; |
485 return !drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_GEM_CLOSE, | 485 return !drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_GEM_CLOSE, |
486 &close_request); | 486 &close_request); |
487 } | 487 } |
488 | 488 |
489 bool DrmDevice::CommitProperties(drmModePropertySet* properties, | 489 bool DrmDevice::CommitProperties(drmModePropertySet* properties, |
490 uint32_t flags, | 490 uint32_t flags, |
| 491 bool is_sync, |
491 const PageFlipCallback& callback) { | 492 const PageFlipCallback& callback) { |
492 #if defined(USE_DRM_ATOMIC) | 493 #if defined(USE_DRM_ATOMIC) |
| 494 flags |= DRM_MODE_PAGE_FLIP_EVENT; |
| 495 if (!is_sync) |
| 496 flags |= DRM_MODE_PAGE_FLIP_ASYNC; |
493 scoped_ptr<PageFlipPayload> payload( | 497 scoped_ptr<PageFlipPayload> payload( |
494 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback)); | 498 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback)); |
495 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(), | 499 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(), |
496 properties)) { | 500 properties)) { |
497 // If successful the payload will be removed by the event | 501 // If successful the payload will be removed by the event |
498 ignore_result(payload.release()); | 502 ignore_result(payload.release()); |
| 503 |
| 504 // If the flip was requested synchronous or if no watcher has been installed |
| 505 // yet, then synchronously handle the page flip events. |
| 506 if (is_sync || !watcher_) { |
| 507 TRACE_EVENT1("drm", "OnDrmEvent", "socket", file_.GetPlatformFile()); |
| 508 |
| 509 drmEventContext event; |
| 510 event.version = DRM_EVENT_CONTEXT_VERSION; |
| 511 event.page_flip_handler = HandlePageFlipEventOnUI; |
| 512 event.vblank_handler = nullptr; |
| 513 |
| 514 drmHandleEvent(file_.GetPlatformFile(), &event); |
| 515 } |
499 return true; | 516 return true; |
500 } | 517 } |
501 return false; | 518 return false; |
502 #else | 519 #else |
503 return false; | 520 return false; |
504 #endif // defined(USE_DRM_ATOMIC) | 521 #endif // defined(USE_DRM_ATOMIC) |
505 } | 522 } |
506 | 523 |
507 bool DrmDevice::SetMaster() { | 524 bool DrmDevice::SetMaster() { |
508 DCHECK(file_.IsValid()); | 525 DCHECK(file_.IsValid()); |
509 return (drmSetMaster(file_.GetPlatformFile()) == 0); | 526 return (drmSetMaster(file_.GetPlatformFile()) == 0); |
510 } | 527 } |
511 | 528 |
512 bool DrmDevice::DropMaster() { | 529 bool DrmDevice::DropMaster() { |
513 DCHECK(file_.IsValid()); | 530 DCHECK(file_.IsValid()); |
514 return (drmDropMaster(file_.GetPlatformFile()) == 0); | 531 return (drmDropMaster(file_.GetPlatformFile()) == 0); |
515 } | 532 } |
516 | 533 |
517 } // namespace ui | 534 } // namespace ui |
OLD | NEW |