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  bool _cursorDontScale;
37  bool _cursorPaletteEnabled;
38  bool _screenUpdatePending;
39  int _cursorHotspotX;
40  int _cursorHotspotY;
41  int _cursorKeyColor;
42  int _screenChangeID;
43  int _cursorHotspotXScaled;
44  int _cursorHotspotYScaled;
45  float _cursorWidthScaled;
46  float _cursorHeightScaled;
47 
48 public:
51  Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
52  const OSystem::GraphicsMode *getSupportedGraphicsModes(void) const override;
53  void initSize(uint width, uint height, const Graphics::PixelFormat *format) override;
54  int16 getHeight(void) const override;
55  int16 getWidth(void) const override;
56  Graphics::PixelFormat getScreenFormat(void) const override;
57  void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) override;
58  void updateScreen(void) override;
59  void clearOverlay(void) override;
60  void grabOverlay(Graphics::Surface &surface) const override;
61  void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) override;
62  int16 getOverlayHeight(void) const override;
63  int16 getOverlayWidth(void) const override;
64  Graphics::PixelFormat getOverlayFormat() const override;
65  const Graphics::ManagedSurface *getScreen(void);
66  void warpMouse(int x, int y) override;
67  void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, bool dontScale = false, const Graphics::PixelFormat *format = NULL, const byte *mask = nullptr) override;
68  void setCursorPalette(const byte *colors, uint start, uint num) override;
69  bool isOverlayInGUI(void);
70 
71  bool hasFeature(OSystem::Feature f) const override;
72  void setFeatureState(OSystem::Feature f, bool enable) override;
73  bool getFeatureState(OSystem::Feature f) const override;
74 
75  int getDefaultGraphicsMode() const override {
76  return 0;
77  }
78  bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override {
79  return true;
80  }
81  int getGraphicsMode() const override {
82  return 0;
83  }
84  Graphics::Surface *lockScreen() override {
85  return &_gameScreen;
86  }
87  void unlockScreen() override {}
88 
89  int getScreenChangeID() const override;
90  void beginGFXTransaction() override {}
91  OSystem::TransactionError endGFXTransaction() override;
92  void fillScreen(uint32 col) override {}
93  void fillScreen(const Common::Rect &r, uint32 col) override {}
94  void setFocusRectangle(const Common::Rect &rect) override {}
95  void clearFocusRectangle() override {}
96 
97  void realUpdateScreen(void);
98 
99  bool gameNeedsAspectRatioCorrection() const override {
100  return false;
101  }
102  void handleResizeImpl(const int width, const int height) override;
103  void setSystemMousePosition(const int x, const int y) override {}
104  void setMousePosition(int x, int y);
105 
106  void displayMessageOnOSD(const Common::U32String &msg) override;
107 
108 protected:
109  void setPalette(const byte *colors, uint start, uint num) override;
110  void grabPalette(byte *colors, uint start, uint num) const override;
111 private:
112  void overrideCursorScaling();
113 };
114 #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:99
Definition: system.h:779
Definition: pixelformat.h:138
Definition: system.h:730
Feature
Definition: system.h:403
Definition: list.h:44
Definition: rect.h:144
void setSystemMousePosition(const int x, const int y) override
Definition: libretro-graphics-surface.h:103
Definition: windowed.h:52
void warpMouse(int x, int y) override
Definition: ustr.h:57
TransactionError
Definition: system.h:1155
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:45