ANDROID: Shift graphics code to graphics.cpp
This brings our port more in line with ScummVM. Much of the code there now is analogous to graphics/opengl/opengl-graphics.h
This commit is contained in:
parent
33975233de
commit
7823e94c18
7 changed files with 722 additions and 672 deletions
|
@ -60,6 +60,7 @@
|
|||
|
||||
#include "backends/platform/android/jni-android.h"
|
||||
#include "backends/platform/android/android.h"
|
||||
#include "backends/platform/android/graphics.h"
|
||||
|
||||
const char *android_log_tag = "ResidualVM";
|
||||
|
||||
|
@ -115,22 +116,6 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
|||
_audio_sample_rate(audio_sample_rate),
|
||||
_audio_buffer_size(audio_buffer_size),
|
||||
_screen_changeid(0),
|
||||
_force_redraw(false),
|
||||
_game_texture(0),
|
||||
_game_pbuf(),
|
||||
_overlay_texture(0),
|
||||
_opengl(false),
|
||||
_mouse_texture(0),
|
||||
_mouse_texture_palette(0),
|
||||
_mouse_texture_rgb(0),
|
||||
_mouse_hotspot(),
|
||||
_mouse_keycolor(0),
|
||||
_use_mouse_palette(false),
|
||||
_graphicsMode(0),
|
||||
_fullscreen(true),
|
||||
_ar_correction(true),
|
||||
_show_mouse(false),
|
||||
_show_overlay(false),
|
||||
_mixer(0),
|
||||
_queuedEventTime(0),
|
||||
_event_queue_lock(0),
|
||||
|
@ -148,18 +133,14 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
|||
|
||||
_fsFactory = new POSIXFilesystemFactory();
|
||||
|
||||
Common::String mf = getSystemProperty("ro.product.manufacturer");
|
||||
|
||||
LOGI("Running on: [%s] [%s] [%s] [%s] [%s] SDK:%s ABI:%s",
|
||||
mf.c_str(),
|
||||
getSystemProperty("ro.product.manufacturer").c_str(),
|
||||
getSystemProperty("ro.product.model").c_str(),
|
||||
getSystemProperty("ro.product.brand").c_str(),
|
||||
getSystemProperty("ro.build.fingerprint").c_str(),
|
||||
getSystemProperty("ro.build.display.id").c_str(),
|
||||
getSystemProperty("ro.build.version.sdk").c_str(),
|
||||
getSystemProperty("ro.product.cpu.abi").c_str());
|
||||
|
||||
mf.toLowercase();
|
||||
}
|
||||
|
||||
OSystem_Android::~OSystem_Android() {
|
||||
|
@ -376,15 +357,9 @@ void OSystem_Android::initBackend() {
|
|||
_audio_thread_exit = false;
|
||||
pthread_create(&_audio_thread, 0, audioThreadFunc, this);
|
||||
|
||||
initSurface();
|
||||
initViewport();
|
||||
_graphicsManager = new AndroidGraphicsManager();
|
||||
|
||||
_game_texture = new GLESFakePalette565Texture();
|
||||
_overlay_texture = new GLES4444Texture();
|
||||
_mouse_texture_palette = new GLESFakePalette5551Texture();
|
||||
_mouse_texture = _mouse_texture_palette;
|
||||
|
||||
initOverlay();
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->initSurface();
|
||||
|
||||
// renice this thread to boost the audio thread
|
||||
if (setpriority(PRIO_PROCESS, 0, 19) < 0)
|
||||
|
@ -400,39 +375,23 @@ bool OSystem_Android::hasFeature(Feature f) {
|
|||
f == kFeatureOpenUrl ||
|
||||
f == kFeatureTouchpadMode ||
|
||||
f == kFeatureOnScreenControl ||
|
||||
f == kFeatureFullscreenMode ||
|
||||
f == kFeatureClipboardSupport ||
|
||||
f == kFeatureAspectRatioCorrection ||
|
||||
f == kFeatureCursorPalette ||
|
||||
f == kFeatureOpenGL ||
|
||||
f == kFeatureOverlaySupportsAlpha ||
|
||||
f == kFeatureClipboardSupport) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ModularBackend::hasFeature(f);
|
||||
}
|
||||
|
||||
void OSystem_Android::setFeatureState(Feature f, bool enable) {
|
||||
ENTER("%d, %d", f, enable);
|
||||
|
||||
switch (f) {
|
||||
case kFeatureFullscreenMode:
|
||||
_fullscreen = enable;
|
||||
updateScreenRect();
|
||||
break;
|
||||
case kFeatureAspectRatioCorrection:
|
||||
_ar_correction = enable;
|
||||
updateScreenRect();
|
||||
break;
|
||||
case kFeatureVirtualKeyboard:
|
||||
_virtkeybd_on = enable;
|
||||
showVirtualKeyboard(enable);
|
||||
break;
|
||||
case kFeatureCursorPalette:
|
||||
_use_mouse_palette = enable;
|
||||
if (!enable)
|
||||
disableCursorPalette();
|
||||
break;
|
||||
case kFeatureTouchpadMode:
|
||||
ConfMan.setBool("touchpad_mouse_mode", enable);
|
||||
_touchpad_mode = enable;
|
||||
|
@ -442,29 +401,29 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
|
|||
JNI::showKeyboardControl(enable);
|
||||
break;
|
||||
default:
|
||||
ModularBackend::setFeatureState(f, enable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool OSystem_Android::getFeatureState(Feature f) {
|
||||
switch (f) {
|
||||
case kFeatureFullscreenMode:
|
||||
return _fullscreen;
|
||||
case kFeatureAspectRatioCorrection:
|
||||
return _ar_correction;
|
||||
case kFeatureVirtualKeyboard:
|
||||
return _virtkeybd_on;
|
||||
case kFeatureCursorPalette:
|
||||
return _use_mouse_palette;
|
||||
case kFeatureTouchpadMode:
|
||||
return ConfMan.getBool("touchpad_mouse_mode");
|
||||
case kFeatureOnScreenControl:
|
||||
return ConfMan.getBool("onscreen_control");
|
||||
default:
|
||||
return false;
|
||||
return ModularBackend::getFeatureState(f);
|
||||
}
|
||||
}
|
||||
|
||||
// ResidualVM specific method
|
||||
void OSystem_Android::launcherInitSize(uint w, uint h) {
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->setupScreen(w, h, true, true, false);
|
||||
}
|
||||
|
||||
uint32 OSystem_Android::getMillis(bool skipRecord) {
|
||||
timeval curTime;
|
||||
|
||||
|
@ -489,12 +448,7 @@ void OSystem_Android::quit() {
|
|||
_timer_thread_exit = true;
|
||||
pthread_join(_timer_thread, 0);
|
||||
|
||||
delete _game_texture;
|
||||
delete _overlay_texture;
|
||||
delete _mouse_texture_palette;
|
||||
delete _mouse_texture_rgb;
|
||||
|
||||
deinitSurface();
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
|
||||
}
|
||||
|
||||
void OSystem_Android::setWindowCaption(const char *caption) {
|
||||
|
@ -503,11 +457,6 @@ void OSystem_Android::setWindowCaption(const char *caption) {
|
|||
JNI::setWindowCaption(caption);
|
||||
}
|
||||
|
||||
void OSystem_Android::displayMessageOnOSD(const char *msg) {
|
||||
ENTER("%s", msg);
|
||||
|
||||
JNI::displayMessageOnOSD(msg);
|
||||
}
|
||||
|
||||
void OSystem_Android::showVirtualKeyboard(bool enable) {
|
||||
ENTER("%d", enable);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#if defined(__ANDROID__)
|
||||
|
||||
#include "backends/platform/android/portdefs.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/archive.h"
|
||||
#include "audio/mixer_intern.h"
|
||||
|
@ -39,6 +40,7 @@
|
|||
|
||||
#include "backends/platform/android/events.h"
|
||||
#include "backends/platform/android/texture.h"
|
||||
#include "backends/platform/android/graphics.h"
|
||||
#include "backends/platform/android/touchcontrols.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
@ -98,7 +100,7 @@ extern void checkGlError(const char *expr, const char *file, int line);
|
|||
#define GLTHREADCHECK do { } while (false)
|
||||
#endif
|
||||
|
||||
class OSystem_Android : public ModularBackend, public PaletteManager, Common::EventSource {
|
||||
class OSystem_Android : public ModularBackend, Common::EventSource {
|
||||
private:
|
||||
// passed from the dark side
|
||||
int _audio_sample_rate;
|
||||
|
@ -106,33 +108,6 @@ private:
|
|||
|
||||
int _screen_changeid;
|
||||
|
||||
bool _force_redraw;
|
||||
|
||||
bool _opengl;
|
||||
|
||||
// Game layer
|
||||
GLESBaseTexture *_game_texture;
|
||||
Graphics::PixelBuffer _game_pbuf;
|
||||
OpenGL::FrameBuffer *_frame_buffer;
|
||||
|
||||
// Overlay layer
|
||||
GLES4444Texture *_overlay_texture;
|
||||
bool _show_overlay;
|
||||
|
||||
// Mouse layer
|
||||
GLESBaseTexture *_mouse_texture;
|
||||
GLESBaseTexture *_mouse_texture_palette;
|
||||
GLES5551Texture *_mouse_texture_rgb;
|
||||
Common::Point _mouse_hotspot;
|
||||
uint32 _mouse_keycolor;
|
||||
int _mouse_targetscale;
|
||||
bool _show_mouse;
|
||||
bool _use_mouse_palette;
|
||||
|
||||
int _graphicsMode;
|
||||
bool _fullscreen;
|
||||
bool _ar_correction;
|
||||
|
||||
pthread_t _main_thread;
|
||||
|
||||
bool _timer_thread_exit;
|
||||
|
@ -150,19 +125,7 @@ private:
|
|||
|
||||
Common::String getSystemProperty(const char *name) const;
|
||||
|
||||
void initSurface();
|
||||
void deinitSurface();
|
||||
void initViewport();
|
||||
|
||||
void initOverlay();
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
void initTexture(GLESBaseTexture **texture, uint width, uint height,
|
||||
const Graphics::PixelFormat *format);
|
||||
#endif
|
||||
|
||||
void setupKeymapper();
|
||||
void setCursorPaletteInternal(const byte *colors, uint start, uint num);
|
||||
|
||||
protected:
|
||||
virtual Common::EventSource *getDefaultEventSource() { return this; }
|
||||
|
@ -177,35 +140,8 @@ public:
|
|||
virtual void setFeatureState(OSystem::Feature f, bool enable);
|
||||
virtual bool getFeatureState(OSystem::Feature f);
|
||||
|
||||
virtual const GraphicsMode *getSupportedGraphicsModes() const;
|
||||
virtual int getDefaultGraphicsMode() const;
|
||||
virtual bool setGraphicsMode(int mode);
|
||||
virtual int getGraphicsMode() const;
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
virtual Graphics::PixelFormat getScreenFormat() const;
|
||||
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
|
||||
#endif
|
||||
|
||||
virtual void initSize(uint width, uint height,
|
||||
const Graphics::PixelFormat *format);
|
||||
|
||||
enum FixupType {
|
||||
kClear = 0, // glClear
|
||||
kClearSwap, // glClear + swapBuffers
|
||||
kClearUpdate // glClear + updateScreen
|
||||
};
|
||||
|
||||
void clearScreen(FixupType type, byte count = 1);
|
||||
|
||||
void updateScreenRect();
|
||||
virtual int getScreenChangeID() const;
|
||||
|
||||
virtual int16 getHeight();
|
||||
virtual int16 getWidth();
|
||||
|
||||
virtual PaletteManager *getPaletteManager() {
|
||||
return this;
|
||||
virtual PaletteManager *getPaletteManager() override {
|
||||
return dynamic_cast<AndroidGraphicsManager *>(_graphicsManager);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -228,46 +164,12 @@ private:
|
|||
int _fingersDown;
|
||||
|
||||
void clipMouse(Common::Point &p);
|
||||
void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true, bool touchpadMode = false);
|
||||
void updateEventScale();
|
||||
void scaleMouse(Common::Point &p, int x, int y, bool touchpadMode = false);
|
||||
void disableCursorPalette();
|
||||
|
||||
TouchControls _touchControls;
|
||||
|
||||
void drawVirtControls();
|
||||
|
||||
protected:
|
||||
// PaletteManager API
|
||||
virtual void setPalette(const byte *colors, uint start, uint num);
|
||||
virtual void grabPalette(byte *colors, uint start, uint num) const;
|
||||
|
||||
public:
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h);
|
||||
virtual void updateScreen();
|
||||
virtual Graphics::Surface *lockScreen();
|
||||
virtual void unlockScreen();
|
||||
virtual void setShakePos(int shakeXOffset, int shakeYOffset);
|
||||
virtual void fillScreen(uint32 col);
|
||||
|
||||
virtual void showOverlay();
|
||||
virtual void hideOverlay();
|
||||
virtual void clearOverlay();
|
||||
virtual void grabOverlay(void *buf, int pitch);
|
||||
virtual void copyRectToOverlay(const void *buf, int pitch,
|
||||
int x, int y, int w, int h);
|
||||
virtual int16 getOverlayHeight();
|
||||
virtual int16 getOverlayWidth();
|
||||
virtual Graphics::PixelFormat getOverlayFormat() const;
|
||||
|
||||
virtual bool showMouse(bool visible);
|
||||
|
||||
virtual void warpMouse(int x, int y);
|
||||
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
|
||||
int hotspotY, uint32 keycolor,
|
||||
bool dontScale,
|
||||
const Graphics::PixelFormat *format);
|
||||
virtual void setCursorPalette(const byte *colors, uint start, uint num);
|
||||
|
||||
virtual void pushEvent(const Common::Event &event);
|
||||
virtual void pushKeyPressEvent(Common::Event &event);
|
||||
|
@ -278,7 +180,6 @@ public:
|
|||
virtual void quit();
|
||||
|
||||
virtual void setWindowCaption(const char *caption);
|
||||
virtual void displayMessageOnOSD(const char *msg);
|
||||
virtual void showVirtualKeyboard(bool enable);
|
||||
|
||||
virtual Audio::Mixer *getMixer();
|
||||
|
@ -295,12 +196,8 @@ public:
|
|||
|
||||
// ResidualVM specific method
|
||||
virtual void launcherInitSize(uint w, uint h);
|
||||
bool lockMouse(bool lock);
|
||||
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) {
|
||||
setupScreen(screenW, screenH, fullscreen, accel3d, true);
|
||||
}
|
||||
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame);
|
||||
Graphics::PixelBuffer getScreenPixelBuffer();
|
||||
void updateEventScale(const GLESBaseTexture *tex);
|
||||
TouchControls* getTouchControls() { return &_touchControls; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "backends/platform/android/android.h"
|
||||
#include "backends/platform/android/events.h"
|
||||
#include "backends/platform/android/graphics.h"
|
||||
#include "backends/platform/android/jni-android.h"
|
||||
|
||||
#include "engines/engine.h"
|
||||
|
@ -79,40 +80,13 @@ void OSystem_Android::setupKeymapper() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void OSystem_Android::warpMouse(int x, int y) {
|
||||
ENTER("%d, %d", x, y);
|
||||
|
||||
Common::Event e;
|
||||
|
||||
e.type = Common::EVENT_MOUSEMOVE;
|
||||
e.mouse.x = x;
|
||||
e.mouse.y = y;
|
||||
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
}
|
||||
|
||||
void OSystem_Android::clipMouse(Common::Point &p) {
|
||||
const GLESBaseTexture *tex;
|
||||
|
||||
if (_show_overlay)
|
||||
tex = _overlay_texture;
|
||||
else
|
||||
tex = _game_texture;
|
||||
|
||||
p.x = CLIP(p.x, int16(0), int16(tex->width() - 1));
|
||||
p.y = CLIP(p.y, int16(0), int16(tex->height() - 1));
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->clipMouse(p);
|
||||
}
|
||||
|
||||
void OSystem_Android::scaleMouse(Common::Point &p, int x, int y,
|
||||
bool deductDrawRect, bool touchpadMode) {
|
||||
const GLESBaseTexture *tex;
|
||||
|
||||
if (_show_overlay)
|
||||
tex = _overlay_texture;
|
||||
else
|
||||
tex = _game_texture;
|
||||
void OSystem_Android::scaleMouse(Common::Point &p, int x, int y, bool touchpadMode) {
|
||||
const GLESBaseTexture *tex =
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->getActiveTexture();
|
||||
|
||||
const Common::Rect &r = tex->getDrawRect();
|
||||
|
||||
|
@ -121,23 +95,11 @@ void OSystem_Android::scaleMouse(Common::Point &p, int x, int y,
|
|||
y = y * 100 / _touchpad_scale;
|
||||
}
|
||||
|
||||
if (deductDrawRect) {
|
||||
x -= r.left;
|
||||
y -= r.top;
|
||||
}
|
||||
|
||||
p.x = scalef(x, tex->width(), r.width());
|
||||
p.y = scalef(y, tex->height(), r.height());
|
||||
}
|
||||
|
||||
void OSystem_Android::updateEventScale() {
|
||||
const GLESBaseTexture *tex;
|
||||
|
||||
if (_show_overlay)
|
||||
tex = _overlay_texture;
|
||||
else
|
||||
tex = _game_texture;
|
||||
|
||||
void OSystem_Android::updateEventScale(const GLESBaseTexture *tex) {
|
||||
_eventScaleY = 100 * 480 / tex->height();
|
||||
_eventScaleX = 100 * 640 / tex->width();
|
||||
}
|
||||
|
@ -429,12 +391,10 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
}
|
||||
|
||||
scaleMouse(e.mouse, arg3 - _touch_pt_scroll.x,
|
||||
arg4 - _touch_pt_scroll.y, false, true);
|
||||
arg4 - _touch_pt_scroll.y, true);
|
||||
e.mouse += _touch_pt_down;
|
||||
clipMouse(e.mouse);
|
||||
} else {
|
||||
scaleMouse(e.mouse, arg3, arg4);
|
||||
clipMouse(e.mouse);
|
||||
}
|
||||
|
||||
pushEvent(e);
|
||||
|
@ -462,7 +422,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
e.mouse = getEventManager()->getMousePos();
|
||||
} else {
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -515,7 +474,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
e.mouse = getEventManager()->getMousePos();
|
||||
} else {
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -542,10 +500,8 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
if (_touchpad_mode) {
|
||||
scaleMouse(e.mouse, arg1 - _touch_pt_dt.x,
|
||||
arg2 - _touch_pt_dt.y, false, true);
|
||||
arg2 - _touch_pt_dt.y, true);
|
||||
e.mouse += _touch_pt_down;
|
||||
|
||||
clipMouse(e.mouse);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -653,9 +609,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
case JE_MOUSE_MOVE:
|
||||
e.type = Common::EVENT_MOUSEMOVE;
|
||||
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
|
@ -663,9 +617,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
case JE_LMB_DOWN:
|
||||
e.type = Common::EVENT_LBUTTONDOWN;
|
||||
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
|
@ -673,9 +625,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
case JE_LMB_UP:
|
||||
e.type = Common::EVENT_LBUTTONUP;
|
||||
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
|
@ -683,9 +633,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
case JE_RMB_DOWN:
|
||||
e.type = Common::EVENT_RBUTTONDOWN;
|
||||
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
|
@ -693,9 +641,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||
|
||||
case JE_RMB_UP:
|
||||
e.type = Common::EVENT_RBUTTONUP;
|
||||
|
||||
scaleMouse(e.mouse, arg1, arg2);
|
||||
clipMouse(e.mouse);
|
||||
|
||||
pushEvent(e);
|
||||
|
||||
|
@ -732,29 +678,23 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
|
|||
|
||||
if (pthread_self() == _main_thread) {
|
||||
if (_screen_changeid != JNI::surface_changeid) {
|
||||
_screen_changeid = JNI::surface_changeid;
|
||||
if (JNI::egl_surface_width > 0 && JNI::egl_surface_height > 0) {
|
||||
// surface changed
|
||||
JNI::deinitSurface();
|
||||
initSurface();
|
||||
initViewport();
|
||||
updateScreenRect();
|
||||
updateEventScale();
|
||||
|
||||
// double buffered, flip twice
|
||||
clearScreen(kClearUpdate, 2);
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->initSurface();
|
||||
_touchControls.init(JNI::egl_surface_width, JNI::egl_surface_height);
|
||||
|
||||
event.type = Common::EVENT_SCREEN_CHANGED;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// surface lost
|
||||
deinitSurface();
|
||||
dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->deinitSurface();
|
||||
}
|
||||
}
|
||||
|
||||
if (JNI::pause) {
|
||||
deinitSurface();
|
||||
|
||||
LOGD("main thread going to sleep");
|
||||
sem_wait(&JNI::pause_sem);
|
||||
LOGD("main thread woke up");
|
||||
|
@ -779,11 +719,17 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
|
|||
|
||||
unlockMutex(_event_queue_lock);
|
||||
|
||||
if (event.type == Common::EVENT_MOUSEMOVE) {
|
||||
const Common::Point &m = getEventManager()->getMousePos();
|
||||
|
||||
if (m != event.mouse)
|
||||
_force_redraw = true;
|
||||
switch (event.type) {
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
if (_graphicsManager)
|
||||
return dynamic_cast<AndroidGraphicsManager *>(_graphicsManager)->notifyMousePosition(event.mouse);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
File diff suppressed because it is too large
Load diff
168
backends/platform/android/graphics.h
Executable file
168
backends/platform/android/graphics.h
Executable file
|
@ -0,0 +1,168 @@
|
|||
/* ResidualVM - Graphic Adventure Engine
|
||||
*
|
||||
* ResidualVM 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 ANDROID_GRAPHICS_H
|
||||
#define ANDROID_GRAPHICS_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "backends/graphics/resvm-graphics.h"
|
||||
|
||||
class AndroidGraphicsManager : public ResVmGraphicsManager {
|
||||
public:
|
||||
AndroidGraphicsManager();
|
||||
virtual ~AndroidGraphicsManager();
|
||||
|
||||
void initSurface();
|
||||
void deinitSurface();
|
||||
|
||||
void updateScreen() override;
|
||||
|
||||
void displayMessageOnOSD(const char *msg);
|
||||
|
||||
bool notifyMousePosition(Common::Point &mouse);
|
||||
Common::Point getMousePosition() { return Common::Point(_cursorX, _cursorY); }
|
||||
void setMousePosition(int x, int y) { _cursorX = x; _cursorY = y; }
|
||||
|
||||
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
|
||||
virtual int getDefaultGraphicsMode() const override;
|
||||
virtual bool setGraphicsMode(int mode) override;
|
||||
virtual void resetGraphicsScale() override;
|
||||
virtual int getGraphicsMode() const override;
|
||||
|
||||
virtual bool hasFeature(OSystem::Feature f) const override;
|
||||
virtual void setFeatureState(OSystem::Feature f, bool enable) override;
|
||||
virtual bool getFeatureState(OSystem::Feature f) const override;
|
||||
|
||||
virtual void showOverlay() override;
|
||||
virtual void hideOverlay() override;
|
||||
virtual void clearOverlay() override;
|
||||
virtual void grabOverlay(void *buf, int pitch) const override;
|
||||
virtual void copyRectToOverlay(const void *buf, int pitch,
|
||||
int x, int y, int w, int h) override;
|
||||
virtual int16 getOverlayHeight() const override;
|
||||
virtual int16 getOverlayWidth() const override;
|
||||
virtual Graphics::PixelFormat getOverlayFormat() const override;
|
||||
|
||||
virtual int16 getHeight() const override;
|
||||
virtual int16 getWidth() const override;
|
||||
|
||||
// PaletteManager API
|
||||
virtual void setPalette(const byte *colors, uint start, uint num) override;
|
||||
virtual void grabPalette(byte *colors, uint start, uint num) const override;
|
||||
virtual void copyRectToScreen(const void *buf, int pitch, int x, int y,
|
||||
int w, int h) override;
|
||||
virtual Graphics::Surface *lockScreen() override;
|
||||
virtual void unlockScreen() override;
|
||||
virtual void fillScreen(uint32 col);
|
||||
|
||||
virtual void initSize(uint width, uint height,
|
||||
const Graphics::PixelFormat *format) override;
|
||||
virtual int getScreenChangeID() const override;
|
||||
|
||||
virtual bool showMouse(bool visible) override;
|
||||
virtual void warpMouse(int x, int y) override;
|
||||
virtual bool lockMouse(bool lock) override;
|
||||
virtual void setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
|
||||
int hotspotY, uint32 keycolor,
|
||||
bool dontScale,
|
||||
const Graphics::PixelFormat *format) override;
|
||||
virtual void setCursorPalette(const byte *colors, uint start, uint num) override;
|
||||
|
||||
|
||||
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d) override;
|
||||
|
||||
// ResidualVM specific method
|
||||
void setupScreen(uint screenW, uint screenH, bool fullscreen, bool accel3d, bool isGame);
|
||||
virtual Graphics::PixelBuffer getScreenPixelBuffer() override;
|
||||
virtual void suggestSideTextures(Graphics::Surface *left, Graphics::Surface *right) override;
|
||||
void updateScreenRect();
|
||||
const GLESBaseTexture *getActiveTexture() const;
|
||||
void clipMouse(Common::Point &p) const;
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
virtual Graphics::PixelFormat getScreenFormat() const override;
|
||||
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void setSystemMousePosition(int x, int y) {}
|
||||
|
||||
bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format);
|
||||
|
||||
void refreshScreen();
|
||||
|
||||
void *getProcAddress(const char *name) const;
|
||||
|
||||
// ResidualVM specific code
|
||||
private:
|
||||
void setCursorPaletteInternal(const byte *colors, uint start, uint num);
|
||||
void disableCursorPalette();
|
||||
void initOverlay();
|
||||
void initViewport();
|
||||
void updateEventScale();
|
||||
|
||||
enum FixupType {
|
||||
kClear = 0, // glClear
|
||||
kClearSwap, // glClear + swapBuffers
|
||||
kClearUpdate // glClear + updateScreen
|
||||
};
|
||||
|
||||
void clearScreen(FixupType type, byte count = 1);
|
||||
#ifdef USE_RGB_COLOR
|
||||
void initTexture(GLESBaseTexture **texture, uint width, uint height,
|
||||
const Graphics::PixelFormat *format);
|
||||
#endif
|
||||
|
||||
private:
|
||||
int _screenChangeID;
|
||||
int _graphicsMode;
|
||||
bool _opengl;
|
||||
bool _fullscreen;
|
||||
bool _ar_correction;
|
||||
bool _force_redraw;
|
||||
|
||||
// Game layer
|
||||
GLESBaseTexture *_game_texture;
|
||||
Graphics::PixelBuffer _game_pbuf;
|
||||
OpenGL::FrameBuffer *_frame_buffer;
|
||||
|
||||
/**
|
||||
* The position of the mouse cursor, in window coordinates.
|
||||
*/
|
||||
int _cursorX, _cursorY;
|
||||
|
||||
// Overlay layer
|
||||
GLES4444Texture *_overlay_texture;
|
||||
bool _show_overlay;
|
||||
|
||||
// Mouse layer
|
||||
GLESBaseTexture *_mouse_texture;
|
||||
GLESBaseTexture *_mouse_texture_palette;
|
||||
GLES5551Texture *_mouse_texture_rgb;
|
||||
Common::Point _mouse_hotspot;
|
||||
uint32 _mouse_keycolor;
|
||||
int _mouse_targetscale;
|
||||
bool _show_mouse;
|
||||
bool _use_mouse_palette;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -5,7 +5,7 @@ MODULE_OBJS := \
|
|||
texture.o \
|
||||
asset-archive.o \
|
||||
android.o \
|
||||
gfx.o \
|
||||
graphics.o \
|
||||
events.o \
|
||||
snprintf.o \
|
||||
touchcontrols.o
|
||||
|
|
|
@ -58,11 +58,6 @@ static bool npot_supported = false;
|
|||
OpenGL::Shader * g_box_shader;
|
||||
GLuint g_verticesVBO;
|
||||
|
||||
static inline GLfixed xdiv(int numerator, int denominator) {
|
||||
assert(numerator < (1 << 16));
|
||||
return (numerator << 16) / denominator;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static T nextHigher2(T k) {
|
||||
if (k == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue