From patchwork Mon Nov 1 07:16:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14433 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 94C34C324E for ; Mon, 1 Nov 2021 07:17:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE520600C9; Mon, 1 Nov 2021 08:17:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="EAMKVYT3"; dkim-atps=neutral Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 862BC600BD for ; Mon, 1 Nov 2021 08:17:01 +0100 (CET) Received: by mail-pg1-x533.google.com with SMTP id 75so16468568pga.3 for ; Mon, 01 Nov 2021 00:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2glnQsNPM3DcbbpvdGpPNleGnA7CSlP3RH/MuoYhCnQ=; b=EAMKVYT3pA/fLIBP2+/Vix92t5SxLFT6yDIh6ysqupjpqZ4+Ur3+dRINqWz2tT0oB4 wcAyf5qo1yAwYjpzbmW8uJsMx/GvEtI+NolwHXcFww7WA0wDHkr7/uZBOZV/2FuJJMGJ vORwiOW+sEaJOf5kGPnPhK72BJlV6SLCaLl0g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2glnQsNPM3DcbbpvdGpPNleGnA7CSlP3RH/MuoYhCnQ=; b=0QOi1xFXUoG7yTs6RZtP/iJ9/EQEINrOGT+lSKfP63pqlEOVdYF//H7hzKtIqkgLEN zSqtf0KsktkckXQUmXtyeQTd/zQa/ccRe1Okrj8Je75J+spAeHp6WoW7uOKmtnUL80kl V05Ilw+HB7h20HB5zXThoKGBkv7kLHQgOQffRlCjIsn0uCGuhUUmcikIFNHVTIyGypoV uNwS66/zfcv9N0qg5v5LSpof5VMHBblCWzupI6ulhwcpF5Lu4SIPVSTJ0OfW0ZSMER6l FwHV5UHOUPOVGga7OOonD3LLuHzlIjx40XLbnv6Nn6KKUD4RfWhHRg/Zb5MuHuIviwEA zj1A== X-Gm-Message-State: AOAM530pG5/gxGBAgcvfnRu2MGsNiMTnRMBTHbpU1muIHie9tjjHmhaw u+fcxtaaLP+jDyWDcZxAnnpyxhXxn3cUPw== X-Google-Smtp-Source: ABdhPJyGVrv5O0MtQRz6GON34tpRV4n8jEB0XHkxzTFVpriUXFghpdaSH9iiL6jzpNPHbG5N7GnLyQ== X-Received: by 2002:a63:710:: with SMTP id 16mr13096419pgh.324.1635751019898; Mon, 01 Nov 2021 00:16:59 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3b39:f865:c90:680a]) by smtp.gmail.com with ESMTPSA id g14sm11910879pgo.88.2021.11.01.00.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 00:16:59 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Nov 2021 16:16:51 +0900 Message-Id: <20211101071652.107912-2-hiroh@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211101071652.107912-1-hiroh@chromium.org> References: <20211101071652.107912-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: framebuffer: Enable attaching additional data to FrameBuffer 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" 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 Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/framebuffer.h | 3 +++ include/libcamera/internal/framebuffer.h | 1 + src/libcamera/framebuffer.cpp | 26 ++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 7f2f176a..98ef9d5d 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -58,6 +58,9 @@ public: }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); + FrameBuffer(std::unique_ptr d, + const std::vector &planes, unsigned int cookie = 0); + const std::vector &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 d44a98ba..34e6cd4d 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -116,6 +116,15 @@ FrameBuffer::Private::Private() { } +/** + * \fn FrameBuffer::Private::~Private() + * \brief FrameBuffer::Private destructor + * + */ +FrameBuffer::Private::~Private() +{ +} + /** * \fn FrameBuffer::Private::setRequest() * \brief Set the request this buffer belongs to @@ -213,8 +222,21 @@ FrameBuffer::Private::Private() * \param[in] cookie Cookie */ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) - : Extensible(std::make_unique()), planes_(planes), - cookie_(cookie) + : FrameBuffer(std::make_unique(), 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 d, + const std::vector &planes, + unsigned int cookie) + : Extensible(std::move(d)), planes_(planes), cookie_(cookie) { metadata_.planes_.resize(planes_.size());