diff options
Diffstat (limited to 'backends/platform/android/android.cpp')
-rw-r--r-- | backends/platform/android/android.cpp | 149 |
1 files changed, 13 insertions, 136 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 2ae36c8073..67657b732e 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -60,6 +60,7 @@ #include "backends/platform/android/jni.h" #include "backends/platform/android/android.h" +#include "backends/platform/android/graphics.h" const char *android_log_tag = "ScummVM"; @@ -80,62 +81,11 @@ extern "C" { } } -#ifdef ANDROID_DEBUG_GL -static const char *getGlErrStr(GLenum error) { - switch (error) { - case GL_INVALID_ENUM: - return "GL_INVALID_ENUM"; - case GL_INVALID_VALUE: - return "GL_INVALID_VALUE"; - case GL_INVALID_OPERATION: - return "GL_INVALID_OPERATION"; - case GL_STACK_OVERFLOW: - return "GL_STACK_OVERFLOW"; - case GL_STACK_UNDERFLOW: - return "GL_STACK_UNDERFLOW"; - case GL_OUT_OF_MEMORY: - return "GL_OUT_OF_MEMORY"; - } - - static char buf[40]; - snprintf(buf, sizeof(buf), "(Unknown GL error code 0x%x)", error); - - return buf; -} - -void checkGlError(const char *expr, const char *file, int line) { - GLenum error = glGetError(); - - if (error != GL_NO_ERROR) - LOGE("GL ERROR: %s on %s (%s:%d)", getGlErrStr(error), expr, file, line); -} -#endif - 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), - _egl_surface_width(0), - _egl_surface_height(0), - _htc_fail(true), - _force_redraw(false), - _game_texture(0), - _overlay_texture(0), - _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), - _enable_zoning(false), - _mutexManager(0), _mixer(0), - _shake_offset(0), _queuedEventTime(0), _event_queue_lock(0), _touch_pt_down(), @@ -153,22 +103,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(); - /*_htc_fail = mf.contains("htc"); - - if (_htc_fail) - LOGI("Enabling HTC workaround");*/ } OSystem_Android::~OSystem_Android() { @@ -182,9 +124,6 @@ OSystem_Android::~OSystem_Android() { _timerManager = 0; deleteMutex(_event_queue_lock); - - delete _mutexManager; - _mutexManager = 0; } void *OSystem_Android::timerThreadFunc(void *arg) { @@ -390,15 +329,7 @@ void OSystem_Android::initBackend() { _audio_thread_exit = false; pthread_create(&_audio_thread, 0, audioThreadFunc, this); - initSurface(); - initViewport(); - - _game_texture = new GLESFakePalette565Texture(); - _overlay_texture = new GLES4444Texture(); - _mouse_texture_palette = new GLESFakePalette5551Texture(); - _mouse_texture = _mouse_texture_palette; - - initOverlay(); + _graphicsManager = new AndroidGraphicsManager(); // renice this thread to boost the audio thread if (setpriority(PRIO_PROCESS, 0, 19) < 0) @@ -406,42 +337,28 @@ void OSystem_Android::initBackend() { JNI::setReadyForEvents(true); - EventsBaseBackend::initBackend(); + ModularBackend::initBackend(); } bool OSystem_Android::hasFeature(Feature f) { - return (f == kFeatureFullscreenMode || - f == kFeatureAspectRatioCorrection || - f == kFeatureCursorPalette || - f == kFeatureVirtualKeyboard || - f == kFeatureOverlaySupportsAlpha || + if (f == kFeatureVirtualKeyboard || f == kFeatureOpenUrl || f == kFeatureTouchpadMode || f == kFeatureOnScreenControl || - f == kFeatureClipboardSupport); + f == kFeatureClipboardSupport) { + return true; + } + 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; @@ -451,26 +368,21 @@ 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); } } @@ -487,26 +399,6 @@ void OSystem_Android::delayMillis(uint msecs) { usleep(msecs * 1000); } -OSystem::MutexRef OSystem_Android::createMutex() { - assert(_mutexManager); - return _mutexManager->createMutex(); -} - -void OSystem_Android::lockMutex(MutexRef mutex) { - assert(_mutexManager); - _mutexManager->lockMutex(mutex); -} - -void OSystem_Android::unlockMutex(MutexRef mutex) { - assert(_mutexManager); - _mutexManager->unlockMutex(mutex); -} - -void OSystem_Android::deleteMutex(MutexRef mutex) { - assert(_mutexManager); - _mutexManager->deleteMutex(mutex); -} - void OSystem_Android::quit() { ENTER(); @@ -517,13 +409,6 @@ 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(); } void OSystem_Android::setWindowCaption(const char *caption) { @@ -532,12 +417,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); @@ -563,15 +442,13 @@ void OSystem_Android::getTimeAndDate(TimeDate &td) const { td.tm_wday = tm.tm_wday; } -void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, - int priority) { +void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { ENTER(""); JNI::addSysArchivesToSearchSet(s, priority); } -void OSystem_Android::logMessage(LogMessageType::Type type, - const char *message) { +void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) { switch (type) { case LogMessageType::kInfo: __android_log_write(ANDROID_LOG_INFO, android_log_tag, message); |