summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-02-26 11:48:47 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-03-03 09:50:44 +0100
commit1427d124e86a134076f6abdd4a11b037e005fede (patch)
tree7ea9e5ceec0c48eef437806a63036f8010fcfcbb
parent00fec7d5edaf190429654191a651a180b02d56f9 (diff)
android: mm: Provide helper macro for PIMPL
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@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--src/android/camera_buffer.h33
-rw-r--r--src/android/mm/generic_camera_buffer.cpp39
2 files changed, 34 insertions, 38 deletions
diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h
index 784fbd50..7e8970b4 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 98e63dfa..929e078a 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