[PATCH hwc v2 11/18] drm_hwcomposer: Add utility functions to copy displaycomposition internals
Alexandru Gheorghe
alexandru-cosmin.gheorghe at arm.com
Wed Apr 11 15:22:22 UTC 2018
Add utility functions to copy the DrmHwcLayer and DrmCompositionPlanes
from another DrmDisplayComposition.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe at arm.com>
---
drmdisplaycomposition.cpp | 29 +++++++++++++++++++++++++++++
drmdisplaycomposition.h | 3 +++
2 files changed, 32 insertions(+)
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 66e67a4..dd64f46 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -99,6 +99,35 @@ int DrmDisplayComposition::SetLayers(DrmHwcLayer *layers, size_t num_layers,
return 0;
}
+int DrmDisplayComposition::CopyLayers(DrmDisplayComposition *src) {
+ geometry_changed_ = true;
+ type_ = DRM_COMPOSITION_TYPE_FRAME;
+ std::shared_ptr<Importer> importer =
+ drm_->resource_manager()->GetImporter(crtc()->display());
+ if (!importer) {
+ ALOGE("Failed to find a valid importer");
+ return -EINVAL;
+ }
+ for (DrmHwcLayer &src_layer : src->layers()) {
+ DrmHwcLayer copy;
+ copy.PopulateFromDrmHwcLayer(&src_layer);
+ int ret = copy.ImportBuffer(importer.get(),
+ drm_->resource_manager()->GetGralloc());
+ if (ret) {
+ ALOGE("Failed to import buffer ret = %d", ret);
+ return -EINVAL;
+ }
+ layers_.emplace_back(std::move(copy));
+ }
+ return 0;
+}
+
+void DrmDisplayComposition::CopyCompPlanes(DrmDisplayComposition *src) {
+ for (auto comp_plane : src->composition_planes()) {
+ composition_planes_.push_back(comp_plane);
+ }
+}
+
int DrmDisplayComposition::SetDpmsMode(uint32_t dpms_mode) {
if (!validate_composition_type(DRM_COMPOSITION_TYPE_DPMS))
return -EINVAL;
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 9183925..c646420 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -68,6 +68,7 @@ class DrmCompositionPlane {
DrmCompositionPlane() = default;
DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
+ DrmCompositionPlane(const DrmCompositionPlane &rhs) = default;
DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
DrmCompositionPlane(Type type, DrmPlane *plane, DrmCrtc *crtc)
: type_(type), plane_(plane), crtc_(crtc) {
@@ -120,6 +121,8 @@ class DrmDisplayComposition {
Planner *planner, uint64_t frame_no);
int SetLayers(DrmHwcLayer *layers, size_t num_layers, bool geometry_changed);
+ int CopyLayers(DrmDisplayComposition *src);
+ void CopyCompPlanes(DrmDisplayComposition *src);
int AddPlaneComposition(DrmCompositionPlane plane);
int AddPlaneDisable(DrmPlane *plane);
int SetDpmsMode(uint32_t dpms_mode);
--
2.7.4
More information about the dri-devel
mailing list