add roi API 67/66567/3 submit/tizen/20160421.022931
authorNAMJEONGYOON <just.nam@samsung.com>
Tue, 19 Apr 2016 12:00:48 +0000 (21:00 +0900)
committerNAMJEONGYOON <just.nam@samsung.com>
Wed, 20 Apr 2016 02:18:18 +0000 (11:18 +0900)
Change-Id: I40aa07f8eef97583ee2edfa7f967f428d9c2b4da
Signed-off-by: NAMJEONGYOON <just.nam@samsung.com>
src/include/mm_evas_renderer.h
src/mm_evas_renderer.c

index 6f38a5f..5694d1e 100644 (file)
@@ -99,6 +99,7 @@ typedef struct {
        /* properties */
        visible_info visible;
        rect_info eo_size;
+       rect_info dst_roi;
        gboolean use_ratio;
        guint rotate_angle;
        guint display_geometry_method;
@@ -136,6 +137,10 @@ int mm_evas_renderer_get_rotation(MMHandleType handle, int *rotate);
 /* set and get geometry value */
 int mm_evas_renderer_set_geometry(MMHandleType handle, int mode);
 int mm_evas_renderer_get_geometry(MMHandleType handle, int *mode);
+/* set and get coordinate and resolution value for the destination */
+/* it would be better not to call set_geometry for DISP_GEO_METHOD_CUSTOM_ROI */
+int mm_evas_renderer_set_roi_area(MMHandleType handle, int x, int y, int w, int h);
+int mm_evas_renderer_get_roi_area(MMHandleType handle, int *x, int *y, int *w, int *h);
 /* set and get flip value */
 int mm_evas_renderer_set_flip(MMHandleType handle, int flip);
 int mm_evas_renderer_get_flip(MMHandleType handle, int *flip);
index 6b69187..fb7b7f4 100644 (file)
@@ -87,6 +87,7 @@ enum {
        DISP_GEO_METHOD_FULL_SCREEN,
        DISP_GEO_METHOD_CROPPED_FULL_SCREEN,
        DISP_GEO_METHOD_ORIGIN_SIZE_OR_LETTER_BOX,
+       DISP_GEO_METHOD_CUSTOM_ROI,
        DISP_GEO_METHOD_NUM,
 };
 
@@ -286,7 +287,9 @@ void _evas_pipe_cb(void *data, void *buffer, update_info info)
 
        if (result.x || result.y)
                LOGD("coordinate x, y (%d, %d) for locating video to center", result.x, result.y);
-       evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
+
+       if (evas_info->display_geometry_method != DISP_GEO_METHOD_CUSTOM_ROI)
+               evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
 
        evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE);
        LOGD("GEO_METHOD : src(%dx%d), dst(%dx%d), dst_x(%d), dst_y(%d), rotate(%d), flip(%d)", evas_info->w, evas_info->h, evas_info->eo_size.w, evas_info->eo_size.h, evas_info->eo_size.x, evas_info->eo_size.y, evas_info->rotate_angle, evas_info->flip);
@@ -418,7 +421,9 @@ int _flush_packets(mm_evas_info *evas_info)
 
                if (result.x || result.y)
                        LOGD("coordinate x, y (%d, %d) for locating video to center", result.x, result.y);
-               evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
+
+               if (evas_info->display_geometry_method != DISP_GEO_METHOD_CUSTOM_ROI)
+                       evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
 
                /* set flush buffer */
                surf.type = EVAS_NATIVE_SURFACE_TBM;
@@ -585,8 +590,8 @@ int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
                evas_info->pkt_info[i].tbm_surf = NULL;
                evas_info->pkt_info[i].prev = -1;
        }
-
        evas_info->cur_idx = -1;
+       evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
        evas_info->eo = eo;
        evas_info->epipe = ecore_pipe_add((Ecore_Pipe_Cb) _evas_pipe_cb, evas_info);
        if (!evas_info->epipe) {
@@ -626,6 +631,7 @@ int _mm_evas_renderer_reset(mm_evas_info *evas_info)
        }
 
        evas_info->eo_size.x = evas_info->eo_size.y = evas_info->eo_size.w = evas_info->eo_size.h = 0;
+       evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
        evas_info->w = evas_info->h = 0;
 
        if (evas_info->flush_buffer)
@@ -728,6 +734,18 @@ void _mm_evas_renderer_update_geometry(mm_evas_info *evas_info, rect_info *resul
                        result->h = evas_info->eo_size.h;
                }
                break;
+       case DISP_GEO_METHOD_CUSTOM_ROI:
+               LOGD("custom roi mode");
+               evas_info->use_ratio= FALSE;
+               result->x = evas_info->dst_roi.x;
+               result->y = evas_info->dst_roi.y;
+               result->w = evas_info->dst_roi.w;
+               result->h = evas_info->dst_roi.h;
+
+               /* don't call evas_object_image_fill_set */
+               evas_object_move(evas_info->eo, result->x, result->y);
+               evas_object_resize(evas_info->eo, result->w, result->h);
+               break;
        default:
                LOGW("unsupported mode.");
                break;
@@ -761,7 +779,8 @@ int _mm_evas_renderer_apply_geometry(mm_evas_info *evas_info)
                if (result.x || result.y)
                        LOGD("coordinate x, y (%d, %d) for locating video to center", result.x, result.y);
 
-               evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
+               if (evas_info->display_geometry_method != DISP_GEO_METHOD_CUSTOM_ROI)
+                       evas_object_image_fill_set(evas_info->eo, result.x, result.y, result.w, result.h);
                return MM_ERROR_NONE;
        } else
                LOGW("there is no surf");
@@ -1046,7 +1065,9 @@ int mm_evas_renderer_update_param(MMHandleType handle)
                        if (!ret) {
                                LOGW("fail to ecore_pipe_write() for updating visibility\n");
                                return MM_ERROR_UNKNOWN;
-                       }
+                       } else
+                               ret = MM_ERROR_NONE;
+
 #if 0          /* FIXME: pause state only */
                        g_mutex_lock(&evas_info->idx_lock);
                        ret = ecore_pipe_write(evas_info->epipe, evas_info, UPDATE_TBM_SURF);
@@ -1273,6 +1294,52 @@ int mm_evas_renderer_get_geometry(MMHandleType handle, int *mode)
        return MM_ERROR_NONE;
 }
 
+int mm_evas_renderer_set_roi_area(MMHandleType handle, int x, int y, int w, int h)
+{
+       int ret = MM_ERROR_NONE;
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+       if (!evas_info) {
+               LOGW("skip it. it is not evas surface type or handle is not prepared");
+               return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+       }
+       if (!w || !h) {
+               LOGW("invalid resolution");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       /* display mode is set to DISP_GEO_METHOD_CUSTOM_ROI internally */
+       evas_info->display_geometry_method = DISP_GEO_METHOD_CUSTOM_ROI;
+       evas_info->dst_roi.x = x;
+       evas_info->dst_roi.y = y;
+       evas_info->dst_roi.w = w;
+       evas_info->dst_roi.h = h;
+       ret = _mm_evas_renderer_apply_geometry(evas_info);
+
+       return ret;
+}
+
+int mm_evas_renderer_get_roi_area(MMHandleType handle, int *x, int *y, int *w, int *h)
+{
+       mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+       if (!evas_info) {
+               LOGW("skip it. it is not evas surface type or handle is not prepared");
+               return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+       }
+       if (evas_info->display_geometry_method != DISP_GEO_METHOD_CUSTOM_ROI) {
+               LOGW("invalid mode");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       *x = evas_info->dst_roi.x;
+       *y = evas_info->dst_roi.y;
+       *w = evas_info->dst_roi.w;
+       *h = evas_info->dst_roi.h;
+
+       return MM_ERROR_NONE;
+}
+
 int mm_evas_renderer_set_flip(MMHandleType handle, int flip)
 {
        int ret = MM_ERROR_NONE;
@@ -1285,7 +1352,7 @@ int mm_evas_renderer_set_flip(MMHandleType handle, int flip)
 
        switch(flip) {
        case FLIP_NONE :
-               evas_info->flip = 0;
+               evas_info->flip = EVAS_IMAGE_ORIENT_NONE;
                break;
        case FLIP_HORIZONTAL:
                evas_info->flip = EVAS_IMAGE_FLIP_HORIZONTAL;
@@ -1325,7 +1392,7 @@ int mm_evas_renderer_get_flip(MMHandleType handle, int *flip)
        }
 
        switch(evas_info->flip) {
-       case 0:
+       case EVAS_IMAGE_ORIENT_NONE:
                *flip = FLIP_NONE;
                break;
        case EVAS_IMAGE_FLIP_HORIZONTAL: