evas_map: use source size for uv instead of proxy size

Summary:
Usually application sets uv point value using proxy object size.
if source object is bigger than proxy object, then only part of
source image is used for map, and it leads to unexpected result.

This patch is solving this problem make map use source object size
instead of proxy object size by comparing both size.

Test Plan:
[Samle Code]
{F4606414}

[Sample Image]
{F4606413}

[Before apply map]
{F4606418}

[After apply map WITHOUT patch]
{F4606416}

[After apply map WITH patch]
{F4606417}

Reviewers: raster, Hermet

Reviewed By: raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12292
This commit is contained in:
Shinwoo Kim 2021-09-20 10:11:11 +01:00 committed by Carsten Haitzler (Rasterman)
parent 7d434bdcc0
commit 2bf995efa1
3 changed files with 29 additions and 2 deletions

View File

@ -159,6 +159,26 @@ _efl_canvas_proxy_source_events_get(const Eo *eo_obj, void *_pd EINA_UNUSED)
return _evas_image_proxy_source_events_get(eo_obj);
}
void
_evas_image_proxy_source_scale_get(const Eo *eo_obj, double *sw, double *sh)
{
*sw = 1.0;
*sh = 1.0;
Evas_Object_Protected_Data *source = NULL;
Evas_Image_Data *o = efl_data_scope_get(eo_obj, EFL_CANVAS_IMAGE_INTERNAL_CLASS);
if (!o->cur->source) return;
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
source = efl_data_scope_get(o->cur->source, EFL_CANVAS_OBJECT_CLASS);
if (obj->cur->geometry.w > 0)
*sw = (double) source->cur->geometry.w / obj->cur->geometry.w;
if (obj->cur->geometry.h > 0)
*sh = (double) source->cur->geometry.h / obj->cur->geometry.h;
}
Evas_Object *
_evas_object_image_source_get(Evas_Object *eo_obj)
{

View File

@ -1377,6 +1377,12 @@ evas_object_map_update(Evas_Object *eo_obj,
pts[0].py = obj->map->cur.map->persp.py << FP;
pts[0].foc = obj->map->cur.map->persp.foc << FP;
pts[0].z0 = obj->map->cur.map->persp.z0 << FP;
double uscale = 1.0, vscale = 1.0;
if (obj->is_image_object)
{
_evas_image_proxy_source_scale_get(eo_obj, &uscale, &vscale);
}
// draw geom +x +y
for (; p < p_end; p++, pt++)
{
@ -1387,9 +1393,9 @@ evas_object_map_update(Evas_Object *eo_obj,
pt->fy = p->y + (float) y;
pt->fz = p->z;
if ((uvw == 0) || (imagew == 0)) pt->u = 0;
else pt->u = ((lround(p->u) * imagew) / uvw) * FP1;
else pt->u = ((lround(p->u * uscale) * imagew) / uvw) * FP1;
if ((uvh == 0) || (imageh == 0)) pt->v = 0;
else pt->v = ((lround(p->v) * imageh) / uvh) * FP1;
else pt->v = ((lround(p->v * vscale) * imageh) / uvh) * FP1;
if (pt->u < 0) pt->u = 0;
else if (pt->u > (imagew * FP1)) pt->u = (imagew * FP1);
if (pt->v < 0) pt->v = 0;

View File

@ -1196,6 +1196,7 @@ void evas_smart_cb_descriptions_fix(Evas_Smart_Cb_Description_Array *a) EINA_ARG
Eina_Bool evas_smart_cb_descriptions_resize(Evas_Smart_Cb_Description_Array *a, unsigned int size) EINA_ARG_NONNULL(1);
const Evas_Smart_Cb_Description *evas_smart_cb_description_find(const Evas_Smart_Cb_Description_Array *a, const char *name) EINA_ARG_NONNULL(1, 2) EINA_PURE;
void _evas_image_proxy_source_scale_get(const Eo *eo_obj, double *sw, double *sh);
Evas_Object *_evas_object_image_source_get(Evas_Object *obj);
Eina_Bool _evas_object_image_preloading_get(const Evas_Object *obj);
Evas_Object *_evas_object_image_video_parent_get(Evas_Object *obj);