remove ratiofit workaround code and replace transform bg feature 18/97918/4
authorSungbae Park <sb34.park@samsung.com>
Tue, 15 Nov 2016 10:07:20 +0000 (19:07 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 17 Nov 2016 06:09:24 +0000 (22:09 -0800)
Signed-off-by: Sungbae Park <sb34.park@samsung.com>
Change-Id: Ib677e1a3a73f6518449d3c10195e9ffab471eea1
Signed-off-by: Sungbae Park <sb34.park@samsung.com>
src/bin/e_client.c
src/bin/e_client.h
src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_util_transform.c
src/bin/e_util_transform.h

index 15a09c767dfdc8e8bff9ca33a489ecba354e05b4..a4ed1817885d024a98d77bd70ea898ced60673ee 100644 (file)
@@ -6094,7 +6094,7 @@ e_client_transform_core_update(E_Client *ec)
         E_Util_Transform_Rect source_rect;
         E_Util_Transform_Matrix matrix, boundary_matrix;
         Eina_List *l;
-        Eina_Bool keep_ratio = EINA_FALSE;
+        Eina_Bool background;
         E_Util_Transform *temp_trans;
 
         // 1. init state
@@ -6116,21 +6116,23 @@ e_client_transform_core_update(E_Client *ec)
              e_util_transform_rect_init(&source_rect, vx, vy, vw, vh);
           }
 
-        // 3. covert to matrix and apply keep_ratio
-        boundary_matrix = e_util_transform_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
-        keep_ratio = e_util_transform_keep_ratio_get(&ec->transform_core.result.transform);
+        // 3. apply background transform
+        matrix = e_util_transform_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
 
-        if (keep_ratio)
+        if (e_util_transform_bg_transform_flag_get(&ec->transform_core.result.transform))
           {
-             ec->transform_core.result.transform = e_util_transform_keep_ratio_apply(&ec->transform_core.result.transform, ec->w, ec->h);
-             matrix = e_util_transform_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
+             boundary_matrix = e_util_transform_bg_convert_to_matrix(&ec->transform_core.result.transform, &source_rect);
+             background = EINA_TRUE;
           }
         else
-           matrix = boundary_matrix;
+          {
+             background = EINA_FALSE;
+             boundary_matrix = matrix;
+          }
 
-        if (keep_ratio != ec->transform_core.keep_ratio)
+        if (background != ec->transform_core.background)
           {
-             if (keep_ratio)
+             if (background)
                {
                   e_comp_object_transform_bg_set(ec->frame, EINA_TRUE);
                }
@@ -6139,7 +6141,7 @@ e_client_transform_core_update(E_Client *ec)
                   e_comp_object_transform_bg_set(ec->frame, EINA_FALSE);
                }
 
-             ec->transform_core.keep_ratio = keep_ratio;
+             ec->transform_core.background = background;
           }
 
         // 3.1 if 24bit window then set transp rect
index 5041e1b587ca9fafec37401ddb2635aec30f5603..f4942fade15f73e87c1e80af48948acb21a0405e 100644 (file)
@@ -840,7 +840,7 @@ struct E_Client
  struct
    {
        Eina_List *transform_list;
-       Eina_Bool  keep_ratio;
+       Eina_Bool  background;
        Eina_Bool  changed;
 
        struct
index b54010564ec9042e41754846f94c3d9e806c8170..89a70d81cc8afee63ac896a71ce412f17f9396a8 100644 (file)
@@ -2127,7 +2127,7 @@ static struct
    },
    {
       "transform",
-      "[id enable x y w h angle keep_ratio]",
+      "[id enable x y w h angle is_bg]",
       "Set transform in runtime",
       _e_info_client_proc_transform_set
    },
index 65b914ffe66e7315b405e14b187491ee8feb16ad..c19e4ebfeb282954c0b953cf037be2b7a36bd60c 100644 (file)
@@ -50,6 +50,7 @@ typedef struct _E_Info_Transform
    E_Util_Transform *transform;
    int               id;
    int               enable;
+   int               background;
 } E_Info_Transform;
 
 static E_Info_Server e_info_server;
@@ -82,9 +83,9 @@ static Eina_List *module_hook = NULL;
 #define VALUE_TYPE_REPLY_RESLIST "ssi"
 #define VALUE_TYPE_FOR_INPUTDEV "ssi"
 
-static E_Info_Transform *_e_info_transform_new(E_Client *ec, int id, int enable, int x, int y, int sx, int sy, int degree, int keep_ratio);
+static E_Info_Transform *_e_info_transform_new(E_Client *ec, int id, int enable, int x, int y, int sx, int sy, int degree, int background);
 static E_Info_Transform *_e_info_transform_find(E_Client *ec, int id);
-static void              _e_info_transform_set(E_Info_Transform *transform, int enable, int x, int y, int sx, int sy, int degree, int keep_ratio);
+static void              _e_info_transform_set(E_Info_Transform *transform, int enable, int x, int y, int sx, int sy, int degree);
 static void              _e_info_transform_del(E_Info_Transform *transform);
 static void              _e_info_transform_del_with_id(E_Client *ec, int id);
 
