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>
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index c801f2e..cd79e7b 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -491,9 +491,13 @@
   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 @@
   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_) {