add some beginnigns of utility funcs to evas map. move it to its own file.

SVN revision: 43201
This commit is contained in:
Carsten Haitzler 2009-10-22 15:47:30 +00:00
parent 8984a75799
commit 7fce71c5d9
5 changed files with 218 additions and 172 deletions

View File

@ -852,7 +852,10 @@ extern "C" {
EAPI Eina_Bool evas_object_map_enable_get (const Evas_Object *obj);
EAPI void evas_object_map_set (Evas_Object *obj, const Evas_Map_Point *points);
EAPI void evas_object_map_get (const Evas_Object *obj, Evas_Map_Point *points);
EAPI void evas_map_util_rotate (Evas_Map_Point *mp, double degrees, Evas_Coord cx, Evas_Coord cy);
EAPI void evas_map_util_zoom (Evas_Map_Point *mp, double zoomx, double zoomy, Evas_Coord cx, Evas_Coord cy);
EAPI Evas_Map_Point *evas_map_new (int num);
EAPI void evas_map_free (Evas_Map_Point *mp);
EAPI void evas_map_point_coord_set (Evas_Map_Point *mp, int n, Evas_Coord x, Evas_Coord y, Evas_Coord z);

View File

@ -49,7 +49,8 @@ evas_smart.c \
evas_stack.c \
evas_async_events.c \
evas_transform.c \
evas_stats.c
evas_stats.c \
evas_map.c
libevas_canvas_la_LIBADD = @EVIL_LIBS@

View File

@ -0,0 +1,211 @@
#include "evas_common.h"
#include "evas_private.h"
#include <math.h>
static void
_calc_map_geometry(Evas_Object *obj)
{
int i;
int is, was = 0, pass = 0;
Evas_Coord x1, x2, y1, y2;
if (!obj->cur.mappoints) return;
x1 = obj->cur.mappoints[0].x;
x2 = obj->cur.mappoints[0].x;
y1 = obj->cur.mappoints[0].y;
y2 = obj->cur.mappoints[0].y;
for (i = 1; i < 4; i++)
{
if (obj->cur.mappoints[i].x < x1) x1 = obj->cur.mappoints[i].x;
if (obj->cur.mappoints[i].x > x2) x2 = obj->cur.mappoints[i].x;
if (obj->cur.mappoints[i].y < y1) y1 = obj->cur.mappoints[i].y;
if (obj->cur.mappoints[i].y > y2) y2 = obj->cur.mappoints[i].y;
}
obj->cur.geometry.x = x1;
obj->cur.geometry.y = y1;
obj->cur.geometry.w = (x2 - x1) + 1;
obj->cur.geometry.h = (y2 - y1) + 1;
evas_object_change(obj);
evas_object_clip_dirty(obj);
if (obj->layer->evas->events_frozen <= 0)
{
evas_object_recalc_clippees(obj);
if (!pass)
{
if (!obj->smart.smart)
{
is = evas_object_is_in_output_rect(obj,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y, 1, 1);
if ((is ^ was) && obj->cur.visible)
evas_event_feed_mouse_move(obj->layer->evas,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y,
obj->layer->evas->last_timestamp,
NULL);
}
}
}
evas_object_inform_call_move(obj);
evas_object_inform_call_resize(obj);
}
EAPI void
evas_object_map_enable_set(Evas_Object *obj, Eina_Bool enabled)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (obj->cur.usemap == !!enabled) return;
obj->cur.usemap = enabled;
if (obj->cur.usemap) _calc_map_geometry(obj);
}
EAPI Eina_Bool
evas_object_map_enable_get(const Evas_Object *obj)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return 0;
MAGIC_CHECK_END();
return obj->cur.usemap;
}
EAPI void
evas_object_map_set(Evas_Object *obj, const Evas_Map_Point *points)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (!points)
{
if (obj->cur.mappoints)
{
if (!obj->prev.mappoints)
{
free(obj->cur.mappoints);
obj->cur.mappoints = NULL;
return;
}
obj->cur.mappoints = NULL;
}
return;
}
if (!obj->cur.mappoints)
{
obj->cur.mappoints = malloc(4 * sizeof(Evas_Map_Point));
if (obj->cur.mappoints)
{
memcpy(obj->cur.mappoints, points, 4 * sizeof(Evas_Map_Point));
}
obj->prev.mappoints = NULL;
}
else
{
memcpy(obj->cur.mappoints, points, 4 * sizeof(Evas_Map_Point));
obj->prev.mappoints = NULL;
}
if (obj->cur.usemap) _calc_map_geometry(obj);
}
EAPI void
evas_object_map_get(const Evas_Object *obj, Evas_Map_Point *points)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (obj->cur.mappoints)
{
memcpy(points, obj->cur.mappoints, 4 * sizeof(Evas_Map_Point));
}
}
EAPI Evas_Map_Point *
evas_map_new(int num)
{
return calloc(num, sizeof(Evas_Map_Point));
}
EAPI void
evas_map_free(Evas_Map_Point *mp)
{
if (!mp) return;
free(mp);
}
EAPI void
evas_map_point_coord_set(Evas_Map_Point *mp, int n, Evas_Coord x, Evas_Coord y, Evas_Coord z)
{
if (!mp) return;
mp[n].x = x;
mp[n].y = y;
mp[n].z = z;
}
EAPI void
evas_map_point_coord_get(const Evas_Map_Point *mp, int n, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
{
if (!mp) return;
if (x) *x = mp[n].x;
if (y) *y = mp[n].y;
if (z) *z = mp[n].z;
}
EAPI void
evas_map_point_image_uv_set(Evas_Map_Point *mp, int n, double u, double v)
{
if (!mp) return;
mp[n].u = u;
mp[n].v = v;
}
EAPI void
evas_map_point_image_uv_get(const Evas_Map_Point *mp, int n, double *u, double *v)
{
if (!mp) return;
if (u) *u = mp[n].u;
if (v) *v = mp[n].v;
}
EAPI void
evas_map_util_rotate(Evas_Map_Point *mp, double degrees, Evas_Coord cx, Evas_Coord cy)
{
double r = (degrees * M_PI) / 180.0;
int i;
for (i = 0; i < 4; i++)
{
Evas_Coord x, y, xx, yy;
xx = x = mp[i].x - cx;
yy = y = mp[i].y - cy;
xx = (x * cos(r));
yy = (x * sin(r));
x = xx + (y * cos(r + (M_PI / 2.0)));
y = yy + (y * sin(r + (M_PI / 2.0)));
mp[i].x = x + cx;
mp[i].y = y + cy;
}
}
EAPI void
evas_map_util_zoom(Evas_Map_Point *mp, double zoomx, double zoomy, Evas_Coord cx, Evas_Coord cy)
{
int i;
for (i = 0; i < 4; i++)
{
Evas_Coord x, y;
x = mp[i].x - cx;
y = mp[i].y - cy;
x = (((double)x) * zoomx);
y = (((double)y) * zoomy);
mp[i].x = x + cx;
mp[i].y = y + cy;
}
}

View File

@ -1658,171 +1658,6 @@ evas_object_precise_is_inside_get(const Evas_Object *obj)
return obj->precise_is_inside;
}
static void
_calc_map_geometry(Evas_Object *obj)
{
int i;
int is, was = 0, pass = 0;
Evas_Coord x1, x2, y1, y2;
if (!obj->cur.mappoints) return;
x1 = obj->cur.mappoints[0].x;
x2 = obj->cur.mappoints[0].x;
y1 = obj->cur.mappoints[0].y;
y2 = obj->cur.mappoints[0].y;
for (i = 1; i < 4; i++)
{
if (obj->cur.mappoints[i].x < x1) x1 = obj->cur.mappoints[i].x;
if (obj->cur.mappoints[i].x > x2) x2 = obj->cur.mappoints[i].x;
if (obj->cur.mappoints[i].y < y1) y1 = obj->cur.mappoints[i].y;
if (obj->cur.mappoints[i].y > y2) y2 = obj->cur.mappoints[i].y;
}
obj->cur.geometry.x = x1;
obj->cur.geometry.y = y1;
obj->cur.geometry.w = (x2 - x1) + 1;
obj->cur.geometry.h = (y2 - y1) + 1;
evas_object_change(obj);
evas_object_clip_dirty(obj);
if (obj->layer->evas->events_frozen <= 0)
{
evas_object_recalc_clippees(obj);
if (!pass)
{
if (!obj->smart.smart)
{
is = evas_object_is_in_output_rect(obj,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y, 1, 1);
if ((is ^ was) && obj->cur.visible)
evas_event_feed_mouse_move(obj->layer->evas,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y,
obj->layer->evas->last_timestamp,
NULL);
}
}
}
evas_object_inform_call_move(obj);
evas_object_inform_call_resize(obj);
}
EAPI void
evas_object_map_enable_set(Evas_Object *obj, Eina_Bool enabled)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (obj->cur.usemap == !!enabled) return;
obj->cur.usemap = enabled;
if (obj->cur.usemap) _calc_map_geometry(obj);
}
EAPI Eina_Bool
evas_object_map_enable_get(const Evas_Object *obj)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return 0;
MAGIC_CHECK_END();
return obj->cur.usemap;
}
EAPI void
evas_object_map_set(Evas_Object *obj, const Evas_Map_Point *points)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (!points)
{
if (obj->cur.mappoints)
{
if (!obj->prev.mappoints)
{
free(obj->cur.mappoints);
obj->cur.mappoints = NULL;
return;
}
obj->cur.mappoints = NULL;
}
return;
}
if (!obj->cur.mappoints)
{
obj->cur.mappoints = malloc(4 * sizeof(Evas_Map_Point));
if (obj->cur.mappoints)
{
memcpy(obj->cur.mappoints, points, 4 * sizeof(Evas_Map_Point));
}
obj->prev.mappoints = NULL;
}
else
{
memcpy(obj->cur.mappoints, points, 4 * sizeof(Evas_Map_Point));
obj->prev.mappoints = NULL;
}
if (obj->cur.usemap) _calc_map_geometry(obj);
}
EAPI void
evas_object_map_get(const Evas_Object *obj, Evas_Map_Point *points)
{
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if (obj->cur.mappoints)
{
memcpy(points, obj->cur.mappoints, 4 * sizeof(Evas_Map_Point));
}
}
EAPI Evas_Map_Point *
evas_map_new(int num)
{
return calloc(num, sizeof(Evas_Map_Point));
}
EAPI void
evas_map_free(Evas_Map_Point *mp)
{
if (!mp) return;
free(mp);
}
EAPI void
evas_map_point_coord_set(Evas_Map_Point *mp, int n, Evas_Coord x, Evas_Coord y, Evas_Coord z)
{
if (!mp) return;
mp[n].x = x;
mp[n].y = y;
mp[n].z = z;
}
EAPI void
evas_map_point_coord_get(const Evas_Map_Point *mp, int n, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
{
if (!mp) return;
if (x) *x = mp[n].x;
if (y) *y = mp[n].y;
if (z) *z = mp[n].z;
}
EAPI void
evas_map_point_image_uv_set(Evas_Map_Point *mp, int n, double u, double v)
{
if (!mp) return;
mp[n].u = u;
mp[n].v = v;
}
EAPI void
evas_map_point_image_uv_get(const Evas_Map_Point *mp, int n, double *u, double *v)
{
if (!mp) return;
if (u) *u = mp[n].u;
if (v) *v = mp[n].v;
}
/**
* @}
*/

View File

@ -409,20 +409,16 @@ evas_common_map4_rgba_internal(RGBA_Image *src, RGBA_Image *dst,
else
{
spans[yp].span[0].x1 = -1;
// printf("duck for y %i, edge_num is %i\n", y, edge_num);
}
}
}
if (dc->mul.use)
func = evas_common_gfx_func_composite_pixel_color_span_get(src, dc->mul.col, dst, cw, dc->render_op);
else
func = evas_common_gfx_func_composite_pixel_span_get(src, dst, dst->cache_entry.w, dc->render_op);
func = evas_common_gfx_func_composite_pixel_span_get(src, dst, cw, dc->render_op);
buf = alloca(dst->cache_entry.w * sizeof(DATA32));
// walk spans and fill
// printf("---------- %i -> %i / %i %i [ %i %i]\n",
// ystart, yend, cy, ch, cx, cw);
for (y = ystart; y <= yend; y++)
{
int x, w, ww, dx, dy, sx, sy;