@@ -555,17 +556,17 @@ _msg_window_prop_client_append(Eldbus_Message_Iter *iter, E_Client *target_ec)
           {
              double dx, dy, dsx, dsy, drz;
              int x, y, rz;
-             int keep_ratio;
              int view_port;
              int vx, vy, vw, vh;
+             E_Util_Transform *transform = NULL;
+             char label[32];
 
-             E_Util_Transform *transform = e_client_transform_core_transform_get(target_ec, i);
+             transform = e_client_transform_core_transform_get(target_ec, i);
              if (!transform) continue;
 
              e_util_transform_move_get(transform, &dx, &dy, NULL);
              e_util_transform_scale_get(transform, &dsx, &dsy, NULL);
              e_util_transform_rotation_get(transform, NULL, NULL, &drz);
-             keep_ratio = e_util_transform_keep_ratio_get(transform);
              view_port = e_util_transform_viewport_flag_get(transform);
 
              x = (int)(dx + 0.5);
@@ -584,8 +585,22 @@ _msg_window_prop_client_append(Eldbus_Message_Iter *iter, E_Client *target_ec)
                   vh = 0;
                }
 
-             __WINDOW_PROP_ARG_APPEND_TYPE("Transform", "[%d] [%d, %d] [%2.1f, %2.1f] [%d] [%d] [%d :%d, %d, %d, %d]",
-                                           i, x, y, dsx, dsy, rz, keep_ratio, view_port, vx, vy, vw, vh);
+             __WINDOW_PROP_ARG_APPEND_TYPE("Transform", "[%d] [%d, %d] [%2.1f, %2.1f] [%d] [%d :%d, %d, %d, %d]",
+                                           i, x, y, dsx, dsy, rz, view_port, vx, vy, vw, vh);
+
+             if (e_util_transform_bg_transform_flag_get(transform))
+               {
+                  e_util_transform_bg_move_get(transform, &dx, &dy, NULL);
+                  e_util_transform_bg_scale_get(transform, &dsx, &dsy, NULL);
+                  e_util_transform_bg_rotation_get(transform, NULL, NULL, &drz);
+
+                  x = (int)(dx + 0.5);
+                  y = (int)(dy + 0.5);
+                  rz = (int)(drz + 0.5);
+
+                  __WINDOW_PROP_ARG_APPEND_TYPE("Transform_BG", "--------- [%d] [%d, %d] [%2.1f, %2.1f] [%d]",
+                                                i, x, y, dsx, dsy, rz);
+               }
           }
      }
 #undef __WINDOW_PROP_ARG_APPEND
