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