openMSX
RawFrame.hh
Go to the documentation of this file.
1#ifndef RAWFRAME_HH
2#define RAWFRAME_HH
3
4#include "FrameSource.hh"
5
6#include "MemBuffer.hh"
7
8#include <cassert>
9
10namespace openmsx {
11
15class RawFrame final : public FrameSource
16{
17public:
18 RawFrame(unsigned maxWidth, unsigned height);
19
20 [[nodiscard]] std::span<Pixel> getLineDirect(unsigned y) {
21 assert(y < getHeight());
22 return {data.data() + y * size_t(maxWidth), maxWidth};
23 }
24 [[nodiscard]] std::span<const Pixel> getLineDirect(unsigned y) const {
25 return const_cast<RawFrame*>(this)->getLineDirect(y);
26 }
27
28 [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
29 assert(y < getHeight());
30 return lineWidths[y];
31 }
32
33 void setLineWidth(unsigned line, unsigned width) {
34 assert(line < getHeight());
35 assert(width <= maxWidth);
36 lineWidths[line] = width;
37 }
38
39 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]] std::span<const Pixel> getUnscaledLine(
48 unsigned line, std::span<Pixel> helpBuf) const override;
49 [[nodiscard]] bool hasContiguousStorage() const override;
50
51private:
52 MemBuffer<Pixel, 64> data; // aligned on cache-lines
53 MemBuffer<unsigned> lineWidths;
54 unsigned maxWidth; // may be larger (rounded up) than requested in the constructor
55};
56
57} // namespace openmsx
58
59#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:16
unsigned getLineWidthDirect(unsigned y) const
Definition RawFrame.hh:28
std::span< Pixel > getLineDirect(unsigned y)
Definition RawFrame.hh:20
void setBlank(unsigned line, Pixel color)
Definition RawFrame.hh:39
std::span< const Pixel > getLineDirect(unsigned y) const
Definition RawFrame.hh:24
void setLineWidth(unsigned line, unsigned width)
Definition RawFrame.hh:33
This file implemented 3 utility functions:
Definition Autofire.cc:11