@@ -1679,13 +1694,13 @@ e_info_server_cb_transform_message(const Eldbus_Service_Interface *iface EINA_UN
    Eldbus_Message *reply = eldbus_message_method_return_new(msg);
    uint32_t enable, transform_id;
    uint32_t x, y, sx, sy, degree;
-   uint32_t keep_ratio;
+   uint32_t background;
    const char *value = NULL;
    int32_t value_number;
    Evas_Object *o;
    E_Client *ec;
 
-   if (!eldbus_message_arguments_get(msg, "siiiiiiii", &value, &transform_id, &enable, &x, &y, &sx, &sy, &degree, &keep_ratio))
+   if (!eldbus_message_arguments_get(msg, "siiiiiiii", &value, &transform_id, &enable, &x, &y, &sx, &sy, &degree, &background))
      {
         ERR("Error getting arguments.");
         return reply;
@@ -1711,7 +1726,7 @@ e_info_server_cb_transform_message(const Eldbus_Service_Interface *iface EINA_UN
 
         if (transform_info)
           {
-             _e_info_transform_set(transform_info, enable, x, y, sx, sy, degree, keep_ratio);
+             _e_info_transform_set(transform_info, enable, x, y, sx, sy, degree);
 
              if (!enable)
                 _e_info_transform_del_with_id(ec, transform_id);
@@ -1720,7 +1735,7 @@ e_info_server_cb_transform_message(const Eldbus_Service_Interface *iface EINA_UN
           {
              if (enable)
                {
-                  _e_info_transform_new(ec, transform_id, enable, x, y, sx, sy, degree, keep_ratio);
+                  _e_info_transform_new(ec, transform_id, enable, x, y, sx, sy, degree, background);
                }
           }
 
@@ -2723,7 +2738,7 @@ err:
 
 
 static E_Info_Transform*
-_e_info_transform_new(E_Client *ec, int id, int enable, int x, int y, int sx, int sy, int degree, int keep_ratio)
+_e_info_transform_new(E_Client *ec, int id, int enable, int x, int y, int sx, int sy, int degree, int background)
 {
    E_Info_Transform *result = NULL;
    result = _e_info_transform_find(ec, id);
@@ -2735,9 +2750,10 @@ _e_info_transform_new(E_Client *ec, int id, int enable, int x, int y, int sx, in
         result->id = id;
         result->ec = ec;
         result->transform = e_util_transform_new();
-        _e_info_transform_set(result, enable, x, y, sx, sy, degree, keep_ratio);
+        result->background = background;
+        result->enable = 0;
+        _e_info_transform_set(result, enable, x, y, sx, sy, degree);
         e_info_transform_list = eina_list_append(e_info_transform_list, result);
-
      }
 
    return result;
@@ -2763,20 +2779,33 @@ _e_info_transform_find(E_Client *ec, int id)
 }
 
 static void
-_e_info_transform_set(E_Info_Transform *transform, int enable, int x, int y, int sx, int sy, int degree, int keep_ratio)
+_e_info_transform_set(E_Info_Transform *transform, int enable, int x, int y, int sx, int sy, int degree)
 {
    if (!transform) return;
    if (!transform->transform) return;
 
-   e_util_transform_move(transform->transform, (double)x, (double)y, 0.0);
-   e_util_transform_scale(transform->transform, (double)sx / 100.0, (double)sy / 100.0, 1.0);
-   e_util_transform_rotation(transform->transform, 0.0, 0.0, degree);
-   e_util_transform_keep_ratio_set(transform->transform, keep_ratio);
-
-   if (enable)
-      e_client_transform_core_add(transform->ec, transform->transform);
+   if (transform->background)
+     {
+        e_util_transform_bg_move(transform->transform, (double)x, (double)y, 0.0);
+        e_util_transform_bg_scale(transform->transform, (double)sx / 100.0, (double)sy / 100.0, 1.0);
+        e_util_transform_bg_rotation(transform->transform, 0.0, 0.0, degree);
+     }
    else
-      e_client_transform_core_remove(transform->ec, transform->transform);
+     {
+        e_util_transform_move(transform->transform, (double)x, (double)y, 0.0);
+        e_util_transform_scale(transform->transform, (double)sx / 100.0, (double)sy / 100.0, 1.0);
+        e_util_transform_rotation(transform->transform, 0.0, 0.0, degree);
+     }
+
+   if (enable != transform->enable)
+     {
+        if (enable)
+          e_client_transform_core_add(transform->ec, transform->transform);
+        else
+          e_client_transform_core_remove(transform->ec, transform->transform);
+
+        transform->enable = enable;
+     }
 
    e_client_transform_core_update(transform->ec);
 }
@@ -2787,7 +2816,12 @@ _e_info_transform_del(E_Info_Transform *transform)
    if (!transform) return;
 
    e_info_transform_list = eina_list_remove(e_info_transform_list, transform);
-   e_client_transform_core_remove(transform->ec, transform->transform);
+
+   if (transform->enable)
+     {
+        e_client_transform_core_remove(transform->ec, transform->transform);
+     }
+
    e_util_transform_del(transform->transform);
    free(transform);
 }
index 7f4857daa76ef5591ee37a18e9f1894f43197715..05e19a53182b40d448d64c3acc38f7bc95fc3a5c 100644 (file)
@@ -1,6 +1,11 @@
 #include "e.h"
 #define E_UTIL_TRANSFORM_IS_ZERO(p) ((p) > -1e-21 && (p) < 1e-21)
 
+static void _e_util_transform_value_merge(E_Util_Transform_Value *inout, E_Util_Transform_Value *input);
+static void _e_util_transform_value_convert_to_matrix(E_Util_Transform_Matrix *out,
+                                                      E_Util_Transform_Value *value,
+                                                      E_Util_Transform_Rect *source_rect);
+
 E_API E_Util_Transform*
 e_util_transform_new(void)
 {
@@ -21,6 +26,17 @@ e_util_transform_del(E_Util_Transform *transform)
    e_util_transform_unref(transform);
 }
 
+E_API void
+e_util_transform_copy(E_Util_Transform *dest, E_Util_Transform *source)
+{
+   if ((!dest) || (!source)) return;
+
+   int back_ref_count = dest->ref_count;
+   memcpy(dest, source, sizeof(E_Util_Transform));
+   dest->ref_count = back_ref_count;
+   dest->changed = EINA_TRUE;
+}
+
 E_API void
 e_util_transform_init(E_Util_Transform *transform)
 {
@@ -29,9 +45,12 @@ e_util_transform_init(E_Util_Transform *transform)
 
    back_ref_count = transform->ref_count;
    memset(transform, 0, sizeof(E_Util_Transform));
-   transform->scale.value[0] = 1.0;
-   transform->scale.value[1] = 1.0;
-   transform->scale.value[2] = 1.0;
+   transform->transform.scale[0] = 1.0;
+   transform->transform.scale[1] = 1.0;
+   transform->transform.scale[2] = 1.0;
+   transform->bg_transform.scale[0] = 1.0;
+   transform->bg_transform.scale[1] = 1.0;
+   transform->bg_transform.scale[2] = 1.0;
    transform->changed = EINA_TRUE;
    transform->ref_count = back_ref_count;
 }
@@ -49,7 +68,7 @@ e_util_transform_unref(E_Util_Transform *transform)
    if (!transform) return;
    transform->ref_count -= 1;
    if (transform->ref_count <= 0)
-      free(transform);
+     free(transform);
 }
 
 E_API int
@@ -64,9 +83,9 @@ e_util_transform_move(E_Util_Transform *transform, double x, double y, double z)
 {
    if (!transform) return;
 
-   transform->move.value[0] = x;
-   transform->move.value[1] = y;
-   transform->move.value[2] = z;
+   transform->transform.move[0] = x;
+   transform->transform.move[1] = y;
+   transform->transform.move[2] = z;
    transform->changed = EINA_TRUE;
 }
 
@@ -75,9 +94,9 @@ e_util_transform_scale(E_Util_Transform *transform, double sx, double sy, double
 {
    if (!transform) return;
 
-   transform->scale.value[0] = sx;
-   transform->scale.value[1] = sy;
-   transform->scale.value[2] = sz;
+   transform->transform.scale[0] = sx;
+   transform->transform.scale[1] = sy;
+   transform->transform.scale[2] = sz;
    transform->changed = EINA_TRUE;
 }
 
@@ -86,9 +105,45 @@ e_util_transform_rotation(E_Util_Transform *transform, double rx, double ry, dou
 {
    if (!transform) return;
 
-   transform->rotation.value[0] = rx;
-   transform->rotation.value[1] = ry;
-   transform->rotation.value[2] = rz;
+   transform->transform.rotation[0] = rx;
+   transform->transform.rotation[1] = ry;
+   transform->transform.rotation[2] = rz;
+   transform->changed = EINA_TRUE;
+}
+
+E_API void
+e_util_transform_bg_move(E_Util_Transform *transform, double x, double y, double z)
+{
+   if (!transform) return;
+
+   transform->bg_transform.move[0] = x;
+   transform->bg_transform.move[1] = y;
+   transform->bg_transform.move[2] = z;
+   transform->use_bg_transform = EINA_TRUE;
+   transform->changed = EINA_TRUE;
+}
+
+E_API void
+e_util_transform_bg_scale(E_Util_Transform *transform, double sx, double sy, double sz)
+{
+   if (!transform) return;
+
+   transform->bg_transform.scale[0] = sx;
+   transform->bg_transform.scale[1] = sy;
+   transform->bg_transform.scale[2] = sz;
+   transform->use_bg_transform = EINA_TRUE;
+   transform->changed = EINA_TRUE;
+}
+
+E_API void
+e_util_transform_bg_rotation(E_Util_Transform *transform, double rx, double ry, double rz)
+{
+   if (!transform) return;
+
+   transform->bg_transform.rotation[0] = rx;
+   transform->bg_transform.rotation[1] = ry;
+   transform->bg_transform.rotation[2] = rz;
+   transform->use_bg_transform = EINA_TRUE;
    transform->changed = EINA_TRUE;
 }
 
@@ -117,31 +172,6 @@ e_util_transform_viewport_set(E_Util_Transform *transform, int x, int y, int w,
    transform->changed = EINA_TRUE;
 }
 
-E_API void
-e_util_transform_source_to_target(E_Util_Transform *transform,
-                                  E_Util_Transform_Rect *dest,
-                                  E_Util_Transform_Rect *source)
-{
-   if (!transform) return;
-   if (!dest || !source) return;
-
-   e_util_transform_init(transform);
-
-   if ((dest->x != source->x) || (dest->y != source->y))
-      e_util_transform_move(transform, dest->x - source->x, dest->y - source->y, 0.0);
-
-   if ((dest->w != source->w) || (dest->w != source->w))
-     {
-        if (!E_UTIL_TRANSFORM_IS_ZERO(source->w) &&
-            !E_UTIL_TRANSFORM_IS_ZERO(source->h))
-          {
-             e_util_transform_scale(transform, dest->w / source->w, dest->h / source->h, 1.0);
-          }
-     }
-
-   transform->changed = EINA_TRUE;
-}
-
 E_API void
 e_util_transform_merge(E_Util_Transform *in_out, E_Util_Transform *input)
 {
@@ -150,22 +180,28 @@ e_util_transform_merge(E_Util_Transform *in_out, E_Util_Transform *input)
    if (!in_out) return;
    if (!input) return;
 
-   for (i = 0 ; i < 3 ; ++i)
+   if ((in_out->use_bg_transform) || (input->use_bg_transform))
      {
-        in_out->move.value[i] += input->move.value[i];
-        in_out->scale.value[i] *= input->scale.value[i];
-        in_out->rotation.value[i] += input->rotation.value[i];
+        if (!in_out->use_bg_transform)
+          memcpy(&in_out->bg_transform, &in_out->transform, sizeof(E_Util_Transform_Value));
+
+        if (input->use_bg_transform)
+          _e_util_transform_value_merge(&in_out->bg_transform, &input->bg_transform);
+        else
+          _e_util_transform_value_merge(&in_out->bg_transform, &input->transform);
      }
 
+   _e_util_transform_value_merge(&in_out->transform, &input->transform);
+
    // texcoord and viewport just one setting.
    if (input->use_texcoord)
      memcpy(&in_out->texcoord, &input->texcoord, sizeof(input->texcoord));
    if (input->use_viewport)
      memcpy(&in_out->viewport, &input->viewport, sizeof(input->viewport));
 
-   in_out->keep_ratio |= input->keep_ratio;
    in_out->use_texcoord |= input->use_texcoord;
    in_out->use_viewport |= input->use_viewport;
+   in_out->use_bg_transform |= input->use_bg_transform;
 
    in_out->changed = EINA_TRUE;
 }
@@ -174,26 +210,24 @@ E_API E_Util_Transform_Matrix
 e_util_transform_convert_to_matrix(E_Util_Transform *transform, E_Util_Transform_Rect *source_rect)
 {
    E_Util_Transform_Matrix result;
-   e_util_transform_matrix_load_identity(&result);
 
    if (!transform) return result;
    if (!source_rect) return result;
 
-   double dest_w = source_rect->w * transform->scale.value[0];
-   double dest_h = source_rect->h * transform->scale.value[1];
+   _e_util_transform_value_convert_to_matrix(&result, &transform->transform, source_rect);
 
-   e_util_transform_matrix_translate(&result, -source_rect->x - source_rect->w / 2.0, -source_rect->y - source_rect->h / 2.0, 0.0);
-   e_util_transform_matrix_scale(&result, transform->scale.value[0], transform->scale.value[1], transform->scale.value[2]);
+   return result;
+}
+
+E_API E_Util_Transform_Matrix
+e_util_transform_bg_convert_to_matrix(E_Util_Transform *transform, E_Util_Transform_Rect *source_rect)
+{
+   E_Util_Transform_Matrix result;
 
-   if (!E_UTIL_TRANSFORM_IS_ZERO(transform->rotation.value[0]))
-      e_util_transform_matrix_rotation_x(&result, transform->rotation.value[0]);
-   if (!E_UTIL_TRANSFORM_IS_ZERO(transform->rotation.value[1]))
-      e_util_transform_matrix_rotation_y(&result, transform->rotation.value[1]);
-   if (!E_UTIL_TRANSFORM_IS_ZERO(transform->rotation.value[2]))
-      e_util_transform_matrix_rotation_z(&result, transform->rotation.value[2]);
+   if (!transform) return result;
+   if (!source_rect) return result;
 
-   e_util_transform_matrix_translate(&result, source_rect->x + transform->move.value[0] + (dest_w / 2.0),
-                                     source_rect->y + transform->move.value[1] + (dest_h / 2.0), 0.0);
+   _e_util_transform_value_convert_to_matrix(&result, &transform->bg_transform, source_rect);
 
    return result;
 }
@@ -213,75 +247,57 @@ e_util_transform_change_unset(E_Util_Transform *transform)
 }
 
 E_API void
-e_util_transform_keep_ratio_set(E_Util_Transform *transform, Eina_Bool enable)
+e_util_transform_move_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
    if (!transform) return;
-   if (transform->keep_ratio == enable) return;
-   transform->keep_ratio = enable;
-   transform->changed = EINA_TRUE;
+   if (x) *x = transform->transform.move[0];
+   if (y) *y = transform->transform.move[1];
+   if (z) *z = transform->transform.move[2];
 }
 
-E_API Eina_Bool
-e_util_transform_keep_ratio_get(E_Util_Transform *transform)
+E_API void
+e_util_transform_scale_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
-   if (!transform) return EINA_FALSE;
-   return transform->keep_ratio;
+   if (!transform) return;
+   if (x) *x = transform->transform.scale[0];
+   if (y) *y = transform->transform.scale[1];
+   if (z) *z = transform->transform.scale[2];
 }
 
-E_API E_Util_Transform
-e_util_transform_keep_ratio_apply(E_Util_Transform *transform, int origin_w, int origin_h)
+E_API void
+e_util_transform_rotation_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
-   int i;
-   E_Util_Transform result;
-   E_Util_Transform_Vertex move_ver;
-   E_Util_Transform_Matrix matrix;
-
-   e_util_transform_vertex_init(&move_ver, 0.0, 0.0, 0.0, 1.0);
-   e_util_transform_matrix_load_identity(&matrix);
-
-   if (!transform) return result;
-
-   memcpy(&result, transform, sizeof(E_Util_Transform));
-
-   if (transform->scale.value[0] > transform->scale.value[1])
-      result.scale.value[0] = result.scale.value[1] = transform->scale.value[1];
-   else
-      result.scale.value[0] = result.scale.value[1] = transform->scale.value[0];
-
-   move_ver.vertex[0] += (transform->scale.value[0] - result.scale.value[0]) * origin_w * 0.5;
-   move_ver.vertex[1] += (transform->scale.value[1] - result.scale.value[1]) * origin_h * 0.5;
-
-   for(i = 0 ; i < 3 ; ++i)
-      result.move.value[i] += move_ver.vertex[i];
-
-   return result;
+   if (!transform) return;
+   if (x) *x = transform->transform.rotation[0];
+   if (y) *y = transform->transform.rotation[1];
+   if (z) *z = transform->transform.rotation[2];
 }
 
 E_API void
-e_util_transform_move_get(E_Util_Transform *transform, double *x, double *y, double *z)
+e_util_transform_bg_move_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
    if (!transform) return;
-   if (x) *x = transform->move.value[0];
-   if (y) *y = transform->move.value[1];
-   if (z) *z = transform->move.value[2];
+   if (x) *x = transform->bg_transform.move[0];
+   if (y) *y = transform->bg_transform.move[1];
+   if (z) *z = transform->bg_transform.move[2];
 }
 
 E_API void
-e_util_transform_scale_get(E_Util_Transform *transform, double *x, double *y, double *z)
+e_util_transform_bg_scale_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
    if (!transform) return;
-   if (x) *x = transform->scale.value[0];
-   if (y) *y = transform->scale.value[1];
-   if (z) *z = transform->scale.value[2];
+   if (x) *x = transform->bg_transform.scale[0];
+   if (y) *y = transform->bg_transform.scale[1];
+   if (z) *z = transform->bg_transform.scale[2];
 }
 
 E_API void
-e_util_transform_rotation_get(E_Util_Transform *transform, double *x, double *y, double *z)
+e_util_transform_bg_rotation_get(E_Util_Transform *transform, double *x, double *y, double *z)
 {
    if (!transform) return;
-   if (x) *x = transform->rotation.value[0];
-   if (y) *y = transform->rotation.value[1];
-   if (z) *z = transform->rotation.value[2];
+   if (x) *x = transform->bg_transform.rotation[0];
+   if (y) *y = transform->bg_transform.rotation[1];
+   if (z) *z = transform->bg_transform.rotation[2];
 }
 
 E_API void
@@ -319,17 +335,11 @@ e_util_transform_viewport_flag_get(E_Util_Transform *transform)
    return transform->use_viewport;
 }
 
