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 <concepts>
8
9namespace openmsx {
10
14class RawFrame final : public FrameSource
15{
16public:
17 RawFrame(const PixelFormat& format, unsigned maxWidth, unsigned height);
18
19 template<std::unsigned_integral Pixel>
20 [[nodiscard]] std::span<Pixel> getLineDirect(unsigned y) {
21 assert(y < getHeight());
22 return {reinterpret_cast<Pixel*>(data.data() + y * pitch), maxWidth};
23 }
24
25 [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
26 assert(y < getHeight());
27 return lineWidths[y];
28 }
29
30 inline void setLineWidth(unsigned line, unsigned width) {
31 assert(line < getHeight());
32 assert(width <= maxWidth);
33 lineWidths[line] = width;
34 }
35
36 template<std::unsigned_integral Pixel>
37 inline void setBlank(unsigned line, Pixel color) {
38 assert(line < getHeight());
39 getLineDirect<Pixel>(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:20
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:25
std::span< Pixel > getLineDirect(unsigned y)
Definition: RawFrame.hh:20
void setBlank(unsigned line, Pixel color)
Definition: RawFrame.hh:37
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
Definition: RawFrame.cc:35
RawFrame(const PixelFormat &format, unsigned maxWidth, unsigned height)
Definition: RawFrame.cc:7
bool hasContiguousStorage() const override
Returns true when two consecutive rows are also consecutive in memory.
Definition: RawFrame.cc:50
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
Definition: RawFrame.cc:41
void setLineWidth(unsigned line, unsigned width)
Definition: RawFrame.hh:30
void format(SectorAccessibleDisk &disk, bool dos1)
Format the given disk (= a single partition).
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel