libcamera: framebuffer: Move planes check to constructor

The FrameBuffer::planes() function checks that planes are correctly
initialized with an offset. This can be done at construction time
instead, as the planes are constant. The backtrace generated by the
assertion will show where the faulty frame buffer is created instead of
where it is used, easing debugging.

As the runtime overhead is reduced, there's no real need to drop the
assertion in the future anymore, it can be useful to ensure that the
planes are correctly populated by the caller. Drop the comment that
calls for removing the check.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
Laurent Pinchart 2021-09-02 01:56:07 +03:00
parent 1b0bd492c2
commit 78875938e9
2 changed files with 3 additions and 8 deletions

View file

@ -51,14 +51,7 @@ public:
FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
const std::vector<Plane> &planes() const
{
/* \todo Remove the assertions after sufficient testing */
for (const auto &plane : planes_)
assert(plane.offset != Plane::kInvalidOffset);
return planes_;
}
const std::vector<Plane> &planes() const { return planes_; }
Request *request() const;
const FrameMetadata &metadata() const { return metadata_; }