-E_API void
-e_util_transform_log(E_Util_Transform *transform, const char *str)
+E_API Eina_Bool
+e_util_transform_bg_transform_flag_get(E_Util_Transform *transform)
 {
-   if (!transform) return;
-   if (!str) return;
-
-   printf("[e_util_transform_log : %s\n", str);
-   printf("[move     : %2.1f, %2.1f, %2.1f]\n", transform->move.value[0], transform->move.value[1], transform->move.value[2]);
-   printf("[scale    : %2.1f, %2.1f, %2.1f]\n", transform->scale.value[0], transform->scale.value[1], transform->scale.value[2]);
-   printf("[rotation : %2.1f, %2.1f, %2.1f]\n", transform->rotation.value[0], transform->rotation.value[1], transform->rotation.value[2]);
-
+   if (!transform) return EINA_FALSE;
+   return transform->use_bg_transform;
 }
 
 E_API void
@@ -412,7 +422,7 @@ e_util_transform_vertices_init(E_Util_Transform_Rect_Vertex *vertices)
    if (!vertices) return;
 
    for (i = 0 ; i < 4 ; ++i)
-      e_util_transform_vertex_init(&vertices->vertices[i], 0.0, 0.0, 0.0, 1.0);
+     e_util_transform_vertex_init(&vertices->vertices[i], 0.0, 0.0, 0.0, 1.0);
 }
 
 E_API E_Util_Transform_Rect
