From 40f2cc28e91ab260f2f3b53d76200d4a45f660b1 Mon Sep 17 00:00:00 2001 From: RadialApps Date: Wed, 9 Aug 2017 16:05:10 +0530 Subject: [PATCH] Added preprocessor directives to most Android-specific changes --- src/bitmap.cpp | 17 +++++++++++++---- src/config.cpp | 4 ++++ src/eventthread.cpp | 7 ++++++- src/eventthread.h | 2 ++ src/input.cpp | 6 ++++++ src/main.cpp | 4 ++++ 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 0bad361..cbd5699 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -1079,8 +1079,13 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align) Vec2i gpTexSize; shState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize); - /* Disable alpha for more performance*/ - bool fastBlit = !p->touchesTaintedArea(posRect); //&& txtAlpha == 1.0f; + /* FIXME: Disable alpha while fastblitting + * for more performance on mobile devices */ +#ifdef __ANDROID__ + bool fastBlit = !p->touchesTaintedArea(posRect); +#else + bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0f; +#endif if (fastBlit) { @@ -1197,8 +1202,12 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align) } SDL_FreeSurface(txtSurf); - /* Remove this for a performance advantage, with a risk */ - /* p->addTaintedArea(posRect); */ + + /* FIXME: Marking text areas as tainted + * creates performance issues on Android */ +#ifndef __ANDROID__ + p->addTaintedArea(posRect); +#endif p->onModified(); } diff --git a/src/config.cpp b/src/config.cpp index 775316c..033e37d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -145,7 +145,11 @@ std::set setFromVec(const std::vector &vec) typedef std::vector StringVec; namespace po = boost::program_options; +#ifdef __ANDROID__ #define CONF_FILE FULL_MKXP_PATH +#else +#define CONF_FILE "mkxp.conf" +#endif Config::Config() {} diff --git a/src/eventthread.cpp b/src/eventthread.cpp index b9ae899..6702886 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -324,11 +324,12 @@ void EventThread::process(RGSSThreadData &rtData) rtData.rqReset.set(); break; } - +#ifdef __ANDROID__ if (event.key.keysym.scancode == SDL_SCANCODE_AC_BACK) { mouseState.buttons[SDL_BUTTON_RIGHT] = true; } +#endif keyStates[event.key.keysym.scancode] = true; break; @@ -345,10 +346,12 @@ void EventThread::process(RGSSThreadData &rtData) } keyStates[event.key.keysym.scancode] = false; +#ifdef __ANDROID__ if (event.key.keysym.scancode == SDL_SCANCODE_AC_BACK) { mouseState.buttons[SDL_BUTTON_RIGHT] = false; } +#endif break; @@ -406,7 +409,9 @@ void EventThread::process(RGSSThreadData &rtData) case SDL_FINGERUP : i = event.tfinger.fingerId; memset(&touchState.fingers[i], 0, sizeof(touchState.fingers[0])); +#ifdef __ANDROID__ touchState.ignoreMouse = false; +#endif break; default : diff --git a/src/eventthread.h b/src/eventthread.h index c41a494..4561ed3 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -68,7 +68,9 @@ public: struct TouchState { +#ifdef __ANDROID__ bool ignoreMouse; +#endif FingerState fingers[MAX_FINGERS]; }; diff --git a/src/input.cpp b/src/input.cpp index 896e144..b429239 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -276,7 +276,9 @@ struct OlBinding : public Binding if ((x >= olb.x && x <= olb.x + olb.u.r.width) && y >= olb.y && y <= olb.y + olb.u.r.height) { +#ifdef __ANDROID__ EventThread::touchState.ignoreMouse = true; +#endif return true; } @@ -290,7 +292,9 @@ struct OlBinding : public Binding if (d <= olb.u.c.radius) { +#ifdef __ANDROID__ EventThread::touchState.ignoreMouse = true; +#endif return true; } @@ -306,7 +310,9 @@ struct OlBinding : public Binding if ((s0 == s1) && (s1 == s2)) { +#ifdef __ANDROID__ EventThread::touchState.ignoreMouse = true; +#endif return true; } diff --git a/src/main.cpp b/src/main.cpp index c1bbcaf..0b15d2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,6 +102,10 @@ int rgssThreadFun(void *userdata) return 0; } + /* WORKAROUND: Disable blitting on Adreno devices + * Many old generation devices have multiple rendering + * issues including broken tilesets and text + * TODO: Find a real fix for this */ std::string RendererName = glGetStringInt(GL_RENDERER); bool checkAdreno = RendererName.find("Adreno") != std::string::npos; if (!conf.enableBlitting || checkAdreno)