diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-03 21:19:36 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-08-03 21:19:36 +0900 |
commit | b24e4295913ab94026f169e9c7d93ec994a25131 (patch) | |
tree | b4849b264ad29ad882c3681a507a4897ecd0d731 /sample/simple-egl | |
parent | 66fa7d855401b3ec31f5d9d85de1d584ede9525e (diff) |
Use new libwindowmanager API
Change-Id: I7239b6ef7034c4982a7e17c5bbbff57c9bd7dce4
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'sample/simple-egl')
-rw-r--r-- | sample/simple-egl/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sample/simple-egl/src/simple-egl.cpp | 97 |
2 files changed, 56 insertions, 43 deletions
diff --git a/sample/simple-egl/CMakeLists.txt b/sample/simple-egl/CMakeLists.txt index 57bdfbd..05cfaff 100644 --- a/sample/simple-egl/CMakeLists.txt +++ b/sample/simple-egl/CMakeLists.txt @@ -16,7 +16,7 @@ project(simple-egl C CXX) -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 2.8) set(PROJECT_NAME "simple-egl") set(PROJECT_VERSION "1.0") diff --git a/sample/simple-egl/src/simple-egl.cpp b/sample/simple-egl/src/simple-egl.cpp index be694d7..0f601c2 100644 --- a/sample/simple-egl/src/simple-egl.cpp +++ b/sample/simple-egl/src/simple-egl.cpp @@ -55,12 +55,12 @@ using namespace std; - +const char* log_prefix = "simple-egl"; uint32_t g_id_ivisurf = 9009; long port = 1700; string token = string("wm"); -string app_name = string("Navigation"); +const char* role = "test"; LibHomeScreen* hs; LibWindowmanager *wm; @@ -194,7 +194,7 @@ init_egl(struct display *display, struct window *window) if (window->opaque || window->buffer_size == 16) config_attribs[9] = 0; - + display->egl.dpy = weston_platform_get_egl_display(EGL_PLATFORM_WAYLAND_KHR, display->display, NULL); assert(display->egl.dpy); @@ -223,7 +223,7 @@ init_egl(struct display *display, struct window *window) } free(configs); if (display->egl.conf == NULL) { - HMI_ERROR("simple-egl","did not find config with buffer size %d", + HMI_ERROR(log_prefix,"did not find config with buffer size %d", window->buffer_size); exit(EXIT_FAILURE); } @@ -243,7 +243,7 @@ init_egl(struct display *display, struct window *window) eglGetProcAddress("eglSwapBuffersWithDamageEXT"); if (display->swap_buffers_with_damage) - HMI_DEBUG("simple-egl","has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage"); + HMI_DEBUG(log_prefix,"has EGL_EXT_buffer_age and EGL_EXT_swap_buffers_with_damage"); } @@ -271,7 +271,7 @@ create_shader(struct window *window, const char *source, GLenum shader_type) char log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - HMI_ERROR("simple-egl","Error: compiling %s: %*s", + HMI_ERROR(log_prefix,"Error: compiling %s: %*s", shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment", len, log); exit(1); @@ -300,7 +300,7 @@ init_gl(struct window *window) char log[1000]; GLsizei len; glGetProgramInfoLog(program, 1000, &len, log); - HMI_ERROR("simple-egl","Error: linking:%*s", len, log); + HMI_ERROR(log_prefix,"Error: linking:%*s", len, log); exit(1); } @@ -326,7 +326,7 @@ create_ivi_surface(struct window *window, struct display *display) id_ivisurf, window->surface); if (window->ivi_surface == NULL) { - HMI_ERROR("simple-egl","Failed to create ivi_client_surface"); + HMI_ERROR(log_prefix,"Failed to create ivi_client_surface"); abort(); } @@ -426,7 +426,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) window->benchmark_time = time; if (time - window->benchmark_time > (benchmark_interval * 1000)) { - HMI_DEBUG("simple-egl","%d frames in %d seconds: %f fps", + HMI_DEBUG(log_prefix,"%d frames in %d seconds: %f fps", window->frames, benchmark_interval, (float) window->frames / benchmark_interval); @@ -484,7 +484,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) } else { eglSwapBuffers(display->egl.dpy, window->egl_surface); } - + window->frames++; } @@ -525,29 +525,29 @@ signal_int(int signum) int init_wm(LibWindowmanager *wm, struct window *window) { - HMI_DEBUG("simple-egl","called"); + HMI_DEBUG(log_prefix,"called"); - if (wm->init(port, token.c_str()) != 0) { - HMI_ERROR("simple-egl","wm init failed. "); + if (wm->init(port, token) != 0) { + HMI_ERROR(log_prefix,"wm init failed. "); return -1; } - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str())); - g_id_ivisurf = wm->requestSurface(obj); + g_id_ivisurf = wm->requestSurface(role); if (g_id_ivisurf < 0) { - HMI_ERROR("simple-egl","wm request surface failed "); + HMI_ERROR(log_prefix,"wm request surface failed "); return -1; } - HMI_DEBUG("simple-egl","IVI_SURFACE_ID: %d ", g_id_ivisurf); - wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm, window](json_object *object) { - const char *label = json_object_get_string( - json_object_object_get(object, wm->kKeyDrawingName)); - const char *area = json_object_get_string( - json_object_object_get(object, wm->kKeyDrawingArea)); - - HMI_DEBUG("simple-egl","Surface %s got syncDraw! Area: %s. ", label, area); - if ((wm->kStrLayoutNormal + "." + wm->kStrAreaFull) == std::string(area)) { + HMI_DEBUG(log_prefix,"IVI_SURFACE_ID: %d ", g_id_ivisurf); + wm->setSyncDrawHandler([wm, window](const char* role, const char* area, const Rect& rect) { + + HMI_DEBUG(log_prefix,"Surface %s got syncDraw! Area: %s. ", role, area); + + window->geometry.width = rect.width(); + window->geometry.width = rect.height(); + + wm->endDraw(role); + + /* if ((wm->kStrLayoutNormal + "." + wm->kStrAreaFull) == std::string(area)) { wl_egl_window_resize(window->native, 1080, 1488, 0, 0); window->geometry.width = 1080; window->geometry.height = 1488; @@ -562,10 +562,29 @@ init_wm(LibWindowmanager *wm, struct window *window) if (!window->fullscreen) window->window_size = window->geometry; json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str())); + json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(role())); - wm->endDraw(obj); + wm->endDraw(obj);*/ }); + wm->setActivatedHandler([](const char* role){ + HMI_DEBUG(log_prefix, "activated : %s", role); + }); + wm->setInactivedHandler([](const char* role){ + HMI_DEBUG(log_prefix, "inactivated : %s", role); + }); + wm->setVisibleHandler([](const char* role){ + HMI_DEBUG(log_prefix, "visible : %s", role); + }); + wm->setInvisibleHandler([](const char* role){ + HMI_DEBUG(log_prefix, "invisible : %s", role); + }); + wm->setFlushDrawHandler([](const char* role){ + HMI_DEBUG(log_prefix, "flushDraw : %s", role); + }); + wm->setScreenUpdatedHandler([](const vector<string> &ids){ + HMI_DEBUG(log_prefix, "id : %s", ids[0].c_str()); + }); + return 0; } @@ -574,21 +593,18 @@ int init_hs(LibHomeScreen* hs){ if(hs->init(port, token)!=0) { - HMI_ERROR("simple-egl","homescreen init failed. "); + HMI_ERROR(log_prefix,"homescreen init failed. "); return -1; } hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](json_object *object){ const char *application_name = json_object_get_string( json_object_object_get(object, "application_name")); - HMI_DEBUG("simple-egl","Event_TapShortcut application_name = %s ", application_name); - if(strcmp(application_name, app_name.c_str()) == 0) + HMI_DEBUG(log_prefix,"Event_TapShortcut application_name = %s ", application_name); + if(strcmp(application_name, "Navigation") == 0) { - HMI_DEBUG("simple-egl","try to activesurface %s ", app_name.c_str()); - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str())); - json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full")); - wm->activateSurface(obj); + wm->activateWindow(role, "normal.full"); + HMI_DEBUG(log_prefix,"try to activesurface %s ", role); } }); @@ -615,7 +631,7 @@ main(int argc, char **argv) token = argv[2]; } - HMI_DEBUG("simple-egl","app_name: %s, port: %d, token: %s. ", app_name.c_str(), port, token.c_str()); + HMI_DEBUG(log_prefix,"app_name: %s, port: %d, token: %s. ", role, port, token.c_str()); display.display = wl_display_connect(NULL); assert(display.display); @@ -662,10 +678,7 @@ main(int argc, char **argv) sigaction(SIGINT, &sigint, NULL); eglSwapBuffers(window.display->egl.dpy, window.egl_surface); - json_object *obj = json_object_new_object(); - json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str())); - json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full")); - wm->activateSurface(obj); + wm->activateWindow(role, "normal.full"); /* The mainloop here is a little subtle. Redrawing will cause * EGL to read events so we can just call @@ -676,7 +689,7 @@ main(int argc, char **argv) redraw(&window, NULL, 0); } - HMI_DEBUG("simple-egl","simple-egl exiting! "); + HMI_DEBUG(log_prefix,"simple-egl exiting! "); destroy_surface(&window); fini_egl(&display); |