aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Firago <alexey_firago@mentor.com>2018-11-21 23:47:05 +0300
committerAlexey Firago <alexey_firago@mentor.com>2018-11-27 11:45:41 +0300
commit18ec688fadef2319092389407f98bb1f377ef8d7 (patch)
treed31b2a65078354babe9a7171fd9a741a58d19064
parentea1c5e5a1bd4830b7c8b8da230e816e5efda1acb (diff)
downloaddrm_hwcomposer-18ec688fadef2319092389407f98bb1f377ef8d7.tar.gz
drm_hwcomposer: Add checking if we can import a buffer
Add CanImportBuffer() function to the Importer interface. Platform specific importer should check in this function if it can import given buffer_handle_t. For example platformhisi will return false for buffers without GRALLOC_USAGE_HW_FB. This function should be used on ValidateDisplay step to avoid the need of 'fake-importing' of buffers. Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
-rw-r--r--drmhwctwo.cpp11
-rw-r--r--platform.h3
-rw-r--r--platformdrmgeneric.cpp6
-rw-r--r--platformdrmgeneric.h1
-rw-r--r--platformhisi.cpp6
-rw-r--r--platformhisi.h2
6 files changed, 26 insertions, 3 deletions
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index c801f2e..cd79e7b 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -491,9 +491,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::CreateComposition(bool test) {
std::map<uint32_t, DrmHwcTwo::HwcLayer *> z_map;
for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
HWC2::Composition comp_type;
- if (test)
+ if (test) {
comp_type = l.second.sf_type();
- else
+ if (comp_type == HWC2::Composition::Device) {
+ if (!importer_->CanImportBuffer(l.second.buffer()))
+ comp_type = HWC2::Composition::Client;
+ }
+ } else
comp_type = l.second.validated_type();
switch (comp_type) {
@@ -735,7 +739,8 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) {
if (comp_failed || !avail_planes--)
break;
- l.second->set_validated_type(HWC2::Composition::Device);
+ if (importer_->CanImportBuffer(l.second->buffer()))
+ l.second->set_validated_type(HWC2::Composition::Device);
}
for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
diff --git a/platform.h b/platform.h
index 547a297..a58d62e 100644
--- a/platform.h
+++ b/platform.h
@@ -49,6 +49,9 @@ class Importer {
// Note: This can be called from a different thread than ImportBuffer. The
// implementation is responsible for ensuring thread safety.
virtual int ReleaseBuffer(hwc_drm_bo_t *bo) = 0;
+
+ // Checks if importer can import the buffer.
+ virtual bool CanImportBuffer(buffer_handle_t handle) = 0;
};
class Planner {
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index 24d0650..503c04a 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -161,6 +161,12 @@ int DrmGenericImporter::ReleaseBuffer(hwc_drm_bo_t *bo) {
return 0;
}
+bool DrmGenericImporter::CanImportBuffer(buffer_handle_t handle) {
+ if (handle == NULL)
+ return false;
+ return true;
+}
+
#ifdef USE_DRM_GENERIC_IMPORTER
std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
std::unique_ptr<Planner> planner(new Planner);
diff --git a/platformdrmgeneric.h b/platformdrmgeneric.h
index d46e8b0..233ba55 100644
--- a/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -33,6 +33,7 @@ class DrmGenericImporter : public Importer {
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
int ReleaseBuffer(hwc_drm_bo_t *bo) override;
+ bool CanImportBuffer(buffer_handle_t handle) override;
uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
diff --git a/platformhisi.cpp b/platformhisi.cpp
index bf4033b..c5cadf6 100644
--- a/platformhisi.cpp
+++ b/platformhisi.cpp
@@ -139,6 +139,12 @@ int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
return ret;
}
+bool HisiImporter::CanImportBuffer(buffer_handle_t handle) {
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
+ handle);
+ return hnd && (hnd->usage & GRALLOC_USAGE_HW_FB);
+}
+
class PlanStageHiSi : public Planner::PlanStage {
public:
int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
diff --git a/platformhisi.h b/platformhisi.h
index 2b2d439..927da17 100644
--- a/platformhisi.h
+++ b/platformhisi.h
@@ -36,6 +36,8 @@ class HisiImporter : public DrmGenericImporter {
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+ bool CanImportBuffer(buffer_handle_t handle) override;
+
private:
DrmDevice *drm_;