openMSX
SDLRasterizer.hh
Go to the documentation of this file.
1#ifndef SDLRASTERIZER_HH
2#define SDLRASTERIZER_HH
3
4#include "Rasterizer.hh"
5#include "BitmapConverter.hh"
7#include "SpriteConverter.hh"
8#include "Observer.hh"
9#include "openmsx.hh"
10#include <array>
11#include <cstdint>
12#include <memory>
13
14namespace openmsx {
15
16class Display;
17class VDP;
18class VDPVRAM;
19class OutputSurface;
20class RawFrame;
21class RenderSettings;
22class Setting;
23class PostProcessor;
24
28class SDLRasterizer final : public Rasterizer
29 , private Observer<Setting>
30{
31public:
32 using Pixel = uint32_t;
33
35 VDP& vdp, Display& display, OutputSurface& screen,
36 std::unique_ptr<PostProcessor> postProcessor);
37 SDLRasterizer(const SDLRasterizer&) = delete;
41 ~SDLRasterizer() override;
42
43 // Rasterizer interface:
44 [[nodiscard]] PostProcessor* getPostProcessor() const override;
45 [[nodiscard]] bool isActive() override;
46 void reset() override;
47 void frameStart(EmuTime::param time) override;
48 void frameEnd() override;
49 void setDisplayMode(DisplayMode mode) override;
50 void setPalette(unsigned index, int grb) override;
51 void setBackgroundColor(byte index) override;
52 void setHorizontalAdjust(int adjust) override;
53 void setHorizontalScrollLow(byte scroll) override;
54 void setBorderMask(bool masked) override;
55 void setTransparency(bool enabled) override;
56 void setSuperimposeVideoFrame(const RawFrame* videoSource) override;
57 void drawBorder(int fromX, int fromY, int limitX, int limitY) override;
58 void drawDisplay(
59 int fromX, int fromY,
60 int displayX, int displayY,
61 int displayWidth, int displayHeight) override;
62 void drawSprites(
63 int fromX, int fromY,
64 int displayX, int displayY,
65 int displayWidth, int displayHeight) override;
66 [[nodiscard]] bool isRecording() const override;
67
68private:
69 inline void renderBitmapLine(std::span<Pixel> buf, unsigned vramLine);
70
73 void resetPalette();
74
79 void precalcPalette();
80
85 void precalcColorIndex0(DisplayMode mode, bool transparency,
86 const RawFrame* superimposing, byte bgcolorIndex);
87
88 // Get the border color(s). These are 16bpp or 32bpp host pixels.
89 std::pair<Pixel, Pixel> getBorderColors();
90
91 // Observer<Setting>
92 void update(const Setting& setting) noexcept override;
93
94private:
97 VDP& vdp;
98
101 VDPVRAM& vram;
102
105 OutputSurface& screen;
106
110 const std::unique_ptr<PostProcessor> postProcessor;
111
114 std::unique_ptr<RawFrame> workFrame;
115
118 RenderSettings& renderSettings;
119
122 CharacterConverter characterConverter;
123
126 BitmapConverter bitmapConverter;
127
130 SpriteConverter spriteConverter;
131
135 int lineRenderTop;
136
144 std::array<Pixel, 16 * 2> palFg;
145 std::array<Pixel, 16> palBg;
146
149 std::array<Pixel, 16> palGraphic7Sprites;
150
154 std::array<std::array<std::array<Pixel, 8>, 8>, 8> V9938_COLORS;
155
159 std::array<Pixel, 256> PALETTE256;
160
163 std::array<Pixel, 32768> V9958_COLORS;
164};
165
166} // namespace openmsx
167
168#endif
BaseSetting * setting
Utility class for converting VRAM contents to host pixels.
Utility class for converting VRAM contents to host pixels.
Represents a VDP display mode.
Represents the output window/screen of openMSX.
Definition Display.hh:32
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
A frame buffer where pixels can be written to.
A post processor builds the frame that is displayed from the MSX frame, while applying effects such a...
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition RawFrame.hh:16
Class containing all settings for renderers.
Rasterizer using a frame buffer approach: it writes pixels to a single rectangular pixel buffer.
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor().
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
void setBackgroundColor(byte index) override
Changes the background color.
SDLRasterizer & operator=(const SDLRasterizer &)=delete
void drawDisplay(int fromX, int fromY, int displayX, int displayY, int displayWidth, int displayHeight) override
Render a rectangle of display pixels on the host screen.
void setPalette(unsigned index, int grb) override
Change an entry in the palette.
void frameEnd() override
Indicates the end of the current frame.
SDLRasterizer(const SDLRasterizer &)=delete
void setBorderMask(bool masked) override
void frameStart(EmuTime::param time) override
Indicates the start of a new frame.
void setHorizontalAdjust(int adjust) override
void setDisplayMode(DisplayMode mode) override
Precalc several values that depend on the display mode.
SDLRasterizer(SDLRasterizer &&)=delete
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
void drawSprites(int fromX, int fromY, int displayX, int displayY, int displayWidth, int displayHeight) override
Render a rectangle of sprite pixels on the host screen.
void reset() override
Resynchronize with VDP: all cached states are flushed.
bool isRecording() const override
Is video recording active?
SDLRasterizer & operator=(SDLRasterizer &&)=delete
void setTransparency(bool enabled) override
void setSuperimposeVideoFrame(const RawFrame *videoSource) override
void setHorizontalScrollLow(byte scroll) override
Utility class for converting VRAM contents to host pixels.
Manages VRAM contents and synchronizes the various users of the VRAM.
Definition VDPVRAM.hh:399
Unified implementation of MSX Video Display Processors (VDPs).
Definition VDP.hh:66
This file implemented 3 utility functions:
Definition Autofire.cc:11