#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include <unistd.h>
+#include <time.h>
+
#include "libwindowmanager.h"
#include <libhomescreen.hpp>
LibHomeScreen* hs;
LibWindowmanager *wm;
+bool gIsDraw = false;
static const struct wl_interface *types[] = {
NULL,
EGLSurface egl_surface;
struct wl_callback *callback;
int fullscreen, opaque, buffer_size, frame_sync;
-};
+} *gWindow;
static const char *vert_shader_text =
"uniform mat4 rotation;\n"
glGetUniformLocation(program, "rotation");
}
-static void
-handle_ivi_surface_configure(void *data, struct ivi_surface *ivi_surface,
- int32_t width, int32_t height)
-{
- struct window *window = data;
-
- wl_egl_window_resize(window->native, width, height, 0, 0);
-
- window->geometry.width = width;
- window->geometry.height = height;
-
- if (!window->fullscreen)
- window->window_size = window->geometry;
-}
-
-static const struct ivi_surface_listener ivi_surface_listener = {
- handle_ivi_surface_configure,
-};
-
static void
create_ivi_surface(struct window *window, struct display *display)
{
abort();
}
- ivi_surface_add_listener(window->ivi_surface,
- &ivi_surface_listener, window);
}
static void
{ 0, 0.5 }
};
+ static const GLfloat verts_sub[3][2] = {
+ { -0.25, -0.5 },
+ { 0.25, -0.5 },
+ { 0, 0.5 }
+ };
+
static const GLfloat colors_H[3][3] = {
{ 1, 1, 1 },
{ 1, 1, 1 },
time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
if (window->frames == 0)
window->benchmark_time = time;
+
if (time - window->benchmark_time > (benchmark_interval * 1000)) {
debug_out("%d frames in %d seconds: %f fps\n",
window->frames,
glClearColor(0.0, 0.0, 0.0, 0.5);
glClear(GL_COLOR_BUFFER_BIT);
- glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
+ if(window->geometry.height == 1488)
+ {
+ glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
+ }
+ else
+ {
+ glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts_sub);
+ }
if(app_name == string("HVAC")){
glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors_H);
}
return -1;
}
- if (wm->requestSurface(app_name.c_str()) != 0) {
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+ if (wm->requestSurface(obj) != 0) {
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] wm request surface failed \n");
return -1;
}
- wm->set_event_handler(LibWindowmanager::Event_Active, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Active, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got activated! \n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Inactive, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Inactive, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got inactivated!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Visible, [wm](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Visible, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got visibled!\n", label);
});
- wm->set_event_handler(LibWindowmanager::Event_Invisible, [](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_Invisible, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got invisibled!\n", label);
+ gIsDraw = false;
});
- wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](char const *label) {
+ wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](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));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got syncdraw!\n", label);
+ if ((wm->kStrLayoutNormal + "." + wm->kStrAreaFull) == std::string(area)) {
+ wl_egl_window_resize(gWindow->native, 1080, 1488, 0, 0);
+ gWindow->geometry.width = 1080;
+ gWindow->geometry.height = 1488;
+ }
+ else if ((wm->kStrLayoutSplit + "." + wm->kStrAreaMain) == std::string(area) ||
+ (wm->kStrLayoutSplit + "." + wm->kStrAreaSub) == std::string(area)) {
+ wl_egl_window_resize(gWindow->native, 1080, 744, 0, 0);
+ gWindow->geometry.width = 1080;
+ gWindow->geometry.height = 744;
+ }
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] try to endDraw %s \n", app_name.c_str());
- wm->endDraw(app_name.c_str());
- });
-
- wm->set_event_handler(LibWindowmanager::Event_FlushDraw, [](char const *label) {
+ if (!gWindow->fullscreen)
+ gWindow->window_size = gWindow->geometry;
+ gIsDraw = true;
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
+
+ wm->endDraw(obj);
+ });
+
+ wm->set_event_handler(LibWindowmanager::Event_FlushDraw, [wm](json_object *object) {
+ const char *label = json_object_get_string(
+ json_object_object_get(object, wm->kKeyDrawingName));
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] Surface %s got flushdraw! \n", label);
});
do
{
surfaceIdStr = getenv("QT_IVI_SURFACE_ID");
- } while (surfaceIdStr == NULL);
-
+ } while (surfaceIdStr == NULL);
+
g_id_ivisurf = atoi(surfaceIdStr);
debug_out("************** [SIMPLE EGL] [WM SIMPLE >>>>] IVI_SURFACE_ID: %d \n", g_id_ivisurf);
return -1;
}
- hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [](const char* application_name){
+ 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"));
debug_out("************** [SIMPLE EGL] [HS SIMPLE >>>>] Event_TapShortcut application_name = %s \n", application_name);
if(strcmp(application_name, app_name.c_str()) == 0)
{
debug_out("************** [SIMPLE EGL] [HS SIMPLE] try to activesurface %s \n", app_name.c_str());
- wm->activateSurface(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"));
+ gIsDraw = false;
+ wm->activateSurface(obj);
}
});
- hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](const char* display_message){
+ hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [](json_object *object){
+ const char *display_message = json_object_get_string(
+ json_object_object_get(object, "display_message"));
debug_out("************** [SIMPLE EGL] [HS SIMPLE >>>>] Event_OnScreenMessage display_message = %s \n", display_message);
});
main(int argc, char **argv)
{
struct sigaction sigint;
- struct window window = { 0 };
+ struct window window = { 0 };
struct display display = { 0 };
if(getenv("ENABLE_DEMO_DEBUG"))
window.window_size = window.geometry;
window.buffer_size = 32;
window.frame_sync = 1;
+ gWindow = &window;
if(argc > 2)
{
create_surface(&window);
init_gl(&window);
-
+
//Ctrl+C
sigint.sa_handler = signal_int;
sigemptyset(&sigint.sa_mask);
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
- eglSwapBuffers(display.egl.dpy, window.egl_surface);
- wm->activateSurface(app_name.c_str());
-
+ wl_display_dispatch_pending(display.display);
+ redraw(&window, NULL, 0);
+ 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);
+
/* The mainloop here is a little subtle. Redrawing will cause
* EGL to read events so we can just call
* wl_display_dispatch_pending() to handle any events that got
* queued up as a side effect. */
while (running) {
wl_display_dispatch_pending(display.display);
- redraw(&window, NULL, 0);
+ if(!gIsDraw) {
+ usleep(100000);
+ continue;
+ }
+ else
+ {
+ redraw(&window, NULL, 0);
+ }
}
-
debug_out("************** [SIMPLE EGL] [MAIN] simple-egl exiting! \n");
destroy_surface(&window);