@@ -679,7 +689,7 @@ e_util_transform_matrix_multiply_rect_vertex(E_Util_Transform_Matrix *matrix,
    if (!vertices) return result;
 
    for (i = 0 ; i < 4 ; ++i)
-      result.vertices[i] = e_util_transform_matrix_multiply_vertex(matrix, &vertices->vertices[i]);
+     result.vertices[i] = e_util_transform_matrix_multiply_vertex(matrix, &vertices->vertices[i]);
 
    return result;
 }
@@ -706,3 +716,77 @@ e_util_transform_matrix_equal_check(E_Util_Transform_Matrix *matrix,
 
    return result;
 }
+
+static void
+_e_util_transform_value_merge(E_Util_Transform_Value *inout, E_Util_Transform_Value *input)
+{
+   int i;
+
+   if ((!inout) || (!input)) return;
+
+   for (i = 0 ; i < 3 ; ++i)
+     {
+        inout->move[i] *= input->scale[i];
+        inout->move[i] += input->move[i];
+        inout->scale[i] *= input->scale[i];
+        inout->rotation[i] += input->rotation[i];
+     }
+}
+
+static void
+_e_util_transform_value_convert_to_matrix(E_Util_Transform_Matrix *out, E_Util_Transform_Value *value, E_Util_Transform_Rect *source_rect)
+{
+   if (!out) return;
+   if (!value) return;
+   if (!source_rect) return;
+
+   e_util_transform_matrix_load_identity(out);
+
+   double dest_w = source_rect->w * value->scale[0];
+   double dest_h = source_rect->h * value->scale[1];
+
+   e_util_transform_matrix_translate(out, -source_rect->x - source_rect->w / 2.0, -source_rect->y - source_rect->h / 2.0, 0.0);
+   e_util_transform_matrix_scale(out, value->scale[0], value->scale[1], value->scale[2]);
+
+   if (!E_UTIL_TRANSFORM_IS_ZERO(value->rotation[0]))
+     e_util_transform_matrix_rotation_x(out, value->rotation[0]);
+   if (!E_UTIL_TRANSFORM_IS_ZERO(value->rotation[1]))
+     e_util_transform_matrix_rotation_y(out, value->rotation[1]);
+   if (!E_UTIL_TRANSFORM_IS_ZERO(value->rotation[2]))
+     e_util_transform_matrix_rotation_z(out, value->rotation[2]);
+
+   e_util_transform_matrix_translate(out, source_rect->x + value->move[0] + (dest_w / 2.0),
+                                     source_rect->y + value->move[1] + (dest_h / 2.0), 0.0);
+}
+
+
+// will delete function
+E_API void
+e_util_transform_source_to_target(E_Util_Transform *transform,
+                                  E_Util_Transform_Rect *dest,
+                                  E_Util_Transform_Rect *source)
+{
+}
+
+E_API void
+e_util_transform_log(E_Util_Transform *transform, const char *str)
+{
+}
+
+E_API void
+e_util_transform_keep_ratio_set(E_Util_Transform *transform, Eina_Bool enable)
+{
+}
+
+E_API Eina_Bool
+e_util_transform_keep_ratio_get(E_Util_Transform *transform)
+{
+   return EINA_FALSE;
+}
+
+E_API E_Util_Transform
+e_util_transform_keep_ratio_apply(E_Util_Transform *transform, int origin_w, int origin_h)
+{
+   E_Util_Transform result;
+   return result;
+}
\ No newline at end of file
index 8ba61f57d25108d89eb456f80961860ff7a852ff..f5e07b8a5e2ebb0a09eb0cbba244b4289741ef57 100644 (file)
@@ -1,22 +1,18 @@
 #ifdef E_TYPEDEFS
 
