openMSX
OSDImageBasedWidget.hh
Go to the documentation of this file.
1 #ifndef OSDIMAGEBASEDWIDGET_HH
2 #define OSDIMAGEBASEDWIDGET_HH
3 
4 #include "OSDWidget.hh"
5 #include <cstdint>
6 
7 namespace openmsx {
8 
9 class BaseImage;
10 class Display;
11 
13 {
14 public:
15  uint32_t getRGBA(uint32_t corner) const { return rgba[corner]; }
16  const uint32_t* getRGBA4() const { return rgba; }
17 
18  virtual uint8_t getFadedAlpha() const = 0;
19 
20  std::vector<std::string_view> getProperties() const override;
21  void setProperty(Interpreter& interp,
22  std::string_view name, const TclObject& value) override;
23  void getProperty(std::string_view name, TclObject& result) const override;
24  float getRecursiveFadeValue() const override;
25 
26 protected:
27  OSDImageBasedWidget(Display& display, const TclObject& name);
28  ~OSDImageBasedWidget() override;
29  bool hasConstantAlpha() const;
30  void createImage(OutputSurface& output);
31  void invalidateLocal() override;
32  void paintSDL(OutputSurface& output) override;
33  void paintGL (OutputSurface& output) override;
34  virtual std::unique_ptr<BaseImage> createSDL(OutputSurface& output) = 0;
35  virtual std::unique_ptr<BaseImage> createGL (OutputSurface& output) = 0;
36 
37  void setError(std::string message);
38  bool hasError() const { return error; }
39 
40  std::unique_ptr<BaseImage> image;
41 
42 private:
43  void setRGBA(const uint32_t newRGBA[4]);
44  bool isFading() const;
45  float getCurrentFadeValue() const;
46  float getCurrentFadeValue(uint64_t now) const;
47  void updateCurrentFadeValue();
48 
49  void paint(OutputSurface& output, bool openGL);
50  gl::vec2 getTransformedPos(const OutputSurface& output) const;
51 
52  uint64_t startFadeTime;
53  float fadePeriod;
54  float fadeTarget;
55  mutable float startFadeValue;
56  uint32_t rgba[4];
57  bool error;
58 };
59 
60 } // namespace openmsx
61 
62 #endif
void setError(std::string message)
Represents the output window/screen of openMSX.
Definition: Display.hh:31
void paintGL(OutputSurface &output) override
std::unique_ptr< BaseImage > image
OSDImageBasedWidget(Display &display, const TclObject &name)
A frame buffer where pixels can be written to.
const uint32_t * getRGBA4() const
void paintSDL(OutputSurface &output) override
virtual std::unique_ptr< BaseImage > createSDL(OutputSurface &output)=0
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
float getRecursiveFadeValue() const override
virtual std::unique_ptr< BaseImage > createGL(OutputSurface &output)=0
std::vector< std::string_view > getProperties() const override
void createImage(OutputSurface &output)
void getProperty(std::string_view name, TclObject &result) const override
void setProperty(Interpreter &interp, std::string_view name, const TclObject &value) override
uint32_t getRGBA(uint32_t corner) const
virtual uint8_t getFadedAlpha() const =0