Message ID | 20211123183947.46839-1-hiroh@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Wed, Nov 24, 2021 at 03:39:46AM +0900, Hirokazu Honda wrote: > We cannot have a subclass of FrameBuffer because it is marked as final. > This adds a FrameBuffer constructor with FrameBuffer::Private. So we > can attach some additional resources with FrameBuffer through a > customized FrameBuffer::Private class. > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > include/libcamera/framebuffer.h | 2 ++ > include/libcamera/internal/framebuffer.h | 1 + > src/libcamera/framebuffer.cpp | 24 ++++++++++++++++++++++-- > 3 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h > index 7f2f176a..abcede31 100644 > --- a/include/libcamera/framebuffer.h > +++ b/include/libcamera/framebuffer.h > @@ -58,6 +58,8 @@ public: > }; > > FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0); > + FrameBuffer(std::unique_ptr<Private> d, > + const std::vector<Plane> &planes, unsigned int cookie = 0); > > const std::vector<Plane> &planes() const { return planes_; } > Request *request() const; > diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h > index cd33c295..3cced5b1 100644 > --- a/include/libcamera/internal/framebuffer.h > +++ b/include/libcamera/internal/framebuffer.h > @@ -19,6 +19,7 @@ class FrameBuffer::Private : public Extensible::Private > > public: > Private(); > + virtual ~Private(); > > void setRequest(Request *request) { request_ = request; } > bool isContiguous() const { return isContiguous_; } > diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp > index 337ea115..3a324471 100644 > --- a/src/libcamera/framebuffer.cpp > +++ b/src/libcamera/framebuffer.cpp > @@ -116,6 +116,13 @@ FrameBuffer::Private::Private() > { > } > > +/** > + * \brief FrameBuffer::Private destructor > + */ > +FrameBuffer::Private::~Private() > +{ > +} > + > /** > * \fn FrameBuffer::Private::setRequest() > * \brief Set the request this buffer belongs to > @@ -213,8 +220,21 @@ FrameBuffer::Private::Private() > * \param[in] cookie Cookie > */ > FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie) > - : Extensible(std::make_unique<Private>()), planes_(planes), > - cookie_(cookie) > + : FrameBuffer(std::make_unique<Private>(), planes, cookie) > +{ > +} > + > +/** > + * \brief Construct a FrameBuffer with an extensible private class and an array > + * of planes > + * \param[in] d The extensible private class > + * \param[in] planes The frame memory planes > + * \param[in] cookie Cookie > + */ > +FrameBuffer::FrameBuffer(std::unique_ptr<Private> d, > + const std::vector<Plane> &planes, > + unsigned int cookie) > + : Extensible(std::move(d)), planes_(planes), cookie_(cookie) > { > metadata_.planes_.resize(planes_.size()); >
diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 7f2f176a..abcede31 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -58,6 +58,8 @@ public: }; FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0); + FrameBuffer(std::unique_ptr<Private> d, + const std::vector<Plane> &planes, unsigned int cookie = 0); const std::vector<Plane> &planes() const { return planes_; } Request *request() const; diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index cd33c295..3cced5b1 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -19,6 +19,7 @@ class FrameBuffer::Private : public Extensible::Private public: Private(); + virtual ~Private(); void setRequest(Request *request) { request_ = request; } bool isContiguous() const { return isContiguous_; } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 337ea115..3a324471 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -116,6 +116,13 @@ FrameBuffer::Private::Private() { } +/** + * \brief FrameBuffer::Private destructor + */ +FrameBuffer::Private::~Private() +{ +} + /** * \fn FrameBuffer::Private::setRequest() * \brief Set the request this buffer belongs to @@ -213,8 +220,21 @@ FrameBuffer::Private::Private() * \param[in] cookie Cookie */ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie) - : Extensible(std::make_unique<Private>()), planes_(planes), - cookie_(cookie) + : FrameBuffer(std::make_unique<Private>(), planes, cookie) +{ +} + +/** + * \brief Construct a FrameBuffer with an extensible private class and an array + * of planes + * \param[in] d The extensible private class + * \param[in] planes The frame memory planes + * \param[in] cookie Cookie + */ +FrameBuffer::FrameBuffer(std::unique_ptr<Private> d, + const std::vector<Plane> &planes, + unsigned int cookie) + : Extensible(std::move(d)), planes_(planes), cookie_(cookie) { metadata_.planes_.resize(planes_.size());