-typedef struct _E_Util_Transform_Value       E_Util_Transform_Value;
-typedef struct _E_Util_Transform_Texcoord    E_Util_Transform_Texcoord;
-typedef struct _E_Util_Transform             E_Util_Transform;
-typedef struct _E_Util_Transform_Rect        E_Util_Transform_Rect;
-typedef struct _E_Util_Transform_Vertex      E_Util_Transform_Vertex;
-typedef struct _E_Util_Transform_Rect_Vertex E_Util_Transform_Rect_Vertex;
-typedef struct _E_Util_Transform_Matrix      E_Util_Transform_Matrix;
+typedef struct _E_Util_Transform_Value              E_Util_Transform_Value;
+typedef struct _E_Util_Transform_Texcoord           E_Util_Transform_Texcoord;
+typedef struct _E_Util_Transform                    E_Util_Transform;
+typedef struct _E_Util_Transform_Rect               E_Util_Transform_Rect;
+typedef struct _E_Util_Transform_Vertex             E_Util_Transform_Vertex;
+typedef struct _E_Util_Transform_Rect_Vertex        E_Util_Transform_Rect_Vertex;
+typedef struct _E_Util_Transform_Matrix             E_Util_Transform_Matrix;
+
 
 #else
 #ifndef E_UTIL_TRANSFORM_H_
 #define E_UTIL_TRANSFORM_H_
 
-struct _E_Util_Transform_Value
-{
-   double value[3];
-};
-
 struct _E_Util_Transform_Texcoord
 {
    double value[4][2];
@@ -30,18 +26,24 @@ struct _E_Util_Transform_Rect
    int h;
 };
 
+struct _E_Util_Transform_Value
+{
+   double move[3];
+   double scale[3];
+   double rotation[3];
+};
+
 struct _E_Util_Transform
 {
-   E_Util_Transform_Value    scale;
-   E_Util_Transform_Value    move;
-   E_Util_Transform_Value    rotation;
+   E_Util_Transform_Value    transform;
+   E_Util_Transform_Value    bg_transform;
    E_Util_Transform_Texcoord texcoord;
    E_Util_Transform_Rect     viewport;
    int                       ref_count;
-   Eina_Bool                 keep_ratio;
    Eina_Bool                 changed;
    Eina_Bool                 use_texcoord;
    Eina_Bool                 use_viewport;
+   Eina_Bool                 use_bg_transform;
 };
 
 struct _E_Util_Transform_Vertex
@@ -61,6 +63,7 @@ struct _E_Util_Transform_Matrix
 
 E_API E_Util_Transform            *e_util_transform_new(void);
 E_API void                         e_util_transform_del(E_Util_Transform *transform);
