From patchwork Sun Jul 4 23:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12803 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6251DC3222 for ; Sun, 4 Jul 2021 23:29:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 800356850E; Mon, 5 Jul 2021 01:29:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jFUwztlz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4435960285 for ; Mon, 5 Jul 2021 01:29:02 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C7A9C2E4; Mon, 5 Jul 2021 01:29:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625441342; bh=xFRGxn6j48ULjmSDD4kDRN8p50XOodLPb+s3O8I4/Cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFUwztlzx5QartCILqv8bi1lpkZ26CDIXBvi6nPWsOyt8kFo4pkQjI4R3LsBnPeUQ 843u+sRD3+1YGkNNIBpONrOgsl2I1nqvmDDrI9mjyOzgQalThmDpY300muV8h82iqt 735qZx8qRmi/kfY1NYibMiXA1HsAg0BooZ2ggZac= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Jul 2021 02:28:15 +0300 Message-Id: <20210704232817.8205-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> References: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] libcamera: base: class: Expose Extensible private data to other classes X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Despite sharing the same name, the private data class created by the Extensible design pattern and the C++ private access specifier have different goals. The latter specifies class members private to the class, while the former stores data not visible to the application. There are use cases for accessing the private data class from other classes inside libcamera. Make this possible by exposing public _d() functions in the class deriving from Extensible. This won't allow access to the private data by applications as the definition of the Private class isn't visible outside of libcamera. The _d() functions need to be defined as template functions to delay their evaluation, as the static_cast() operator in the Extensible::_d() functions needs the Private class to be fully defined. Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda --- include/libcamera/base/class.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h index a07dac057331..8212c3d4a5ae 100644 --- a/include/libcamera/base/class.h +++ b/include/libcamera/base/class.h @@ -33,14 +33,24 @@ namespace libcamera { #define LIBCAMERA_DECLARE_PRIVATE() \ public: \ class Private; \ - friend class Private; + friend class Private; \ + template \ + const Private *_d() const \ + { \ + return Extensible::_d(); \ + } \ + template \ + Private *_d() \ + { \ + return Extensible::_d(); \ + } #define LIBCAMERA_DECLARE_PUBLIC(klass) \ friend class klass; \ using Public = klass; #define LIBCAMERA_D_PTR() \ - _d(); + _d(); #define LIBCAMERA_O_PTR() \ _o(); From patchwork Sun Jul 4 23:28:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12804 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1FD1EC0100 for ; Sun, 4 Jul 2021 23:29:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 28A8F68511; Mon, 5 Jul 2021 01:29:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PejG+U6C"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A480D60285 for ; Mon, 5 Jul 2021 01:29:02 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3246DE7; Mon, 5 Jul 2021 01:29:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625441342; bh=1Kd2NE0xjyPuFgEmbj4m+e80O33xGH4ELyB+2v2jWVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PejG+U6CkoJEF5fbMXdGu5Ci3eEbWasB66Pk1Bg+kSEvyzc2m4bFqrHIXBRSJvagG 6zA5BIC/OJ9nyR9XJ4v5oueGSeikk2YTCbqAAgeAlChwv5O7ALHizlXDduhvjLxnl7 HVBzzwZ61Z63MzYhUBsEHKPRwVA1fXl298/Xv1GA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Jul 2021 02:28:16 +0300 Message-Id: <20210704232817.8205-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> References: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: buffer: Rename buffer.h to framebuffer.h X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera names header files based on the classes they define. The buffer.h file is an exception. Rename it to framebuffer.h. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Hirokazu Honda Reviewed-by: Kieran Bingham --- include/libcamera/{buffer.h => framebuffer.h} | 8 ++++---- .../libcamera/internal/{buffer.h => framebuffer.h} | 10 +++++----- include/libcamera/internal/ipa_data_serializer.h | 2 +- include/libcamera/internal/meson.build | 2 +- include/libcamera/internal/tracepoints/request.tp | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- include/libcamera/ipa/ipa_interface.h | 2 +- include/libcamera/meson.build | 2 +- include/libcamera/stream.h | 2 +- src/android/camera_device.h | 4 ++-- src/android/camera_stream.h | 4 ++-- src/android/camera_worker.h | 2 +- src/android/jpeg/encoder.h | 2 +- src/android/jpeg/encoder_libjpeg.h | 2 +- src/android/jpeg/post_processor_jpeg.h | 2 +- src/android/jpeg/thumbnailer.h | 2 +- src/android/mm/generic_camera_buffer.cpp | 2 +- src/android/post_processor.h | 4 ++-- src/cam/buffer_writer.h | 2 +- src/cam/capture.h | 2 +- src/ipa/ipu3/ipu3.cpp | 4 ++-- src/ipa/raspberrypi/raspberrypi.cpp | 4 ++-- src/ipa/rkisp1/rkisp1.cpp | 2 +- src/libcamera/{buffer.cpp => framebuffer.cpp} | 14 +++++++------- src/libcamera/framebuffer_allocator.cpp | 2 +- src/libcamera/meson.build | 2 +- src/libcamera/pipeline/ipu3/frames.cpp | 2 +- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/simple/converter.cpp | 2 +- src/libcamera/pipeline_handler.cpp | 2 +- src/libcamera/request.cpp | 2 +- src/qcam/dng_writer.h | 2 +- src/qcam/main_window.h | 2 +- src/qcam/viewfinder.h | 2 +- src/qcam/viewfinder_gl.h | 2 +- src/qcam/viewfinder_qt.h | 2 +- src/v4l2/v4l2_camera.h | 2 +- test/mapped-buffer.cpp | 2 +- test/v4l2_subdevice/v4l2_subdevice_test.h | 2 +- test/v4l2_videodevice/buffer_sharing.cpp | 2 +- test/v4l2_videodevice/capture_async.cpp | 2 +- test/v4l2_videodevice/v4l2_m2mdevice.cpp | 2 +- test/v4l2_videodevice/v4l2_videodevice_test.h | 2 +- 44 files changed, 62 insertions(+), 62 deletions(-) rename include/libcamera/{buffer.h => framebuffer.h} (89%) rename include/libcamera/internal/{buffer.h => framebuffer.h} (78%) rename src/libcamera/{buffer.cpp => framebuffer.cpp} (97%) diff --git a/include/libcamera/buffer.h b/include/libcamera/framebuffer.h similarity index 89% rename from include/libcamera/buffer.h rename to include/libcamera/framebuffer.h index 323d1cba41a9..baf22a466907 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/framebuffer.h @@ -2,10 +2,10 @@ /* * Copyright (C) 2019, Google Inc. * - * buffer.h - Buffer handling + * framebuffer.h - Frame buffer handling */ -#ifndef __LIBCAMERA_BUFFER_H__ -#define __LIBCAMERA_BUFFER_H__ +#ifndef __LIBCAMERA_FRAMEBUFFER_H__ +#define __LIBCAMERA_FRAMEBUFFER_H__ #include #include @@ -71,4 +71,4 @@ private: } /* namespace libcamera */ -#endif /* __LIBCAMERA_BUFFER_H__ */ +#endif /* __LIBCAMERA_FRAMEBUFFER_H__ */ diff --git a/include/libcamera/internal/buffer.h b/include/libcamera/internal/framebuffer.h similarity index 78% rename from include/libcamera/internal/buffer.h rename to include/libcamera/internal/framebuffer.h index beae0cb98544..0c76fc62af1d 100644 --- a/include/libcamera/internal/buffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -2,10 +2,10 @@ /* * Copyright (C) 2020, Google Inc. * - * buffer.h - Internal buffer handling + * framebuffer.h - Internal frame buffer handling */ -#ifndef __LIBCAMERA_INTERNAL_BUFFER_H__ -#define __LIBCAMERA_INTERNAL_BUFFER_H__ +#ifndef __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ +#define __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ #include #include @@ -13,7 +13,7 @@ #include #include -#include +#include namespace libcamera { @@ -49,4 +49,4 @@ public: } /* namespace libcamera */ -#endif /* __LIBCAMERA_INTERNAL_BUFFER_H__ */ +#endif /* __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ */ diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h index 76325b1d109f..519093bd314f 100644 --- a/include/libcamera/internal/ipa_data_serializer.h +++ b/include/libcamera/internal/ipa_data_serializer.h @@ -16,8 +16,8 @@ #include -#include #include +#include #include #include diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 16a76ebdf9cc..6d4eb7ed3df6 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -11,7 +11,6 @@ libcamera_tracepoint_header = custom_target( libcamera_internal_headers = files([ 'bayer_format.h', - 'buffer.h', 'byte_stream_buffer.h', 'camera_controls.h', 'camera_sensor.h', @@ -23,6 +22,7 @@ libcamera_internal_headers = files([ 'device_enumerator_sysfs.h', 'device_enumerator_udev.h', 'formats.h', + 'framebuffer.h', 'ipa_manager.h', 'ipa_module.h', 'ipa_proxy.h', diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp index 9c841b97438a..37d8c46f4d96 100644 --- a/include/libcamera/internal/tracepoints/request.tp +++ b/include/libcamera/internal/tracepoints/request.tp @@ -5,7 +5,7 @@ * request.tp - Tracepoints for the request object */ -#include +#include #include TRACEPOINT_EVENT_CLASS( diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index a7c3d5290d92..e767ec84c4da 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 9a15c86b16e2..1590584c1fb4 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -15,8 +15,8 @@ #include -#include #include +#include #include namespace libcamera { diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index e4d5c655c1e9..5b25ef847ed4 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -1,12 +1,12 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_public_headers = files([ - 'buffer.h', 'camera.h', 'camera_manager.h', 'compiler.h', 'controls.h', 'file_descriptor.h', + 'framebuffer.h', 'framebuffer_allocator.h', 'geometry.h', 'logging.h', diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index bb47c390f8a1..0c55e7164592 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 3361918d4484..32ba15566621 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -18,12 +18,12 @@ #include #include -#include #include +#include #include #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" #include "camera_capabilities.h" #include "camera_metadata.h" diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 8ecc6e345414..629d9e00e08d 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -13,13 +13,13 @@ #include -#include #include +#include #include #include #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" class CameraDevice; class CameraMetadata; diff --git a/src/android/camera_worker.h b/src/android/camera_worker.h index 6e1aee4a3247..67ae50bd9288 100644 --- a/src/android/camera_worker.h +++ b/src/android/camera_worker.h @@ -12,8 +12,8 @@ #include #include -#include #include +#include #include #include diff --git a/src/android/jpeg/encoder.h b/src/android/jpeg/encoder.h index 28e7f92a3ecb..a28522f41714 100644 --- a/src/android/jpeg/encoder.h +++ b/src/android/jpeg/encoder.h @@ -9,7 +9,7 @@ #include -#include +#include #include class Encoder diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 838da7728382..14bf89223982 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -9,8 +9,8 @@ #include "encoder.h" -#include "libcamera/internal/buffer.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/framebuffer.h" #include diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index 5d2d4ab224b1..5c399be9eb6a 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -13,7 +13,7 @@ #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" class CameraDevice; diff --git a/src/android/jpeg/thumbnailer.h b/src/android/jpeg/thumbnailer.h index 4e9226c34104..68cbf74329a9 100644 --- a/src/android/jpeg/thumbnailer.h +++ b/src/android/jpeg/thumbnailer.h @@ -9,8 +9,8 @@ #include -#include "libcamera/internal/buffer.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/framebuffer.h" class Thumbnailer { diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index 326fdc066499..166be36efd5b 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -11,7 +11,7 @@ #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" using namespace libcamera; diff --git a/src/android/post_processor.h b/src/android/post_processor.h index 547fda379ed8..689f85d9d3b8 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -7,10 +7,10 @@ #ifndef __ANDROID_POST_PROCESSOR_H__ #define __ANDROID_POST_PROCESSOR_H__ -#include +#include #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" #include "camera_buffer.h" diff --git a/src/cam/buffer_writer.h b/src/cam/buffer_writer.h index 47e26103e13e..604ce8702ec7 100644 --- a/src/cam/buffer_writer.h +++ b/src/cam/buffer_writer.h @@ -10,7 +10,7 @@ #include #include -#include +#include class BufferWriter { diff --git a/src/cam/capture.h b/src/cam/capture.h index 59d138766b1e..de478c98e9c1 100644 --- a/src/cam/capture.h +++ b/src/cam/capture.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index f43f862085bb..71698d36e50f 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -13,14 +13,14 @@ #include -#include #include +#include #include #include #include #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" #include "ipu3_agc.h" #include "ipu3_awb.h" diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 4d09a84f6532..4ae81f352596 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -18,17 +18,17 @@ #include #include -#include #include #include #include +#include #include #include #include #include #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" #include "agc_algorithm.hpp" #include "agc_status.h" diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index cdfb4d139e41..b881d42ea131 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -17,8 +17,8 @@ #include -#include #include +#include #include #include #include diff --git a/src/libcamera/buffer.cpp b/src/libcamera/framebuffer.cpp similarity index 97% rename from src/libcamera/buffer.cpp rename to src/libcamera/framebuffer.cpp index e4c345d518da..4bde556c4013 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Google Inc. * - * buffer.cpp - Buffer handling + * framebuffer.cpp - Frame buffer handling */ -#include -#include "libcamera/internal/buffer.h" +#include +#include "libcamera/internal/framebuffer.h" #include #include @@ -16,11 +16,11 @@ #include /** - * \file libcamera/buffer.h - * \brief Buffer handling + * \file libcamera/framebuffer.h + * \brief Frame buffer handling * - * \file libcamera/internal/buffer.h - * \brief Internal buffer handling support + * \file libcamera/internal/framebuffer.h + * \brief Internal frame buffer handling support */ namespace libcamera { diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp index 86a57923286c..695073fd1c1c 100644 --- a/src/libcamera/framebuffer_allocator.cpp +++ b/src/libcamera/framebuffer_allocator.cpp @@ -11,8 +11,8 @@ #include -#include #include +#include #include #include "libcamera/internal/pipeline_handler.h" diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 517e763d40f0..4f08580157f9 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -2,7 +2,6 @@ libcamera_sources = files([ 'bayer_format.cpp', - 'buffer.cpp', 'byte_stream_buffer.cpp', 'camera.cpp', 'camera_controls.cpp', @@ -17,6 +16,7 @@ libcamera_sources = files([ 'device_enumerator_sysfs.cpp', 'file_descriptor.cpp', 'formats.cpp', + 'framebuffer.cpp', 'framebuffer_allocator.cpp', 'geometry.cpp', 'ipa_controls.cpp', diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp index d9a2249b81ff..ce5ccbf18e41 100644 --- a/src/libcamera/pipeline/ipu3/frames.cpp +++ b/src/libcamera/pipeline/ipu3/frames.cpp @@ -7,7 +7,7 @@ #include "frames.h" -#include +#include #include #include "libcamera/internal/pipeline_handler.h" diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082eb1ee1c23..4f1a5985d62f 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -30,10 +30,10 @@ #include #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/buffer.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 00df4f0b3e6b..42911a8fdfdb 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -17,10 +17,10 @@ #include #include -#include #include #include #include +#include #include #include #include diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index 3baf78f9364c..b5e34c4cd0c5 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 0ed172dcd750..c9928d444b04 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -12,9 +12,9 @@ #include #include -#include #include #include +#include #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 518384eb8cf6..5faf3c71ff02 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -12,9 +12,9 @@ #include -#include #include #include +#include #include #include "libcamera/internal/camera_controls.h" diff --git a/src/qcam/dng_writer.h b/src/qcam/dng_writer.h index bf44c879aff7..20905f37ab94 100644 --- a/src/qcam/dng_writer.h +++ b/src/qcam/dng_writer.h @@ -10,9 +10,9 @@ #ifdef HAVE_TIFF #define HAVE_DNG -#include #include #include +#include #include using namespace libcamera; diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 271314614391..85d56ce49abe 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -18,10 +18,10 @@ #include #include -#include #include #include #include +#include #include #include #include diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h index e33dc4525224..46747c227d0c 100644 --- a/src/qcam/viewfinder.h +++ b/src/qcam/viewfinder.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include struct MappedBuffer { void *memory; diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index bce94c87f2fb..4a0f8ca58f29 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include "viewfinder.h" diff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h index d755428887c0..501c72a70dec 100644 --- a/src/qcam/viewfinder_qt.h +++ b/src/qcam/viewfinder_qt.h @@ -14,8 +14,8 @@ #include #include -#include #include +#include #include #include "format_converter.h" diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index dbe0573bd3a4..a095f4e27524 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -14,9 +14,9 @@ #include -#include #include #include +#include #include using namespace libcamera; diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp index 5de8201e45f6..c9479194cb68 100644 --- a/test/mapped-buffer.cpp +++ b/test/mapped-buffer.cpp @@ -9,7 +9,7 @@ #include -#include "libcamera/internal/buffer.h" +#include "libcamera/internal/framebuffer.h" #include "camera_test.h" #include "test.h" diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h index 00c6399d3b8a..e981abf79225 100644 --- a/test/v4l2_subdevice/v4l2_subdevice_test.h +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h @@ -8,7 +8,7 @@ #ifndef __LIBCAMERA_V4L2_SUBDEVICE_TEST_H__ #define __LIBCAMERA_V4L2_SUBDEVICE_TEST_H__ -#include +#include #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp index 91b3e4a0dad6..6af96a983cd0 100644 --- a/test/v4l2_videodevice/buffer_sharing.cpp +++ b/test/v4l2_videodevice/buffer_sharing.cpp @@ -12,7 +12,7 @@ #include -#include +#include #include #include diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp index f12c8bef97f6..805cb610296f 100644 --- a/test/v4l2_videodevice/capture_async.cpp +++ b/test/v4l2_videodevice/capture_async.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp index fe4b3cc6487f..ebf3e245f86b 100644 --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h index 21054561e068..d46540d4861e 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.h +++ b/test/v4l2_videodevice/v4l2_videodevice_test.h @@ -9,7 +9,7 @@ #include -#include +#include #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" From patchwork Sun Jul 4 23:28:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12805 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5C454C3223 for ; Sun, 4 Jul 2021 23:29:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB2F868509; Mon, 5 Jul 2021 01:29:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rXxyKSMu"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 092EE60285 for ; Mon, 5 Jul 2021 01:29:03 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9AB052E4; Mon, 5 Jul 2021 01:29:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625441342; bh=f4mBgqo2UbWxfmCfWGseTbkEI5ADgdXsN4wFD71pwMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXxyKSMujniIruuqqo34MRS0RuTuWnrBGW/fwOu1Q9OlYWWYdKkicd9fTOs63y7Q7 PMQyPv3vTQ7xwuAF7suFqLzlE9ofAynJZYUnJbz28iFdXFco5yJJvSs7mvzV7VyjX+ yiAH+I0DhbkcjnEimnye0kZKUxzasrfWQGpjb8Tw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Jul 2021 02:28:17 +0300 Message-Id: <20210704232817.8205-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> References: <20210704232817.8205-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: framebuffer: Make FrameBuffer class Extensible X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 for 1/3 too Reviewed-by: Umang Jain --- include/libcamera/framebuffer.h | 8 +++--- include/libcamera/internal/framebuffer.h | 13 +++++++++ src/libcamera/framebuffer.cpp | 34 +++++++++++++++--------- src/libcamera/pipeline/ipu3/cio2.cpp | 3 ++- src/libcamera/pipeline/ipu3/frames.cpp | 5 ++-- src/libcamera/request.cpp | 7 ++--- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index baf22a466907..7265e816b036 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -35,8 +35,10 @@ struct FrameMetadata { std::vector planes; }; -class FrameBuffer final +class FrameBuffer final : public Extensible { + LIBCAMERA_DECLARE_PRIVATE(); + public: struct Plane { FileDescriptor fd; @@ -47,8 +49,7 @@ public: const std::vector &planes() const { return planes_; } - Request *request() const { return request_; } - void setRequest(Request *request) { request_ = request; } + Request *request() const; const FrameMetadata &metadata() const { return metadata_; } unsigned int cookie() const { return cookie_; } @@ -63,7 +64,6 @@ private: std::vector planes_; - Request *request_; FrameMetadata metadata_; unsigned int cookie_; diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index 0c76fc62af1d..a11e895d9b88 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -47,6 +47,19 @@ public: MappedFrameBuffer(const FrameBuffer *buffer, int flags); }; +class FrameBuffer::Private : public Extensible::Private +{ + LIBCAMERA_DECLARE_PUBLIC(FrameBuffer) + +public: + Private(FrameBuffer *buffer); + + void setRequest(Request *request) { request_ = request; } + +private: + Request *request_; +}; + } /* namespace libcamera */ #endif /* __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ */ diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 4bde556c4013..5e13e281fb8c 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,12 @@ 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 */ +Request *FrameBuffer::request() const +{ + const Private *const d = LIBCAMERA_D_PTR(); -/** - * \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. - */ + return d->request_; +} /** * \fn FrameBuffer::metadata() diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 1be2cbcd5cac..1bcd580e251c 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -14,6 +14,7 @@ #include #include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/v4l2_subdevice.h" @@ -278,7 +279,7 @@ FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer) buffer = availableBuffers_.front(); availableBuffers_.pop(); - buffer->setRequest(request); + buffer->_d()->setRequest(request); } int ret = output_->queueBuffer(buffer); diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp index ce5ccbf18e41..a4c3477cd9ef 100644 --- a/src/libcamera/pipeline/ipu3/frames.cpp +++ b/src/libcamera/pipeline/ipu3/frames.cpp @@ -10,6 +10,7 @@ #include #include +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/v4l2_videodevice.h" @@ -56,8 +57,8 @@ IPU3Frames::Info *IPU3Frames::create(Request *request) FrameBuffer *paramBuffer = availableParamBuffers_.front(); FrameBuffer *statBuffer = availableStatBuffers_.front(); - paramBuffer->setRequest(request); - statBuffer->setRequest(request); + paramBuffer->_d()->setRequest(request); + statBuffer->_d()->setRequest(request); availableParamBuffers_.pop(); availableStatBuffers_.pop(); diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 5faf3c71ff02..c095c9f45b09 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -18,6 +18,7 @@ #include #include "libcamera/internal/camera_controls.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/tracepoints.h" /** @@ -121,7 +122,7 @@ void Request::reuse(ReuseFlag flags) if (flags & ReuseBuffers) { for (auto pair : bufferMap_) { FrameBuffer *buffer = pair.second; - buffer->setRequest(this); + buffer->_d()->setRequest(this); pending_.insert(buffer); } } else { @@ -191,7 +192,7 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer) return -EEXIST; } - buffer->setRequest(this); + buffer->_d()->setRequest(this); pending_.insert(buffer); bufferMap_[stream] = buffer; @@ -336,7 +337,7 @@ bool Request::completeBuffer(FrameBuffer *buffer) int ret = pending_.erase(buffer); ASSERT(ret == 1); - buffer->setRequest(nullptr); + buffer->_d()->setRequest(nullptr); if (buffer->metadata().status == FrameMetadata::FrameCancelled) cancelled_ = true;