[Title] emulator host lcd screen surface support gl
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 19 Jul 2012 08:35:16 +0000 (17:35 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 19 Jul 2012 08:35:16 +0000 (17:35 +0900)
[Type] feature
[Module] Emulator / skin
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/emulator.c
tizen/src/maru_sdl.c
tizen/src/maru_sdl.h
vl.c

index 79c5d90b1764deff70ee67b16d3012cb8089085f..1c99efaf26a487edab25bb7b38bb97139389d97f 100644 (file)
@@ -80,6 +80,7 @@ static char** skin_argv = NULL;
 static int qemu_argc = 0;
 static char** qemu_argv = NULL;
 
+extern void maruskin_sdl_quit(void);
 void exit_emulator(void)
 {
     cleanup_multi_touch_state();
@@ -88,7 +89,7 @@ void exit_emulator(void)
     shutdown_skin_server();
     shutdown_guest_server();
 
-    SDL_Quit();
+    maruskin_sdl_quit();
 }
 
 static int check_port_bind_listen(u_int port)
@@ -475,7 +476,7 @@ static void system_info(void)
     ZeroMemory(&sysi, sizeof(SYSTEM_INFO));
 
     GetSystemInfo(&sysi);
-    INFO("* Processor type : %d, Number of processors : %d\n", sysi.dwProcessorType,  sysi.dwNumberOfProcessors);
+    INFO("* Processor type : %d, Number of processors : %d\n", sysi.dwProcessorType, sysi.dwNumberOfProcessors);
 
     MEMORYSTATUSEX memInfo;
     memInfo.dwLength = sizeof(MEMORYSTATUSEX);
@@ -486,7 +487,7 @@ static void system_info(void)
 #elif defined(__linux__)
     /* depends on building */
     INFO("* Qemu build machine linux kernel version : (%d, %d, %d)\n",
-        LINUX_VERSION_CODE >> 16, (LINUX_VERSION_CODE >> 8) & 0xff , LINUX_VERSION_CODE & 0xff);
+        LINUX_VERSION_CODE >> 16, (LINUX_VERSION_CODE >> 8) & 0xff, LINUX_VERSION_CODE & 0xff);
 
      /* depends on launching */
     struct utsname host_uname_buf;
@@ -508,6 +509,8 @@ static void system_info(void)
     int i = system(lscmd);
     INFO("system function command : %s, system function returned value : %d\n", lscmd, i);
 #endif
+
+    INFO("\n");
 }
 
 void prepare_maru(void)
@@ -518,7 +521,7 @@ void prepare_maru(void)
 
     INFO("call construct_main_window\n");
 
-    construct_main_window(skin_argc, skin_argv, qemu_argc, qemu_argv );
+    construct_main_window(skin_argc, skin_argv, qemu_argc, qemu_argv);
 
     int guest_server_port = tizen_base_port + SDB_UDP_SENSOR_INDEX;
     start_guest_server( guest_server_port );
index cc76a5c371e1903aaa17cb65239edda98419b1f1..31108e115e08148733f432e0cf4080a2ffdb69f2 100644 (file)
@@ -68,8 +68,7 @@ static int sdl_thread_initialized = 0;
 #define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME)
 #define SDL_BPP 32
 
-
-extern int gl_acceleration_capability_check (void);
+extern int capability_check_gl;
 static void _sdl_init(void)
 {
     int w, h, temp;
@@ -98,8 +97,8 @@ static void _sdl_init(void)
         h = temp;
     }
 
-    /*if (gl_acceleration_capability_check () != 0) {
-        fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n");
+    if (capability_check_gl != 0) {
+        ERR("GL check returned non-zero\n");
         surface_screen = NULL;
     } else {
         surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_OPENGL);
@@ -108,31 +107,33 @@ static void _sdl_init(void)
     if (surface_screen == NULL) {
         sdl_opengl = 0;
         INFO("No OpenGL support on this system!??\n");
-        ERR("%s\n", SDL_GetError());*/
+        ERR("%s\n", SDL_GetError());
 
         surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_FLAGS);
         if (surface_screen == NULL) {
             ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, get_emul_sdl_bpp(), SDL_GetError());
             return;
         }
