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>
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) {
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_) {
// 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 {
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);
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);
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,
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+ bool CanImportBuffer(buffer_handle_t handle) override;
+
private:
DrmDevice *drm_;