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#include <cassert>
7#include <cstdint>
8
9namespace openmsx {
10
14class RawFrame final : public FrameSource
15{
16public:
17 using Pixel = uint32_t;
18
19 RawFrame(unsigned maxWidth, unsigned height);
20
21 [[nodiscard]] std::span<Pixel> getLineDirect(unsigned y) {
22 assert(y < getHeight());
23 return {reinterpret_cast<Pixel*>(data.data() + y * pitch), maxWidth};
24 }
25
26 [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
27 assert(y < getHeight());
28 return lineWidths[y];
29 }
30
31 inline void setLineWidth(unsigned line, unsigned width) {
32 assert(line < getHeight());
33 assert(width <= maxWidth);
34 lineWidths[line] = width;
35 }
36
37 inline void setBlank(unsigned line, Pixel color) {
38 assert(line < getHeight());
39 getLineDirect(line)[0] = color;
40 lineWidths[line] = 1;
41 }
42
43protected:
44 [[nodiscard]] unsigned getLineWidth(unsigned line) const override;
45 [[nodiscard]] const void* getLineInfo(
46 unsigned line, unsigned& width,
47 void* buf, unsigned bufWidth) const override;
48 [[nodiscard]] bool hasContiguousStorage() const override;
49
50private:
52 MemBuffer<unsigned> lineWidths;
53 unsigned maxWidth;
54 unsigned pitch;
55};
56
57} // namespace openmsx
58
59#endif
Interface for getting lines from a video frame.
Definition: FrameSource.hh:18
unsigned getHeight() const
Gets the number of lines in this frame.
Definition: FrameSource.hh:49
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:15
unsigned getLineWidthDirect(unsigned y) const
Definition: RawFrame.hh:26
std::span< Pixel > getLineDirect(unsigned y)
Definition: RawFrame.hh:21
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
Definition: RawFrame.cc:28
RawFrame(unsigned maxWidth, unsigned height)
Definition: RawFrame.cc:7
void setBlank(unsigned line, Pixel color)
Definition: RawFrame.hh:37
bool hasContiguousStorage() const override
Returns true when two consecutive rows are also consecutive in memory.
Definition: RawFrame.cc:43
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
Definition: RawFrame.cc:34
void setLineWidth(unsigned line, unsigned width)
Definition: RawFrame.hh:31
This file implemented 3 utility functions:
Definition: Autofire.cc:9