Chromium Code Reviews| 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_ptr<HardwareDisplayPlaneList> crtc_plane_list = |
| 143 controller->drm().get(), | 143 scoped_ptr<HardwareDisplayPlaneList>(new HardwareDisplayPlaneList()); |
| 144 scoped_ptr<HardwareDisplayPlaneList>(new HardwareDisplayPlaneList())); | 144 |
| 145 // Check if this controller owns any planes and if so keep track of them. | |
| 146 scoped_refptr<DrmDevice> drm = controller->drm(); | |
| 147 HardwareDisplayPlaneManager* manager = drm->plane_manager(); | |
| 148 const ScopedVector<HardwareDisplayPlane>& all_planes = manager->planes(); | |
| 149 uint32_t crtc = controller->crtc(); | |
| 150 for (auto* plane : all_planes) { | |
| 151 if (plane->in_use() && (plane->owning_crtc() == crtc)) | |
| 152 crtc_plane_list->old_plane_list.push_back(plane); | |
| 153 } | |
| 154 | |
| 155 owned_hardware_planes_.add(drm.get(), crtc_plane_list.Pass()); | |
|
dnicoara
2015/08/19 14:09:44
Move this at the begining and use the result to ge
kalyank
2015/08/19 15:38:54
Done.
kalyank
2015/08/19 15:38:54
Acknowledged.
| |
| 145 crtc_controllers_.push_back(controller.Pass()); | 156 crtc_controllers_.push_back(controller.Pass()); |
| 146 } | 157 } |
| 147 | 158 |
| 148 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 159 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( |
| 149 const scoped_refptr<DrmDevice>& drm, | 160 const scoped_refptr<DrmDevice>& drm, |
| 150 uint32_t crtc) { | 161 uint32_t crtc) { |
| 151 for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); | 162 for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); |
| 152 it != crtc_controllers_.end(); ++it) { | 163 it != crtc_controllers_.end(); ++it) { |
| 153 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 164 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { |
| 154 scoped_ptr<CrtcController> controller(*it); | 165 scoped_ptr<CrtcController> controller(*it); |
| 155 crtc_controllers_.weak_erase(it); | 166 crtc_controllers_.weak_erase(it); |
| 156 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. | 167 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. |
| 157 bool found = false; | 168 bool found = false; |
| 158 for (ScopedVector<CrtcController>::iterator it = | 169 for (ScopedVector<CrtcController>::iterator it = |
| 159 crtc_controllers_.begin(); | 170 crtc_controllers_.begin(); |
| 160 it != crtc_controllers_.end(); ++it) { | 171 it != crtc_controllers_.end(); ++it) { |
| 161 if ((*it)->drm() == controller->drm()) { | 172 if ((*it)->drm() == controller->drm()) { |
| 162 found = true; | 173 found = true; |
| 163 break; | 174 break; |
| 164 } | 175 } |
| 165 } | 176 } |
| 166 if (!found) | 177 if (found) { |
| 178 std::vector<HardwareDisplayPlane*> all_planes; | |
| 179 HardwareDisplayPlaneList* plane_list = | |
| 180 owned_hardware_planes_.get(drm.get()); | |
| 181 all_planes.swap(plane_list->old_plane_list); | |
| 182 for (auto* plane : all_planes) { | |
| 183 if (plane->owning_crtc() != crtc) | |
| 184 plane_list->old_plane_list.push_back(plane); | |
| 185 } | |
| 186 } else { | |
| 167 owned_hardware_planes_.erase(controller->drm().get()); | 187 owned_hardware_planes_.erase(controller->drm().get()); |
| 188 } | |
| 168 | 189 |
| 169 return controller.Pass(); | 190 return controller.Pass(); |
| 170 } | 191 } |
| 171 } | 192 } |
| 172 | 193 |
| 173 return nullptr; | 194 return nullptr; |
| 174 } | 195 } |
| 175 | 196 |
| 176 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, | 197 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, |
| 177 uint32_t crtc) const { | 198 uint32_t crtc) const { |
| 178 for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 199 for (size_t i = 0; i < crtc_controllers_.size(); ++i) |
| 179 if (crtc_controllers_[i]->drm() == drm && | 200 if (crtc_controllers_[i]->drm() == drm && |
| 180 crtc_controllers_[i]->crtc() == crtc) | 201 crtc_controllers_[i]->crtc() == crtc) |
| 181 return true; | 202 return true; |
| 182 | 203 |
| 183 return false; | 204 return false; |
| 184 } | 205 } |
| 185 | 206 |
| 207 bool HardwareDisplayController::HasPlane(const scoped_refptr<DrmDevice>& drm, | |
| 208 uint32_t plane_id, | |
| 209 uint32_t crtc) const { | |
| 210 HardwareDisplayPlaneList* plane_list = owned_hardware_planes_.get(drm.get()); | |
| 211 if (!plane_list) | |
| 212 return false; | |
| 213 | |
| 214 for (auto* plane : plane_list->old_plane_list) { | |
| 215 if (plane->plane_id() == plane_id && plane->owning_crtc() == crtc) | |
| 216 return true; | |
| 217 } | |
| 218 | |
| 219 return false; | |
| 220 } | |
| 221 | |
| 186 bool HardwareDisplayController::IsMirrored() const { | 222 bool HardwareDisplayController::IsMirrored() const { |
| 187 return crtc_controllers_.size() > 1; | 223 return crtc_controllers_.size() > 1; |
| 188 } | 224 } |
| 189 | 225 |
| 190 bool HardwareDisplayController::IsDisabled() const { | 226 bool HardwareDisplayController::IsDisabled() const { |
| 191 return is_disabled_; | 227 return is_disabled_; |
| 192 } | 228 } |
| 193 | 229 |
| 194 gfx::Size HardwareDisplayController::GetModeSize() const { | 230 gfx::Size HardwareDisplayController::GetModeSize() const { |
| 195 return gfx::Size(mode_.hdisplay, mode_.vdisplay); | 231 return gfx::Size(mode_.hdisplay, mode_.vdisplay); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 206 | 242 |
| 207 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 243 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
| 208 const { | 244 const { |
| 209 DCHECK(!crtc_controllers_.empty()); | 245 DCHECK(!crtc_controllers_.empty()); |
| 210 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 246 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
| 211 // which device should be used for allocations. | 247 // which device should be used for allocations. |
| 212 return crtc_controllers_[0]->drm(); | 248 return crtc_controllers_[0]->drm(); |
| 213 } | 249 } |
| 214 | 250 |
| 215 } // namespace ui | 251 } // namespace ui |
| OLD | NEW |