libcamera/include/libcamera/framebuffer.h
Laurent Pinchart c20d3f5575 libcamera: framebuffer: Move remaining private data to Private class
Private members of the FrameBuffer class are split between FrameBuffer
and FrameBuffer::Private. There was no real justification for this
split, and keeping some members private in the FrameBuffer class causes
multiple issues:

- Future modifications of the FrameBuffer class without breaking the ABI
  may be more difficult.
- Mutable access to members that should not be modified by applications
  require a friend statement, or going through the Private class.

Move all remaining private members to the Private class to address the
first issue, and add a Private::metadata() function to address the
second problem.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-10-10 17:49:49 +03:00

77 lines
1.4 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* framebuffer.h - Frame buffer handling
*/
#pragma once
#include <assert.h>
#include <limits>
#include <memory>
#include <stdint.h>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/shared_fd.h>
#include <libcamera/base/span.h>
namespace libcamera {
class Fence;
class Request;
struct FrameMetadata {
enum Status {
FrameSuccess,
FrameError,
FrameCancelled,
};
struct Plane {
unsigned int bytesused;
};
Status status;
unsigned int sequence;
uint64_t timestamp;
Span<Plane> planes() { return planes_; }
Span<const Plane> planes() const { return planes_; }
private:
friend class FrameBuffer;
std::vector<Plane> planes_;
};
class FrameBuffer final : public Extensible
{
LIBCAMERA_DECLARE_PRIVATE()
public:
struct Plane {
static constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();
SharedFD fd;
unsigned int offset = kInvalidOffset;
unsigned int length;
};
FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);
FrameBuffer(std::unique_ptr<Private> d);
const std::vector<Plane> &planes() const;
Request *request() const;
const FrameMetadata &metadata() const;
uint64_t cookie() const;
void setCookie(uint64_t cookie);
std::unique_ptr<Fence> releaseFence();
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(FrameBuffer)
};
} /* namespace libcamera */