| 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/dri/hardware_display_controller.h" | 5 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 6 | 6 |
| 7 #include <drm.h> | 7 #include <drm.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <xf86drm.h> | 10 #include <xf86drm.h> |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 pending_planes_); | 113 pending_planes_); |
| 114 } | 114 } |
| 115 | 115 |
| 116 for (const auto& planes : owned_hardware_planes_) { | 116 for (const auto& planes : owned_hardware_planes_) { |
| 117 if (!planes.first->plane_manager()->Commit(planes.second)) { | 117 if (!planes.first->plane_manager()->Commit(planes.second)) { |
| 118 LOG(ERROR) << "Failed to commit planes"; | 118 LOG(ERROR) << "Failed to commit planes"; |
| 119 status = false; | 119 status = false; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 current_planes_.swap(pending_planes_); |
| 124 pending_planes_.clear(); |
| 125 |
| 123 return status; | 126 return status; |
| 124 } | 127 } |
| 125 | 128 |
| 126 void HardwareDisplayController::WaitForPageFlipEvent() { | 129 void HardwareDisplayController::WaitForPageFlipEvent() { |
| 127 TRACE_EVENT0("dri", "HDC::WaitForPageFlipEvent"); | 130 TRACE_EVENT0("dri", "HDC::WaitForPageFlipEvent"); |
| 128 | 131 |
| 129 drmEventContext drm_event; | 132 drmEventContext drm_event; |
| 130 drm_event.version = DRM_EVENT_CONTEXT_VERSION; | 133 drm_event.version = DRM_EVENT_CONTEXT_VERSION; |
| 131 drm_event.page_flip_handler = HandlePageFlipEvent; | 134 drm_event.page_flip_handler = HandlePageFlipEvent; |
| 132 drm_event.vblank_handler = NULL; | 135 drm_event.vblank_handler = NULL; |
| 133 | 136 |
| 134 bool has_pending_page_flips = false; | |
| 135 // Wait for the page-flips to complete. | 137 // Wait for the page-flips to complete. |
| 136 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { | 138 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { |
| 137 // In mirror mode the page flip callbacks can happen in different order than | 139 // In mirror mode the page flip callbacks can happen in different order than |
| 138 // scheduled, so we need to make sure that the event for the current CRTC is | 140 // scheduled, so we need to make sure that the event for the current CRTC is |
| 139 // processed before moving to the next CRTC. | 141 // processed before moving to the next CRTC. |
| 140 while (crtc_controllers_[i]->page_flip_pending()) { | 142 while (crtc_controllers_[i]->page_flip_pending()) { |
| 141 has_pending_page_flips = true; | |
| 142 crtc_controllers_[i]->drm()->HandleEvent(drm_event); | 143 crtc_controllers_[i]->drm()->HandleEvent(drm_event); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | |
| 146 // In case there are no pending pageflips do not replace the current planes | |
| 147 // since they are still being used. | |
| 148 if (has_pending_page_flips) | |
| 149 current_planes_.swap(pending_planes_); | |
| 150 | |
| 151 pending_planes_.clear(); | |
| 152 } | 146 } |
| 153 | 147 |
| 154 bool HardwareDisplayController::SetCursor( | 148 bool HardwareDisplayController::SetCursor( |
| 155 const scoped_refptr<ScanoutBuffer>& buffer) { | 149 const scoped_refptr<ScanoutBuffer>& buffer) { |
| 156 bool status = true; | 150 bool status = true; |
| 157 | 151 |
| 158 if (is_disabled_) | 152 if (is_disabled_) |
| 159 return true; | 153 return true; |
| 160 | 154 |
| 161 for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 155 for (size_t i = 0; i < crtc_controllers_.size(); ++i) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 uint64_t HardwareDisplayController::GetTimeOfLastFlip() const { | 233 uint64_t HardwareDisplayController::GetTimeOfLastFlip() const { |
| 240 uint64_t time = 0; | 234 uint64_t time = 0; |
| 241 for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 235 for (size_t i = 0; i < crtc_controllers_.size(); ++i) |
| 242 if (time < crtc_controllers_[i]->time_of_last_flip()) | 236 if (time < crtc_controllers_[i]->time_of_last_flip()) |
| 243 time = crtc_controllers_[i]->time_of_last_flip(); | 237 time = crtc_controllers_[i]->time_of_last_flip(); |
| 244 | 238 |
| 245 return time; | 239 return time; |
| 246 } | 240 } |
| 247 | 241 |
| 248 } // namespace ui | 242 } // namespace ui |
| OLD | NEW |