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 touchControlNotifyChanged() override;
125  void touchControlDraw(int16 x, int16 y, int16 w, int16 h, const Common::Rect &clip) override;
126 
127  void syncVirtkeyboardState(bool virtkeybd_on) override;
128 
129 protected:
130  void updateScreenRect();
131  void updateCursorScaling();
132  const GLESBaseTexture *getActiveTexture() const;
133 
134  Common::Point convertScreenToVirtual(int &x, int &y) const;
135  Common::Point convertVirtualToScreen(int x, int y) const;
136 
137  void setSystemMousePosition(int x, int y) {}
138 
139  bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
140 
141 private:
142  void initOverlay();
143 
144  enum FixupType {
145  kClear = 0, // glClear
146  kClearSwap, // glClear + swapBuffers
147  kClearUpdate // glClear + updateScreen
148  };
149 
150  void clearScreen(FixupType type, byte count = 1);
151 
152 private:
153  int _screenChangeID;
154  int _graphicsMode;
155  bool _fullscreen;
156  bool _ar_correction;
157  bool _force_redraw;
158 
159  bool _virtkeybd_on;
160 
161  // Game layer
162  GLESTexture *_game_texture;
163  OpenGL::FrameBuffer *_frame_buffer;
164 
165 #ifdef USE_RGB_COLOR
166  // Backup of the previous pixel format to pass it back when we leave 3d
167  Graphics::PixelFormat _2d_pixel_format;
168 #endif
169 
173  int _cursorX, _cursorY;
174 
175  // Overlay layer
176  GLESTexture *_overlay_background;
177  GLESTexture *_overlay_texture;
178  bool _show_overlay;
179  bool _overlay_in_gui;
180 
181  // Mouse layer
182  GLESBaseTexture *_mouse_texture;
183  GLESFakePaletteTexture *_mouse_texture_palette;
184  GLESTexture *_mouse_texture_rgb;
185  Common::Point _mouse_hotspot;
186  Common::Point _mouse_hotspot_scaled;
187  int _mouse_width_scaled, _mouse_height_scaled;
188  bool _mouse_dont_scale;
189  bool _show_mouse;
190 
191  // Touch controls layer
192  GLESTexture *_touchcontrols_texture;
193  int _old_touch_mode;
194 };
195 
196 #endif
Definition: texture.h:202
Definition: surface.h:66
Definition: system.h:788
Definition: android-graphics3d.h:34
virtual bool setState(const AndroidCommonGraphics::State &state) override
Definition: pixelformat.h:138
Definition: system.h:739
Feature
Definition: system.h:417
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:1148
virtual void grabPalette(byte *colors, uint start, uint num) const override
Definition: android-graphics.h:47
Definition: rect.h:45
Definition: graphics.h:36
Definition: texture.h:290
Definition: system.h:1149
Definition: touchcontrols.h:27
Definition: texture.h:38
virtual AndroidCommonGraphics::State getState() const override