uihv: move the creation of the screenshot path
[platform/core/system/swap-manager.git] / ui_viewer / ui_viewer_screenshot.c
index 9e624c5..f173ba6 100644 (file)
@@ -50,7 +50,6 @@
 
 #define MAX_PATH_LENGTH                256
 
-static int screenshotIndex = 0;
 static pthread_mutex_t captureScreenLock = PTHREAD_MUTEX_INITIALIZER;
 
 struct efl_data {
@@ -424,18 +423,15 @@ fail_tbm_client:
 
        return buf;
 }
-static int capture_object(char *screenshot_path, int width, int height,
+static int capture_object(const char *screenshot_path, int width, int height,
                          Evas_Object *obj, const char *type_name)
 {
-       char dstpath[MAX_PATH_LENGTH];
        Evas_Object *img;
        Evas *canvas, *sub_canvas;
        Ecore_Evas *ee, *sub_ee;
        int ret = 0;
        char *image_data = NULL;
 
-       screenshotIndex++;
-
        canvas = evas_object_evas_get(obj);
        ee = ecore_evas_ecore_evas_get(canvas);
        img = ecore_evas_object_image_new(ee);
@@ -488,12 +484,7 @@ static int capture_object(char *screenshot_path, int width, int height,
 finish:
        ecore_evas_manual_render(sub_ee);
 
-       snprintf(dstpath, sizeof(dstpath), TMP_DIR "/%d_%d.png", _getpid(),
-                screenshotIndex);
-
-       if (evas_object_image_save(img, dstpath, NULL, "compress=5") != 0) {
-               strncpy(screenshot_path, dstpath, MAX_PATH_LENGTH);
-       } else {
+       if (!evas_object_image_save(img, screenshot_path, NULL, "compress=5")) {
                ui_viewer_log("ERROR: capture_object : can't save image\n");
                ret = -1;
        }
@@ -504,7 +495,7 @@ finish:
        return ret;
 }
 
-int ui_viewer_capture_screen(char *screenshot_path, Evas_Object *obj)
+int ui_viewer_capture_screen(const char *screenshot_path, Evas_Object *obj)
 {
        int view_w, view_h;
        int obj_x, obj_y, obj_w, obj_h;
@@ -512,12 +503,6 @@ int ui_viewer_capture_screen(char *screenshot_path, Evas_Object *obj)
        Evas *evas;
        char type_name[MAX_PATH_LENGTH];
 
-       if (!screenshot_path) {
-               ui_viewer_log("ui_viewer_capture_screen: no screenshot path\n");
-               ret = -1;
-               return ret;
-       }
-
        pthread_mutex_lock(&captureScreenLock);
 
        evas = evas_object_evas_get(obj);
@@ -579,9 +564,6 @@ int ui_viewer_capture_screen(char *screenshot_path, Evas_Object *obj)
                                     type_name);
        }
 
-       if (ret)
-               screenshot_path[0] = '\0';
-
        pthread_mutex_unlock(&captureScreenLock);
        return ret;
 }