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