rotation: apply transform of ec for rotation object 38/127338/1
authorMinJeong Kim <minjjj.kim@samsung.com>
Wed, 26 Apr 2017 07:36:30 +0000 (16:36 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 27 Apr 2017 04:44:51 +0000 (13:44 +0900)
Change-Id: Ic3734fc2c888dc5d8d80b33e5bf1705c8b36987d
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/e_mod_effect_rotation.c

index 7f757a5..f7046f1 100644 (file)
@@ -230,6 +230,100 @@ _rotation_effect_targets_get(Rotation_Effect *effect, E_Desk *desk)
 }
 
 static void
+_rotation_effect_object_transform_pos_map(E_Client *ec, int sx, int sy, int *dx, int *dy)
+{
+   E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
+   int transform = vp->buffer.transform;
+   int bw, bh, tx, ty;
+
+   e_pixmap_size_get(ec->pixmap, &bw, &bh);
+
+   /* for subsurface, it should be swap 90 and 270 */
+   if (ec->comp_data->sub.data)
+     switch (transform)
+       {
+        case WL_OUTPUT_TRANSFORM_90:          transform = WL_OUTPUT_TRANSFORM_270;         break;
+        case WL_OUTPUT_TRANSFORM_270:         transform = WL_OUTPUT_TRANSFORM_90;          break;
+        case WL_OUTPUT_TRANSFORM_FLIPPED_90:  transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; break;
+        case WL_OUTPUT_TRANSFORM_FLIPPED_270: transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;  break;
+        default: break;
+       }
+
+   switch (transform)
+     {
+      case WL_OUTPUT_TRANSFORM_NORMAL:
+      default:                              tx = sx,      ty = sy;      break;
+      case WL_OUTPUT_TRANSFORM_90:          tx = sy,      ty = bw - sx; break;
+      case WL_OUTPUT_TRANSFORM_180:         tx = bw - sx, ty = bh - sy; break;
+      case WL_OUTPUT_TRANSFORM_270:         tx = bh - sy, ty = sx;      break;
+      case WL_OUTPUT_TRANSFORM_FLIPPED:     tx = bw - sx, ty = sy;      break;
+      case WL_OUTPUT_TRANSFORM_FLIPPED_90:  tx = sy,      ty = sx;      break;
+      case WL_OUTPUT_TRANSFORM_FLIPPED_180: tx = sx,      ty = bh - sy; break;
+      case WL_OUTPUT_TRANSFORM_FLIPPED_270: tx = bh - sy, ty = bw - sx; break;
+     }
+
+   tx *= vp->buffer.scale;
+   ty *= vp->buffer.scale;
+
+   *dx = tx;
+   *dy = ty;
+}
+
+static void
+_rotation_effect_object_transform_apply(Rotation_Effect_Object *eobj)
+{
+   Evas_Map *map;
+   E_Client *ec;
+   int x1, y1, x2, y2, x, y, bw, bh;
+   char buffer[128];
+   char *p = buffer;
+   int l, remain = sizeof buffer;
+
+   if (!(ec = eobj->ec)) return;
+   if (!ec->comp_data) return;
+
+   if (!ec->comp_data->scaler.buffer_viewport.buffer.transform &&
+       ec->comp_data->scaler.buffer_viewport.buffer.scale == 1)
+     return;
+
+   map = evas_map_new(4);
+   if (!map) return;
+
+   e_pixmap_size_get(ec->pixmap, &bw, &bh);
+
+   x1 = y1 = 0;
+   x2 = bw;
+   y2 = bh;
+
+   evas_map_util_points_populate_from_geometry(map, ec->x, ec->y, bw, bh, 0);
+
+   _rotation_effect_object_transform_pos_map(ec, x1, y1, &x, &y);
+   evas_map_point_image_uv_set(map, 0, x, y);
+   l = snprintf(p, remain, " %d,%d", x, y);
+   p += l, remain -= l;
+
+   _rotation_effect_object_transform_pos_map(ec, x2, y1, &x, &y);
+   evas_map_point_image_uv_set(map, 1, x, y);
+   l = snprintf(p, remain, " %d,%d", x, y);
+   p += l, remain -= l;
+
+   _rotation_effect_object_transform_pos_map(ec, x2, y2, &x, &y);
+   evas_map_point_image_uv_set(map, 2, x, y);
+   l = snprintf(p, remain, " %d,%d", x, y);
+   p += l, remain -= l;
+
+   _rotation_effect_object_transform_pos_map(ec, x1, y2, &x, &y);
+   evas_map_point_image_uv_set(map, 3, x, y);
+   l = snprintf(p, remain, " %d,%d", x, y);
+   p += l, remain -= l;
+
+   evas_object_map_set(eobj->img, map);
+   evas_object_map_enable_set(eobj->img, EINA_TRUE);
+
+   evas_map_free(map);
+}
+
+static void
 _rotation_effect_object_free(Rotation_Effect_Object *eobj)
 {
    if (!eobj) return;
@@ -436,6 +530,8 @@ _rotation_effect_begin_create(Rotation_Effect *effect, Eina_List *targets, E_Des
         eobj = _rotation_effect_object_create(target);
         if (!eobj) continue;
 
+        _rotation_effect_object_transform_apply(eobj);
+
         ctx_begin->objects = eina_list_append(ctx_begin->objects, eobj);
         if (eobj->ec)
           effect->waiting_list = eina_list_append(effect->waiting_list, eobj->ec);
@@ -495,6 +591,8 @@ _rotation_effect_end_create(Rotation_Effect *effect, Eina_List *targets, E_Desk
         eobj = _rotation_effect_object_create(target);
         if (!eobj) continue;
 
+        _rotation_effect_object_transform_apply(eobj);
+
         evas_object_geometry_get(target, &x, &y, &w, &h);
 
         ctx_end->objects = eina_list_append(ctx_end->objects, eobj);