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 "openmsx.hh"
7 #include <cassert>
8 
9 namespace openmsx {
10 
11 // Used by SDLRasterizer to implement left/right border drawing optimization.
13 {
14  uint32_t color0, color1;
15  byte mode = 0xff; // invalid mode
18  bool masked;
19 };
20 
21 
25 class RawFrame final : public FrameSource
26 {
27 public:
28  RawFrame(const SDL_PixelFormat& format, unsigned maxWidth, unsigned height);
29 
30  template<typename Pixel>
31  Pixel* getLinePtrDirect(unsigned y) {
32  return reinterpret_cast<Pixel*>(data.data() + y * pitch);
33  }
34 
35  unsigned getLineWidthDirect(unsigned y) const {
36  return lineWidths[y];
37  }
38 
39  inline void setLineWidth(unsigned line, unsigned width) {
40  assert(line < getHeight());
41  assert(width <= maxWidth);
42  lineWidths[line] = width;
43  }
44 
45  template <class Pixel>
46  inline void setBlank(unsigned line, Pixel color) {
47  assert(line < getHeight());
48  auto* pixels = getLinePtrDirect<Pixel>(line);
49  pixels[0] = color;
50  lineWidths[line] = 1;
51  }
52 
53  unsigned getRowLength() const override;
54 
55  // RawFrame is mostly agnostic of the border info struct. The only
56  // thing it does is store the information and give access to it.
57  V9958RasterizerBorderInfo& getBorderInfo() { return borderInfo; }
58 
59 protected:
60  unsigned getLineWidth(unsigned line) const override;
61  const void* getLineInfo(
62  unsigned line, unsigned& width,
63  void* buf, unsigned bufWidth) const override;
64  bool hasContiguousStorage() const override;
65 
66 private:
68  MemBuffer<unsigned> lineWidths;
69  unsigned maxWidth;
70  unsigned pitch;
71 
72  V9958RasterizerBorderInfo borderInfo;
73 };
74 
75 } // namespace openmsx
76 
77 #endif
V9958RasterizerBorderInfo & getBorderInfo()
Definition: RawFrame.hh:57
unsigned getLineWidthDirect(unsigned y) const
Definition: RawFrame.hh:35
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
uint32_t Pixel
Interface for getting lines from a video frame.
Definition: FrameSource.hh:14
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setBlank(unsigned line, Pixel color)
Definition: RawFrame.hh:46
Pixel * getLinePtrDirect(unsigned y)
Definition: RawFrame.hh:31
void format(SectorAccessibleDisk &disk, bool dos1)
Format the given disk (= a single partition).
void setLineWidth(unsigned line, unsigned width)
Definition: RawFrame.hh:39