{"id":11400,"url":"https://patchwork.libcamera.org/api/patches/11400/?format=json","web_url":"https://patchwork.libcamera.org/patch/11400/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210226132932.165484-8-jacopo@jmondi.org>","date":"2021-02-26T13:29:27","name":"[libcamera-devel,07/12] android: camera_buffer: Implement PIMPL pattern","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"907e86e396cb8b94b6b8a81755c62dee04c41c80","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11400/mbox/","series":[{"id":1731,"url":"https://patchwork.libcamera.org/api/series/1731/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1731","date":"2021-02-26T13:29:20","name":"android: Support memory backends","version":1,"mbox":"https://patchwork.libcamera.org/series/1731/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11400/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11400/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8CDEABD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Feb 2021 13:29:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D556168A8E;\n\tFri, 26 Feb 2021 14:29:21 +0100 (CET)","from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E9A668A71\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Feb 2021 14:29:16 +0100 (CET)","from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id C67E2200005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Feb 2021 13:29:15 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 26 Feb 2021 14:29:27 +0100","Message-Id":"<20210226132932.165484-8-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.30.0","In-Reply-To":"<20210226132932.165484-1-jacopo@jmondi.org>","References":"<20210226132932.165484-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 07/12] android: camera_buffer: Implement\n\tPIMPL pattern","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"In order to prepare to support more memory backends, make the\nCameraBuffer class implement the PIMPL (pointer-to-implementation)\npattern.\n\nDefine the CameraBuffer class interface whose actual implementation is\ndelegated to an inner CameraBufferImpl class.\n\nTemporary maintain libcamera::MappedBuffer as the CameraBuffer base\nclass to maintain compatibility of the CameraStream::process() interface\nthat requires a MappedBuffer * as second argument and will be converted\nto use a CameraBuffer in the next patch.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_buffer.h               | 12 ++++\n src/android/mm/android_generic_buffer.cpp | 80 ++++++++++++++++++++++-\n 2 files changed, 91 insertions(+), 1 deletion(-)","diff":"diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\nindex 0590cd84652b..2a91e6a3c9c1 100644\n--- a/src/android/camera_buffer.h\n+++ b/src/android/camera_buffer.h\n@@ -16,6 +16,18 @@ class CameraBuffer : public libcamera::MappedBuffer\n public:\n \tCameraBuffer(buffer_handle_t camera3Buffer, int flags);\n \t~CameraBuffer();\n+\n+\tbool isValid() const;\n+\n+\tunsigned int numPlanes() const;\n+\tssize_t planeSize(unsigned int plane) const;\n+\n+\tconst uint8_t *plane(unsigned int plane) const;\n+\tuint8_t *plane(unsigned int plane);\n+\n+private:\n+\tclass CameraBufferImpl;\n+\tCameraBufferImpl *impl_;\n };\n \n #endif /* __ANDROID_CAMERA_BUFFER_H__ */\ndiff --git a/src/android/mm/android_generic_buffer.cpp b/src/android/mm/android_generic_buffer.cpp\nindex 807304a9e42d..10a43a61bd4d 100644\n--- a/src/android/mm/android_generic_buffer.cpp\n+++ b/src/android/mm/android_generic_buffer.cpp\n@@ -13,7 +13,21 @@ using namespace libcamera;\n \n LOG_DECLARE_CATEGORY(HAL)\n \n-CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\n+class CameraBuffer::CameraBufferImpl : public libcamera::MappedBuffer\n+{\n+public:\n+\tCameraBufferImpl(buffer_handle_t camera3Buffer, int flags);\n+\t~CameraBufferImpl();\n+\n+\tunsigned int numPlanes() const;\n+\tssize_t planeSize(unsigned int plane) const;\n+\n+\tconst uint8_t *plane(unsigned int plane) const;\n+\tuint8_t *plane(unsigned int plane);\n+};\n+\n+CameraBuffer::CameraBufferImpl::CameraBufferImpl(buffer_handle_t camera3Buffer,\n+\t\t\t\t\t\t int flags)\n {\n \tmaps_.reserve(camera3Buffer->numFds);\n \terror_ = 0;\n@@ -42,6 +56,70 @@ CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\n \t}\n }\n \n+CameraBuffer::CameraBufferImpl::~CameraBufferImpl()\n+{\n+}\n+\n+unsigned int CameraBuffer::CameraBufferImpl::numPlanes() const\n+{\n+\treturn maps_.size();\n+}\n+\n+ssize_t CameraBuffer::CameraBufferImpl::planeSize(unsigned int plane) const\n+{\n+\tif (plane >= maps_.size())\n+\t\treturn -EINVAL;\n+\n+\treturn maps_[plane].size();\n+}\n+\n+const uint8_t *CameraBuffer::CameraBufferImpl::plane(unsigned int plane) const\n+{\n+\tif (plane >= maps_.size())\n+\t\treturn nullptr;\n+\n+\treturn maps_[plane].data();\n+}\n+\n+uint8_t *CameraBuffer::CameraBufferImpl::plane(unsigned int plane)\n+{\n+\tif (plane >= maps_.size())\n+\t\treturn nullptr;\n+\n+\treturn maps_[plane].data();\n+}\n+\n+CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\n+\t: impl_(new CameraBuffer::CameraBufferImpl(camera3Buffer, flags))\n+{\n+}\n+\n CameraBuffer::~CameraBuffer()\n {\n+\tdelete impl_;\n+}\n+\n+bool CameraBuffer::isValid() const\n+{\n+\treturn impl_->isValid();\n+}\n+\n+unsigned int CameraBuffer::numPlanes() const\n+{\n+\treturn impl_->numPlanes();\n+}\n+\n+ssize_t CameraBuffer::planeSize(unsigned int plane) const\n+{\n+\treturn impl_->planeSize(plane);\n+}\n+\n+const uint8_t *CameraBuffer::plane(unsigned int plane) const\n+{\n+\treturn impl_->plane(plane);\n+}\n+\n+uint8_t *CameraBuffer::plane(unsigned int plane)\n+{\n+\treturn impl_->plane(plane);\n }\n","prefixes":["libcamera-devel","07/12"]}