From dcc10a6a0a4cf0ec6e2a2a95f8b110230d65f1aa Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 7 Mar 2018 16:29:31 +0000 Subject: Android: improvements to Fl:flush() implementation. Initial draw, no wasted draw cycles. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12717 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- .../app/src/main/cpp/HelloAndroid.cxx | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'ide/AndroidStudio3') diff --git a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx index bba38a5b7..b3204cdfd 100644 --- a/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx +++ b/ide/AndroidStudio3/app/src/main/cpp/HelloAndroid.cxx @@ -52,15 +52,17 @@ struct engine { struct engine engine = { 0 }; +#if 0 static void engine_draw_frame() { //if (Fl_Android_Application::lock_screen()) { - Fl::damage(FL_DAMAGE_ALL); - win->redraw(); + //Fl::damage(FL_DAMAGE_ALL); + //win->redraw(); Fl::flush(); // Fl_Android_Application::unlock_and_post_screen(); //} } + #endif static void engine_term_display() { engine.animating = 0; @@ -110,7 +112,7 @@ static void engine_handle_cmd(int32_t cmd) { ANativeWindow_getHeight(app->window), #endif WINDOW_FORMAT_RGB_565); - engine_draw_frame(); + Fl::damage(FL_DAMAGE_EXPOSE); } break; case APP_CMD_TERM_WINDOW: @@ -127,7 +129,7 @@ static void engine_handle_cmd(int32_t cmd) { break; case APP_CMD_LOST_FOCUS: engine.animating = 0; - engine_draw_frame(); + //engine_draw_frame(); break; default: break; } @@ -145,9 +147,14 @@ int main(int argc, char **argv) win = new Fl_Window(10, 10, 600, 400, "Hallo"); btn = new Fl_Button(190, 200, 280, 35, "Hello, Android!"); btn->color(FL_LIGHT2); - win->show(); - Fl::damage(FL_DAMAGE_ALL); - win->redraw(); + win->show(argc, argv); + int x; + if (Fl::damage()) + x = 0; + if (win->damage()) + x = 2; + //Fl::damage(FL_DAMAGE_ALL); + //win->redraw(); // loop waiting for stuff to do. @@ -161,7 +168,7 @@ int main(int argc, char **argv) // If not animating, we will block forever waiting for events. // If animating, we loop until all events are read, then continue // to draw the next frame of animation. - while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events, + while ((ident=ALooper_pollAll(Fl::damage() ? 0 : -1, NULL, &events, (void**)&source)) >= 0) { // Process this event. -- cgit v1.2.3