ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

jni.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef _ANDROID_JNI_H_
00024 #define _ANDROID_JNI_H_
00025 
00026 #if defined(__ANDROID__)
00027 
00028 #include <jni.h>
00029 #include <semaphore.h>
00030 
00031 #include "common/fs.h"
00032 #include "common/archive.h"
00033 
00034 class OSystem_Android;
00035 
00036 class JNI {
00037 private:
00038     JNI();
00039     virtual ~JNI();
00040 
00041 public:
00042     static bool pause;
00043     static sem_t pause_sem;
00044 
00045     static int surface_changeid;
00046     static int egl_surface_width;
00047     static int egl_surface_height;
00048 
00049     static jint onLoad(JavaVM *vm);
00050 
00051     static JNIEnv *getEnv();
00052 
00053     static void attachThread();
00054     static void detachThread();
00055 
00056     static void setReadyForEvents(bool ready);
00057 
00058     static void setWindowCaption(const char *caption);
00059     static void getDPI(float *values);
00060     static void displayMessageOnOSD(const char *msg);
00061     static bool openUrl(const char *url);
00062     static bool isConnectionLimited();
00063     static void showVirtualKeyboard(bool enable);
00064     static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
00065 
00066     static inline bool haveSurface();
00067     static inline bool swapBuffers();
00068     static bool initSurface();
00069     static void deinitSurface();
00070 
00071     static void setAudioPause();
00072     static void setAudioPlay();
00073     static void setAudioStop();
00074 
00075     static inline int writeAudio(JNIEnv *env, jbyteArray &data, int offset,
00076                                     int size);
00077 
00078 private:
00079     static JavaVM *_vm;
00080     // back pointer to (java) peer instance
00081     static jobject _jobj;
00082     static jobject _jobj_audio_track;
00083     static jobject _jobj_egl;
00084     static jobject _jobj_egl_display;
00085     static jobject _jobj_egl_surface;
00086 
00087     static Common::Archive *_asset_archive;
00088     static OSystem_Android *_system;
00089 
00090     static bool _ready_for_events;
00091 
00092     static jmethodID _MID_getDPI;
00093     static jmethodID _MID_displayMessageOnOSD;
00094     static jmethodID _MID_openUrl;
00095     static jmethodID _MID_isConnectionLimited;
00096     static jmethodID _MID_setWindowCaption;
00097     static jmethodID _MID_showVirtualKeyboard;
00098     static jmethodID _MID_getSysArchives;
00099     static jmethodID _MID_initSurface;
00100     static jmethodID _MID_deinitSurface;
00101 
00102     static jmethodID _MID_EGL10_eglSwapBuffers;
00103 
00104     static jmethodID _MID_AudioTrack_flush;
00105     static jmethodID _MID_AudioTrack_pause;
00106     static jmethodID _MID_AudioTrack_play;
00107     static jmethodID _MID_AudioTrack_stop;
00108     static jmethodID _MID_AudioTrack_write;
00109 
00110     static const JNINativeMethod _natives[];
00111 
00112     static void throwByName(JNIEnv *env, const char *name, const char *msg);
00113     static void throwRuntimeException(JNIEnv *env, const char *msg);
00114 
00115     // natives for the dark side
00116     static void create(JNIEnv *env, jobject self, jobject asset_manager,
00117                         jobject egl, jobject egl_display,
00118                         jobject at, jint audio_sample_rate,
00119                         jint audio_buffer_size);
00120     static void destroy(JNIEnv *env, jobject self);
00121 
00122     static void setSurface(JNIEnv *env, jobject self, jint width, jint height);
00123     static jint main(JNIEnv *env, jobject self, jobjectArray args);
00124 
00125     static void pushEvent(JNIEnv *env, jobject self, int type, int arg1,
00126                             int arg2, int arg3, int arg4, int arg5, int arg6);
00127     static void enableZoning(JNIEnv *env, jobject self, jboolean enable);
00128 
00129     static void setPause(JNIEnv *env, jobject self, jboolean value);
00130 };
00131 
00132 inline bool JNI::haveSurface() {
00133     return _jobj_egl_surface != 0;
00134 }
00135 
00136 inline bool JNI::swapBuffers() {
00137     JNIEnv *env = JNI::getEnv();
00138 
00139     return env->CallBooleanMethod(_jobj_egl, _MID_EGL10_eglSwapBuffers,
00140                                     _jobj_egl_display, _jobj_egl_surface);
00141 }
00142 
00143 inline int JNI::writeAudio(JNIEnv *env, jbyteArray &data, int offset, int size) {
00144     return env->CallIntMethod(_jobj_audio_track, _MID_AudioTrack_write, data,
00145                                 offset, size);
00146 }
00147 
00148 #endif
00149 #endif


Generated on Sat Mar 23 2019 05:01:44 for ResidualVM by doxygen 1.7.1
curved edge   curved edge