[libcamera-devel] [PATCH v3 09/10] android: mm: Provide helper macro for PIMPL
Jacopo Mondi
jacopo at jmondi.org
Tue Mar 2 12:51:07 CET 2021
Each memory backend has to declare a CameraBuffer class implementation
that bridges the API calls to each CameraBuffer::Private implementation.
As the code is likely the same for most (if not all) backends, provide
a convenience macro that expands to the CameraBuffer class declaration.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_buffer.h | 33 ++++++++++++++++++++
src/android/mm/generic_camera_buffer.cpp | 39 +-----------------------
2 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h
index 342aac6d3f14..eb1c12c1e9dd 100644
--- a/src/android/camera_buffer.h
+++ b/src/android/camera_buffer.h
@@ -30,4 +30,37 @@ public:
size_t jpegBlobSize(size_t maxJpegBlobSize);
};
+#define PUBLIC_CAMERA_BUFFER_IMPLEMENTATION \
+CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags) \
+ : Extensible(new Private(this, camera3Buffer, flags)) \
+{ \
+} \
+CameraBuffer::~CameraBuffer() \
+{ \
+} \
+bool CameraBuffer::isValid() const \
+{ \
+ const Private *const d = LIBCAMERA_D_PTR(); \
+ return d->isValid(); \
+} \
+unsigned int CameraBuffer::numPlanes() const \
+{ \
+ const Private *const d = LIBCAMERA_D_PTR(); \
+ return d->numPlanes(); \
+} \
+Span<const uint8_t> CameraBuffer::plane(unsigned int plane) const \
+{ \
+ const Private *const d = LIBCAMERA_D_PTR(); \
+ return const_cast<Private *>(d)->plane(plane); \
+} \
+Span<uint8_t> CameraBuffer::plane(unsigned int plane) \
+{ \
+ Private *const d = LIBCAMERA_D_PTR(); \
+ return d->plane(plane); \
+} \
+size_t CameraBuffer::jpegBlobSize(size_t maxJpegBlobSize) \
+{ \
+ Private *const d = LIBCAMERA_D_PTR(); \
+ return d->jpegBlobSize(maxJpegBlobSize); \
+}
#endif /* __ANDROID_CAMERA_BUFFER_H__ */
diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
index 5637b3f415eb..c5e66a454fbb 100644
--- a/src/android/mm/generic_camera_buffer.cpp
+++ b/src/android/mm/generic_camera_buffer.cpp
@@ -85,41 +85,4 @@ size_t CameraBuffer::Private::jpegBlobSize(size_t maxJpegBlobSize)
maxJpegBlobSize);
}
-CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)
- : Extensible(new Private(this, camera3Buffer, flags))
-{
-}
-
-CameraBuffer::~CameraBuffer()
-{
-}
-
-bool CameraBuffer::isValid() const
-{
- const Private *const d = LIBCAMERA_D_PTR();
- return d->isValid();
-}
-
-unsigned int CameraBuffer::numPlanes() const
-{
- const Private *const d = LIBCAMERA_D_PTR();
- return d->numPlanes();
-}
-
-Span<const uint8_t> CameraBuffer::plane(unsigned int plane) const
-{
- const Private *const d = LIBCAMERA_D_PTR();
- return const_cast<Private *>(d)->plane(plane);
-}
-
-Span<uint8_t> CameraBuffer::plane(unsigned int plane)
-{
- Private *const d = LIBCAMERA_D_PTR();
- return d->plane(plane);
-}
-
-size_t CameraBuffer::jpegBlobSize(size_t maxJpegBlobSize)
-{
- Private *const d = LIBCAMERA_D_PTR();
- return d->jpegBlobSize(maxJpegBlobSize);
-}
+PUBLIC_CAMERA_BUFFER_IMPLEMENTATION
--
2.30.0
More information about the libcamera-devel
mailing list