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