ScummVM API documentation
libretro-graphics-surface.h
1 /* Copyright (C) 2024 Giovanni Cascione <ing.cascione@gmail.com>
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 #ifndef BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
18 #define BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
19 
20 #include "common/system.h"
21 #include "graphics/palette.h"
22 #include "graphics/managed_surface.h"
23 #include "backends/graphics/windowed.h"
24 
26 
27 public:
29  Graphics::Surface _gameScreen;
30  Graphics::Surface _overlay;
31  Graphics::Surface _cursor;
32  Graphics::Palette _cursorPalette;
33  Graphics::Palette _gamePalette;
34 
35 private:
36  float _cursorScaleX;
37  float _cursorScaleY;
38  bool _cursorPaletteEnabled;
39  bool _screenUpdatePending;
40  int _cursorHotspotX;
41  int _cursorHotspotY;
42  int _cursorKeyColor;
43  int _screenChangeID;
44  int _cursorHotspotXScaled;
45  int _cursorHotspotYScaled;
46  float _cursorWidthScaled;
47  float _cursorHeightScaled;
48 
49 public:
52  Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
53  const OSystem::GraphicsMode *getSupportedGraphicsModes(void) const override;
54  void initSize(uint width, uint height, const Graphics::PixelFormat *format) override;
55  int16 getHeight(void) const override;
56  int16 getWidth(void) const override;
57  Graphics::PixelFormat getScreenFormat(void) const override;
58  void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
59  void updateScreen(void) override;
60  void clearOverlay(void) override;
61  void grabOverlay(Graphics::Surface &surface) const override;
62  void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
63  int16 getOverlayHeight(void) const override;
64  int16 getOverlayWidth(void) const override;
65  Graphics::PixelFormat getOverlayFormat() const override;
66  const Graphics::ManagedSurface *getScreen(void);
67  void warpMouse(int x, int y) override;
68  void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, const Graphics::PixelFormat *format, const byte *mask, frac_t scaleX, frac_t scaleY) override;
69  void setCursorPalette(const byte *colors, uint start, uint num) override;
70  bool isOverlayInGUI(void);
71 
72  bool hasFeature(OSystem::Feature f) const override;
73  void setFeatureState(OSystem::Feature f, bool enable) override;
74  bool getFeatureState(OSystem::Feature f) const override;
75 
76  int getDefaultGraphicsMode() const override {
77  return 0;
78  }
79  bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override {
80  return true;
81  }
82  int getGraphicsMode() const override {
83  return 0;
84  }
85  Graphics::Surface *lockScreen() override {
86  return &_gameScreen;
87  }
88  void unlockScreen() override {}
89 
90  int getScreenChangeID() const override;
91  void beginGFXTransaction() override {}
92  OSystem::TransactionError endGFXTransaction() override;
93  void fillScreen(uint32 col) override {}
94  void fillScreen(const Common::Rect &r, uint32 col) override {}
95  void setFocusRectangle(const Common::Rect &rect) override {}
96  void clearFocusRectangle() override {}
97 
98  void realUpdateScreen(void);
99 
100  bool gameNeedsAspectRatioCorrection() const override {
101  return false;
102  }
103  void handleResizeImpl(const int width, const int height) override;
104  void setSystemMousePosition(const int x, const int y) override {}
105  void setMousePosition(int x, int y);
106 
107  void displayMessageOnOSD(const Common::U32String &msg) override;
108 
109 protected:
110  void setPalette(const byte *colors, uint start, uint num) override;
111  void grabPalette(byte *colors, uint start, uint num) const override;
112 private:
113  void overrideCursorScaling();
114 };
115 #endif //BACKENDS_LIBRETRO_GRAPHICS_SURFACE_H
Definition: managed_surface.h:51
void grabPalette(byte *colors, uint start, uint num) const override
Definition: surface.h:67
bool gameNeedsAspectRatioCorrection() const override
Definition: libretro-graphics-surface.h:100
Definition: system.h:790
Definition: pixelformat.h:138
Definition: system.h:741
Feature
Definition: system.h:415
Definition: list.h:44
Definition: rect.h:536
void setSystemMousePosition(const int x, const int y) override
Definition: libretro-graphics-surface.h:104
Definition: windowed.h:52
void warpMouse(int x, int y) override
Definition: ustr.h:57
TransactionError
Definition: system.h:1188
void setPalette(const byte *colors, uint start, uint num) override
Definition: libretro-graphics-surface.h:25
void handleResizeImpl(const int width, const int height) override
Simple class for handling a palette data.
Definition: palette.h:61
int32 frac_t
Definition: frac.h:52