Chromium Code Reviews| Index: ui/ozone/platform/dri/hardware_display_plane_manager.cc |
| diff --git a/ui/ozone/platform/dri/hardware_display_plane_manager.cc b/ui/ozone/platform/dri/hardware_display_plane_manager.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..18a08326611e5d472bf6ac343342091f1641a035 |
| --- /dev/null |
| +++ b/ui/ozone/platform/dri/hardware_display_plane_manager.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/ozone/platform/dri/hardware_display_plane_manager.h" |
| + |
| +#include <drm.h> |
| +#include <errno.h> |
| +#include <xf86drm.h> |
| + |
| +#include "base/logging.h" |
| +#include "ui/gfx/geometry/rect.h" |
| +#include "ui/ozone/platform/dri/dri_wrapper.h" |
| + |
| +namespace ui { |
| + |
| +HardwareDisplayPlaneManager::HardwareDisplayPlaneManager(DriWrapper* drm) |
| + : drm_(drm), property_set_(NULL) { |
| +} |
| + |
| +HardwareDisplayPlaneManager::~HardwareDisplayPlaneManager() { |
| + if (property_set_) |
| + drmModePropertySetFree(property_set_); |
| +} |
| + |
| +bool HardwareDisplayPlaneManager::Initialize() { |
| + ScopedDrmPlaneResPtr plane_resources( |
| + drmModeGetPlaneResources(drm_->get_fd())); |
| + if (!plane_resources) { |
| + LOG(ERROR) << "Failed to get plane resources"; |
|
dnicoara
2014/07/22 20:48:32
nit: Period at the end :)
|
| + return false; |
| + } |
| + |
| + property_set_ = drmModePropertySetAlloc(); |
| + if (!property_set_) { |
| + LOG(ERROR) << "Failed to get property set"; |
|
dnicoara
2014/07/22 20:48:32
s/get/allocate/ ?
|
| + return false; |
| + } |
| + |
| + uint32_t num_planes = plane_resources->count_planes; |
| + for (uint32_t i = 0; i < num_planes; i++) { |
|
dnicoara
2014/07/22 20:48:32
nit: pre-increment. I'm conflicted about this one,
|
| + ScopedDrmPlanePtr drm_plane( |
| + drmModeGetPlane(drm_->get_fd(), plane_resources->planes[i])); |
| + if (!drm_plane) { |
| + LOG(ERROR) << "Failed to get plane " << i; |
| + return false; |
| + } |
| + scoped_ptr<HardwareDisplayPlane> plane( |
| + new HardwareDisplayPlane(drm_, property_set_, drm_plane.Pass())); |
| + if (plane->Initialize()) |
| + planes_.push_back(plane.release()); |
| + } |
| + |
| + return true; |
| +} |
| + |
| +} // namespace ui |