1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H
#define BACKENDS_GRAPHICS_SDL_SDLGRAPHICS_H
#include "backends/graphics/graphics.h"
#include "backends/platform/sdl/sdl-window.h"
#include "common/rect.h"
class SdlEventSource;
/**
* Base class for a SDL based graphics manager.
*
* It features a few extra a few extra features required by SdlEventSource.
*/
class SdlGraphicsManager : virtual public GraphicsManager {
public:
SdlGraphicsManager(SdlEventSource *source, SdlWindow *window);
virtual ~SdlGraphicsManager();
/**
* Makes this graphics manager active. That means it should be ready to
* process inputs now. However, even without being active it should be
* able to query the supported modes and other bits.
*/
virtual void activateManager();
/**
* Makes this graphics manager inactive. This should allow another
* graphics manager to become active again.
*/
virtual void deactivateManager();
/**
* Notify the graphics manager that the graphics needs to be redrawn, since
* the application window was modified.
*
* This is basically called when SDL_VIDEOEXPOSE was received.
*/
virtual void notifyVideoExpose() = 0;
/**
* Notify the graphics manager about an resize event.
*
* It is noteworthy that the requested width/height should actually be set
* up as is and not changed by the graphics manager, since else it might
* lead to odd behavior for certain window managers.
*
* It is only required to overwrite this method in case you want a
* resizable window. The default implementation just does nothing.
*
* @param width Requested window width.
* @param height Requested window height.
*/
virtual void notifyResize(const uint width, const uint height) {}
/**
* Transforms real screen coordinates into the current active screen
* coordinates (may be either game screen or overlay).
*
* @param point Mouse coordinates to transform.
*/
virtual void transformMouseCoordinates(Common::Point &point) = 0;
/**
* Notifies the graphics manager about a position change according to the
* real screen coordinates.
*
* @param mouse Mouse position.
*/
virtual void notifyMousePos(Common::Point mouse) = 0;
/**
* A (subset) of the graphic manager's state. This is used when switching
* between different SDL graphic managers on runtime.
*/
struct State {
int screenWidth, screenHeight;
bool aspectRatio;
bool fullscreen;
bool cursorPalette;
#ifdef USE_RGB_COLOR
Graphics::PixelFormat pixelFormat;
#endif
};
/**
* Queries the current state of the graphic manager.
*/
State getState();
/**
* Setup a basic state of the graphic manager.
*/
bool setState(const State &state);
/**
* Queries the SDL window.
*/
SdlWindow *getWindow() const { return _window; }
protected:
SdlEventSource *_eventSource;
SdlWindow *_window;
};
#endif
|