| e8555c89 Andy McCall |
1 |
#ifndef PIXELRENDERER_HH |
| 2 |
#define PIXELRENDERER_HH |
| 3 |
|
| 4 |
#include "RenderSettings.hh" |
| 5 |
#include "Renderer.hh" |
| 6 |
|
| 7 |
#include "Observer.hh" |
| 8 |
|
| 9 |
#include <cstdint> |
| 10 |
#include <memory> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
class EventDistributor; |
| 15 |
class RealTime; |
| 16 |
class SpeedManager; |
| 17 |
class ThrottleManager; |
| 18 |
class Display; |
| 19 |
class Rasterizer; |
| 20 |
class VDP; |
| 21 |
class VDPVRAM; |
| 22 |
class SpriteChecker; |
| 23 |
class DisplayMode; |
| 24 |
class Setting; |
| 25 |
class VideoSourceSetting; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class PixelRenderer final : public Renderer, private Observer<Setting> |
| 31 |
{ |
| 32 |
public: |
| 33 |
PixelRenderer(VDP& vdp, Display& display); |
| 34 |
~PixelRenderer() override; |
| 35 |
|
| 36 |
|
| 37 |
[[nodiscard]] PostProcessor* getPostProcessor() const override; |
| 38 |
[[nodiscard]] const RawFrame* getWorkingFrame(EmuTime time) override; |
| 39 |
[[nodiscard]] const RawFrame* getLastFrame() const override; |
| 40 |
void reInit() override; |
| 41 |
void frameStart(EmuTime time) override; |
| 42 |
void frameEnd(EmuTime time) override; |
| 43 |
void updateHorizontalScrollLow(uint8_t scroll, EmuTime time) override; |
| 44 |
void updateHorizontalScrollHigh(uint8_t scroll, EmuTime time) override; |
| 45 |
void updateBorderMask(bool masked, EmuTime time) override; |
| 46 |
void updateMultiPage(bool multiPage, EmuTime time) override; |
| 47 |
void updateTransparency(bool enabled, EmuTime time) override; |
| 48 |
void updateSuperimposing(const RawFrame* videoSource, EmuTime time) override; |
| 49 |
void updateForegroundColor(uint8_t color, EmuTime time) override; |
| 50 |
void updateBackgroundColor(uint8_t color, EmuTime time) override; |
| 51 |
void updateBlinkForegroundColor(uint8_t color, EmuTime time) override; |
| 52 |
void updateBlinkBackgroundColor(uint8_t color, EmuTime time) override; |
| 53 |
void updateBlinkState(bool enabled, EmuTime time) override; |
| 54 |
void updatePalette(unsigned index, int grb, EmuTime time) override; |
| 55 |
void updateVerticalScroll(int scroll, EmuTime time) override; |
| 56 |
void updateHorizontalAdjust(int adjust, EmuTime time) override; |
| 57 |
void updateLineZero(EmuTime time) override; |
| 58 |
void updateDisplayEnabled(bool enabled, EmuTime time) override; |
| 59 |
void updateDisplayMode(DisplayMode mode, EmuTime time) override; |
| 60 |
void updateNameBase(unsigned addr, EmuTime time) override; |
| 61 |
void updatePatternBase(unsigned addr, EmuTime time) override; |
| 62 |
void updateColorBase(unsigned addr, EmuTime time) override; |
| 63 |
void updateSpritesEnabled(bool enabled, EmuTime time) override; |
| 64 |
void updateVRAM(unsigned offset, EmuTime time) override; |
| 65 |
void updateWindow(bool enabled, EmuTime time) override; |
| 66 |
|
| 67 |
private: |
| 68 |
|
| 69 |
enum DrawType : uint8_t { DRAW_BORDER, DRAW_DISPLAY }; |
| 70 |
|
| 71 |
|
| 72 |
void update(const Setting& setting) noexcept override; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
void draw( |
| 78 |
int startX, int startY, int endX, int endY, DrawType drawType, |
| 79 |
bool atEnd); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
void subdivide( |
| 89 |
int startX, int startY, int endX, int endY, |
| 90 |
int clipL, int clipR, DrawType drawType); |
| 91 |
|
| 92 |
[[nodiscard]] bool checkSync(unsigned offset, EmuTime time) const; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
void sync(EmuTime time, bool force = false); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
void renderUntil(EmuTime time); |
| 108 |
|
| 109 |
private: |
| 110 |
|
| 111 |
|
| 112 |
VDP& vdp; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
VDPVRAM& vram; |
| 117 |
|
| 118 |
EventDistributor& eventDistributor; |
| 119 |
RealTime& realTime; |
| 120 |
SpeedManager& speedManager; |
| 121 |
ThrottleManager& throttleManager; |
| 122 |
RenderSettings& renderSettings; |
| 123 |
VideoSourceSetting& videoSourceSetting; |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
SpriteChecker& spriteChecker; |
| 128 |
|
| 129 |
const std::unique_ptr<Rasterizer> rasterizer; |
| 130 |
|
| 131 |
float finishFrameDuration = 0.0f; |
| 132 |
float frameSkipCounter = 999.0f; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
int nextX; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
int nextY; |
| 143 |
|
| 144 |
|
| 145 |
int textModeCounter; |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
int renderScroll = 0; |
| 153 |
int pendingScroll = 0; |
| 154 |
int pendingScrollTicks = -1; |
| 155 |
void applyPendingScroll(EmuTime time); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
RenderSettings::Accuracy accuracy; |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
bool displayEnabled; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
bool renderFrame; |
| 170 |
bool prevRenderFrame = false; |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
bool paintFrame; |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
uint64_t lastPaintTime = 0; |
| 183 |
}; |
| 184 |
|
| 185 |
} |
| 186 |
|
| 187 |
#endif |