OXYGENHUB
◆ main openmsx / src / video / Rasterizer.hh
4.0 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef RASTERIZER_HH
2
#define RASTERIZER_HH
3
4
#include "DisplayMode.hh"
5
6
#include "EmuTime.hh"
7
8
namespace openmsx {
9
10
class PostProcessor;
11
class RawFrame;
12
13
class Rasterizer
14
{
15
public:
16
	virtual ~Rasterizer() = default;
17
18
	/** See VDP::getPostProcessor(). */
19
	[[nodiscard]] virtual PostProcessor* getPostProcessor() const = 0;
20
21
	/** See VDP::getWorkingFrame() and VDP::getLastFrame() */
22
	[[nodiscard]] virtual const RawFrame* getWorkingFrame() const = 0;
23
	[[nodiscard]] virtual const RawFrame* getLastFrame() const = 0;
24
25
	/** Will the output of this Rasterizer be displayed?
26
	  * There is no point in producing a frame that will not be displayed.
27
	  * TODO: Is querying the next pipeline step the best way to solve this,
28
	  *       or is it better to explicitly disable the first step in the pipeline?
29
	  */
30
	virtual bool isActive() = 0;
31
32
	/** Resynchronize with VDP: all cached states are flushed.
33
	  */
34
	virtual void reset() = 0;
35
36
	/** Indicates the start of a new frame.
37
	  * The rasterizer can fetch per-frame settings from the VDP.
38
	  */
39
	virtual void frameStart(EmuTime time) = 0;
40
41
	/** Indicates the end of the current frame.
42
	  * The rasterizer can perform image post processing.
43
	  */
44
	virtual void frameEnd() = 0;
45
46
	/** Precalc several values that depend on the display mode.
47
	  * @param mode The new display mode.
48
	  */
49
	virtual void setDisplayMode(DisplayMode mode) = 0;
50
51
	/** Change an entry in the palette.
52
	  * @param index The index [0..15] in the palette that changes.
53
	  * @param grb The new definition for the changed palette index:
54
	  *   bit 10..8 is green, bit 6..4 is red and bit 2..0 is blue;
55
	  *   all other bits are zero.
56
	  */
57
	virtual void setPalette(unsigned index, int grb) = 0;
58
59
	/** Changes the background color.
60
	  * @param index Palette index of the new background color.
61
	  */
62
	virtual void setBackgroundColor(uint8_t index) = 0;
63
64
	virtual void setHorizontalAdjust(int adjust) = 0;
65
	virtual void setHorizontalScrollLow(uint8_t scroll) = 0;
66
	virtual void setBorderMask(bool masked) = 0;
67
	virtual void setTransparency(bool enabled) = 0;
68
	virtual void setSuperimposeVideoFrame(const RawFrame* videoSource) = 0;
69
70
	/** Render a rectangle of border pixels on the host screen.
71
	  * The units are absolute lines (Y) and VDP clock ticks (X).
72
	  * @param fromX X coordinate of render start (inclusive).
73
	  * @param fromY Y coordinate of render start (inclusive).
74
	  * @param limitX X coordinate of render end (exclusive).
75
	  * @param limitY Y coordinate of render end (exclusive).
76
	  */
77
	virtual void drawBorder(int fromX, int fromY, int limitX, int limitY) = 0;
78
79
	/** Render a rectangle of display pixels on the host screen.
80
	  * @param fromX X coordinate of render start in VDP ticks.
81
	  * @param fromY Y coordinate of render start in absolute lines.
82
	  * @param displayX display coordinate of render start: [0..512).
83
	  * @param displayY display coordinate of render start: [0..256).
84
	  * @param displayWidth rectangle width in pixels (512 per line).
85
	  * @param displayHeight rectangle height in lines.
86
	  */
87
	virtual void drawDisplay(
88
		int fromX, int fromY,
89
		int displayX, int displayY,
90
		int displayWidth, int displayHeight) = 0;
91
92
	/** Render a rectangle of sprite pixels on the host screen.
93
	  * Although the parameters are very similar to drawDisplay,
94
	  * the displayX and displayWidth use range [0..256) instead of
95
	  * [0..512) because VDP sprite coordinates work that way.
96
	  * @param fromX X coordinate of render start in VDP ticks.
97
	  * @param fromY Y coordinate of render start in absolute lines.
98
	  * @param displayX display coordinate of render start: [0..256).
99
	  * @param displayY display coordinate of render start: [0..256).
100
	  * @param displayWidth rectangle width in pixels (256 per line).
101
	  * @param displayHeight rectangle height in lines.
102
	  */
103
	virtual void drawSprites(
104
		int fromX, int fromY,
105
		int displayX, int displayY,
106
		int displayWidth, int displayHeight) = 0;
107
108
	/** Is video recording active?
109
	  */
110
	[[nodiscard]] virtual bool isRecording() const = 0;
111
112
protected:
113
	Rasterizer() = default;
114
};
115
116
} // namespace openmsx
117
118
#endif