From 8daf20485b90af2065e3db0e3fd0cd5b72fd7ac4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 28 Feb 2020 17:01:43 +0200 Subject: libcamera: controls: Add zero-copy set API for ControlValue Extend the ControlValue class with a reserve() function to set the value without actually copying data, and a non-const data() function that allows writing data directly to the ControlValue storage. This allows allocating memory directly in ControlValue, potentially removing a data copy. Note that this change was implemented before ByteStreamBuffer gained the zero-copy read() variant, and doesn't actually save a copy in the control serializer. It however still simplifies ControlSerializer::loadControlValue(). Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- include/libcamera/controls.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 2a665712..4b2e7e9c 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -115,6 +115,7 @@ public: bool isArray() const { return isArray_; } std::size_t numElements() const { return numElements_; } Span data() const; + Span data(); std::string toString() const; @@ -174,6 +175,9 @@ public: value.data(), value.size(), sizeof(typename T::value_type)); } + void reserve(ControlType type, bool isArray = false, + std::size_t numElements = 1); + private: ControlType type_ : 8; bool isArray_; -- cgit v1.2.1