openMSX
PixelRenderer.hh
Go to the documentation of this file.
1 #ifndef PIXELRENDERER_HH
2 #define PIXELRENDERER_HH
3 
4 #include "Renderer.hh"
5 #include "Observer.hh"
6 #include "RenderSettings.hh"
7 #include "openmsx.hh"
8 #include "noncopyable.hh"
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class EventDistributor;
14 class RealTime;
15 class Display;
16 class Rasterizer;
17 class VDP;
18 class VDPVRAM;
19 class SpriteChecker;
20 class DisplayMode;
21 class Setting;
22 class VideoSourceSetting;
23 
27 class PixelRenderer final : public Renderer, private Observer<Setting>
28  , private noncopyable
29 {
30 public:
31  PixelRenderer(VDP& vdp, Display& display);
33 
34  // Renderer interface:
35  PostProcessor* getPostProcessor() const override;
36  void reInit() override;
37  void frameStart(EmuTime::param time) override;
38  void frameEnd(EmuTime::param time) override;
39  void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override;
40  void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override;
41  void updateBorderMask(bool masked, EmuTime::param time) override;
42  void updateMultiPage(bool multiPage, EmuTime::param time) override;
43  void updateTransparency(bool enabled, EmuTime::param time) override;
44  void updateSuperimposing(const RawFrame* videoSource, EmuTime::param time) override;
45  void updateForegroundColor(int color, EmuTime::param time) override;
46  void updateBackgroundColor(int color, EmuTime::param time) override;
47  void updateBlinkForegroundColor(int color, EmuTime::param time) override;
48  void updateBlinkBackgroundColor(int color, EmuTime::param time) override;
49  void updateBlinkState(bool enabled, EmuTime::param time) override;
50  void updatePalette(int index, int grb, EmuTime::param time) override;
51  void updateVerticalScroll(int scroll, EmuTime::param time) override;
52  void updateHorizontalAdjust(int adjust, EmuTime::param time) override;
53  void updateDisplayEnabled(bool enabled, EmuTime::param time) override;
54  void updateDisplayMode(DisplayMode mode, EmuTime::param time) override;
55  void updateNameBase(int addr, EmuTime::param time) override;
56  void updatePatternBase(int addr, EmuTime::param time) override;
57  void updateColorBase(int addr, EmuTime::param time) override;
58  void updateSpritesEnabled(bool enabled, EmuTime::param time) override;
59  void updateVRAM(unsigned offset, EmuTime::param time) override;
60  void updateWindow(bool enabled, EmuTime::param time) override;
61 
62 private:
64  enum DrawType { DRAW_BORDER, DRAW_DISPLAY };
65 
66  // Observer<Setting> interface:
67  void update(const Setting& setting) override;
68 
72  void draw(
73  int startX, int startY, int endX, int endY, DrawType drawType,
74  bool atEnd);
75 
83  void subdivide(
84  int startX, int startY, int endX, int endY,
85  int clipL, int clipR, DrawType drawType );
86 
87  inline bool checkSync(int offset, EmuTime::param time);
88 
94  void sync(EmuTime::param time, bool force = false);
95 
102  void renderUntil(EmuTime::param time);
103 
106  VDP& vdp;
107 
110  VDPVRAM& vram;
111 
112  EventDistributor& eventDistributor;
113  RealTime& realTime;
114  RenderSettings& renderSettings;
115  VideoSourceSetting& videoSourceSetting;
116 
119  SpriteChecker& spriteChecker;
120 
121  const std::unique_ptr<Rasterizer> rasterizer;
122 
123  double finishFrameDuration;
124  int frameSkipCounter;
125 
129  int nextX;
130 
134  int nextY;
135 
136  // internal VDP counter, actually belongs in VDP
137  int textModeCounter;
138 
141  RenderSettings::Accuracy accuracy;
142 
147  bool displayEnabled;
148 
151  bool renderFrame;
152  bool prevRenderFrame;
153 };
154 
155 } // namespace openmsx
156 
157 #endif
signed char offset
Definition: CPUCore.cc:252
void updateSuperimposing(const RawFrame *videoSource, EmuTime::param time) override
Informs the renderer of a VDP superimposing change.
void updateHorizontalAdjust(int adjust, EmuTime::param time) override
Informs the renderer of a horizontal adjust change.
void updatePalette(int index, int grb, EmuTime::param time) override
Informs the renderer of a VDP palette change.
Represents the output window/screen of openMSX.
Definition: Display.hh:32
PostProcessor * getPostProcessor() const override
See VDP::getPostProcessor.
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
void updateBorderMask(bool masked, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the border mask has been enabled/disabled.
void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the higher scroll value has changed.
Represents a VDP display mode.
Definition: DisplayMode.hh:14
void reInit() override
Reinitialise Renderer state.
void updateColorBase(int addr, EmuTime::param time) override
Informs the renderer of a color table base address change.
void updateBlinkState(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP blinking state change.
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
void updateHorizontalScrollLow(byte scroll, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the lower scroll value has changed.
void updateDisplayMode(DisplayMode mode, EmuTime::param time) override
Informs the renderer of a VDP display mode change.
Abstract base class for Renderers.
Definition: Renderer.hh:22
Generic implementation of a pixel-based Renderer.
Accuracy
Render accuracy: granularity of the rendered area.
void updateVerticalScroll(int scroll, EmuTime::param time) override
Informs the renderer of a vertical scroll change.
void frameEnd(EmuTime::param time) override
Signals the end of a frame.
void updateMultiPage(bool multiPage, EmuTime::param time) override
Informs the renderer of a horizontal scroll change: the multi page setting has changed.
void updateDisplayEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP display enabled change.
void updateTransparency(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP transparency enable/disable change.
PixelRenderer(VDP &vdp, Display &display)
void updateNameBase(int addr, EmuTime::param time) override
Informs the renderer of a name table base address change.
Unified implementation of MSX Video Display Processors (VDPs).
Definition: VDP.hh:66
Abstract base class for post processors.
void updateBlinkBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink background color change.
void updatePatternBase(int addr, EmuTime::param time) override
Informs the renderer of a pattern table base address change.
Class containing all settings for renderers.
Manages VRAM contents and synchronises the various users of the VRAM.
Definition: VDPVRAM.hh:383
void updateForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP foreground color change.
void updateBlinkForegroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP blink foreground color change.
void updateBackgroundColor(int color, EmuTime::param time) override
Informs the renderer of a VDP background color change.
void updateSpritesEnabled(bool enabled, EmuTime::param time) override
Informs the renderer of a VDP sprites enabled change.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
void frameStart(EmuTime::param time) override
Signals the start of a new frame.
void updateWindow(bool enabled, EmuTime::param time) override
Informs the observer that the entire VRAM window will change.
void updateVRAM(unsigned offset, EmuTime::param time) override
Informs the observer of a change in VRAM contents.