OXYGENHUB
◆ main openmsx / src / video / VideoLayer.hh
2.8 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef VIDEOLAYER_HH
2
#define VIDEOLAYER_HH
3
4
#include "Layer.hh"
5
6
#include "MSXEventListener.hh"
7
#include "VideoSourceSetting.hh"
8
9
#include "Observer.hh"
10
11
#include <cstdint>
12
#include <optional>
13
#include <string>
14
15
namespace openmsx {
16
17
class MSXMotherBoard;
18
class Display;
19
class Setting;
20
class BooleanSetting;
21
22
class VideoLayer : public Layer, protected Observer<Setting>
23
                 , private MSXEventListener
24
{
25
public:
26
	VideoLayer(const VideoLayer&) = delete;
27
	VideoLayer(VideoLayer&&) = delete;
28
	VideoLayer& operator=(const VideoLayer&) = delete;
29
	VideoLayer& operator=(VideoLayer&&) = delete;
30
31
	/** Returns the ID for this VideoLayer.
32
	  * These IDs are globally unique. The 'videosource' setting uses
33
	  * these IDs as possible values.
34
	  */
35
	[[nodiscard]] int getVideoSource() const;
36
	[[nodiscard]] int getVideoSourceSetting() const;
37
38
	/** Create a raw (=non-post-processed) screenshot. The 'height'
39
	 * parameter should be either '240' or '480' if specified. If not
40
	 * specified, the height will be determined based on the available
41
	 * widths in the raw frame. The result will be scaled to either
42
	 * '320x240' or '640x480' and written to a png file.
43
	 */
44
	virtual void takeRawScreenShot(
45
		std::optional<unsigned> height, const std::string& filename) = 0;
46
47
	// We used to test whether a Layer is active by looking at the
48
	// Z-coordinate (Z_MSX_ACTIVE vs Z_MSX_PASSIVE). Though in case of
49
	// Video9000 it's possible the Video9000 layer is selected, but we
50
	// still need to render this layer (the v99x8 or v9990 layer).
51
	enum class Video9000Active : uint8_t { NO, FRONT, BACK };
52
	void setVideo9000Active(int video9000Source_, Video9000Active active) {
53
		video9000Source = video9000Source_;
54
		activeVideo9000 = active;
55
	}
56
	[[nodiscard]] bool needRender() const;
57
	[[nodiscard]] bool needRecord() const;
58
59
protected:
60
	VideoLayer(MSXMotherBoard& motherBoard,
61
	           const std::string& videoSource);
62
	~VideoLayer() override;
63
64
	// Observer<Setting> interface:
65
	void update(const Setting& setting) noexcept override;
66
67
private:
68
	/** Calculates the current Z coordinate of this layer. */
69
	void calcZ();
70
	/** Calculates the current coverage of this layer. */
71
	void calcCoverage();
72
73
	// MSXEventListener
74
	void signalMSXEvent(const Event& event,
75
	                    EmuTime time) noexcept override;
76
77
private:
78
	/** This layer belongs to a specific machine. */
79
	MSXMotherBoard& motherBoard;
80
	/** Settings shared between all renderers. */
81
	Display& display;
82
	/** Reference to "videosource" setting. */
83
	VideoSourceSetting& videoSourceSetting;
84
	/** Activate the videosource */
85
	VideoSourceActivator videoSourceActivator;
86
	/** Reference to "power" setting. */
87
	BooleanSetting& powerSetting;
88
89
	/** Video source ID of the Video9000 layer. */
90
	int video9000Source = 0;
91
	/** Active when Video9000 is shown. */
92
	Video9000Active activeVideo9000 = Video9000Active::NO;
93
};
94
95
} // namespace openmsx
96
97
#endif