[libcamera-devel] [PATCH v4 10/11] android: mm: Provide helper macro for PIMPL
Jacopo Mondi
jacopo at jmondi.org
Tue Mar 2 15:18:43 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 784fbd50e50b..7e8970b49f49 100644
--- a/src/android/camera_buffer.h
+++ b/src/android/camera_buffer.h
@@ -30,4 +30,37 @@ public:
size_t jpegBufferSize(size_t maxJpegBufferSize) const;
};
+#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::jpegBufferSize(size_t maxJpegBufferSize) const \
+{ \
+ const Private *const d = LIBCAMERA_D_PTR(); \
+ return d->jpegBufferSize(maxJpegBufferSize); \
+}
#endif /* __ANDROID_CAMERA_BUFFER_H__ */
diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
index 98e63dfa0577..929e078ad4c9 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::jpegBufferSize(size_t maxJpegBufferSize) const
maxJpegBufferSize);
}
-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::jpegBufferSize(size_t maxJpegBufferSize) const
-{
- const Private *const d = LIBCAMERA_D_PTR();
- return d->jpegBufferSize(maxJpegBufferSize);
-}
+PUBLIC_CAMERA_BUFFER_IMPLEMENTATION
--
2.30.0
More information about the libcamera-devel
mailing list