remove webview further
This commit is contained in:
parent
d645d3eb18
commit
21fd354931
2 changed files with 172 additions and 168 deletions
|
@ -27,7 +27,8 @@
|
|||
#include <android/log.h>
|
||||
#include <android/native_activity.h>
|
||||
|
||||
#include "webview_native_activity.h"
|
||||
//webview
|
||||
//webview #include "webview_native_activity.h"
|
||||
struct android_app * gapp;
|
||||
|
||||
#define LOGI(...) ((void)printf(__VA_ARGS__))
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
//#include "cnfa/CNFA.h"
|
||||
#include "CNFG.h"
|
||||
|
||||
//#define WEBVIEW_NATIVE_ACTIVITY_IMPLEMENTATION
|
||||
//#include "webview_native_activity.h"
|
||||
//webview//#define WEBVIEW_NATIVE_ACTIVITY_IMPLEMENTATION
|
||||
//webview//#include "webview_native_activity.h"
|
||||
|
||||
float mountainangle;
|
||||
float mountainoffsetx;
|
||||
|
@ -36,13 +36,15 @@ bool no_sensor_for_gyro = false;
|
|||
ASensorEventQueue* aeq;
|
||||
ALooper * l;
|
||||
|
||||
//WebViewNativeActivityObject MyWebView;
|
||||
//webview//WebViewNativeActivityObject MyWebView;
|
||||
|
||||
const uint32_t SAMPLE_RATE = 44100;
|
||||
const uint16_t SAMPLE_COUNT = 512;
|
||||
uint32_t stream_offset = 0;
|
||||
uint16_t audio_frequency;
|
||||
|
||||
|
||||
// Inertial Measurement Unit (gyroscopes and accelerometer)
|
||||
void SetupIMU()
|
||||
{
|
||||
sm = ASensorManager_getInstanceForPackage("gyroscope");
|
||||
|
@ -353,164 +355,164 @@ void HandleThisWindowTermination()
|
|||
|
||||
|
||||
uint32_t randomtexturedata[256*256];
|
||||
//uint32_t webviewdata[500*500];
|
||||
//char fromJSBuffer[128];
|
||||
//webview //uint32_t webviewdata[500*500];
|
||||
//webview //char fromJSBuffer[128];
|
||||
//webview
|
||||
//webview //void CheckWebView( void * v )
|
||||
//webview //{
|
||||
//webview // static int runno = 0;
|
||||
//webview // WebViewNativeActivityObject * wvn = (WebViewNativeActivityObject*)v;
|
||||
//webview // if( WebViewGetProgress( wvn ) != 100 ) return;
|
||||
//webview //
|
||||
//webview // runno++;
|
||||
//webview // if( runno == 1 )
|
||||
//webview // {
|
||||
//webview // // The attach (initial) message payload has no meaning.
|
||||
//webview // WebViewPostMessage( wvn, "", 1 );
|
||||
//webview // }
|
||||
//webview // else
|
||||
//webview // {
|
||||
//webview // // Invoke JavaScript, which calls a function to send a webmessage
|
||||
//webview // // back into C land.
|
||||
//webview // WebViewExecuteJavascript( wvn, "SendMessageToC();" );
|
||||
//webview //
|
||||
//webview // // Send a WebMessage into the JavaScript code.
|
||||
//webview // char st[128];
|
||||
//webview // sprintf( st, "Into JavaScript %d\n", runno );
|
||||
//webview // WebViewPostMessage( wvn, st, 0 );
|
||||
//webview // }
|
||||
//webview //}
|
||||
|
||||
//void CheckWebView( void * v )
|
||||
//{
|
||||
// static int runno = 0;
|
||||
// WebViewNativeActivityObject * wvn = (WebViewNativeActivityObject*)v;
|
||||
// if( WebViewGetProgress( wvn ) != 100 ) return;
|
||||
//
|
||||
// runno++;
|
||||
// if( runno == 1 )
|
||||
// {
|
||||
// // The attach (initial) message payload has no meaning.
|
||||
// WebViewPostMessage( wvn, "", 1 );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Invoke JavaScript, which calls a function to send a webmessage
|
||||
// // back into C land.
|
||||
// WebViewExecuteJavascript( wvn, "SendMessageToC();" );
|
||||
//
|
||||
// // Send a WebMessage into the JavaScript code.
|
||||
// char st[128];
|
||||
// sprintf( st, "Into JavaScript %d\n", runno );
|
||||
// WebViewPostMessage( wvn, st, 0 );
|
||||
// }
|
||||
//}
|
||||
//webview//jobject g_attachLooper;
|
||||
|
||||
jobject g_attachLooper;
|
||||
|
||||
//void SetupWebView( void * v )
|
||||
//{
|
||||
// WebViewNativeActivityObject * wvn = (WebViewNativeActivityObject*)v;
|
||||
//
|
||||
//
|
||||
// const struct JNINativeInterface * env = 0;
|
||||
// const struct JNINativeInterface ** envptr = &env;
|
||||
// const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm;
|
||||
// const struct JNIInvokeInterface * jnii = *jniiptr;
|
||||
//
|
||||
// jnii->AttachCurrentThread( jniiptr, &envptr, NULL);
|
||||
// env = (*envptr);
|
||||
//
|
||||
// while( g_attachLooper == 0 ) usleep(1);
|
||||
// WebViewCreate( wvn, "file:///android_asset/index.html", g_attachLooper, 500, 500 );
|
||||
// //WebViewCreate( wvn, "about:blank", g_attachLooper, 500, 500 );
|
||||
//}
|
||||
//webview //void SetupWebView( void * v )
|
||||
//webview //{
|
||||
//webview // WebViewNativeActivityObject * wvn = (WebViewNativeActivityObject*)v;
|
||||
//webview //
|
||||
//webview //
|
||||
//webview // const struct JNINativeInterface * env = 0;
|
||||
//webview // const struct JNINativeInterface ** envptr = &env;
|
||||
//webview // const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm;
|
||||
//webview // const struct JNIInvokeInterface * jnii = *jniiptr;
|
||||
//webview //
|
||||
//webview // jnii->AttachCurrentThread( jniiptr, &envptr, NULL);
|
||||
//webview // env = (*envptr);
|
||||
//webview //
|
||||
//webview // while( g_attachLooper == 0 ) usleep(1);
|
||||
//webview // WebViewCreate( wvn, "file:///android_asset/index.html", g_attachLooper, 500, 500 );
|
||||
//webview // //WebViewCreate( wvn, "about:blank", g_attachLooper, 500, 500 );
|
||||
//webview //}
|
||||
|
||||
|
||||
//pthread_t jsthread;
|
||||
//
|
||||
//void * JavscriptThread( void * v )
|
||||
//{
|
||||
// const struct JNINativeInterface * env = 0;
|
||||
// const struct JNINativeInterface ** envptr = &env;
|
||||
// const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm;
|
||||
// const struct JNIInvokeInterface * jnii = *jniiptr;
|
||||
//
|
||||
// jnii->AttachCurrentThread( jniiptr, &envptr, NULL);
|
||||
// env = (*envptr);
|
||||
//
|
||||
// // Create a looper on this thread...
|
||||
// jclass LooperClass = env->FindClass(envptr, "android/os/Looper");
|
||||
// jmethodID myLooperMethod = env->GetStaticMethodID(envptr, LooperClass, "myLooper", "()Landroid/os/Looper;");
|
||||
// jobject thisLooper = env->CallStaticObjectMethod( envptr, LooperClass, myLooperMethod );
|
||||
// if( !thisLooper )
|
||||
// {
|
||||
// jmethodID prepareMethod = env->GetStaticMethodID(envptr, LooperClass, "prepare", "()V");
|
||||
// env->CallStaticVoidMethod( envptr, LooperClass, prepareMethod );
|
||||
// thisLooper = env->CallStaticObjectMethod( envptr, LooperClass, myLooperMethod );
|
||||
// g_attachLooper = env->NewGlobalRef(envptr, thisLooper);
|
||||
// }
|
||||
//
|
||||
// jmethodID getQueueMethod = env->GetMethodID( envptr, LooperClass, "getQueue", "()Landroid/os/MessageQueue;" );
|
||||
// jobject lque = env->CallObjectMethod( envptr, g_attachLooper, getQueueMethod );
|
||||
//
|
||||
// jclass MessageQueueClass = env->FindClass(envptr, "android/os/MessageQueue");
|
||||
// jmethodID nextMethod = env->GetMethodID( envptr, MessageQueueClass, "next", "()Landroid/os/Message;" );
|
||||
//
|
||||
// jclass MessageClass = env->FindClass(envptr, "android/os/Message");
|
||||
// jfieldID objid = env->GetFieldID( envptr, MessageClass, "obj", "Ljava/lang/Object;" );
|
||||
// jclass PairClass = env->FindClass(envptr, "android/util/Pair");
|
||||
// jfieldID pairfirst = env->GetFieldID( envptr, PairClass, "first", "Ljava/lang/Object;" );
|
||||
//
|
||||
// while(1)
|
||||
// {
|
||||
// // Instead of using Looper::loop(), we just call next on the looper object.
|
||||
// jobject msg = env->CallObjectMethod( envptr, lque, nextMethod );
|
||||
// jobject innerObj = env->GetObjectField( envptr, msg, objid );
|
||||
// const char * name;
|
||||
// jstring strObj;
|
||||
// jclass innerClass;
|
||||
//
|
||||
// // Check Object Type
|
||||
// {
|
||||
// innerClass = env->GetObjectClass( envptr, innerObj );
|
||||
// jmethodID mid = env->GetMethodID( envptr, innerClass, "getClass", "()Ljava/lang/Class;");
|
||||
// jobject clsObj = env->CallObjectMethod( envptr, innerObj, mid );
|
||||
// jclass clazzz = env->GetObjectClass( envptr, clsObj );
|
||||
// mid = env->GetMethodID(envptr, clazzz, "getName", "()Ljava/lang/String;");
|
||||
// strObj = (jstring)env->CallObjectMethod( envptr, clsObj, mid);
|
||||
// name = env->GetStringUTFChars( envptr, strObj, 0);
|
||||
// env->DeleteLocalRef( envptr, clsObj );
|
||||
// env->DeleteLocalRef( envptr, clazzz );
|
||||
// }
|
||||
//
|
||||
// if( strcmp( name, "z5" ) == 0 )
|
||||
// {
|
||||
// // Special, Some Androids (notably Meta Quest) use a different private message type.
|
||||
// jfieldID mstrf = env->GetFieldID( envptr, innerClass, "a", "[B" );
|
||||
// jbyteArray jba = (jstring)env->GetObjectField(envptr, innerObj, mstrf );
|
||||
// int len = env->GetArrayLength( envptr, jba );
|
||||
// jboolean isCopy = 0;
|
||||
// jbyte * bufferPtr = env->GetByteArrayElements(envptr, jba, &isCopy);
|
||||
//
|
||||
// if( len >= 6 )
|
||||
// {
|
||||
// const char *descr = (const char*)bufferPtr + 6;
|
||||
// char tcpy[len-5];
|
||||
// memcpy( tcpy, descr, len-6 );
|
||||
// tcpy[len-6] = 0;
|
||||
// snprintf( fromJSBuffer, sizeof( fromJSBuffer)-1, "WebMessage: %s\n", tcpy );
|
||||
//
|
||||
// env->DeleteLocalRef( envptr, jba );
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// jobject MessagePayload = env->GetObjectField( envptr, innerObj, pairfirst );
|
||||
// // MessagePayload is a org.chromium.content_public.browser.MessagePayload
|
||||
//
|
||||
// jclass mpclass = env->GetObjectClass( envptr, MessagePayload );
|
||||
//
|
||||
// // Get field "b" which is the web message payload.
|
||||
// // If you are using binary sockets, it will be in `c` and be a byte array.
|
||||
// jfieldID mstrf = env->GetFieldID( envptr, mpclass, "b", "Ljava/lang/String;" );
|
||||
// jstring strObjDescr = (jstring)env->GetObjectField(envptr, MessagePayload, mstrf );
|
||||
//
|
||||
// const char *descr = env->GetStringUTFChars( envptr, strObjDescr, 0);
|
||||
// snprintf( fromJSBuffer, sizeof( fromJSBuffer)-1, "WebMessage: %s\n", descr );
|
||||
//
|
||||
// env->ReleaseStringUTFChars(envptr, strObjDescr, descr);
|
||||
// env->DeleteLocalRef( envptr, strObjDescr );
|
||||
// env->DeleteLocalRef( envptr, MessagePayload );
|
||||
// env->DeleteLocalRef( envptr, mpclass );
|
||||
// }
|
||||
// env->ReleaseStringUTFChars(envptr, strObj, name);
|
||||
// env->DeleteLocalRef( envptr, strObj );
|
||||
// env->DeleteLocalRef( envptr, msg );
|
||||
// env->DeleteLocalRef( envptr, innerObj );
|
||||
// env->DeleteLocalRef( envptr, innerClass );
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void SetupJSThread()
|
||||
//{
|
||||
// pthread_create( &jsthread, 0, JavscriptThread, 0 );
|
||||
//}
|
||||
//webview //pthread_t jsthread;
|
||||
//webview //
|
||||
//webview //void * JavscriptThread( void * v )
|
||||
//webview //{
|
||||
//webview // const struct JNINativeInterface * env = 0;
|
||||
//webview // const struct JNINativeInterface ** envptr = &env;
|
||||
//webview // const struct JNIInvokeInterface ** jniiptr = gapp->activity->vm;
|
||||
//webview // const struct JNIInvokeInterface * jnii = *jniiptr;
|
||||
//webview //
|
||||
//webview // jnii->AttachCurrentThread( jniiptr, &envptr, NULL);
|
||||
//webview // env = (*envptr);
|
||||
//webview //
|
||||
//webview // // Create a looper on this thread...
|
||||
//webview // jclass LooperClass = env->FindClass(envptr, "android/os/Looper");
|
||||
//webview // jmethodID myLooperMethod = env->GetStaticMethodID(envptr, LooperClass, "myLooper", "()Landroid/os/Looper;");
|
||||
//webview // jobject thisLooper = env->CallStaticObjectMethod( envptr, LooperClass, myLooperMethod );
|
||||
//webview // if( !thisLooper )
|
||||
//webview // {
|
||||
//webview // jmethodID prepareMethod = env->GetStaticMethodID(envptr, LooperClass, "prepare", "()V");
|
||||
//webview // env->CallStaticVoidMethod( envptr, LooperClass, prepareMethod );
|
||||
//webview // thisLooper = env->CallStaticObjectMethod( envptr, LooperClass, myLooperMethod );
|
||||
//webview // g_attachLooper = env->NewGlobalRef(envptr, thisLooper);
|
||||
//webview // }
|
||||
//webview //
|
||||
//webview // jmethodID getQueueMethod = env->GetMethodID( envptr, LooperClass, "getQueue", "()Landroid/os/MessageQueue;" );
|
||||
//webview // jobject lque = env->CallObjectMethod( envptr, g_attachLooper, getQueueMethod );
|
||||
//webview //
|
||||
//webview // jclass MessageQueueClass = env->FindClass(envptr, "android/os/MessageQueue");
|
||||
//webview // jmethodID nextMethod = env->GetMethodID( envptr, MessageQueueClass, "next", "()Landroid/os/Message;" );
|
||||
//webview //
|
||||
//webview // jclass MessageClass = env->FindClass(envptr, "android/os/Message");
|
||||
//webview // jfieldID objid = env->GetFieldID( envptr, MessageClass, "obj", "Ljava/lang/Object;" );
|
||||
//webview // jclass PairClass = env->FindClass(envptr, "android/util/Pair");
|
||||
//webview // jfieldID pairfirst = env->GetFieldID( envptr, PairClass, "first", "Ljava/lang/Object;" );
|
||||
//webview //
|
||||
//webview // while(1)
|
||||
//webview // {
|
||||
//webview // // Instead of using Looper::loop(), we just call next on the looper object.
|
||||
//webview // jobject msg = env->CallObjectMethod( envptr, lque, nextMethod );
|
||||
//webview // jobject innerObj = env->GetObjectField( envptr, msg, objid );
|
||||
//webview // const char * name;
|
||||
//webview // jstring strObj;
|
||||
//webview // jclass innerClass;
|
||||
//webview //
|
||||
//webview // // Check Object Type
|
||||
//webview // {
|
||||
//webview // innerClass = env->GetObjectClass( envptr, innerObj );
|
||||
//webview // jmethodID mid = env->GetMethodID( envptr, innerClass, "getClass", "()Ljava/lang/Class;");
|
||||
//webview // jobject clsObj = env->CallObjectMethod( envptr, innerObj, mid );
|
||||
//webview // jclass clazzz = env->GetObjectClass( envptr, clsObj );
|
||||
//webview // mid = env->GetMethodID(envptr, clazzz, "getName", "()Ljava/lang/String;");
|
||||
//webview // strObj = (jstring)env->CallObjectMethod( envptr, clsObj, mid);
|
||||
//webview // name = env->GetStringUTFChars( envptr, strObj, 0);
|
||||
//webview // env->DeleteLocalRef( envptr, clsObj );
|
||||
//webview // env->DeleteLocalRef( envptr, clazzz );
|
||||
//webview // }
|
||||
//webview //
|
||||
//webview // if( strcmp( name, "z5" ) == 0 )
|
||||
//webview // {
|
||||
//webview // // Special, Some Androids (notably Meta Quest) use a different private message type.
|
||||
//webview // jfieldID mstrf = env->GetFieldID( envptr, innerClass, "a", "[B" );
|
||||
//webview // jbyteArray jba = (jstring)env->GetObjectField(envptr, innerObj, mstrf );
|
||||
//webview // int len = env->GetArrayLength( envptr, jba );
|
||||
//webview // jboolean isCopy = 0;
|
||||
//webview // jbyte * bufferPtr = env->GetByteArrayElements(envptr, jba, &isCopy);
|
||||
//webview //
|
||||
//webview // if( len >= 6 )
|
||||
//webview // {
|
||||
//webview // const char *descr = (const char*)bufferPtr + 6;
|
||||
//webview // char tcpy[len-5];
|
||||
//webview // memcpy( tcpy, descr, len-6 );
|
||||
//webview // tcpy[len-6] = 0;
|
||||
//webview // snprintf( fromJSBuffer, sizeof( fromJSBuffer)-1, "WebMessage: %s\n", tcpy );
|
||||
//webview //
|
||||
//webview // env->DeleteLocalRef( envptr, jba );
|
||||
//webview // }
|
||||
//webview // }
|
||||
//webview // else
|
||||
//webview // {
|
||||
//webview // jobject MessagePayload = env->GetObjectField( envptr, innerObj, pairfirst );
|
||||
//webview // // MessagePayload is a org.chromium.content_public.browser.MessagePayload
|
||||
//webview //
|
||||
//webview // jclass mpclass = env->GetObjectClass( envptr, MessagePayload );
|
||||
//webview //
|
||||
//webview // // Get field "b" which is the web message payload.
|
||||
//webview // // If you are using binary sockets, it will be in `c` and be a byte array.
|
||||
//webview // jfieldID mstrf = env->GetFieldID( envptr, mpclass, "b", "Ljava/lang/String;" );
|
||||
//webview // jstring strObjDescr = (jstring)env->GetObjectField(envptr, MessagePayload, mstrf );
|
||||
//webview //
|
||||
//webview // const char *descr = env->GetStringUTFChars( envptr, strObjDescr, 0);
|
||||
//webview // snprintf( fromJSBuffer, sizeof( fromJSBuffer)-1, "WebMessage: %s\n", descr );
|
||||
//webview //
|
||||
//webview // env->ReleaseStringUTFChars(envptr, strObjDescr, descr);
|
||||
//webview // env->DeleteLocalRef( envptr, strObjDescr );
|
||||
//webview // env->DeleteLocalRef( envptr, MessagePayload );
|
||||
//webview // env->DeleteLocalRef( envptr, mpclass );
|
||||
//webview // }
|
||||
//webview // env->ReleaseStringUTFChars(envptr, strObj, name);
|
||||
//webview // env->DeleteLocalRef( envptr, strObj );
|
||||
//webview // env->DeleteLocalRef( envptr, msg );
|
||||
//webview // env->DeleteLocalRef( envptr, innerObj );
|
||||
//webview // env->DeleteLocalRef( envptr, innerClass );
|
||||
//webview // }
|
||||
//webview //}
|
||||
//webview //
|
||||
//webview //void SetupJSThread()
|
||||
//webview //{
|
||||
//webview // pthread_create( &jsthread, 0, JavscriptThread, 0 );
|
||||
//webview //}
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
|
@ -542,16 +544,17 @@ int main( int argc, char ** argv )
|
|||
assettext = temp;
|
||||
}
|
||||
|
||||
// Inertial Measurement Unit (gyroscopes and accelerometer)
|
||||
SetupIMU();
|
||||
|
||||
// Disabled, for now.
|
||||
//InitCNFAAndroid( AudioCallback, "A Name", SAMPLE_RATE, 0, 1, 0, SAMPLE_COUNT, 0, 0, 0 );
|
||||
//SOUND // Disabled, for now.
|
||||
//SOUND //InitCNFAAndroid( AudioCallback, "A Name", SAMPLE_RATE, 0, 1, 0, SAMPLE_COUNT, 0, 0, 0 );
|
||||
|
||||
// SetupJSThread();
|
||||
//webview// SetupJSThread();
|
||||
|
||||
// Create webview and wait for its completion
|
||||
// RunCallbackOnUIThread( SetupWebView, &MyWebView );
|
||||
// while( !MyWebView.WebViewObject ) usleep(1);
|
||||
//webview // Create webview and wait for its completion
|
||||
//webview // RunCallbackOnUIThread( SetupWebView, &MyWebView );
|
||||
//webview // while( !MyWebView.WebViewObject ) usleep(1);
|
||||
|
||||
Log( "Startup Complete" );
|
||||
|
||||
|
@ -570,8 +573,8 @@ int main( int argc, char ** argv )
|
|||
|
||||
if( suspended ) { usleep(50000); continue; }
|
||||
|
||||
// RunCallbackOnUIThread( (void(*)(void*))WebViewRequestRenderToCanvas, &MyWebView );
|
||||
// RunCallbackOnUIThread( CheckWebView, &MyWebView );
|
||||
//webview // RunCallbackOnUIThread( (void(*)(void*))WebViewRequestRenderToCanvas, &MyWebView );
|
||||
//webview // RunCallbackOnUIThread( CheckWebView, &MyWebView );
|
||||
|
||||
CNFGClearFrame();
|
||||
CNFGColor( 0xFFFFFFFF );
|
||||
|
@ -641,8 +644,8 @@ int main( int argc, char ** argv )
|
|||
randomtexturedata[x+y*256] = x | ((x*394543L+y*355+iframeno*3)<<8);
|
||||
CNFGBlitImage( randomtexturedata, 100, 600, 256, 256 );
|
||||
|
||||
//WebViewNativeGetPixels( &MyWebView, webviewdata, 500, 500 );
|
||||
//CNFGBlitImage( webviewdata, 500, 640, 500, 500 );
|
||||
//webview //WebViewNativeGetPixels( &MyWebView, webviewdata, 500, 500 );
|
||||
//webview //CNFGBlitImage( webviewdata, 500, 640, 500, 500 );
|
||||
|
||||
frames++;
|
||||
//On Android, CNFGSwapBuffers must be called, and CNFGUpdateScreenWithBitmap does not have an implied framebuffer swap.
|
||||
|
|
Loading…
Add table
Reference in a new issue