drm_hwcomposer: Reorganize modifiers handling logic

Reasons for this change:
1. Remove redundant code lines.
2. Workaround for cases when DRM_FORMAT_MOD_INVALID is set by gralloc.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/bufferinfo/BufferInfoMapperMetadata.cpp b/bufferinfo/BufferInfoMapperMetadata.cpp
index 3aabeb5..7d64ce8 100644
--- a/bufferinfo/BufferInfoMapperMetadata.cpp
+++ b/bufferinfo/BufferInfoMapperMetadata.cpp
@@ -107,7 +107,6 @@
     ALOGE("Failed to get DRM Modifier err=%d", err);
     return err;
   }
-  bo->with_modifiers = true;
 
   uint64_t width = 0;
   err = mapper.getWidth(handle, &width);
diff --git a/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp
index bd51d0e..c794810 100644
--- a/bufferinfo/legacy/BufferInfoLibdrm.cpp
+++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp
@@ -171,8 +171,6 @@
 #endif
 #if GRALLOC_HANDLE_VERSION == 4
   bo->modifiers[0] = gr_handle->modifier;
-  bo->with_modifiers = gr_handle->modifier != DRM_FORMAT_MOD_NONE &&
-                       gr_handle->modifier != DRM_FORMAT_MOD_INVALID;
 #endif
 
   bo->usage = gr_handle->usage;
diff --git a/bufferinfo/legacy/BufferInfoMaliHisi.cpp b/bufferinfo/legacy/BufferInfoMaliHisi.cpp
index ab5579c..877a83f 100644
--- a/bufferinfo/legacy/BufferInfoMaliHisi.cpp
+++ b/bufferinfo/legacy/BufferInfoMaliHisi.cpp
@@ -120,8 +120,6 @@
       break;
   }
 
-  bo->with_modifiers = true;
-
   return 0;
 }
 
diff --git a/bufferinfo/legacy/BufferInfoMaliMeson.cpp b/bufferinfo/legacy/BufferInfoMaliMeson.cpp
index b6896e1..cf7a873 100644
--- a/bufferinfo/legacy/BufferInfoMaliMeson.cpp
+++ b/bufferinfo/legacy/BufferInfoMaliMeson.cpp
@@ -87,8 +87,6 @@
   bo->pitches[0] = hnd->byte_stride;
   bo->offsets[0] = 0;
 
-  bo->with_modifiers = true;
-
   return 0;
 }
 
diff --git a/drm/DrmGenericImporter.cpp b/drm/DrmGenericImporter.cpp
index 8ab4fe5..7fbbdc6 100644
--- a/drm/DrmGenericImporter.cpp
+++ b/drm/DrmGenericImporter.cpp
@@ -59,13 +59,16 @@
     }
   }
 
-  if (!has_modifier_support_ && bo->modifiers[0]) {
+  bool has_modifiers = bo->modifiers[0] != DRM_FORMAT_MOD_NONE &&
+                       bo->modifiers[0] != DRM_FORMAT_MOD_INVALID;
+
+  if (!has_modifier_support_ && has_modifiers) {
     ALOGE("No ADDFB2 with modifier support. Can't import modifier %" PRIu64,
           bo->modifiers[0]);
     return -EINVAL;
   }
 
-  if (!bo->with_modifiers)
+  if (!has_modifiers)
     ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
                         bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id,
                         0);
@@ -73,8 +76,7 @@
     ret = drmModeAddFB2WithModifiers(drm_->fd(), bo->width, bo->height,
                                      bo->format, bo->gem_handles, bo->pitches,
                                      bo->offsets, bo->modifiers, &bo->fb_id,
-                                     bo->modifiers[0] ? DRM_MODE_FB_MODIFIERS
-                                                      : 0);
+                                     DRM_MODE_FB_MODIFIERS);
 
   if (ret) {
     ALOGE("could not create drm fb %d", ret);
diff --git a/include/drmhwcgralloc.h b/include/drmhwcgralloc.h
index fc0af64..05b2cf0 100644
--- a/include/drmhwcgralloc.h
+++ b/include/drmhwcgralloc.h
@@ -32,7 +32,6 @@
   uint32_t gem_handles[HWC_DRM_BO_MAX_PLANES];
   uint64_t modifiers[HWC_DRM_BO_MAX_PLANES];
   uint32_t fb_id;
-  bool with_modifiers;
   int acquire_fence_fd;
   void *priv;
 } hwc_drm_bo_t;