openMSX
RawFrame.hh
Go to the documentation of this file.
1#ifndef RAWFRAME_HH
2#define RAWFRAME_HH
3
4#include "FrameSource.hh"
5#include "MemBuffer.hh"
6
7#include <bit>
8#include <cassert>
9#include <cstdint>
10
11namespace openmsx {
12
16class RawFrame final : public FrameSource
17{
18public:
19 using Pixel = uint32_t;
20
21 RawFrame(unsigned maxWidth, unsigned height);
22
23 [[nodiscard]] std::span<Pixel> getLineDirect(unsigned y) {
24 assert(y < getHeight());
25 return {std::bit_cast<Pixel*>(data.data() + y * pitch), maxWidth};
26 }
27
28 [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
29 assert(y < getHeight());
30 return lineWidths[y];
31 }
32
33 inline void setLineWidth(unsigned line, unsigned width) {
34 assert(line < getHeight());
35 assert(width <= maxWidth);
36 lineWidths[line] = width;
37 }
38
39 inline void setBlank(unsigned line, Pixel color) {
40 assert(line < getHeight());
41 getLineDirect(line)[0] = color;
42 lineWidths[line] = 1;
43 }
44
45private:
46 [[nodiscard]] unsigned getLineWidth(unsigned line) const override;
47 [[nodiscard]] const void* getLineInfo(
48 unsigned line, unsigned& width,
49 void* buf, unsigned bufWidth) const override;
50 [[nodiscard]] bool hasContiguousStorage() const override;
51
52private:
54 MemBuffer<unsigned> lineWidths;
55 unsigned maxWidth;
56 unsigned pitch;
57};
58
59} // namespace openmsx
60
61#endif
Interface for getting lines from a video frame.
unsigned getHeight() const
Gets the number of lines in this frame.
This class manages the lifetime of a block of memory.
Definition MemBuffer.hh:29
const T * data() const
Returns pointer to the start of the memory buffer.
Definition MemBuffer.hh:81
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition RawFrame.hh:17
unsigned getLineWidthDirect(unsigned y) const
Definition RawFrame.hh:28
std::span< Pixel > getLineDirect(unsigned y)
Definition RawFrame.hh:23
void setBlank(unsigned line, Pixel color)
Definition RawFrame.hh:39
void setLineWidth(unsigned line, unsigned width)
Definition RawFrame.hh:33
This file implemented 3 utility functions:
Definition Autofire.cc:11