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]] Pixel* getLinePtrDirect(unsigned y) {
21 return reinterpret_cast<Pixel*>(data.data() + y * pitch);
22 }
23
24 [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
25 return lineWidths[y];
26 }
27
28 inline void setLineWidth(unsigned line, unsigned width) {
29 assert(line < getHeight());
30 assert(width <= maxWidth);
31 lineWidths[line] = width;
32 }
33
34 template<std::unsigned_integral Pixel>
35 inline void setBlank(unsigned line, Pixel color) {
36 assert(line < getHeight());
37 auto* pixels = getLinePtrDirect<Pixel>(line);
38 pixels[0] = color;
39 lineWidths[line] = 1;
40 }
41
42 [[nodiscard]] unsigned getRowLength() const override;
43
44protected:
45 [[nodiscard]] unsigned getLineWidth(unsigned line) const override;
46 [[nodiscard]] const void* getLineInfo(
47 unsigned line, unsigned& width,
48 void* buf, unsigned bufWidth) const override;
49 [[nodiscard]] bool hasContiguousStorage() const override;
50
51private:
53 MemBuffer<unsigned> lineWidths;
54 unsigned maxWidth;
55 unsigned pitch;
56};
57
58} // namespace openmsx
59
60#endif
Interface for getting lines from a video frame.
Definition: FrameSource.hh:17
unsigned getHeight() const
Gets the number of lines in this frame.
Definition: FrameSource.hh:46
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:24
void setBlank(unsigned line, Pixel color)
Definition: RawFrame.hh:35
unsigned getRowLength() const override
Returns the distance (in pixels) between two consecutive lines.
Definition: RawFrame.cc:50
Pixel * getLinePtrDirect(unsigned y)
Definition: RawFrame.hh:20
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:55
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:28
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