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 <concepts>
12#include <memory>
13
14namespace openmsx {
15
16class Display;
17class VDP;
18class VDPVRAM;
19class OutputSurface;
20class RawFrame;
21class RenderSettings;
22class Setting;
23class PostProcessor;
24
28template<std::unsigned_integral Pixel>
29class SDLRasterizer final : public Rasterizer
30 , private Observer<Setting>
31{
32public:
33 SDLRasterizer(const SDLRasterizer&) = delete;
35
37 VDP& vdp, Display& display, OutputSurface& screen,
38 std::unique_ptr<PostProcessor> postProcessor);
39 ~SDLRasterizer() override;
40
41 // Rasterizer interface:
42 [[nodiscard]] PostProcessor* getPostProcessor() const override;
43 [[nodiscard]] bool isActive() override;
44 void reset() override;
45 void frameStart(EmuTime::param time) override;
46 void frameEnd() override;
47 void setDisplayMode(DisplayMode mode) override;
48 void setPalette(unsigned index, int grb) override;
49 void setBackgroundColor(int index) override;
50 void setHorizontalAdjust(int adjust) override;
51 void setHorizontalScrollLow(byte scroll) override;
52 void setBorderMask(bool masked) override;
53 void setTransparency(bool enabled) override;
54 void setSuperimposeVideoFrame(const RawFrame* videoSource) override;
55 void drawBorder(int fromX, int fromY, int limitX, int limitY) override;
56 void drawDisplay(
57 int fromX, int fromY,
58 int displayX, int displayY,
59 int displayWidth, int displayHeight) override;
60 void drawSprites(
61 int fromX, int fromY,
62 int displayX, int displayY,
63 int displayWidth, int displayHeight) override;
64 [[nodiscard]] bool isRecording() const override;
65
66private:
67 inline void renderBitmapLine(std::span<Pixel> buf, unsigned vramLine);
68
71 void resetPalette();
72
77 void precalcPalette();
78
83 void precalcColorIndex0(DisplayMode mode, bool transparency,
84 const RawFrame* superimposing, byte bgcolorIndex);
85
86 // Get the border color(s). These are 16bpp or 32bpp host pixels.
87 std::pair<Pixel, Pixel> getBorderColors();
88
89 // Observer<Setting>
90 void update(const Setting& setting) noexcept override;
91
92private:
95 VDP& vdp;
96
99 VDPVRAM& vram;
100
103 OutputSurface& screen;
104
108 const std::unique_ptr<PostProcessor> postProcessor;
109
112 std::unique_ptr<RawFrame> workFrame;
113
116 RenderSettings& renderSettings;
117
120 CharacterConverter<Pixel> characterConverter;
121
124 BitmapConverter<Pixel> bitmapConverter;
125
128 SpriteConverter<Pixel> spriteConverter;
129
133 int lineRenderTop;
134
142 std::array<Pixel, 16 * 2> palFg;
143 std::array<Pixel, 16> palBg;
144
147 std::array<Pixel, 16> palGraphic7Sprites;
148
152 std::array<std::array<std::array<Pixel, 8>, 8>, 8> V9938_COLORS;
153
157 std::array<Pixel, 256> PALETTE256;
158
161 std::array<Pixel, 32768> V9958_COLORS;
162};
163
164} // namespace openmsx
165
166#endif
BaseSetting * setting
Definition: Interpreter.cc:28
Utility class for converting VRAM contents to host pixels.
Utility class for converting VRAM contents to host pixels.
Represents a VDP display mode.
Definition: DisplayMode.hh:16
Represents the output window/screen of openMSX.
Definition: Display.hh:33
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
A frame buffer where pixels can be written to.
Abstract base class for post processors.
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:15
Class containing all settings for renderers.
Rasterizer using a frame buffer approach: it writes pixels to a single rectangular pixel buffer.
void setHorizontalScrollLow(byte scroll) override
void setDisplayMode(DisplayMode mode) override
Precalc several values that depend on the display mode.
void setTransparency(bool enabled) override
void setHorizontalAdjust(int adjust) override
SDLRasterizer & operator=(const SDLRasterizer &)=delete
void setBackgroundColor(int index) override
Changes the background color.
bool isRecording() const override
Is video recording active?
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 reset() override
Resynchronize with VDP: all cached states are flushed.
void setPalette(unsigned index, int grb) override
Change an entry in the palette.
void drawBorder(int fromX, int fromY, int limitX, int limitY) override
Render a rectangle of border pixels on the host screen.
void setSuperimposeVideoFrame(const RawFrame *videoSource) override
void frameEnd() override
Indicates the end of the current frame.
void frameStart(EmuTime::param time) override
Indicates the start of a new frame.
void setBorderMask(bool masked) override
bool isActive() override
Will the output of this Rasterizer be displayed? There is no point in producing a frame that will not...
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.
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor().
SDLRasterizer(const SDLRasterizer &)=delete
Utility class for converting VRAM contents to host pixels.
Manages VRAM contents and synchronizes the various users of the VRAM.
Definition: VDPVRAM.hh:387
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:64
This file implemented 3 utility functions:
Definition: Autofire.cc:9