diff options
author | Mykhailo Sopiha <mykhailo.sopiha@linaro.org> | 2019-06-06 14:45:27 +0300 |
---|---|---|
committer | Mykhailo Sopiha <mykhailo.sopiha@linaro.org> | 2019-06-07 12:31:45 +0300 |
commit | ad43886f7d5eb35965fd94fb73a6bdcdbe180d5c (patch) | |
tree | ef10c2e47aa7c595aab24d8ee5de1126b6f95eea | |
parent | 9cf798da27ba1f902f53c3d1e7140922711ca4b2 (diff) |
drm_hwcomposer: clean Importer inherited classes
Move some common logic from Importer class implementations
into DrmGenericImporter class:
- reused generic constructors and destructors for derived
classes
- formed common Init() logic for all derived classes
- removed unused gralloc_ and drm_ variables from derived
classes
- made drm_ protected for base class to be reused in derived
Signed-off-by: Mykhailo Sopiha <mykhailo.sopiha@linaro.org>
-rw-r--r-- | platformdrmgeneric.cpp | 4 | ||||
-rw-r--r-- | platformdrmgeneric.h | 3 | ||||
-rw-r--r-- | platformhisi.cpp | 22 | ||||
-rw-r--r-- | platformhisi.h | 10 | ||||
-rw-r--r-- | platformminigbm.cpp | 22 | ||||
-rw-r--r-- | platformminigbm.h | 11 |
6 files changed, 8 insertions, 64 deletions
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp index 503c04a..2fcbe40 100644 --- a/platformdrmgeneric.cpp +++ b/platformdrmgeneric.cpp @@ -60,6 +60,10 @@ int DrmGenericImporter::Init() { ALOGE("Failed to open gralloc module"); return ret; } + + ALOGI("Using %s gralloc module: %s\n", gralloc_->common.name, + gralloc_->common.author); + return 0; } diff --git a/platformdrmgeneric.h b/platformdrmgeneric.h index 233ba55..c6d2be6 100644 --- a/platformdrmgeneric.h +++ b/platformdrmgeneric.h @@ -38,9 +38,10 @@ class DrmGenericImporter : public Importer { uint32_t ConvertHalFormatToDrm(uint32_t hal_format); uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format); - private: + protected: DrmDevice *drm_; + private: const gralloc_module_t *gralloc_; }; } // namespace android diff --git a/platformhisi.cpp b/platformhisi.cpp index e022010..64b410b 100644 --- a/platformhisi.cpp +++ b/platformhisi.cpp @@ -48,28 +48,6 @@ Importer *Importer::CreateInstance(DrmDevice *drm) { return importer; } -HisiImporter::HisiImporter(DrmDevice *drm) - : DrmGenericImporter(drm), drm_(drm) { -} - -HisiImporter::~HisiImporter() { -} - -int HisiImporter::Init() { - int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, - (const hw_module_t **)&gralloc_); - if (ret) { - ALOGE("Failed to open gralloc module %d", ret); - return ret; - } - - if (strcasecmp(gralloc_->common.author, "ARM Ltd.")) - ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name, - gralloc_->common.author); - - return 0; -} - #if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \ defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16) uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags, diff --git a/platformhisi.h b/platformhisi.h index 14a58b9..9dfea89 100644 --- a/platformhisi.h +++ b/platformhisi.h @@ -29,23 +29,15 @@ namespace android { class HisiImporter : public DrmGenericImporter { public: - HisiImporter(DrmDevice *drm); - ~HisiImporter() override; - - int Init(); + using DrmGenericImporter::DrmGenericImporter; int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; - bool CanImportBuffer(buffer_handle_t handle) override; private: uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags, bool is_rgb); bool IsDrmFormatRgb(uint32_t drm_format); - - DrmDevice *drm_; - - const gralloc_module_t *gralloc_; }; } // namespace android diff --git a/platformminigbm.cpp b/platformminigbm.cpp index dce1d11..ad0a373 100644 --- a/platformminigbm.cpp +++ b/platformminigbm.cpp @@ -45,28 +45,6 @@ Importer *Importer::CreateInstance(DrmDevice *drm) { return importer; } -DrmMinigbmImporter::DrmMinigbmImporter(DrmDevice *drm) - : DrmGenericImporter(drm), drm_(drm) { -} - -DrmMinigbmImporter::~DrmMinigbmImporter() { -} - -int DrmMinigbmImporter::Init() { - int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, - (const hw_module_t **)&gralloc_); - if (ret) { - ALOGE("Failed to open gralloc module %d", ret); - return ret; - } - - if (strcasecmp(gralloc_->common.author, "Chrome OS")) - ALOGW("Using non-minigbm gralloc module: %s/%s\n", gralloc_->common.name, - gralloc_->common.author); - - return 0; -} - int DrmMinigbmImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) { cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle; if (!gr_handle) diff --git a/platformminigbm.h b/platformminigbm.h index 25f8404..ff69f14 100644 --- a/platformminigbm.h +++ b/platformminigbm.h @@ -27,17 +27,8 @@ namespace android { class DrmMinigbmImporter : public DrmGenericImporter { public: - DrmMinigbmImporter(DrmDevice *drm); - ~DrmMinigbmImporter() override; - - int Init(); - + using DrmGenericImporter::DrmGenericImporter; int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; - - private: - DrmDevice *drm_; - - const gralloc_module_t *gralloc_; }; } // namespace android |