+E_API void                         e_util_transform_copy(E_Util_Transform *dest, E_Util_Transform *source);
 E_API void                         e_util_transform_ref(E_Util_Transform *transform);
 E_API void                         e_util_transform_unref(E_Util_Transform *transform);
 E_API int                          e_util_transform_ref_count_get(E_Util_Transform *transform);
@@ -68,26 +71,30 @@ E_API void                         e_util_transform_init(E_Util_Transform *trans
 E_API void                         e_util_transform_move(E_Util_Transform *transform, double x, double y, double z);
 E_API void                         e_util_transform_scale(E_Util_Transform *transform, double sx, double sy, double sz);
 E_API void                         e_util_transform_rotation(E_Util_Transform *transform, double rx, double ry, double rz);
+E_API void                         e_util_transform_bg_move(E_Util_Transform *transform, double x, double y, double z);
+E_API void                         e_util_transform_bg_scale(E_Util_Transform *transform, double sx, double sy, double sz);
+E_API void                         e_util_transform_bg_rotation(E_Util_Transform *transform, double rx, double ry, double rz);
 E_API void                         e_util_transform_texcoord_set(E_Util_Transform *transform, int index, double tu, double tv);
 E_API void                         e_util_transform_viewport_set(E_Util_Transform *transform, int x, int y, int w, int h);
-E_API void                         e_util_transform_source_to_target(E_Util_Transform *transform,
-                                                                     E_Util_Transform_Rect *dest,
-                                                                     E_Util_Transform_Rect *source);
+
 E_API void                         e_util_transform_merge(E_Util_Transform *in_out, E_Util_Transform *input);
 E_API E_Util_Transform_Matrix      e_util_transform_convert_to_matrix(E_Util_Transform *transform, E_Util_Transform_Rect *source_rect);
+E_API E_Util_Transform_Matrix      e_util_transform_bg_convert_to_matrix(E_Util_Transform *transform, E_Util_Transform_Rect *source_rect);
 E_API Eina_Bool                    e_util_transform_change_get(E_Util_Transform *transform);
 E_API void                         e_util_transform_change_unset(E_Util_Transform *transform);
-E_API void                         e_util_transform_keep_ratio_set(E_Util_Transform *transform, Eina_Bool enable);
-E_API Eina_Bool                    e_util_transform_keep_ratio_get(E_Util_Transform *transform);
-E_API E_Util_Transform             e_util_transform_keep_ratio_apply(E_Util_Transform *transform, int origin_w, int origin_h);
+
 E_API void                         e_util_transform_move_get(E_Util_Transform *transform, double *x, double *y, double *z);
 E_API void                         e_util_transform_scale_get(E_Util_Transform *transform, double *x, double *y, double *z);
 E_API void                         e_util_transform_rotation_get(E_Util_Transform *transform, double *x, double *y, double *z);
+E_API void                         e_util_transform_bg_move_get(E_Util_Transform *transform, double *x, double *y, double *z);
+E_API void                         e_util_transform_bg_scale_get(E_Util_Transform *transform, double *x, double *y, double *z);
+E_API void                         e_util_transform_bg_rotation_get(E_Util_Transform *transform, double *x, double *y, double *z);
+
 E_API void                         e_util_transform_texcoord_get(E_Util_Transform *transform, int index, double *tu, double *tv);
 E_API void                         e_util_transform_viewport_get(E_Util_Transform *transform, int *x, int *y, int *w, int *h);
 E_API Eina_Bool                    e_util_transform_texcoord_flag_get(E_Util_Transform *transform);
 E_API Eina_Bool                    e_util_transform_viewport_flag_get(E_Util_Transform *transform);
-E_API void                         e_util_transform_log(E_Util_Transform *transform, const char *str);
+E_API Eina_Bool                    e_util_transform_bg_transform_flag_get(E_Util_Transform *transform);
 
 E_API void                         e_util_transform_rect_init(E_Util_Transform_Rect *rect, int x, int y, int w, int h);
 E_API void                         e_util_transform_rect_client_rect_get(E_Util_Transform_Rect *rect, E_Client *ec);
@@ -115,5 +122,14 @@ E_API E_Util_Transform_Rect_Vertex e_util_transform_matrix_multiply_rect_vertex(
                                                                                 E_Util_Transform_Rect_Vertex *vertices);
 E_API Eina_Bool                    e_util_transform_matrix_equal_check(E_Util_Transform_Matrix *matrix,
                                                                        E_Util_Transform_Matrix *matrix2);
+
+// will delete function
+E_API void                         e_util_transform_source_to_target(E_Util_Transform *transform,
+                                                                     E_Util_Transform_Rect *dest,
+                                                                     E_Util_Transform_Rect *source);
+E_API void                         e_util_transform_keep_ratio_set(E_Util_Transform *transform, Eina_Bool enable);
+E_API Eina_Bool                    e_util_transform_keep_ratio_get(E_Util_Transform *transform);
+E_API E_Util_Transform             e_util_transform_keep_ratio_apply(E_Util_Transform *transform, int origin_w, int origin_h);
+E_API void                         e_util_transform_log(E_Util_Transform *transform, const char *str);
 #endif
 #endif