[libcamera-devel,v3,08/30] libcamera: framebuffer: Move planes check to constructor
diff mbox series

Message ID 20210906225636.14683-8-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Handle fallout of FrameBuffer offset support
Related show

Commit Message

Laurent Pinchart Sept. 6, 2021, 10:56 p.m. UTC
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>
---
 include/libcamera/framebuffer.h | 9 +--------
 src/libcamera/framebuffer.cpp   | 2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h
index d5aeff00387b..fd68ed0a139d 100644
--- a/include/libcamera/framebuffer.h
+++ b/include/libcamera/framebuffer.h
@@ -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_; }
 
diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp
index c99f5b15e6ff..ad63a34a83bf 100644
--- a/src/libcamera/framebuffer.cpp
+++ b/src/libcamera/framebuffer.cpp
@@ -199,6 +199,8 @@  FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)
 	: Extensible(std::make_unique<Private>()), planes_(planes),
 	  cookie_(cookie)
 {
+	for (const auto &plane : planes_)
+		ASSERT(plane.offset != Plane::kInvalidOffset);
 }
 
 /**