VideoLayer.hh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef VIDEOLAYER_HH
  2. #define VIDEOLAYER_HH
  3. #include "VideoSourceSetting.hh"
  4. #include "Layer.hh"
  5. #include "Observer.hh"
  6. #include "MSXEventListener.hh"
  7. #include <string>
  8. namespace openmsx {
  9. class MSXMotherBoard;
  10. class Display;
  11. class Setting;
  12. class BooleanSetting;
  13. class VideoLayer : public Layer, protected Observer<Setting>
  14. , private MSXEventListener
  15. {
  16. public:
  17. VideoLayer(const VideoLayer&) = delete;
  18. VideoLayer& operator=(const VideoLayer&) = delete;
  19. /** Returns the ID for this videolayer.
  20. * These IDs are globally unique. The 'videosource' setting uses
  21. * these IDs as possible values.
  22. */
  23. int getVideoSource() const;
  24. int getVideoSourceSetting() const;
  25. /** Create a raw (=non-postprocessed) screenshot. The 'height'
  26. * parameter should be either '240' or '480'. The current image will be
  27. * scaled to '320x240' or '640x480' and written to a png file. */
  28. virtual void takeRawScreenShot(
  29. unsigned height, const std::string& filename) = 0;
  30. // We used to test whether a Layer is active by looking at the
  31. // Z-coordinate (Z_MSX_ACTIVE vs Z_MSX_PASSIVE). Though in case of
  32. // Video9000 it's possible the Video9000 layer is selected, but we
  33. // still need to render this layer (the v99x8 or v9990 layer).
  34. enum Video9000Active { INACTIVE, ACTIVE_FRONT, ACTIVE_BACK };
  35. void setVideo9000Active(int video9000Source_, Video9000Active active) {
  36. video9000Source = video9000Source_;
  37. activeVideo9000 = active;
  38. }
  39. bool needRender() const;
  40. bool needRecord() const;
  41. protected:
  42. VideoLayer(MSXMotherBoard& motherBoard,
  43. const std::string& videoSource);
  44. ~VideoLayer() override;
  45. // Observer<Setting> interface:
  46. void update(const Setting& setting) override;
  47. private:
  48. /** Calculates the current Z coordinate of this layer. */
  49. void calcZ();
  50. /** Calculates the current coverage of this layer. */
  51. void calcCoverage();
  52. // MSXEventListener
  53. void signalMSXEvent(const std::shared_ptr<const Event>& event,
  54. EmuTime::param time) override;
  55. /** This layer belongs to a specific machine. */
  56. MSXMotherBoard& motherBoard;
  57. /** Settings shared between all renderers. */
  58. Display& display;
  59. /** Reference to "videosource" setting. */
  60. VideoSourceSetting& videoSourceSetting;
  61. /** Activate the videosource */
  62. VideoSourceActivator videoSourceActivator;
  63. /** Reference to "power" setting. */
  64. BooleanSetting& powerSetting;
  65. /** Video source ID of the Video9000 layer. */
  66. int video9000Source;
  67. /** Active when Video9000 is shown. */
  68. Video9000Active activeVideo9000;
  69. };
  70. } // namespace openmsx
  71. #endif