| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" | |
| 6 | |
| 7 #include <drm.h> | |
| 8 #include <errno.h> | |
| 9 #include <xf86drm.h> | |
| 10 | |
| 11 #include "base/logging.h" | |
| 12 #include "ui/gfx/geometry/rect.h" | |
| 13 #include "ui/ozone/platform/dri/dri_wrapper.h" | |
| 14 | |
| 15 namespace ui { | |
| 16 | |
| 17 HardwareDisplayPlaneManager::HardwareDisplayPlaneManager(DriWrapper* drm) | |
| 18 : drm_(drm), property_set_(NULL) { | |
| 19 } | |
| 20 | |
| 21 HardwareDisplayPlaneManager::~HardwareDisplayPlaneManager() { | |
| 22 if (property_set_) | |
| 23 drmModePropertySetFree(property_set_); | |
| 24 } | |
| 25 | |
| 26 bool HardwareDisplayPlaneManager::Initialize() { | |
| 27 ScopedDrmPlaneResPtr plane_resources( | |
| 28 drmModeGetPlaneResources(drm_->get_fd())); | |
| 29 if (!plane_resources) { | |
| 30 LOG(ERROR) << "Failed to get plane resources."; | |
| 31 return false; | |
| 32 } | |
| 33 | |
| 34 property_set_ = drmModePropertySetAlloc(); | |
| 35 if (!property_set_) { | |
| 36 LOG(ERROR) << "Failed to allocate property set."; | |
| 37 return false; | |
| 38 } | |
| 39 | |
| 40 uint32_t num_planes = plane_resources->count_planes; | |
| 41 for (uint32_t i = 0; i < num_planes; ++i) { | |
| 42 ScopedDrmPlanePtr drm_plane( | |
| 43 drmModeGetPlane(drm_->get_fd(), plane_resources->planes[i])); | |
| 44 if (!drm_plane) { | |
| 45 LOG(ERROR) << "Failed to get plane " << i << "."; | |
| 46 return false; | |
| 47 } | |
| 48 scoped_ptr<HardwareDisplayPlane> plane( | |
| 49 new HardwareDisplayPlane(drm_, property_set_, drm_plane.Pass())); | |
| 50 if (plane->Initialize()) | |
| 51 planes_.push_back(plane.release()); | |
| 52 } | |
| 53 | |
| 54 return true; | |
| 55 } | |
| 56 | |
| 57 } // namespace ui | |
| OLD | NEW |