From d6d4710d047528a60c5e436c9bd0b29301c40f3c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 28 Jun 2021 01:02:44 +0300 Subject: libcamera: framebuffer: Make FrameBuffer class Extensible Implement the D-Pointer design pattern in the FrameBuffer class to allow changing internal data without affecting the public ABI. Move the request_ field and the setRequest() function to the FrameBuffer::Private class. This allows hiding the setRequest() function from the public API, removing one todo item. More fields may be moved later. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- src/libcamera/framebuffer.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/libcamera/framebuffer.cpp') diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 4bde556c..40bf64b0 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -100,6 +100,21 @@ LOG_DEFINE_CATEGORY(Buffer) * \brief Array of per-plane metadata */ +FrameBuffer::Private::Private(FrameBuffer *buffer) + : Extensible::Private(buffer), request_(nullptr) +{ +} + +/** + * \fn FrameBuffer::Private::setRequest() + * \brief Set the request this buffer belongs to + * \param[in] request Request to set + * + * For buffers added to requests by applications, this method is called by + * Request::addBuffer() or Request::reuse(). For buffers internal to pipeline + * handlers, it is called by the pipeline handlers themselves. + */ + /** * \class FrameBuffer * \brief Frame buffer data and its associated dynamic metadata @@ -161,7 +176,7 @@ LOG_DEFINE_CATEGORY(Buffer) * \param[in] cookie Cookie */ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) - : planes_(planes), request_(nullptr), cookie_(cookie) + : Extensible(new Private(this)), planes_(planes), cookie_(cookie) { } @@ -172,7 +187,6 @@ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) */ /** - * \fn FrameBuffer::request() * \brief Retrieve the request this buffer belongs to * * The intended callers of this method are buffer completion handlers that @@ -185,18 +199,10 @@ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) * \return The Request the FrameBuffer belongs to, or nullptr if the buffer is * not associated with a request */ - -/** - * \fn FrameBuffer::setRequest() - * \brief Set the request this buffer belongs to - * \param[in] request Request to set - * - * For buffers added to requests by applications, this method is called by - * Request::addBuffer() or Request::reuse(). For buffers internal to pipeline - * handlers, it is called by the pipeline handlers themselves. - * - * \todo Shall be hidden from applications with a d-pointer design. - */ +Request *FrameBuffer::request() const +{ + return _d()->request_; +} /** * \fn FrameBuffer::metadata() -- cgit v1.2.1