VisibleSurface.hh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef VISIBLESURFACE_HH
  2. #define VISIBLESURFACE_HH
  3. #include "Observer.hh"
  4. #include "EventListener.hh"
  5. #include "RTSchedulable.hh"
  6. #include <memory>
  7. namespace openmsx {
  8. class Layer;
  9. class OutputSurface;
  10. class Reactor;
  11. class CommandConsole;
  12. class EventDistributor;
  13. class InputEventGenerator;
  14. class Setting;
  15. class Display;
  16. class OSDGUI;
  17. class CliComm;
  18. class VideoSystem;
  19. /** An OutputSurface which is visible to the user, such as a window or a
  20. * full screen display.
  21. */
  22. class VisibleSurface : public EventListener, private Observer<Setting>
  23. , private RTSchedulable
  24. {
  25. public:
  26. virtual ~VisibleSurface();
  27. virtual void updateWindowTitle() = 0;
  28. virtual bool setFullScreen(bool fullscreen) = 0;
  29. /** When a complete frame is finished, call this method.
  30. * It will 'actually' display it. E.g. when using double buffering
  31. * it will swap the front and back buffer.
  32. */
  33. virtual void finish() = 0;
  34. virtual std::unique_ptr<Layer> createSnowLayer() = 0;
  35. virtual std::unique_ptr<Layer> createConsoleLayer(
  36. Reactor& reactor, CommandConsole& console) = 0;
  37. virtual std::unique_ptr<Layer> createOSDGUILayer(OSDGUI& gui) = 0;
  38. /** Create an off-screen OutputSurface which has similar properties
  39. * as this VisibleSurface. E.g. used to re-render the current frame
  40. * without OSD elements to take a screenshot.
  41. */
  42. virtual std::unique_ptr<OutputSurface> createOffScreenSurface() = 0;
  43. CliComm& getCliComm() const { return cliComm; }
  44. Display& getDisplay() const { return display; }
  45. protected:
  46. VisibleSurface(Display& display,
  47. RTScheduler& rtScheduler,
  48. EventDistributor& eventDistributor,
  49. InputEventGenerator& inputEventGenerator,
  50. CliComm& cliComm,
  51. VideoSystem& videoSystem);
  52. private:
  53. void updateCursor();
  54. // Observer
  55. void update(const Setting& setting) override;
  56. // EventListener
  57. int signalEvent(const std::shared_ptr<const Event>& event) override;
  58. // RTSchedulable
  59. void executeRT() override;
  60. Display& display;
  61. EventDistributor& eventDistributor;
  62. InputEventGenerator& inputEventGenerator;
  63. CliComm& cliComm;
  64. VideoSystem& videoSystem;
  65. bool grab = false;
  66. };
  67. } // namespace openmsx
  68. #endif