OXYGENHUB
◆ main openmsx / src / video / RawFrame.hh
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef RAWFRAME_HH
2
#define RAWFRAME_HH
3
4
#include "FrameSource.hh"
5
6
#include "MemBuffer.hh"
7
8
#include <cassert>
9
10
namespace openmsx {
11
12
/** A video frame as output by the VDP scanline conversion unit,
13
  * before any postprocessing filters are applied.
14
  */
15
class RawFrame final : public FrameSource
16
{
17
public:
18
	RawFrame(unsigned maxWidth, unsigned height);
19
20
	[[nodiscard]] std::span<Pixel> getLineDirect(unsigned y) {
21
		assert(y < getHeight());
22
		return data.subspan(y * size_t(maxWidth), maxWidth);
23
	}
24
	[[nodiscard]] std::span<const Pixel> getLineDirect(unsigned y) const {
25
		assert(y < getHeight());
26
		return data.subspan(y * size_t(maxWidth), maxWidth);
27
	}
28
29
	[[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
30
		assert(y < getHeight());
31
		return lineWidths[y];
32
	}
33
34
	void setLineWidth(unsigned line, unsigned width) {
35
		assert(line < getHeight());
36
		assert(width <= maxWidth);
37
		lineWidths[line] = width;
38
	}
39
40
	void setBlank(unsigned line, Pixel color) {
41
		assert(line < getHeight());
42
		getLineDirect(line)[0] = color;
43
		lineWidths[line] = 1;
44
	}
45
46
private:
47
	[[nodiscard]] unsigned getLineWidth(unsigned line) const override;
48
	[[nodiscard]] std::span<const Pixel> getUnscaledLine(
49
		unsigned line, std::span<Pixel> helpBuf) const override;
50
	[[nodiscard]] bool hasContiguousStorage() const override;
51
52
private:
53
	MemBuffer<Pixel, 64> data; // aligned on cache-lines
54
	MemBuffer<unsigned> lineWidths;
55
	unsigned maxWidth; // may be larger (rounded up) than requested in the constructor
56
};
57
58
} // namespace openmsx
59
60
#endif