Commit d6f9a4e6 authored by achaulk's avatar achaulk Committed by Commit bot

ozone: Add sync flag for atomic commit and page flip event handling

Committed: https://crrev.com/f7553583492a8ea9a54d75cd6b2d3dd83c94512c
Cr-Commit-Position: refs/heads/master@{#326863}

Review URL: https://codereview.chromium.org/1099713005

Cr-Commit-Position: refs/heads/master@{#329919}
parent c747af59
......@@ -559,20 +559,30 @@ bool DrmDevice::CloseBufferHandle(uint32_t handle) {
bool DrmDevice::CommitProperties(drmModePropertySet* properties,
uint32_t flags,
bool is_sync,
const PageFlipCallback& callback) {
#if defined(USE_DRM_ATOMIC)
flags |= DRM_MODE_PAGE_FLIP_EVENT;
scoped_ptr<PageFlipPayload> payload(
new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback));
uint64_t id = page_flip_manager_->GetNextId();
if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(),
properties)) {
// If successful the payload will be removed by the event
ignore_result(payload.release());
page_flip_manager_->RegisterCallback(id, callback);
// If the flip was requested synchronous or if no watcher has been installed
// yet, then synchronously handle the page flip events.
if (is_sync || !watcher_) {
TRACE_EVENT1("drm", "OnDrmEvent", "socket", file_.GetPlatformFile());
ProcessDrmEvent(
file_.GetPlatformFile(),
base::Bind(&PageFlipManager::OnPageFlip, page_flip_manager_));
}
return true;
}
return false;
#else
return false;
#endif // defined(USE_DRM_ATOMIC)
return false;
}
bool DrmDevice::SetCapability(uint64_t capability, uint64_t value) {
......
......@@ -159,6 +159,7 @@ class OZONE_EXPORT DrmDevice : public base::RefCountedThreadSafe<DrmDevice> {
virtual bool CommitProperties(drmModePropertySet* properties,
uint32_t flags,
bool is_sync,
const PageFlipCallback& callback);
// Set the gamma ramp for |crtc_id| to reflect the ramps in |lut|.
......
......@@ -41,7 +41,7 @@ bool HardwareDisplayPlaneManagerAtomic::Commit(
plane_list->plane_list.swap(plane_list->old_plane_list);
plane_list->plane_list.clear();
if (!drm_->CommitProperties(plane_list->atomic_property_set.get(), 0,
if (!drm_->CommitProperties(plane_list->atomic_property_set.get(), 0, is_sync,
base::Bind(&AtomicPageFlipCallback))) {
PLOG(ERROR) << "Failed to commit properties";
return false;
......
......@@ -236,6 +236,7 @@ bool MockDrmDevice::CloseBufferHandle(uint32_t handle) {
bool MockDrmDevice::CommitProperties(drmModePropertySet* properties,
uint32_t flags,
bool is_sync,
const PageFlipCallback& callback) {
return false;
}
......
......@@ -108,6 +108,7 @@ class MockDrmDevice : public ui::DrmDevice {
bool CloseBufferHandle(uint32_t handle) override;
bool CommitProperties(drmModePropertySet* properties,
uint32_t flags,
bool is_sync,
const PageFlipCallback& callback) override;
bool SetGammaRamp(uint32_t crtc_id,
const std::vector<GammaRampRGBEntry>& lut) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment