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 #include "common/rotationmode.h"
29 
30 #include "graphics/mode.h"
31 #include "graphics/paletteman.h"
32 
38 public:
39  virtual ~GraphicsManager() {}
40 
41  virtual bool hasFeature(OSystem::Feature f) const = 0;
42  virtual void setFeatureState(OSystem::Feature f, bool enable) = 0;
43  virtual bool getFeatureState(OSystem::Feature f) const = 0;
44 
45  virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const {
46  static const OSystem::GraphicsMode noGraphicsModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
47  return noGraphicsModes;
48  }
49  virtual int getDefaultGraphicsMode() const { return 0; }
50  virtual bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) { return (mode == 0); }
51  virtual int getGraphicsMode() const { return 0; }
52 #if defined(USE_IMGUI)
53  virtual void setImGuiCallbacks(const ImGuiCallbacks &callbacks) { }
54  virtual void *getImGuiTexture(const Graphics::Surface &image, const byte *palette, int palCount) { return nullptr; }
55  virtual void freeImGuiTexture(void *texture) { }
56 #endif
57  virtual bool setShader(const Common::Path &fileName) { return false; }
58  virtual const OSystem::GraphicsMode *getSupportedStretchModes() const {
59  static const OSystem::GraphicsMode noStretchModes[] = {{"NONE", "Normal", 0}, {nullptr, nullptr, 0 }};
60  return noStretchModes;
61  }
62  virtual int getDefaultStretchMode() const { return 0; }
63  virtual bool setStretchMode(int mode) { return false; }
64  virtual int getStretchMode() const { return 0; }
65  virtual Common::RotationMode getRotationMode() const { return Common::kRotationNormal; }
66  virtual uint getDefaultScaler() const { return 0; }
67  virtual uint getDefaultScaleFactor() const { return 1; }
68  virtual bool setScaler(uint mode, int factor) { return false; }
69  virtual uint getScaler() const { return 0; }
70  virtual uint getScaleFactor() const { return 1; }
71 
72 #ifdef USE_RGB_COLOR
73  virtual Graphics::PixelFormat getScreenFormat() const = 0;
74  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const = 0;
75 #endif
76  virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format = NULL) = 0;
77  virtual void initSizeHint(const Graphics::ModeList &modes) {}
78  virtual int getScreenChangeID() const = 0;
79 
80  virtual void beginGFXTransaction() = 0;
81  virtual OSystem::TransactionError endGFXTransaction() = 0;
82 
83  virtual int16 getHeight() const = 0;
84  virtual int16 getWidth() const = 0;
85  virtual void setPalette(const byte *colors, uint start, uint num) = 0;
86  virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
87  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) = 0;
88  virtual Graphics::Surface *lockScreen() = 0;
89  virtual void unlockScreen() = 0;
90  virtual void fillScreen(uint32 col) = 0;
91  virtual void fillScreen(const Common::Rect &r, uint32 col) = 0;
92  virtual void updateScreen() = 0;
93  virtual void setShakePos(int shakeXOffset, int shakeYOffset) = 0;
94  virtual void setFocusRectangle(const Common::Rect& rect) = 0;
95  virtual void clearFocusRectangle() = 0;
96 
97  virtual void showOverlay(bool inGUI) = 0;
98  virtual void hideOverlay() = 0;
99  virtual bool isOverlayVisible() const = 0;
100  virtual Graphics::PixelFormat getOverlayFormat() const = 0;
101  virtual void clearOverlay() = 0;
102  virtual void grabOverlay(Graphics::Surface &surface) const = 0;
103  virtual void copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) = 0;
104  virtual int16 getOverlayHeight() const = 0;
105  virtual int16 getOverlayWidth() const = 0;
106  virtual float getHiDPIScreenFactor() const { return 1.0f; }
107 
108  virtual bool showMouse(bool visible) = 0;
109  virtual void warpMouse(int x, int y) = 0;
110  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;
111  virtual void setCursorPalette(const byte *colors, uint start, uint num) = 0;
112 
113  virtual void displayMessageOnOSD(const Common::U32String &msg) {}
114  virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) {}
115 
116 
117  // Graphics::PaletteManager interface
118  //virtual void setPalette(const byte *colors, uint start, uint num) = 0;
119  //virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
120 
121  virtual void saveScreenshot() {}
122  virtual bool lockMouse(bool lock) { return false; }
123 };
124 
125 #endif
Definition: surface.h:67
Definition: system.h:779
virtual void setPalette(const byte *colors, uint start, uint num)=0
Definition: array.h:52
Definition: pixelformat.h:138
Definition: system.h:730
Feature
Definition: system.h:403
Definition: list.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: ustr.h:57
TransactionError
Definition: system.h:1155
virtual void grabPalette(byte *colors, uint start, uint num) const =0
Definition: graphics.h:37
RotationMode
Definition: rotationmode.h:44
Definition: paletteman.h:47