ScummVM API documentation
graphics.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_GRAPHICS_ABSTRACT_H
23 #define BACKENDS_GRAPHICS_ABSTRACT_H
24 
25 #include "common/system.h"
26 #include "common/noncopyable.h"
27 #include "common/keyboard.h"
28 
29 #include "graphics/mode.h"
30 #include "graphics/paletteman.h"
31 
37 public:
38  virtual ~GraphicsManager() {}
39 
40  virtual bool hasFeature(OSystem::Feature f) const = 0;
41  virtual void setFeatureState(OSystem::Feature f, bool enable) = 0;
42  virtual bool getFeatureState(OSystem::Feature f) const = 0;
43 
44  virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const {
45  static const OSystem::GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
46  return noGraphicsModes;
47  }
48  virtual int getDefaultGraphicsMode() const { return 0; }
49  virtual bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) { return (mode == 0); }
50  virtual int getGraphicsMode() const { return 0; }
51  virtual bool setShader(const Common::Path &fileName) { return false; }
52  virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
53  static const OSystem::GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
54  return noStretchModes;
55  }
56  virtual int getDefaultStretchMode() const { return 0; }
57  virtual bool setStretchMode(int mode) { return false; }
58  virtual int getStretchMode() const { return 0; }
59  virtual uint getDefaultScaler() const { return 0; }
60  virtual uint getDefaultScaleFactor() const { return 1; }
61  virtual bool setScaler(uint mode, int factor) { return false; }
62  virtual uint getScaler() const { return 0; }
63  virtual uint getScaleFactor() const { return 1; }
64 
65 #ifdef USE_RGB_COLOR
66  virtual Graphics::PixelFormat getScreenFormat() const = 0;
67  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
68 #endif
69  virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0;
70  virtual void initSizeHint(const Graphics::ModeList &modes) {}
71  virtual int getScreenChangeID() const = 0;
72 
73  virtual void beginGFXTransaction() = 0;
74  virtual OSystem::TransactionError endGFXTransaction() = 0;
75 
76  virtual int16 getHeight() const = 0;
77  virtual int16 getWidth() const = 0;
78  virtual void setPalette(const byte *colors, uint start, uint num) = 0;
79  virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
80  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
81  virtual Graphics::Surface *lockScreen() = 0;
82  virtual void unlockScreen() = 0;
83  virtual void fillScreen(uint32 col) = 0;
84  virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
85  virtual void updateScreen() = 0;
86  virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
87  virtual void setFocusRectangle(const Common::Rect& rect) = 0;
88  virtual void clearFocusRectangle() = 0;
89 
90  virtual void showOverlay(bool inGUI) = 0;
91  virtual void hideOverlay() = 0;
92  virtual bool isOverlayVisible() const = 0;
93  virtual Graphics::PixelFormat getOverlayFormat() const = 0;
94  virtual void clearOverlay() = 0;
95  virtual void grabOverlay(Graphics::Surface &surface) const = 0;
96  virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
97  virtual int16 getOverlayHeight() const = 0;
98  virtual int16 getOverlayWidth() const = 0;
99  virtual float getHiDPIScreenFactor() const { return 1.0f; }
100 
101  virtual bool showMouse(bool visible) = 0;
102  virtual void warpMouse(int x, int y) = 0;
103  virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = nullptr, const byte *mask = nullptr) = 0;
104  virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
105 
106  virtual void displayMessageOnOSD(const Common::U32String &msg) {}
107  virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) {}
108 
109 
110  // Graphics::PaletteManager interface
111  //virtual void setPalette(const byte *colors, uint start, uint num) = 0;
112  //virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
113 
114  virtual void saveScreenshot() {}
115  virtual bool lockMouse(bool lock) { return false; }
116 
117  virtual void renderImGui(void(*render)()) {}
118 };
119 
120 #endif
Definition: surface.h:66
Definition: system.h:780
virtual void setPalette(const byte *colors, uint start, uint num)=0
Definition: array.h:52
Definition: pixelformat.h:138
Definition: system.h:731
Feature
Definition: system.h:409
Definition: list.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: ustr.h:57
TransactionError
Definition: system.h:1129
virtual void grabPalette(byte *colors, uint start, uint num) const =0
Definition: graphics.h:36
Definition: paletteman.h:46