| 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/hardware_display_controller.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 
| 6 | 6 | 
| 7 #include <drm.h> | 7 #include <drm.h> | 
| 8 #include <string.h> | 8 #include <string.h> | 
| 9 #include <xf86drm.h> | 9 #include <xf86drm.h> | 
| 10 | 10 | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 132     return true; | 132     return true; | 
| 133 | 133 | 
| 134   bool status = true; | 134   bool status = true; | 
| 135   for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 135   for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 
| 136     status &= crtc_controllers_[i]->MoveCursor(location); | 136     status &= crtc_controllers_[i]->MoveCursor(location); | 
| 137 | 137 | 
| 138   return status; | 138   return status; | 
| 139 } | 139 } | 
| 140 | 140 | 
| 141 void HardwareDisplayController::AddCrtc(scoped_ptr<CrtcController> controller) { | 141 void HardwareDisplayController::AddCrtc(scoped_ptr<CrtcController> controller) { | 
| 142   owned_hardware_planes_.add( | 142   scoped_refptr<DrmDevice> drm = controller->drm(); | 
| 143       controller->drm().get(), | 143   owned_hardware_planes_.add(drm.get(), scoped_ptr<HardwareDisplayPlaneList>( | 
| 144       scoped_ptr<HardwareDisplayPlaneList>(new HardwareDisplayPlaneList())); | 144                                             new HardwareDisplayPlaneList())); | 
|  | 145 | 
|  | 146   // Check if this CRTC owns any planes and ensure we keep track of them. | 
|  | 147   const ScopedVector<HardwareDisplayPlane>& all_planes = | 
|  | 148       drm->plane_manager()->planes(); | 
|  | 149   HardwareDisplayPlaneList* crtc_plane_list = | 
|  | 150       owned_hardware_planes_.get(drm.get()); | 
|  | 151   uint32_t crtc = controller->crtc(); | 
|  | 152   for (auto* plane : all_planes) { | 
|  | 153     if (plane->in_use() && (plane->owning_crtc() == crtc)) | 
|  | 154       crtc_plane_list->old_plane_list.push_back(plane); | 
|  | 155   } | 
|  | 156 | 
| 145   crtc_controllers_.push_back(controller.Pass()); | 157   crtc_controllers_.push_back(controller.Pass()); | 
| 146 } | 158 } | 
| 147 | 159 | 
| 148 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 160 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 
| 149     const scoped_refptr<DrmDevice>& drm, | 161     const scoped_refptr<DrmDevice>& drm, | 
| 150     uint32_t crtc) { | 162     uint32_t crtc) { | 
| 151   for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); | 163   for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); | 
| 152        it != crtc_controllers_.end(); ++it) { | 164        it != crtc_controllers_.end(); ++it) { | 
| 153     if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 165     if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 
| 154       scoped_ptr<CrtcController> controller(*it); | 166       scoped_ptr<CrtcController> controller(*it); | 
| 155       crtc_controllers_.weak_erase(it); | 167       crtc_controllers_.weak_erase(it); | 
| 156       // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. | 168       // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. | 
| 157       bool found = false; | 169       bool found = false; | 
| 158       for (ScopedVector<CrtcController>::iterator it = | 170       for (ScopedVector<CrtcController>::iterator it = | 
| 159                crtc_controllers_.begin(); | 171                crtc_controllers_.begin(); | 
| 160            it != crtc_controllers_.end(); ++it) { | 172            it != crtc_controllers_.end(); ++it) { | 
| 161         if ((*it)->drm() == controller->drm()) { | 173         if ((*it)->drm() == controller->drm()) { | 
| 162           found = true; | 174           found = true; | 
| 163           break; | 175           break; | 
| 164         } | 176         } | 
| 165       } | 177       } | 
| 166       if (!found) | 178       if (found) { | 
|  | 179         std::vector<HardwareDisplayPlane*> all_planes; | 
|  | 180         HardwareDisplayPlaneList* plane_list = | 
|  | 181             owned_hardware_planes_.get(drm.get()); | 
|  | 182         all_planes.swap(plane_list->old_plane_list); | 
|  | 183         for (auto* plane : all_planes) { | 
|  | 184           if (plane->owning_crtc() != crtc) | 
|  | 185             plane_list->old_plane_list.push_back(plane); | 
|  | 186         } | 
|  | 187       } else { | 
| 167         owned_hardware_planes_.erase(controller->drm().get()); | 188         owned_hardware_planes_.erase(controller->drm().get()); | 
|  | 189       } | 
| 168 | 190 | 
| 169       return controller.Pass(); | 191       return controller.Pass(); | 
| 170     } | 192     } | 
| 171   } | 193   } | 
| 172 | 194 | 
| 173   return nullptr; | 195   return nullptr; | 
| 174 } | 196 } | 
| 175 | 197 | 
| 176 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, | 198 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, | 
| 177                                         uint32_t crtc) const { | 199                                         uint32_t crtc) const { | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 206 | 228 | 
| 207 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 229 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 
| 208     const { | 230     const { | 
| 209   DCHECK(!crtc_controllers_.empty()); | 231   DCHECK(!crtc_controllers_.empty()); | 
| 210   // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 232   // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 
| 211   // which device should be used for allocations. | 233   // which device should be used for allocations. | 
| 212   return crtc_controllers_[0]->drm(); | 234   return crtc_controllers_[0]->drm(); | 
| 213 } | 235 } | 
| 214 | 236 | 
| 215 }  // namespace ui | 237 }  // namespace ui | 
| OLD | NEW | 
|---|