Loading...
Searching...
No Matches
mapped_framebuffer.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2021, Google Inc.
*
* Frame buffer memory mapping support
*/
#pragma once
#include <stdint.h>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/flags.h>
#include <libcamera/base/span.h>
#include <libcamera/framebuffer.h>
namespace libcamera {
class MappedBuffer
{
public:
using Plane = Span<uint8_t>;
~MappedBuffer();
MappedBuffer(MappedBuffer &&other);
MappedBuffer &operator=(MappedBuffer &&other);
bool isValid() const { return error_ == 0; }
int error() const { return error_; }
const std::vector<Plane> &planes() const { return planes_; }
protected:
MappedBuffer();
int error_;
std::vector<Plane> planes_;
std::vector<Plane> maps_;
private:
LIBCAMERA_DISABLE_COPY(MappedBuffer)
};
class MappedFrameBuffer : public MappedBuffer
{
public:
enum class MapFlag {
Read = 1 << 0,
Write = 1 << 1,
ReadWrite = Read | Write,
};
using MapFlags = Flags<MapFlag>;
MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags);
};
LIBCAMERA_FLAGS_ENABLE_OPERATORS(MappedFrameBuffer::MapFlag)
} /* namespace libcamera */
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DISABLE_COPY
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Definition class.h:27
libcamera::Flags
Type-safe container for enum-based bitfields.
Definition flags.h:16
libcamera::FrameBuffer
Frame buffer data and its associated dynamic metadata.
Definition framebuffer.h:50
libcamera::MappedBuffer::MappedBuffer
MappedBuffer()
Construct an empty MappedBuffer.
Definition mapped_framebuffer.cpp:53
libcamera::MappedBuffer::error
int error() const
Retrieve the map error status.
Definition mapped_framebuffer.h:32
libcamera::MappedBuffer::isValid
bool isValid() const
Check if the MappedBuffer instance is valid.
Definition mapped_framebuffer.h:31
libcamera::MappedBuffer::planes_
std::vector< Plane > planes_
Stores the internal mapped planes.
Definition mapped_framebuffer.h:39
libcamera::MappedBuffer::MappedBuffer
MappedBuffer(MappedBuffer &&other)
Move constructor, construct the MappedBuffer with the contents of other using move semantics.
Definition mapped_framebuffer.cpp:68
libcamera::MappedBuffer::operator=
MappedBuffer & operator=(MappedBuffer &&other)
Move assignment operator, replace the mappings with those of other.
Definition mapped_framebuffer.cpp:82
libcamera::MappedBuffer::error_
int error_
Stores the error value if present.
Definition mapped_framebuffer.h:38
libcamera::MappedBuffer::maps_
std::vector< Plane > maps_
Stores the mapped buffer.
Definition mapped_framebuffer.h:40
libcamera::MappedBuffer::Plane
Span< uint8_t > Plane
A mapped region of memory accessible to the CPU.
Definition mapped_framebuffer.h:24
libcamera::MappedBuffer::planes
const std::vector< Plane > & planes() const
Retrieve the mapped planes.
Definition mapped_framebuffer.h:33
libcamera::MappedFrameBuffer::MapFlag
MapFlag
Specify the mapping mode for the FrameBuffer.
Definition mapped_framebuffer.h:49
libcamera::MappedFrameBuffer::MapFlag::Write
@ Write
Create a write-only mapping.
Definition mapped_framebuffer.h:51
libcamera::MappedFrameBuffer::MapFlag::ReadWrite
@ ReadWrite
Create a mapping that can be both read and written.
Definition mapped_framebuffer.h:52
libcamera::MappedFrameBuffer::MapFlag::Read
@ Read
Create a read-only mapping.
Definition mapped_framebuffer.h:50
libcamera::MappedFrameBuffer::MappedFrameBuffer
MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)
Map all planes of a FrameBuffer.
Definition mapped_framebuffer.cpp:180
libcamera::MappedFrameBuffer::MapFlags
Flags< MapFlag > MapFlags
A bitwise combination of MappedFrameBuffer::MapFlag values.
Definition mapped_framebuffer.h:55
flags.h
Enum-based bit fields.
LIBCAMERA_FLAGS_ENABLE_OPERATORS
#define LIBCAMERA_FLAGS_ENABLE_OPERATORS(_enum)
Enable bitwise operations on the enum enumeration.
Definition flags.h:189
framebuffer.h
Frame buffer handling.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17