-    /*} else {
+    } else {
         sdl_opengl = 1;
         INFO("OpenGL is supported on this system.\n");
-    }*/
+    }
 
     if (sdl_opengl == 1) {
         /* Set the OpenGL state */
-        glClearColor(0, 0, 0, 0);
-        glViewport(0, 0, w, h);
+        glClear(GL_COLOR_BUFFER_BIT);
         glMatrixMode(GL_PROJECTION);
         glLoadIdentity();
         glOrtho(0, w, h, 0, -1, 1);
         glMatrixMode(GL_MODELVIEW);
+        glViewport(0, 0, w, h);
+        glLoadIdentity();
 
         glGenTextures(1, &texture);
         glBindTexture(GL_TEXTURE_2D, texture);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        //glGenerateMipmapEXT(GL_TEXTURE_2D); // GL_MIPMAP_LINEAR
     }
 
     /* remove multi-touch finger points */
@@ -153,10 +154,10 @@ static void draw_outline_circle(int cx, int cy, int r, int num_segments)
     float y = 0;
 
     glEnable(GL_LINE_STIPPLE);
+    glLoadIdentity();
     glColor3f(0.9, 0.9, 0.9);
     glLineStipple(1, 0xcccc);
     glLineWidth(3.f);
-    glLoadIdentity();
 
     glTranslatef(cx, cy, 0);
     glRotated(point_degree++ % 360, 0, 0, 1);
@@ -178,11 +179,11 @@ static void draw_outline_circle(int cx, int cy, int r, int num_segments)
 static void draw_fill_circle(int cx, int cy, int r)
 {
     glEnable(GL_POINT_SMOOTH);
+    glLoadIdentity();
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glColor4f(0.1, 0.1, 0.1, 0.6);
     glPointSize(r - 2);
-    glLoadIdentity();
 
     glBegin(GL_POINTS);
         glVertex2f(cx, cy);
@@ -205,14 +206,13 @@ static void qemu_update(void)
 
         if (sdl_opengl == 1)
         { //gl surface
-            glEnable(GL_TEXTURE_2D); //enable server-side GL capabilities
+            glEnable(GL_TEXTURE_2D);
+            glLoadIdentity();
             glColor3f(1.0, 1.0, 1.0);
             glTexImage2D(GL_TEXTURE_2D,
                 0, 3, surface_qemu->w, surface_qemu->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, surface_qemu->pixels);
-            glBindTexture(GL_TEXTURE_2D, texture);
 
             glClear(GL_COLOR_BUFFER_BIT);
-            glLoadIdentity();
 
             /* rotation */
             if (current_screen_degree == 270.0) { //reverse landscape
@@ -507,6 +507,20 @@ void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_heigh
 #endif
 }
 
+void maruskin_sdl_quit(void)
+{
+    /* remove multi-touch finger points */
+    get_emul_multi_touch_state()->multitouch_enable = 0;
+    clear_finger_slot();
+
+    if (sdl_opengl == 1) {
+        glDeleteTextures(1, &texture);
+    }
+
+    SDL_Quit();
+}
+
+
 void maruskin_sdl_resize(void)
 {
     SDL_Event ev;
index 3b56bf4e98bd4ecc713a2bee319debf8b15ca67e..f9d3ba7f92fc5415c5202a54827e15ea6785d050 100644 (file)
@@ -49,6 +49,8 @@
 void maruskin_display_init(DisplayState *ds);
 void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
 void maruskin_sdl_resize(void);
+void maruskin_sdl_quit(void);
+
 
 DisplaySurface* get_qemu_display_surface( void );
 
diff --git a/vl.c b/vl.c
index e713bb7e517360fd86b117bbc1d229faeb706fe8..f8a1500453e84eb435b411e821e80489d15e3d6c 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -266,6 +266,7 @@ uint8_t qemu_extra_params_fw[2];
 //#ifndef _WIN32
 extern int gl_acceleration_capability_check (void);
 int enable_gl = 0;
+int capability_check_gl = 0;
 //#endif
 
 typedef struct FWBootEntry FWBootEntry;
@@ -3217,11 +3218,12 @@ int main(int argc, char **argv, char **envp)
     loc_set_none();
 
 //#ifndef _WIN32
-       if (enable_gl && (gl_acceleration_capability_check () != 0)) {
-               enable_gl = 0;
-               fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n");
-       }
-       
+    capability_check_gl = gl_acceleration_capability_check();
+    if (enable_gl && (capability_check_gl != 0)) {
+        enable_gl = 0;
+        fprintf (stderr, "Warn: GL acceleration was disabled due to the fail of GL check!\n");
+    }
+
        // To check host gl driver capability and notify to guest.
        gchar *tmp = kernel_cmdline;
        kernel_cmdline = g_strdup_printf("%s gles=%d", tmp, enable_gl);