@@ -43,26 +43,27 @@ void droidboot_internal_fb_flush(lv_disp_drv_t * disp_drv, const lv_area_t * are
4343{
4444 if (s_simulator_bitmap != NULL ) {
4545 JNIEnv * env ;
46- (* s_simulator_jvm )-> GetEnv (s_simulator_jvm , (void * * ) & env , JNI_VERSION_1_6 );
46+ int ret ;
47+ if ((ret = (* s_simulator_jvm )-> GetEnv (s_simulator_jvm , (void * * ) & env , JNI_VERSION_1_6 )) != JNI_OK ) {
48+ __android_log_print (ANDROID_LOG_ERROR , "droidboot" , "failed to get jni env: %d" , ret );
49+ }
4750 void * addr ;
48- while (!AndroidBitmap_lockPixels (env , s_simulator_bitmap , & addr )) {
49- droidboot_internal_platform_system_log ( " failed locking bitmap, trying again" );
51+ while (!( ret = AndroidBitmap_lockPixels (env , s_simulator_bitmap , & addr ) )) {
52+ __android_log_print ( ANDROID_LOG_ERROR , "droidboot" , " failed to lock bitmap (%d) , trying again", ret );
5053 usleep (10000 );
5154 }
5255 __android_log_print (ANDROID_LOG_VERBOSE , "droidboot" , "locked fb %p" , addr );
53- int w = ( area -> x2 - area -> x1 + 1 ) ;
56+ int w = area -> x2 - area -> x1 + 1 ;
5457 long int location = 0 ;
55- long int byte_location = 0 ;
56- unsigned char bit_location = 0 ;
57- int32_t y ;
58- for (y = area -> y1 ; y <= area -> y2 ; y ++ ) {
59- location = ((area -> x1 + 0 ) + (y + 0 ) * droidboot_internal_get_display_width ()) * 4 ;
60- memcpy (& addr [location ], (uint32_t * ) color_p , w * 4 );
58+ // TODO fix segv :)
59+ for (int32_t y = area -> y1 ; y <= area -> y2 ; y ++ ) {
60+ location = (area -> x1 + 0 ) + (y + 0 ) * s_simulator_w ;
61+ //memcpy(&addr[location], color_p, w);
6162 color_p += w ;
6263 }
6364
64- while (!AndroidBitmap_unlockPixels (env , s_simulator_bitmap )) {
65- droidboot_internal_platform_system_log ( " failed unlocking bitmap, trying again" );
65+ while (!( ret = AndroidBitmap_unlockPixels (env , s_simulator_bitmap ) )) {
66+ __android_log_print ( ANDROID_LOG_ERROR , "droidboot" , " failed to unlock bitmap (%d) , trying again", ret );
6667 usleep (10000 );
6768 }
6869 __android_log_print (ANDROID_LOG_VERBOSE , "droidboot" , "unlocked fb %p" , addr );
@@ -144,7 +145,11 @@ bool droidboot_internal_use_double_buffering()
144145//lvgl thread
145146static void * droidboot_lv_tick_inc_thread (void * arg ) {
146147 /*Handle LitlevGL tick*/
147- (* s_simulator_jvm )-> AttachCurrentThread (s_simulator_jvm , NULL , NULL );
148+ JavaVMAttachArgs args ;
149+ args .version = JNI_VERSION_1_6 ;
150+ args .name = "lv_tick_inc_thread" ;
151+ JNIEnv * env ;
152+ (* s_simulator_jvm )-> AttachCurrentThread (s_simulator_jvm , & env , & args );
148153 while (s_simulator_running ) {
149154 sleep (1 );
150155 lv_tick_inc (1 );
@@ -157,7 +162,11 @@ static void* droidboot_lv_tick_inc_thread(void * arg) {
157162//lvgl thread
158163static void * droidboot_lv_timer_handler_thread (void * arg ) {
159164 /*Handle LitlevGL tick*/
160- (* s_simulator_jvm )-> AttachCurrentThread (s_simulator_jvm , NULL , NULL );
165+ JavaVMAttachArgs args ;
166+ args .version = JNI_VERSION_1_6 ;
167+ args .name = "lv_timer_handler_thread" ;
168+ JNIEnv * env ;
169+ (* s_simulator_jvm )-> AttachCurrentThread (s_simulator_jvm , & env , & args );
161170 while (s_simulator_running ) {
162171 sleep (1 );
163172 lv_timer_handler ();
0 commit comments