openMSX
VideoLayer.cc
Go to the documentation of this file.
1#include "VideoLayer.hh"
2#include "Display.hh"
3#include "Reactor.hh"
4#include "GlobalSettings.hh"
5#include "BooleanSetting.hh"
7#include "MSXMotherBoard.hh"
8#include "Event.hh"
9#include "one_of.hh"
10
11namespace openmsx {
12
14 const std::string& videoSource_)
15 : motherBoard(motherBoard_)
16 , display(motherBoard.getReactor().getDisplay())
17 , videoSourceSetting(motherBoard.getVideoSource())
18 , videoSourceActivator(videoSourceSetting, videoSource_)
19 , powerSetting(motherBoard.getReactor().getGlobalSettings().getPowerSetting())
20 , video9000Source(0)
21 , activeVideo9000(INACTIVE)
22{
23 calcCoverage();
24 calcZ();
25 display.addLayer(*this);
26
27 videoSourceSetting.attach(*this);
28 powerSetting.attach(*this);
30}
31
33{
35 powerSetting.detach(*this);
36 videoSourceSetting.detach(*this);
37
38 display.removeLayer(*this);
39}
40
42{
43 return videoSourceActivator.getID();
44}
46{
47 return videoSourceSetting.getSource();
48}
49
50void VideoLayer::update(const Setting& setting) noexcept
51{
52 if (&setting == &videoSourceSetting) {
53 calcZ();
54 } else if (&setting == &powerSetting) {
55 calcCoverage();
56 }
57}
58
59void VideoLayer::calcZ()
60{
61 setZ((videoSourceSetting.getSource() == getVideoSource())
64}
65
66void VideoLayer::calcCoverage()
67{
68 auto cov = (!powerSetting.getBoolean() || !motherBoard.isActive())
70 : COVER_FULL;
71 setCoverage(cov);
72}
73
74void VideoLayer::signalMSXEvent(const Event& event,
75 EmuTime::param /*time*/) noexcept
76{
79 calcCoverage();
80 }
81}
82
84{
85 // Either when this layer itself is selected or when the video9000
86 // layer is selected and this layer is needed to render a
87 // (superimposed) image.
88 int current = videoSourceSetting.getSource();
89 return (current == getVideoSource()) ||
90 ((current == video9000Source) && (activeVideo9000 != INACTIVE));
91}
92
94{
95 // Either when this layer itself is selected or when the video9000
96 // layer is selected and this layer is the front layer of a
97 // (superimposed) image
98 int current = videoSourceSetting.getSource();
99 return (current == getVideoSource()) ||
100 ((current == video9000Source) && (activeVideo9000 == ACTIVE_FRONT));
101}
102
103} // namespace openmsx
BaseSetting * setting
Definition: Interpreter.cc:27
Definition: one_of.hh:7
bool getBoolean() const noexcept
void removeLayer(Layer &layer)
Definition: Display.cc:393
void addLayer(Layer &layer)
Definition: Display.cc:385
@ COVER_FULL
Layer fully covers the screen: any underlying layers are invisible.
Definition: Layer.hh:32
@ COVER_NONE
Layer is not visible, that is completely transparent.
Definition: Layer.hh:39
void setZ(ZIndex z)
Changes the current Z-index of this layer.
Definition: Layer.cc:6
@ Z_MSX_ACTIVE
Definition: Layer.hh:21
@ Z_MSX_PASSIVE
Definition: Layer.hh:20
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition: Layer.hh:70
void registerEventListener(MSXEventListener &listener)
Registers a given object to receive certain events.
void unregisterEventListener(MSXEventListener &listener)
Unregisters a previously registered event listener.
MSXEventDistributor & getMSXEventDistributor()
void detach(Observer< T > &observer)
Definition: Subject.hh:56
void attach(Observer< T > &observer)
Definition: Subject.hh:50
int getVideoSource() const
Returns the ID for this videolayer.
Definition: VideoLayer.cc:41
bool needRecord() const
Definition: VideoLayer.cc:93
bool needRender() const
Definition: VideoLayer.cc:83
int getVideoSourceSetting() const
Definition: VideoLayer.cc:45
void update(const Setting &setting) noexcept override
Definition: VideoLayer.cc:50
~VideoLayer() override
Definition: VideoLayer.cc:32
VideoLayer(const VideoLayer &)=delete
This file implemented 3 utility functions:
Definition: Autofire.cc:9
EventType getType(const Event &event)
Definition: Event.hh:644