merge transform core and viewport transform 06/74606/8
authorSungbae Park <sb34.park@samsung.com>
Wed, 15 Jun 2016 02:02:56 +0000 (11:02 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Fri, 17 Jun 2016 08:56:08 +0000 (01:56 -0700)
Signed-off-by: Sungbae Park <sb34.park@samsung.com>
Change-Id: Ia936a671e02cdf4b0e3f2ac6b5b78afb6fd9ed59
Signed-off-by: Sungbae Park <sb34.park@samsung.com>
src/bin/e_client.c
src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_util_transform.c
src/bin/e_util_transform.h

index f31d0a83f59029dee24f38102549c6c509683a96..6297397e36f02a7ee8505fb98d63666b6e25a742 100644 (file)
@@ -2973,7 +2973,10 @@ _e_client_transform_core_boundary_update(E_Client *ec, E_Util_Transform_Rect_Ver
 }
 
 static void
-_e_client_transform_core_vertices_apply(E_Client *ec EINA_UNUSED, Evas_Object *obj, E_Util_Transform_Rect_Vertex *vertices)
+_e_client_transform_core_vertices_apply(E_Client *ec EINA_UNUSED,
+                                        Evas_Object *obj,
+                                        E_Util_Transform_Rect_Vertex *vertices,
+                                        E_Util_Transform *transform)
 {
    Evas_Map *map = NULL;
    int i, x, y;
@@ -2999,6 +3002,13 @@ _e_client_transform_core_vertices_apply(E_Client *ec EINA_UNUSED, Evas_Object *o
              y = (int)(dy + 0.5);
 
              evas_map_point_coord_set(map, i, x, y, 1.0);
+
+             if (transform && e_util_transform_texcoord_flag_get(transform))
+               {
+                  double u = 0.0; double v = 0.0;
+                  e_util_transform_texcoord_get(transform, i, &u, &v);
+                  evas_map_point_image_uv_set(map, i, u, v);
+               }
           }
 
         evas_object_map_set(obj, map);
@@ -3023,7 +3033,7 @@ _e_client_transform_core_sub_update(E_Client *ec, E_Util_Transform_Rect_Vertex *
    cdata = (E_Comp_Wl_Client_Data*)ec->comp_data;
 
    if (cdata->sub.below_obj)
-      _e_client_transform_core_vertices_apply(ec, cdata->sub.below_obj, vertices);
+     _e_client_transform_core_vertices_apply(ec, cdata->sub.below_obj, vertices, NULL);
 
    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
       e_client_transform_core_update(subc);
@@ -5940,15 +5950,10 @@ e_client_transform_core_remove(E_Client *ec, E_Util_Transform *transform)
 E_API void
 e_client_transform_core_update(E_Client *ec)
 {
-   E_Comp_Wl_Client_Data *cdata;
-
    if (!ec) return;
    if (ec->new_client) return;
    if (!_e_client_transform_core_check_change(ec)) return;
 
-   cdata = (E_Comp_Wl_Client_Data *)ec->comp_data;
-   if (cdata && cdata->scaler.viewport) return;
-
    if (ec->transform_core.transform_list || ec->transform_core.parent.enable)
      {
         E_Util_Transform_Rect source_rect;
@@ -5965,7 +5970,15 @@ e_client_transform_core_update(E_Client *ec)
         // 2. merge transform
         EINA_LIST_FOREACH(ec->transform_core.transform_list, l, temp_trans)
           {
-             ec->transform_core.result.transform = e_util_transform_merge(&ec->transform_core.result.transform, temp_trans);
+             e_util_transform_merge(&ec->transform_core.result.transform, temp_trans);
+          }
+
+        // 2.5 check viewport
+        if (e_util_transform_viewport_flag_get(&ec->transform_core.result.transform))
+          {
+             int vx = 0, vy = 0, vw = 0, vh = 0;
+             e_util_transform_viewport_get(&ec->transform_core.result.transform, &vx, &vy, &vw, &vh);
+             e_util_transform_rect_init(&source_rect, vx, vy, vw, vh);
           }
 
         // 3. covert to matrix and apply keep_ratio
@@ -6015,7 +6028,7 @@ e_client_transform_core_update(E_Client *ec)
         // 5. apply vertices
         e_comp_object_transform_bg_vertices_set(ec->frame, &ec->transform_core.result.boundary.vertices);
         _e_client_transform_core_boundary_update(ec, &ec->transform_core.result.boundary.vertices);
-        _e_client_transform_core_vertices_apply(ec, ec->frame, &ec->transform_core.result.vertices);
+        _e_client_transform_core_vertices_apply(ec, ec->frame, &ec->transform_core.result.vertices, &ec->transform_core.result.transform);
 
         // 6. subsurface update'
         _e_client_transform_core_sub_update(ec, &ec->transform_core.result.vertices);
@@ -6023,7 +6036,7 @@ e_client_transform_core_update(E_Client *ec)
    else
      {
         ec->transform_core.result.enable = EINA_FALSE;
-        _e_client_transform_core_vertices_apply(ec, ec->frame, NULL);
+        _e_client_transform_core_vertices_apply(ec, ec->frame, NULL, NULL);
         _e_client_transform_core_sub_update(ec, NULL);
      }
 
index ead0de89e1dddaa8a0c97f061ba28cca0e49dddf..3227aa3ede4e2f26139125c4c1b9b85218ae4868 100644 (file)
@@ -386,12 +386,19 @@ e_comp_wl_map_apply(E_Client *ec)
 {
    E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport;
    E_Comp_Wl_Subsurf_Data *sdata;
-   const Evas_Map *m;
-   Evas_Map *map;
+   E_Comp_Wl_Client_Data *cdata;
    int x1, y1, x2, y2, x, y;
    int dx, dy;
 
+   cdata = ec->comp_data;
    sdata = ec->comp_data->sub.data;
+
+   if (!cdata->viewport_transform)
+     {
+        cdata->viewport_transform = e_util_transform_new();
+        e_client_transform_core_add(ec, cdata->viewport_transform);
+     }
+
    if (sdata)
      {
         if (sdata->parent)
@@ -415,21 +422,9 @@ e_comp_wl_map_apply(E_Client *ec)
    if (x != dx || y != dy)
      evas_object_move(ec->frame, dx, dy);
 
-   m = evas_object_map_get(ec->frame);
-   evas_map_point_coord_get(m, 0, &x1, &y1, NULL);
-   evas_map_point_coord_get(m, 2, &x2, &y2, NULL);
-
-   if (x1 == dx && (x2 - x1) == ec->comp_data->width_from_viewport &&
-       y1 == dy && (y2 - y1) == ec->comp_data->height_from_viewport)
-     return;
-
-   map = evas_map_new(4);
-
-   evas_map_util_points_populate_from_geometry(map,
-                                               dx, dy,
-                                               ec->comp_data->width_from_viewport,
-                                               ec->comp_data->height_from_viewport,
-                                               0);
+   e_util_transform_viewport_set(cdata->viewport_transform, dx, dy,
+                                 ec->comp_data->width_from_viewport,
+                                 ec->comp_data->height_from_viewport);
 
    if (vp->buffer.src_width == wl_fixed_from_int(-1))
      {
@@ -449,27 +444,24 @@ e_comp_wl_map_apply(E_Client *ec)
    _e_comp_wl_map_transform(ec->comp_data->width_from_buffer, ec->comp_data->height_from_buffer,
                             vp->buffer.transform, vp->buffer.scale,
                             x1, y1, &x, &y);
-   evas_map_point_image_uv_set(map, 0, x, y);
+   e_util_transform_texcoord_set(cdata->viewport_transform, 0, x, y);
 
    _e_comp_wl_map_transform(ec->comp_data->width_from_buffer, ec->comp_data->height_from_buffer,
                             vp->buffer.transform, vp->buffer.scale,
                             x2, y1, &x, &y);
-   evas_map_point_image_uv_set(map, 1, x, y);
+   e_util_transform_texcoord_set(cdata->viewport_transform, 1, x, y);
 
    _e_comp_wl_map_transform(ec->comp_data->width_from_buffer, ec->comp_data->height_from_buffer,
                             vp->buffer.transform, vp->buffer.scale,
                             x2, y2, &x, &y);
-   evas_map_point_image_uv_set(map, 2, x, y);
+   e_util_transform_texcoord_set(cdata->viewport_transform, 2, x, y);
 
    _e_comp_wl_map_transform(ec->comp_data->width_from_buffer, ec->comp_data->height_from_buffer,
                             vp->buffer.transform, vp->buffer.scale,
                             x1, y2, &x, &y);
-   evas_map_point_image_uv_set(map, 3, x, y);
-
-   evas_object_map_set(ec->frame, map);
-   evas_object_map_enable_set(ec->frame, map ? EINA_TRUE : EINA_FALSE);
+   e_util_transform_texcoord_set(cdata->viewport_transform, 3, x, y);
 
-   evas_map_free(map);
+   e_client_transform_core_update(ec);
 }
 
 static void
@@ -546,25 +538,36 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
    E_Client *subc;
    Eina_List *l;
    int x, y;
-   const Evas_Map *m;
 
    if (!(ec = data)) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
      {
-        if ((m = evas_object_map_get(subc->frame))) continue;
-        x = ec->x + subc->comp_data->sub.data->position.x;
-        y = ec->y + subc->comp_data->sub.data->position.y;
-        evas_object_move(subc->frame, x, y);
+        if (subc->comp_data->scaler.viewport)
+          {
+             e_comp_wl_map_apply(subc);
+          }
+        else
+          {
+             x = ec->x + subc->comp_data->sub.data->position.x;
+             y = ec->y + subc->comp_data->sub.data->position.y;
+             evas_object_move(subc->frame, x, y);
+          }
      }
 
    EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
      {
-        if ((m = evas_object_map_get(subc->frame))) continue;
-        x = ec->x + subc->comp_data->sub.data->position.x;
-        y = ec->y + subc->comp_data->sub.data->position.y;
-        evas_object_move(subc->frame, x, y);
+        if (subc->comp_data->scaler.viewport)
+          {
+             e_comp_wl_map_apply(subc);
+          }
+        else
+          {
+             x = ec->x + subc->comp_data->sub.data->position.x;
+             y = ec->y + subc->comp_data->sub.data->position.y;
+             evas_object_move(subc->frame, x, y);
+          }
      }
 
    if (ec->comp_data->sub.below_obj)
@@ -3950,6 +3953,13 @@ _e_comp_wl_client_cb_del(void *data EINA_UNUSED, E_Client *ec)
         cursor_timer_ec = NULL;
      }
 
+   if (ec->comp_data->viewport_transform)
+     {
+        e_client_transform_core_remove(ec, ec->comp_data->viewport_transform);
+        e_util_transform_del(ec->comp_data->viewport_transform);
+        ec->comp_data->viewport_transform = NULL;
+     }
+
    e_pixmap_cdata_set(ec->pixmap, NULL);
 
    E_FREE(ec->comp_data);
index dcd9c541c176e1996bcf2877b37e537381b0452e..416bcae86fcb2bab856aa732df9720953f21c877 100644 (file)
@@ -447,6 +447,8 @@ struct _E_Comp_Wl_Client_Data
       unsigned char win_type : 1;
       unsigned char layer : 1;
    } fetch;
+
+   E_Util_Transform *viewport_transform;
 };
 
 struct _E_Comp_Wl_Output
index 4ccf96549329b9562f8bfa60cf3e2985eaf2710c..7f4857daa76ef5591ee37a18e9f1894f43197715 100644 (file)
@@ -92,6 +92,31 @@ e_util_transform_rotation(E_Util_Transform *transform, double rx, double ry, dou
    transform->changed = EINA_TRUE;
 }
 
+E_API void
+e_util_transform_texcoord_set(E_Util_Transform *transform, int index, double tu, double tv)
+{
+   if (!transform) return;
+   if (index < 0 || index > 3) return;
+
+   transform->texcoord.value[index][0] = tu;
+   transform->texcoord.value[index][1] = tv;
+   transform->use_texcoord = EINA_TRUE;
+   transform->changed = EINA_TRUE;
+}
+
+E_API void
+e_util_transform_viewport_set(E_Util_Transform *transform, int x, int y, int w, int h)
+{
+   if (!transform) return;
+
+   transform->viewport.x = x;
+   transform->viewport.y = y;
+   transform->viewport.w = w;
+   transform->viewport.h = h;
+   transform->use_viewport = EINA_TRUE;
+   transform->changed = EINA_TRUE;
+}
+
 E_API void
 e_util_transform_source_to_target(E_Util_Transform *transform,
                                   E_Util_Transform_Rect *dest,
@@ -117,32 +142,32 @@ e_util_transform_source_to_target(E_Util_Transform *transform,
    transform->changed = EINA_TRUE;
 }
 
-E_API E_Util_Transform
-e_util_transform_merge(E_Util_Transform *trans1, E_Util_Transform *trans2)
+E_API void
+e_util_transform_merge(E_Util_Transform *in_out, E_Util_Transform *input)
 {
-   E_Util_Transform result;
    int i;
 
-   e_util_transform_init(&result);
-
-   if (!trans1) return result;
-   if (!trans2) return result;
+   if (!in_out) return;
+   if (!input) return;
 
    for (i = 0 ; i < 3 ; ++i)
-      result.move.value[i] = trans1->move.value[i] + trans2->move.value[i];
-
-   for (i = 0 ; i < 3 ; ++i)
-      result.scale.value[i] = trans1->scale.value[i] * trans2->scale.value[i];
-
-   for (i = 0 ; i < 3 ; ++i)
-      result.rotation.value[i] = trans1->rotation.value[i] + trans2->rotation.value[i];
+     {
+        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 (trans1->keep_ratio || trans2->keep_ratio)
-      result.keep_ratio = EINA_TRUE;
+   // 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));
 
-   result.changed = EINA_TRUE;
+   in_out->keep_ratio |= input->keep_ratio;
+   in_out->use_texcoord |= input->use_texcoord;
+   in_out->use_viewport |= input->use_viewport;
 
-   return result;
+   in_out->changed = EINA_TRUE;
 }
 
 E_API E_Util_Transform_Matrix
@@ -259,6 +284,41 @@ e_util_transform_rotation_get(E_Util_Transform *transform, double *x, double *y,
    if (z) *z = transform->rotation.value[2];
 }
 
+E_API void
+e_util_transform_texcoord_get(E_Util_Transform *transform,int index, double *tu, double *tv)
+{
+   if (!transform) return;
+   if (index < 0 || index > 3) return;
+
+   if (tu) *tu = transform->texcoord.value[index][0];
+   if (tv) *tv = transform->texcoord.value[index][1];
+}
+
+E_API void
+e_util_transform_viewport_get(E_Util_Transform *transform, int *x, int *y, int *w, int *h)
+{
+   if (!transform) return;
+
+   if (x) *x = transform->viewport.x;
+   if (y) *y = transform->viewport.y;
+   if (w) *w = transform->viewport.w;
+   if (h) *h = transform->viewport.h;
+}
+
+E_API Eina_Bool
+e_util_transform_texcoord_flag_get(E_Util_Transform *transform)
+{
+   if (!transform) return EINA_FALSE;
+   return transform->use_texcoord;
+}
+
+E_API Eina_Bool
+e_util_transform_viewport_flag_get(E_Util_Transform *transform)
+{
+   if (!transform) return EINA_FALSE;
+   return transform->use_viewport;
+}
+
 E_API void
 e_util_transform_log(E_Util_Transform *transform, const char *str)
 {
index 62d10f44324a60a95583d0e6a59c8b940086b550..8ba61f57d25108d89eb456f80961860ff7a852ff 100644 (file)
@@ -1,6 +1,7 @@
 #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;
@@ -16,14 +17,9 @@ struct _E_Util_Transform_Value
    double value[3];
 };
 
-struct _E_Util_Transform
+struct _E_Util_Transform_Texcoord
 {
-   E_Util_Transform_Value scale;
-   E_Util_Transform_Value move;
-   E_Util_Transform_Value rotation;
-   int                    ref_count;
-   Eina_Bool              keep_ratio;
-   Eina_Bool              changed;
+   double value[4][2];
 };
 
 struct _E_Util_Transform_Rect
@@ -34,6 +30,20 @@ struct _E_Util_Transform_Rect
    int h;
 };
 
+struct _E_Util_Transform
+{
+   E_Util_Transform_Value    scale;
+   E_Util_Transform_Value    move;
+   E_Util_Transform_Value    rotation;
+   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;
+};
+
 struct _E_Util_Transform_Vertex
 {
    double vertex[4];
@@ -58,10 +68,12 @@ 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_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 E_Util_Transform             e_util_transform_merge(E_Util_Transform *trans1, E_Util_Transform *trans2);
+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 Eina_Bool                    e_util_transform_change_get(E_Util_Transform *transform);
 E_API void                         e_util_transform_change_unset(E_Util_Transform *transform);
@@ -71,6 +83,10 @@ E_API E_Util_Transform             e_util_transform_keep_ratio_apply(E_Util_Tran
 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_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 void                         e_util_transform_rect_init(E_Util_Transform_Rect *rect, int x, int y, int w, int h);