comment out wbeview stuff
This commit is contained in:
parent
fb057ac80d
commit
cb08deb96a
1 changed files with 164 additions and 164 deletions
|
@ -23,8 +23,8 @@
|
|||
//#include "cnfa/CNFA.h"
|
||||
#include "CNFG.h"
|
||||
|
||||
#define WEBVIEW_NATIVE_ACTIVITY_IMPLEMENTATION
|
||||
#include "webview_native_activity.h"
|
||||
//#define WEBVIEW_NATIVE_ACTIVITY_IMPLEMENTATION
|
||||
//#include "webview_native_activity.h"
|
||||
|
||||
float mountainangle;
|
||||
float mountainoffsetx;
|
||||
|
@ -36,7 +36,7 @@ bool no_sensor_for_gyro = false;
|
|||
ASensorEventQueue* aeq;
|
||||
ALooper * l;
|
||||
|
||||
WebViewNativeActivityObject MyWebView;
|
||||
//WebViewNativeActivityObject MyWebView;
|
||||
|
||||
const uint32_t SAMPLE_RATE = 44100;
|
||||
const uint16_t SAMPLE_COUNT = 512;
|
||||
|
@ -353,164 +353,164 @@ void HandleThisWindowTermination()
|
|||
|
||||
|
||||
uint32_t randomtexturedata[256*256];
|
||||
uint32_t webviewdata[500*500];
|
||||
char fromJSBuffer[128];
|
||||
//uint32_t webviewdata[500*500];
|
||||
//char fromJSBuffer[128];
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
//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 );
|
||||
// }
|
||||
//}
|
||||
|
||||
jobject g_attachLooper;
|
||||
|
||||
void SetupWebView( void * v )
|
||||
{
|
||||
WebViewNativeActivityObject * wvn = (WebViewNativeActivityObject*)v;
|
||||
//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 );
|
||||
//}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
//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 );
|
||||
//}
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
|
@ -531,7 +531,7 @@ int main( int argc, char ** argv )
|
|||
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 );
|
||||
if( file )
|
||||
{
|
||||
|
@ -547,11 +547,11 @@ int main( int argc, char ** argv )
|
|||
// Disabled, for now.
|
||||
//InitCNFAAndroid( AudioCallback, "A Name", SAMPLE_RATE, 0, 1, 0, SAMPLE_COUNT, 0, 0, 0 );
|
||||
|
||||
SetupJSThread();
|
||||
// SetupJSThread();
|
||||
|
||||
// Create webview and wait for its completion
|
||||
RunCallbackOnUIThread( SetupWebView, &MyWebView );
|
||||
while( !MyWebView.WebViewObject ) usleep(1);
|
||||
// RunCallbackOnUIThread( SetupWebView, &MyWebView );
|
||||
// while( !MyWebView.WebViewObject ) usleep(1);
|
||||
|
||||
Log( "Startup Complete" );
|
||||
|
||||
|
@ -570,8 +570,8 @@ int main( int argc, char ** argv )
|
|||
|
||||
if( suspended ) { usleep(50000); continue; }
|
||||
|
||||
RunCallbackOnUIThread( (void(*)(void*))WebViewRequestRenderToCanvas, &MyWebView );
|
||||
RunCallbackOnUIThread( CheckWebView, &MyWebView );
|
||||
// RunCallbackOnUIThread( (void(*)(void*))WebViewRequestRenderToCanvas, &MyWebView );
|
||||
// RunCallbackOnUIThread( CheckWebView, &MyWebView );
|
||||
|
||||
CNFGClearFrame();
|
||||
CNFGColor( 0xFFFFFFFF );
|
||||
|
@ -633,7 +633,7 @@ int main( int argc, char ** argv )
|
|||
// Last WebMessage
|
||||
CNFGColor( 0xFFFFFFFF );
|
||||
CNFGPenX = 0; CNFGPenY = 100;
|
||||
CNFGDrawText( fromJSBuffer, 6 );
|
||||
// CNFGDrawText( fromJSBuffer, 6 );
|
||||
|
||||
int x, 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);
|
||||
CNFGBlitImage( randomtexturedata, 100, 600, 256, 256 );
|
||||
|
||||
WebViewNativeGetPixels( &MyWebView, webviewdata, 500, 500 );
|
||||
CNFGBlitImage( webviewdata, 500, 640, 500, 500 );
|
||||
//WebViewNativeGetPixels( &MyWebView, webviewdata, 500, 500 );
|
||||
//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