Commit 9701b9ab authored by alexst@chromium.org's avatar alexst@chromium.org

Add plane manager to the atomic swap path.

BUG=none

Review URL: https://codereview.chromium.org/409793007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285024 0039d316-1c4b-4281-b951-d872f2087c98
parent cfac84b2
......@@ -76,6 +76,8 @@
'sources': [
'hardware_display_plane.cc',
'hardware_display_plane.h',
'hardware_display_plane_manager.cc',
'hardware_display_plane_manager.h',
],
}],
],
......
......@@ -62,6 +62,10 @@ HardwareDisplayPlane::HardwareDisplayPlane(
HardwareDisplayPlane::~HardwareDisplayPlane() {
}
bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_id) {
return plane_->possible_crtcs & (1 << crtc_id);
}
bool HardwareDisplayPlane::SetPlaneData(uint32_t crtc_id,
uint32_t framebuffer,
const gfx::Rect& crtc_rect,
......
......@@ -30,11 +30,15 @@ class HardwareDisplayPlane {
bool Initialize();
bool CanUseForCrtc(uint32_t crtc_id);
bool SetPlaneData(uint32_t crtc_id,
uint32_t framebuffer,
const gfx::Rect& crtc_rect,
const gfx::Rect& src_rect);
bool in_use() const { return in_use_; }
void set_in_use(bool in_use) { in_use_ = in_use; }
private:
struct Property {
Property();
......@@ -52,6 +56,7 @@ class HardwareDisplayPlane {
ScopedDrmPlanePtr plane_;
uint32_t plane_id_;
bool in_use_;
Property crtc_prop_;
Property fb_prop_;
......
// 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.";
return false;
}
property_set_ = drmModePropertySetAlloc();
if (!property_set_) {
LOG(ERROR) << "Failed to allocate property set.";
return false;
}
uint32_t num_planes = plane_resources->count_planes;
for (uint32_t i = 0; i < num_planes; ++i) {
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
// 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.
#ifndef UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_
#define UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_
#include <stddef.h>
#include <stdint.h>
#include <xf86drmMode.h>
#include <vector>
#include "base/basictypes.h"
#include "base/memory/scoped_vector.h"
#include "ui/ozone/platform/dri/hardware_display_plane.h"
#include "ui/ozone/platform/dri/scoped_drm_types.h"
namespace gfx {
class Rect;
} // namespace gfx
namespace ui {
class DriWrapper;
class HardwareDisplayPlaneManager {
public:
HardwareDisplayPlaneManager(DriWrapper* drm);
~HardwareDisplayPlaneManager();
bool Initialize();
const ScopedVector<HardwareDisplayPlane>& get_planes() { return planes_; }
private:
// Object containing the connection to the graphics device and wraps the API
// calls to control it.
DriWrapper* drm_;
drmModePropertySetPtr property_set_;
ScopedVector<HardwareDisplayPlane> planes_;
DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlaneManager);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_MANAGER_H_
......@@ -33,6 +33,10 @@ void DrmPlaneDeleter::operator()(drmModePlane* plane) const {
drmModeFreePlane(plane);
}
void DrmPlaneResDeleter::operator()(drmModePlaneRes* plane) const {
drmModeFreePlaneResources(plane);
}
void DrmPropertyDeleter::operator()(drmModePropertyRes* property) const {
drmModeFreeProperty(property);
}
......
......@@ -13,6 +13,7 @@ typedef struct _drmModeEncoder drmModeEncoder;
typedef struct _drmModeFB drmModeFB;
typedef struct _drmModeObjectProperties drmModeObjectProperties;
typedef struct _drmModePlane drmModePlane;
typedef struct _drmModePlaneRes drmModePlaneRes;
typedef struct _drmModeProperty drmModePropertyRes;
typedef struct _drmModePropertyBlob drmModePropertyBlobRes;
typedef struct _drmModeRes drmModeRes;
......@@ -37,6 +38,9 @@ struct DrmObjectPropertiesDeleter {
struct DrmPlaneDeleter {
void operator()(drmModePlane* plane) const;
};
struct DrmPlaneResDeleter {
void operator()(drmModePlaneRes* plane_res) const;
};
struct DrmPropertyDeleter {
void operator()(drmModePropertyRes* property) const;
};
......@@ -54,6 +58,7 @@ typedef scoped_ptr<drmModeEncoder, DrmEncoderDeleter> ScopedDrmEncoderPtr;
typedef scoped_ptr<drmModeObjectProperties, DrmObjectPropertiesDeleter>
ScopedDrmObjectPropertyPtr;
typedef scoped_ptr<drmModePlane, DrmPlaneDeleter> ScopedDrmPlanePtr;
typedef scoped_ptr<drmModePlaneRes, DrmPlaneResDeleter> ScopedDrmPlaneResPtr;
typedef scoped_ptr<drmModePropertyRes, DrmPropertyDeleter> ScopedDrmPropertyPtr;
typedef scoped_ptr<drmModePropertyBlobRes, DrmPropertyBlobDeleter>
ScopedDrmPropertyBlobPtr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment