aboutsummaryrefslogtreecommitdiff
path: root/bufferinfo/BufferInfoGetter.h
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 06:55:18 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 06:55:18 +0000
commit1d29a2e82fad8d0f4d00e62cbac070995ae40a43 (patch)
tree8e2c640be06a05fdc28ced0de956702c43663f1d /bufferinfo/BufferInfoGetter.h
parentb2d6754680caa9db386edf68be423b212801b51b (diff)
parent42f13403a20257cfa97dd490a67681117a6da1b2 (diff)
downloaddrm_hwcomposer-1d29a2e82fad8d0f4d00e62cbac070995ae40a43.tar.gz
Change-Id: I35f1ac23ebfbabfc80481285cc1ad415400c02d0
Diffstat (limited to 'bufferinfo/BufferInfoGetter.h')
-rw-r--r--bufferinfo/BufferInfoGetter.h45
1 files changed, 28 insertions, 17 deletions
diff --git a/bufferinfo/BufferInfoGetter.h b/bufferinfo/BufferInfoGetter.h
index fad3d16..59184a4 100644
--- a/bufferinfo/BufferInfoGetter.h
+++ b/bufferinfo/BufferInfoGetter.h
@@ -31,8 +31,7 @@ namespace android {
class BufferInfoGetter {
public:
- virtual ~BufferInfoGetter() {
- }
+ virtual ~BufferInfoGetter() = default;
virtual int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) = 0;
@@ -49,28 +48,40 @@ class LegacyBufferInfoGetter : public BufferInfoGetter {
int Init();
- int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
+ virtual int ValidateGralloc() {
+ return 0;
+ }
- static LegacyBufferInfoGetter *CreateInstance();
+ static std::unique_ptr<LegacyBufferInfoGetter> CreateInstance();
static uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
+
+ // NOLINTNEXTLINE:(readability-identifier-naming)
const gralloc_module_t *gralloc_;
};
-#define LEGACY_BUFFER_INFO_GETTER(getter_) \
- LegacyBufferInfoGetter *LegacyBufferInfoGetter::CreateInstance() { \
- auto *instance = new getter_(); \
- if (!instance) \
- return NULL; \
- \
- int ret = instance->Init(); \
- if (ret) { \
- ALOGE("Failed to initialize the " #getter_ " getter %d", ret); \
- delete instance; \
- return NULL; \
- } \
- return instance; \
+#ifdef DISABLE_LEGACY_GETTERS
+#define LEGACY_BUFFER_INFO_GETTER(getter_)
+#else
+// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
+#define LEGACY_BUFFER_INFO_GETTER(getter_) \
+ std::unique_ptr<LegacyBufferInfoGetter> \
+ LegacyBufferInfoGetter::CreateInstance() { \
+ auto instance = std::make_unique<getter_>(); \
+ if (instance) { \
+ int err = instance->Init(); \
+ if (err) { \
+ ALOGE("Failed to initialize the " #getter_ " getter %d", err); \
+ instance.reset(); \
+ } \
+ err = instance->ValidateGralloc(); \
+ if (err) { \
+ instance.reset(); \
+ } \
+ } \
+ return std::move(instance); \
}
+#endif
} // namespace android
#endif