From 9c5ebcfbeba9d2e8077c73516f70fb9467855ed7 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Mon, 9 Jun 2014 18:18:10 +0900 Subject: [PATCH] screenshot: modified function/varable names Change-Id: Ie04d92a0f8129ddf3880d9a5c7e9cbfae037b892 Signed-off-by: GiWoong Kim --- tizen/src/maru_display.c | 19 ++++----- tizen/src/maru_display.h | 14 +++---- tizen/src/maru_sdl.c | 6 ++- tizen/src/skin/maruskin_operation.c | 62 +++++++++++++---------------- tizen/src/skin/maruskin_operation.h | 12 +++--- tizen/src/skin/maruskin_server.c | 9 +++-- 6 files changed, 60 insertions(+), 62 deletions(-) diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c index 9b89ececb8..328330e195 100644 --- a/tizen/src/maru_display.c +++ b/tizen/src/maru_display.c @@ -40,7 +40,7 @@ MULTI_DEBUG_CHANNEL(tizen, display); -MaruScreenshot* maru_screenshot = NULL; +MaruScreenShot* screenshot = NULL; //TODO: interface void maru_display_init(DisplayState *ds) @@ -60,17 +60,17 @@ void maru_display_init(DisplayState *ds) dcl->ops = &maru_dcl_ops; register_displaychangelistener(dcl); - maru_screenshot = g_malloc0(sizeof(MaruScreenshot)); - maru_screenshot->pixel_data = NULL; - maru_screenshot->request_screenshot = 0; - maru_screenshot->isReady = 0; + screenshot = g_malloc0(sizeof(MaruScreenShot)); + screenshot->pixels = NULL; + screenshot->request = false; + screenshot->ready = false; } void maru_display_fini(void) { INFO("fini qemu display\n"); - g_free(maru_screenshot); + g_free(screenshot); #ifndef CONFIG_USE_SHM maru_sdl_quit(); @@ -128,8 +128,9 @@ void maru_ds_surface_init(uint64 swt_handle, #endif } -MaruScreenshot *get_maru_screenshot(void) +MaruScreenShot *get_screenshot(void) { - return maru_screenshot; + return screenshot; } -/* set_maru_screenshot() implemented in maruskin_operation.c */ + +/* save_screenshot() implemented in maruskin_operation.c */ diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h index ec0b90124e..a6e496b111 100644 --- a/tizen/src/maru_display.h +++ b/tizen/src/maru_display.h @@ -33,11 +33,11 @@ #include "ui/console.h" -typedef struct MaruScreenshot { - unsigned char *pixel_data; - int request_screenshot; - int isReady; -} MaruScreenshot; +typedef struct MaruScreenShot { + unsigned char *pixels; + bool request; + bool ready; +} MaruScreenShot; void maru_display_init(DisplayState *ds); void maru_display_fini(void); @@ -49,7 +49,7 @@ void maru_ds_surface_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); -MaruScreenshot *get_maru_screenshot(void); -void set_maru_screenshot(DisplaySurface *surface); +MaruScreenShot *get_screenshot(void); +void save_screenshot(DisplaySurface *surface); #endif /* __MARU_DISPLAY_H__ */ diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 89eff7a1fa..2eb7fb5746 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -308,7 +308,7 @@ static void qemu_update(void) if (surface_qemu != NULL) { maru_do_pixman_dpy_surface(dpy_surface->image); - set_maru_screenshot(dpy_surface); + save_screenshot(dpy_surface); if (current_scale_factor != 1.0) { rotated_screen = maru_do_pixman_rotate( @@ -598,7 +598,9 @@ void maru_sdl_resize(void) void maru_sdl_update(void) { - qemu_bh_schedule(sdl_update_bh); + if (sdl_update_bh != NULL) { + qemu_bh_schedule(sdl_update_bh); + } } void maru_sdl_invalidate(bool on) diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 0b55f96cd0..3d849af213 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -369,27 +369,29 @@ void do_rotation_event(int rotation_type) #endif } -void set_maru_screenshot(DisplaySurface *surface) +void save_screenshot(DisplaySurface *surface) { pthread_mutex_lock(&mutex_screenshot); - MaruScreenshot *maru_screenshot = get_maru_screenshot(); - if (maru_screenshot) { - maru_screenshot->isReady = 1; - if (maru_screenshot->request_screenshot == 1) { - memcpy(maru_screenshot->pixel_data, + MaruScreenShot *screenshot = get_screenshot(); + if (screenshot != NULL) { + screenshot->ready = true; + + if (screenshot->request == true) { + memcpy(screenshot->pixels, surface_data(surface), surface_stride(surface) * surface_height(surface)); - maru_screenshot->request_screenshot = 0; + screenshot->request = false; pthread_cond_signal(&cond_screenshot); } } + pthread_mutex_unlock(&mutex_screenshot); } -QemuSurfaceInfo *request_screenshot(void) +Framebuffer *request_screenshot(void) { const int length = get_emul_resolution_width() * get_emul_resolution_height() * 4; INFO("screenshot data length : %d\n", length); @@ -398,16 +400,18 @@ QemuSurfaceInfo *request_screenshot(void) return NULL; } - QemuSurfaceInfo *info = (QemuSurfaceInfo *)g_malloc0(sizeof(QemuSurfaceInfo)); - if (!info) { - ERR("Fail to malloc for QemuSurfaceInfo.\n"); + Framebuffer *framebuffer = (Framebuffer *)g_malloc0(sizeof(Framebuffer)); + if (framebuffer == NULL) { + ERR("failed to malloc for framebuffer\n"); + return NULL; } - info->pixel_data = (unsigned char *)g_malloc0(length); - if (!info->pixel_data) { - g_free(info); - ERR("Fail to malloc for pixel data.\n"); + framebuffer->data = (unsigned char *)g_malloc0(length); + if (framebuffer->data == NULL) { + g_free(framebuffer); + ERR("failed to malloc for framebuffer data\n"); + return NULL; } @@ -416,13 +420,14 @@ QemuSurfaceInfo *request_screenshot(void) if (brightness_off == 0) { 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); + MaruScreenShot* screenshot = get_screenshot(); + if (screenshot == NULL || screenshot->ready == false) { + WARN("screenshot is null\n"); + + memset(framebuffer->data, 0x00, length); } else { - maru_screenshot->pixel_data = info->pixel_data; - maru_screenshot->request_screenshot = 1; + screenshot->pixels = framebuffer->data; + screenshot->request = true; maru_display_update(); // TODO : do not wait on communication thread @@ -432,20 +437,9 @@ QemuSurfaceInfo *request_screenshot(void) pthread_mutex_unlock(&mutex_screenshot); } - info->pixel_data_length = length; + framebuffer->data_length = length; - return info; -} - -void free_screenshot_info(QemuSurfaceInfo *info) -{ - if (info) { - if(info->pixel_data) { - g_free(info->pixel_data); - } - - g_free(info); - } + return framebuffer; } DetailInfo* get_detail_info(int qemu_argc, char** qemu_argv) diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index 0b1330df53..317bfa0025 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -35,10 +35,10 @@ extern int ret_hax_init; -typedef struct ScreenShot { - unsigned char* pixel_data; - int pixel_data_length; -} QemuSurfaceInfo; +typedef struct Framebuffer { + unsigned char* data; + unsigned int data_length; +} Framebuffer; typedef struct DetailInfo { char* data; @@ -58,10 +58,10 @@ 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 *request_screenshot(void); +Framebuffer *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 *); +void free_screenshot(Framebuffer *); void do_open_shell(void); void do_host_kbd_enable(bool on); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 6767ad2c7f..9de293df22 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -1024,13 +1024,14 @@ static void* run_skin_server(void* args) log_cnt += sprintf(log_buf + log_cnt, "RECV_SCREENSHOT_REQ ==\n"); TRACE(log_buf); - QemuSurfaceInfo* screenshot = request_screenshot(); + Framebuffer* framebuffer = request_screenshot(); - if (screenshot != NULL) { + if (framebuffer != NULL) { send_skin_data(client_sock, SEND_SCREENSHOT_DATA, - screenshot->pixel_data, screenshot->pixel_data_length, 1); + framebuffer->data, framebuffer->data_length, 1); - free_screenshot_info(screenshot); + g_free(framebuffer->data); + g_free(framebuffer); } else { ERR("Fail to get screen shot data\n"); } -- 2.34.1