}
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;
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);
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);
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;
// 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
// 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);
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);
}
{
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)
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))
{
_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
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)
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);
unsigned char win_type : 1;
unsigned char layer : 1;
} fetch;
+
+ E_Util_Transform *viewport_transform;
};
struct _E_Comp_Wl_Output
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,
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
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)
{
#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;
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
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];
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);
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);