screenshot: fix screen shot feature 01/21401/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 19 May 2014 09:21:50 +0000 (18:21 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 20 May 2014 01:50:24 +0000 (10:50 +0900)
update display during screenshot generating
modified some variable/function names

Change-Id: I4d57d281b337984d04577724ad1b844f94b4b90e
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/maru_sdl.c
tizen/src/skin/maruskin_operation.c
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index dcd6aa9..3cb4ec8 100644 (file)
@@ -303,9 +303,8 @@ static void qemu_update(void)
     }
 
     if (surface_qemu != NULL) {
-        int i = 0;
-
         maru_do_pixman_dpy_surface(dpy_surface->image);
+
         set_maru_screenshot(dpy_surface);
 
         if (current_scale_factor != 1.0) {
@@ -333,6 +332,7 @@ static void qemu_update(void)
         /* draw multi-touch finger points */
         MultiTouchState *mts = get_emul_multi_touch_state();
         if (mts->multitouch_enable != 0 && mts->finger_point_surface != NULL) {
+            int i = 0;
             FingerPoint *finger = NULL;
             int finger_point_size_half = mts->finger_point_size / 2;
             SDL_Rect rect;
index b66c3db..f4e72c6 100644 (file)
@@ -48,6 +48,7 @@
 #include "emul_state.h"
 #include "maruskin_keymap.h"
 #include "maruskin_server.h"
+#include "maru_display.h"
 #include "hw/maru_pm.h"
 #include "ecs/ecs.h"
 
@@ -395,21 +396,18 @@ void set_maru_screenshot(DisplaySurface *surface)
     pthread_mutex_unlock(&mutex_screenshot);
 }
 
-QemuSurfaceInfo *get_screenshot_info(void)
+QemuSurfaceInfo *request_screenshot(void)
 {
-    QemuSurfaceInfo *info =
-            (QemuSurfaceInfo *)g_malloc0(sizeof(QemuSurfaceInfo));
-    if (!info) {
-        ERR("Fail to malloc for QemuSurfaceInfo.\n");
+    const int length = get_emul_resolution_width() * get_emul_resolution_height() * 4;
+    INFO("screenshot data length : %d\n", length);
+
+    if (0 >= length) {
         return NULL;
     }
 
-    int length = get_emul_resolution_width() * get_emul_resolution_height() * 4;
-    INFO("screenshot data length:%d\n", length);
-
-    if (0 >= length) {
-        g_free(info);
-        ERR("screenshot data ( 0 >=length ). length:%d\n", length);
+    QemuSurfaceInfo *info = (QemuSurfaceInfo *)g_malloc0(sizeof(QemuSurfaceInfo));
+    if (!info) {
+        ERR("Fail to malloc for QemuSurfaceInfo.\n");
         return NULL;
     }
 
@@ -420,24 +418,26 @@ QemuSurfaceInfo *get_screenshot_info(void)
         return NULL;
     }
 
-    /* If the LCD is turned off, return empty buffer.
+    /* If display has been turned off, return empty buffer.
        Because the empty buffer is seen as a black. */
-    if (brightness_off) {
-        info->pixel_data_length = length;
-        return info;
-    }
+    if (brightness_off == 0) {
+        pthread_mutex_lock(&mutex_screenshot);
 
-    pthread_mutex_lock(&mutex_screenshot);
-    MaruScreenshot* maru_screenshot = get_maru_screenshot();
-    if (!maru_screenshot || maru_screenshot->isReady != 1) {
-        ERR("maru screenshot is NULL or not ready.\n");
-        memset(info->pixel_data, 0x00, length);
-    } else {
-        maru_screenshot->pixel_data = info->pixel_data;
-        maru_screenshot->request_screenshot = 1;
-        pthread_cond_wait(&cond_screenshot, &mutex_screenshot);
+        MaruScreenshot* maru_screenshot = get_maru_screenshot();
+        if (!maru_screenshot || maru_screenshot->isReady != 1) {
+            ERR("maru screenshot is NULL or not ready.\n");
+            memset(info->pixel_data, 0x00, length);
+        } else {
+            maru_screenshot->pixel_data = info->pixel_data;
+            maru_screenshot->request_screenshot = 1;
+            maru_display_update();
+
+            // TODO : do not wait on communication thread
+            pthread_cond_wait(&cond_screenshot, &mutex_screenshot);
+        }
+
+        pthread_mutex_unlock(&mutex_screenshot);
     }
-    pthread_mutex_unlock(&mutex_screenshot);
 
     info->pixel_data_length = length;
 
index b770350..0b1330d 100644 (file)
 
 extern int ret_hax_init;
 
-struct QemuSurfaceInfo {
+typedef struct ScreenShot {
     unsigned char* pixel_data;
     int pixel_data_length;
-};
-typedef struct QemuSurfaceInfo QemuSurfaceInfo;
+} QemuSurfaceInfo;
 
-struct DetailInfo {
+typedef struct DetailInfo {
     char* data;
     int data_length;
-};
-typedef struct DetailInfo DetailInfo;
+} DetailInfo;
 
 void start_display(uint64 handle_id,
     unsigned int display_width, unsigned int display_height,
@@ -60,7 +58,7 @@ void do_hw_key_event(int event_type, int keycode);
 void do_scale_event(double scale_factor);
 void do_rotation_event(int rotation_type);
 
-QemuSurfaceInfo *get_screenshot_info(void);
+QemuSurfaceInfo *request_screenshot(void);
 DetailInfo *get_detail_info(int qemu_argc, char **qemu_argv);
 void free_detail_info(DetailInfo *detail_info);
 void free_screenshot_info(QemuSurfaceInfo *);
index 7a7cae3..0055ce1 100644 (file)
@@ -1025,12 +1025,13 @@ static void* run_skin_server(void* args)
                     log_cnt += sprintf(log_buf + log_cnt, "RECV_SCREENSHOT_REQ ==\n");
                     TRACE(log_buf);
 
-                    QemuSurfaceInfo* info = get_screenshot_info();
+                    QemuSurfaceInfo* screenshot = request_screenshot();
 
-                    if (info) {
+                    if (screenshot != NULL) {
                         send_skin_data(client_sock, SEND_SCREENSHOT_DATA,
-                            info->pixel_data, info->pixel_data_length, 1);
-                        free_screenshot_info(info);
+                            screenshot->pixel_data, screenshot->pixel_data_length, 1);
+
+                        free_screenshot_info(screenshot);
                     } else {
                         ERR("Fail to get screen shot data\n");
                     }