diff options
author | Angus Lees | 2010-06-11 10:54:49 +0000 |
---|---|---|
committer | Angus Lees | 2010-06-11 10:54:49 +0000 |
commit | 580c9032f02123ba1f46a49c098dbf34f0b2f3c1 (patch) | |
tree | b7831f4c83c4f3d0b71fbd9f7eb379d0b0c44f5b /backends/platform | |
parent | 3269e5cc4ca2ea04f862767595720ad2044cfd09 (diff) | |
download | scummvm-rg350-580c9032f02123ba1f46a49c098dbf34f0b2f3c1.tar.gz scummvm-rg350-580c9032f02123ba1f46a49c098dbf34f0b2f3c1.tar.bz2 scummvm-rg350-580c9032f02123ba1f46a49c098dbf34f0b2f3c1.zip |
Add support for setFocusRectangle - enabled on 'small' Android screens.
svn-id: r49594
Diffstat (limited to 'backends/platform')
3 files changed, 65 insertions, 32 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 7a8c976c82..105561e595 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -178,8 +178,8 @@ private: // Game layer GLESPaletteTexture* _game_texture; int _shake_offset; + Common::Rect _focus_rect; bool _full_screen_dirty; - Common::Array<Common::Rect> _dirty_rects; // Overlay layer GLES4444Texture* _overlay_texture; @@ -199,6 +199,7 @@ private: pthread_t _timer_thread; static void* timerThreadFunc(void* arg); + bool _enable_zoning; bool _virtkeybd_on; Common::SaveFileManager *_savefile; @@ -221,6 +222,7 @@ public: static OSystem_Android* fromJavaObject(JNIEnv* env, jobject obj); virtual void initBackend(); void addPluginDirectories(Common::FSList &dirs) const; + void enableZoning(bool enable) { _enable_zoning = enable; } virtual bool hasFeature(Feature f); virtual void setFeatureState(Feature f, bool enable); @@ -311,6 +313,7 @@ OSystem_Android::OSystem_Android(jobject am) _use_mouse_palette(false), _show_mouse(false), _show_overlay(false), + _enable_zoning(false), _savefile(0), _mixer(0), _timer(0), @@ -649,16 +652,15 @@ void OSystem_Android::setupScummVMSurface() { _mouse_texture->reinitGL(); glViewport(0, 0, _egl_surface_width, _egl_surface_height); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0, _egl_surface_width, _egl_surface_height, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + clearFocusRectangle(); CHECK_GL_ERROR(); - - _force_redraw = true; } void OSystem_Android::destroyScummVMSurface() { @@ -680,7 +682,7 @@ void OSystem_Android::initSize(uint width, uint height, _overlay_texture->allocBuffer(overlay_width, overlay_height); // Don't know mouse size yet - it gets reallocated in - // setMouseCursor. We need the palette allocated before + // setMouseCursor. We need the palette allocated before // setMouseCursor however, so just take a guess at the desired // size (it's small). _mouse_texture->allocBuffer(20, 20); @@ -695,7 +697,7 @@ int16 OSystem_Android::getWidth() { } void OSystem_Android::setPalette(const byte* colors, uint start, uint num) { - ENTER("setPalette(%p, %u, %u)", colors, start, num); + ENTER("setPalette(%p, %u, %u)", colors, start, num); if (!_use_mouse_palette) _setCursorPalette(colors, start, num); @@ -753,15 +755,39 @@ void OSystem_Android::updateScreen() { glTranslatex(0, -_shake_offset << 16, 0); } - _game_texture->drawTexture(0, 0, - _egl_surface_width, _egl_surface_height); + if (_focus_rect.isEmpty()) { + _game_texture->drawTexture(0, 0, + _egl_surface_width, _egl_surface_height); + } else { + // Need to ensure any exposed out-of-bounds region doesn't go + // all hall-of-mirrors. If _shake_offset != 0, we've already + // done this above. + const Common::Rect + screen_bounds(_game_texture->width(), _game_texture->height()); + if (!screen_bounds.contains(_focus_rect) && _shake_offset != 0) { + glClearColorx(0, 0, 0, 1 << 16); + glClear(GL_COLOR_BUFFER_BIT); + } + + glPushMatrix(); + glScalex(xdiv(_egl_surface_width, _focus_rect.width()), + xdiv(_egl_surface_height, _focus_rect.height()), + 1 << 16); + glTranslatex(-_focus_rect.left << 16, -_focus_rect.top << 16, 0); + glScalex(xdiv(_game_texture->width(), _egl_surface_width), + xdiv(_game_texture->height(), _egl_surface_height), + 1 << 16); + _game_texture->drawTexture(0, 0, + _egl_surface_width, _egl_surface_height); + glPopMatrix(); + } CHECK_GL_ERROR(); if (_show_overlay) { _overlay_texture->drawTexture(0, 0, - _egl_surface_width, - _egl_surface_height); + _egl_surface_width, + _egl_surface_height); CHECK_GL_ERROR(); } @@ -769,8 +795,8 @@ void OSystem_Android::updateScreen() { glPushMatrix(); glTranslatex(-_mouse_hotspot.x << 16, - -_mouse_hotspot.y << 16, - 0); + -_mouse_hotspot.y << 16, + 0); // Scale up ScummVM -> OpenGL (pixel) coordinates int texwidth, texheight; @@ -782,8 +808,8 @@ void OSystem_Android::updateScreen() { texheight = getHeight(); } glScalex(xdiv(_egl_surface_width, texwidth), - xdiv(_egl_surface_height, texheight), - 1 << 16); + xdiv(_egl_surface_height, texheight), + 1 << 16); // Note the extra half texel to position the mouse in // the middle of the x,y square: @@ -845,26 +871,18 @@ void OSystem_Android::fillScreen(uint32 col) { void OSystem_Android::setFocusRectangle(const Common::Rect& rect) { ENTER("setFocusRectangle(%d,%d,%d,%d)", rect.left, rect.top, rect.right, rect.bottom); -#if 0 - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrthof(rect.left, rect.right, rect.top, rect.bottom, 0, 1); - glMatrixMode(GL_MODELVIEW); - - _force_redraw = true; -#endif + if (_enable_zoning) { + _focus_rect = rect; + _force_redraw = true; + } } void OSystem_Android::clearFocusRectangle() { ENTER("clearFocusRectangle()"); -#if 0 - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrthof(0, _egl_surface_width, _egl_surface_height, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - - _force_redraw = true; -#endif + if (_enable_zoning) { + _focus_rect = Common::Rect(); + _force_redraw = true; + } } void OSystem_Android::showOverlay() { @@ -1342,6 +1360,11 @@ void AndroidPluginProvider::addCustomDirectories(Common::FSList &dirs) const { } #endif +static void ScummVM_enableZoning(JNIEnv* env, jobject self, jboolean enable) { + OSystem_Android* cpp_obj = OSystem_Android::fromJavaObject(env, self); + cpp_obj->enableZoning(enable); +} + const static JNINativeMethod gMethods[] = { { "create", "(Landroid/content/res/AssetManager;)V", (void*)ScummVM_create }, @@ -1356,6 +1379,8 @@ const static JNINativeMethod gMethods[] = { (void*)ScummVM_setConfManInt }, { "setConfMan", "(Ljava/lang/String;Ljava/lang/String;)V", (void*)ScummVM_setConfManString }, + { "enableZoning", "(Z)V", + (void*)ScummVM_enableZoning }, }; JNIEXPORT jint JNICALL diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java index f4dca0e7e5..4ce8a85f30 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java @@ -162,6 +162,7 @@ public class ScummVM implements SurfaceHolder.Callback { final public native static void loadConfigFile(String path); final public native static void setConfMan(String key, int value); final public native static void setConfMan(String key, String value); + final public native void enableZoning(boolean enable); // Feed an event to ScummVM. Safe to call from other threads. final public native void pushEvent(Event e); diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java index fb3cd6348f..ba3c058ae4 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java @@ -1,7 +1,7 @@ package org.inodes.gus.scummvm; -import android.app.AlertDialog; import android.app.Activity; +import android.app.AlertDialog; import android.content.DialogInterface; import android.content.res.Configuration; import android.media.AudioManager; @@ -9,13 +9,14 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.Message; +import android.util.DisplayMetrics; import android.util.Log; -import android.view.inputmethod.InputMethodManager; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceView; import android.view.View; import android.view.ViewConfiguration; +import android.view.inputmethod.InputMethodManager; import android.widget.Toast; import java.io.IOException; @@ -33,6 +34,12 @@ public class ScummVMActivity extends Activity { public MyScummVM() { super(ScummVMActivity.this); + + // Enable ScummVM zoning on 'small' screens. + // This 'density' term is very confusing. + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + enableZoning(metrics.densityDpi <= DisplayMetrics.DENSITY_LOW); } @Override |