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 
8 namespace openmsx {
9 
13 class RawFrame final : public FrameSource
14 {
15 public:
16  RawFrame(const PixelFormat& format, unsigned maxWidth, unsigned height);
17 
18  template<typename Pixel>
19  [[nodiscard]] Pixel* getLinePtrDirect(unsigned y) {
20  return reinterpret_cast<Pixel*>(data.data() + y * pitch);
21  }
22 
23  [[nodiscard]] unsigned getLineWidthDirect(unsigned y) const {
24  return lineWidths[y];
25  }
26 
27  inline void setLineWidth(unsigned line, unsigned width) {
28  assert(line < getHeight());
29  assert(width <= maxWidth);
30  lineWidths[line] = width;
31  }
32 
33  template<typename Pixel>
34  inline void setBlank(unsigned line, Pixel color) {
35  assert(line < getHeight());
36  auto* pixels = getLinePtrDirect<Pixel>(line);
37  pixels[0] = color;
38  lineWidths[line] = 1;
39  }
40 
41  [[nodiscard]] unsigned getRowLength() const override;
42 
43 protected:
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 
50 private:
52  MemBuffer<unsigned> lineWidths;
53  unsigned maxWidth;
54  unsigned pitch;
55 };
56 
57 } // namespace openmsx
58 
59 #endif
openmsx::DiskImageUtils::format
void format(SectorAccessibleDisk &disk, bool dos1)
Format the given disk (= a single partition).
Definition: DiskImageUtils.cc:189
FrameSource.hh
openmsx::RawFrame::getLineWidthDirect
unsigned getLineWidthDirect(unsigned y) const
Definition: RawFrame.hh:23
openmsx::RawFrame::RawFrame
RawFrame(const PixelFormat &format, unsigned maxWidth, unsigned height)
Definition: RawFrame.cc:6
openmsx::PixelFormat
Definition: PixelFormat.hh:9
openmsx::RawFrame::getLineInfo
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
Definition: RawFrame.cc:40
openmsx::Pixel
uint32_t Pixel
Definition: GLHQLiteScaler.cc:98
openmsx::MemBuffer< char, 64 >
openmsx::RawFrame::hasContiguousStorage
bool hasContiguousStorage() const override
Returns true when two consecutive rows are also consecutive in memory.
Definition: RawFrame.cc:54
openmsx::RawFrame
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:14
MemBuffer.hh
openmsx::FrameSource::getHeight
unsigned getHeight() const
Gets the number of lines in this frame.
Definition: FrameSource.hh:44
openmsx::RawFrame::setLineWidth
void setLineWidth(unsigned line, unsigned width)
Definition: RawFrame.hh:27
openmsx::RawFrame::getLinePtrDirect
Pixel * getLinePtrDirect(unsigned y)
Definition: RawFrame.hh:19
openmsx::FrameSource
Interface for getting lines from a video frame.
Definition: FrameSource.hh:15
openmsx::MemBuffer::data
const T * data() const
Returns pointer to the start of the memory buffer.
Definition: MemBuffer.hh:81
openmsx::RawFrame::getRowLength
unsigned getRowLength() const override
Returns the distance (in pixels) between two consecutive lines.
Definition: RawFrame.cc:49
openmsx::RawFrame::getLineWidth
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
Definition: RawFrame.cc:34
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::RawFrame::setBlank
void setBlank(unsigned line, Pixel color)
Definition: RawFrame.hh:34