summaryrefslogtreecommitdiffstats
path: root/sample/simple-egl
diff options
context:
space:
mode:
Diffstat (limited to 'sample/simple-egl')
-rw-r--r--sample/simple-egl/src/simple-egl.cpp73
1 files changed, 47 insertions, 26 deletions
diff --git a/sample/simple-egl/src/simple-egl.cpp b/sample/simple-egl/src/simple-egl.cpp
index cfa349c..822590c 100644
--- a/sample/simple-egl/src/simple-egl.cpp
+++ b/sample/simple-egl/src/simple-egl.cpp
@@ -44,6 +44,9 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include <unistd.h>
+#include <time.h>
+
#include "libwindowmanager.h"
#include <libhomescreen.hpp>
@@ -60,6 +63,7 @@ string app_name = string("Navigation");
LibHomeScreen* hs;
LibWindowmanager *wm;
+bool gIsDraw = false;
static const struct wl_interface *types[] = {
NULL,
@@ -144,7 +148,7 @@ struct window {
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"
@@ -327,25 +331,6 @@ init_gl(struct window *window)
}
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)
{
uint32_t id_ivisurf = g_id_ivisurf;
@@ -358,8 +343,6 @@ create_ivi_surface(struct window *window, struct display *display)
abort();
}
- ivi_surface_add_listener(window->ivi_surface,
- &ivi_surface_listener, window);
}
static void
@@ -425,6 +408,12 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
{ 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 },
@@ -460,6 +449,7 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
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,
@@ -487,7 +477,14 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
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);
}
@@ -601,6 +598,7 @@ init_wm(LibWindowmanager *wm)
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](json_object *object) {
@@ -609,7 +607,21 @@ init_wm(LibWindowmanager *wm)
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());
+ 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()));
@@ -651,6 +663,7 @@ init_hs(LibHomeScreen* hs){
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);
}
});
@@ -683,6 +696,7 @@ main(int argc, char **argv)
window.window_size = window.geometry;
window.buffer_size = 32;
window.frame_sync = 1;
+ gWindow = &window;
if(argc > 2)
{
@@ -739,7 +753,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
- eglSwapBuffers(display.egl.dpy, window.egl_surface);
+ 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"));
@@ -751,9 +766,15 @@ main(int argc, char **argv)
* 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);