ScummVM API documentation
android-graphics3d.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_GRAPHICS3D_ANDROID_ANDROID_GRAPHICS3D_H
23 #define BACKENDS_GRAPHICS3D_ANDROID_ANDROID_GRAPHICS3D_H
24 
25 #include "common/scummsys.h"
26 
27 #include "backends/graphics/graphics.h"
28 #include "backends/graphics/android/android-graphics.h"
29 #include "backends/graphics3d/opengl/framebuffer.h"
30 #include "backends/graphics3d/android/texture.h"
31 
32 #include "backends/platform/android/touchcontrols.h"
33 
36 public:
38  virtual ~AndroidGraphics3dManager();
39 
40  virtual void initSurface() override;
41  virtual void deinitSurface() override;
42  virtual void resizeSurface() override;
43 
44  virtual AndroidCommonGraphics::State getState() const override;
45  virtual bool setState(const AndroidCommonGraphics::State &state) override;
46 
47  void updateScreen() override;
48 
49  void displayMessageOnOSD(const Common::U32String &msg);
50 
51  virtual bool notifyMousePosition(Common::Point &mouse) override;
52  virtual Common::Point getMousePosition() override {
53  return Common::Point(_cursorX, _cursorY);
54  }
55  void setMousePosition(int x, int y) {
56  _cursorX = x;
57  _cursorY = y;
58  }
59 
60  virtual void beginGFXTransaction() {}
61  virtual OSystem::TransactionError endGFXTransaction() {
63  }
64 
65  virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
66  virtual int getDefaultGraphicsMode() const override;
67  virtual bool setGraphicsMode(int mode, uint flags = OSystem::kGfxModeNoFlags) override;
68  virtual int getGraphicsMode() const override;
69 
70  virtual bool hasFeature(OSystem::Feature f) const override;
71  virtual void setFeatureState(OSystem::Feature f, bool enable) override;
72  virtual bool getFeatureState(OSystem::Feature f) const override;
73 
74  virtual void showOverlay(bool inGUI) override;
75  virtual void hideOverlay() override;
76  virtual void clearOverlay() override;
77  virtual void grabOverlay(Graphics::Surface &surface) const override;
78  virtual void copyRectToOverlay(const void *buf, int pitch,
79  int x, int y, int w, int h) override;
80  virtual int16 getOverlayHeight() const override;
81  virtual int16 getOverlayWidth() const override;
82  virtual Graphics::PixelFormat getOverlayFormat() const override;
83  virtual bool isOverlayVisible() const override {
84  return _show_overlay;
85  }
86 
87  virtual int16 getHeight() const override;
88  virtual int16 getWidth() const override;
89 
90  // PaletteManager API
91  virtual void setPalette(const byte *colors, uint start, uint num) override;
92  virtual void grabPalette(byte *colors, uint start, uint num) const override;
93  virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
94  int w, int h) override;
95  virtual Graphics::Surface *lockScreen() override;
96  virtual void unlockScreen() override;
97  virtual void fillScreen(uint32 col) override;
98  virtual void fillScreen(const Common::Rect &r, uint32 col) override;
99 
100  virtual void setShakePos(int shakeXOffset, int shakeYOffset) {};
101  virtual void setFocusRectangle(const Common::Rect &rect) {}
102  virtual void clearFocusRectangle() {}
103 
104  virtual void initSize(uint width, uint height,
105  const Graphics::PixelFormat *format) override;
106  virtual int getScreenChangeID() const override;
107 
108  virtual bool showMouse(bool visible) override;
109  virtual void warpMouse(int x, int y) override;
110  virtual bool lockMouse(bool lock) override;
111  virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
112  int hotspotY, uint32 keycolor,
113  bool dontScale,
114  const Graphics::PixelFormat *format, const byte *mask) override;
115  virtual void setCursorPalette(const byte *colors, uint start, uint num) override;
116 
117  float getHiDPIScreenFactor() const override;
118 
119 #ifdef USE_RGB_COLOR
120  virtual Graphics::PixelFormat getScreenFormat() const override;
121  virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
122 #endif
123 
124  void touchControlInitSurface(const Graphics::ManagedSurface &surf) override;
125  void touchControlNotifyChanged() override;
126  void touchControlDraw(uint8 alpha, int16 x, int16 y, int16 w, int16 h, const Common::Rect &clip) override;
127 
128  void syncVirtkeyboardState(bool virtkeybd_on) override;
129  void applyTouchSettings() const override;
130 
131 protected:
132  void updateScreenRect();
133  void updateCursorScaling();
134  const GLESBaseTexture *getActiveTexture() const;
135 
136  Common::Point convertScreenToVirtual(int &x, int &y) const;
137  Common::Point convertVirtualToScreen(int x, int y) const;
138 
139  void setSystemMousePosition(int x, int y) {}
140 
141  bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
142 
143 private:
144  void initOverlay();
145 
146  enum FixupType {
147  kClear = 0, // glClear
148  kClearSwap, // glClear + swapBuffers
149  kClearUpdate // glClear + updateScreen
150  };
151 
152  void clearScreen(FixupType type, byte count = 1);
153 
154 private:
155  int _screenChangeID;
156  int _graphicsMode;
157  bool _fullscreen;
158  bool _ar_correction;
159  bool _force_redraw;
160 
161  bool _virtkeybd_on;
162 
163  // Game layer
164  GLESTexture *_game_texture;
165  OpenGL::FrameBuffer *_frame_buffer;
166 
167 #ifdef USE_RGB_COLOR
168  // Backup of the previous pixel format to pass it back when we leave 3d
169  Graphics::PixelFormat _2d_pixel_format;
170 #endif
171 
175  int _cursorX, _cursorY;
176 
177  // Overlay layer
178  GLESTexture *_overlay_background;
179  GLESTexture *_overlay_texture;
180  bool _show_overlay;
181  bool _overlay_in_gui;
182 
183  // Mouse layer
184  GLESBaseTexture *_mouse_texture;
185  GLESFakePaletteTexture *_mouse_texture_palette;
186  GLESTexture *_mouse_texture_rgb;
187  Common::Point _mouse_hotspot;
188  Common::Point _mouse_hotspot_scaled;
189  int _mouse_width_scaled, _mouse_height_scaled;
190  bool _mouse_dont_scale;
191  bool _show_mouse;
192 
193  // Touch controls layer
194  GLESTexture *_touchcontrols_texture;
195  int _old_touch_mode;
196 };
197 
198 #endif
Definition: managed_surface.h:51
Definition: texture.h:208
Definition: surface.h:67
Definition: system.h:779
Definition: android-graphics3d.h:34
virtual bool setState(const AndroidCommonGraphics::State &state) override
Definition: pixelformat.h:138
Definition: system.h:730
Feature
Definition: system.h:403
Definition: list.h:44
Definition: rect.h:144
Definition: android-graphics.h:30
virtual void setPalette(const byte *colors, uint start, uint num) override
Definition: ustr.h:57
TransactionError
Definition: system.h:1155
virtual void grabPalette(byte *colors, uint start, uint num) const override
Definition: android-graphics.h:48
Definition: rect.h:45
Definition: graphics.h:37
Definition: texture.h:296
Definition: system.h:1156
Definition: touchcontrols.h:31
Definition: texture.h:38
virtual AndroidCommonGraphics::State getState() const override