2009-10-22 08:47:30 -07:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
static void
|
2009-10-28 01:59:01 -07:00
|
|
|
_evas_map_calc_geom_change(Evas_Object *obj)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
|
|
|
int is, was = 0, pass = 0;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
evas_object_change(obj);
|
|
|
|
evas_object_clip_dirty(obj);
|
|
|
|
if (obj->layer->evas->events_frozen <= 0)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
evas_object_inform_call_move(obj);
|
|
|
|
evas_object_inform_call_resize(obj);
|
|
|
|
}
|
|
|
|
|
2009-10-28 01:59:01 -07:00
|
|
|
static void
|
|
|
|
_evas_map_calc_map_geometry(Evas_Object *obj)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2009-10-28 01:59:01 -07:00
|
|
|
Evas_Coord x1, x2, y1, y2;
|
|
|
|
const Evas_Map_Point *p, *p_end;
|
2010-12-06 14:28:38 -08:00
|
|
|
Eina_Bool ch = EINA_FALSE;
|
2009-10-22 08:47:30 -07:00
|
|
|
|
2009-10-28 01:59:01 -07:00
|
|
|
if (!obj->cur.map) return;
|
2011-07-05 23:24:18 -07:00
|
|
|
|
|
|
|
// WARN: Do not merge below code to SLP until it is fixed.
|
|
|
|
// It has an infinite loop bug.
|
2010-12-06 14:28:38 -08:00
|
|
|
if (obj->prev.map)
|
|
|
|
{
|
2011-01-03 02:12:17 -08:00
|
|
|
// FIXME: this causes an infinite loop somewhere... hard to debug
|
|
|
|
if (obj->prev.map->count == obj->cur.map->count)
|
|
|
|
{
|
|
|
|
const Evas_Map_Point *p2;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-01-03 02:12:17 -08:00
|
|
|
p = obj->cur.map->points;
|
|
|
|
p_end = p + obj->cur.map->count;
|
|
|
|
p2 = obj->prev.map->points;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-01-03 02:12:17 -08:00
|
|
|
for (; p < p_end; p++, p2++)
|
|
|
|
{
|
|
|
|
if ((p->a != p2->a) ||
|
|
|
|
(p->r != p2->r) ||
|
|
|
|
(p->g != p2->g) ||
|
|
|
|
(p->b != p2->b))
|
|
|
|
{
|
|
|
|
ch = 1;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-12 02:44:50 -07:00
|
|
|
if ((p->x != p2->x) ||
|
|
|
|
(p->y != p2->y) ||
|
|
|
|
(p->z != p2->z))
|
|
|
|
{
|
|
|
|
ch = 1;
|
|
|
|
break;
|
|
|
|
}
|
2011-01-03 02:12:17 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ch = 1;
|
2010-12-06 14:28:38 -08:00
|
|
|
}
|
2011-04-12 02:44:50 -07:00
|
|
|
else
|
|
|
|
ch = 1;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-10-28 01:59:01 -07:00
|
|
|
p = obj->cur.map->points;
|
2009-11-03 07:41:36 -08:00
|
|
|
p_end = p + obj->cur.map->count;
|
2011-12-11 22:25:14 -08:00
|
|
|
x1 = x2 = lround(p->x);
|
|
|
|
y1 = y2 = lround(p->y);
|
2009-10-28 01:59:01 -07:00
|
|
|
p++;
|
|
|
|
for (; p < p_end; p++)
|
|
|
|
{
|
2011-12-12 00:23:24 -08:00
|
|
|
Evas_Coord x, y;
|
|
|
|
|
|
|
|
x = lround(p->x);
|
|
|
|
y = lround(p->y);
|
|
|
|
if (x < x1) x1 = x;
|
|
|
|
if (x > x2) x2 = x;
|
|
|
|
if (y < y1) y1 = y;
|
|
|
|
if (y > y2) y2 = y;
|
2009-10-28 01:59:01 -07:00
|
|
|
}
|
2011-10-26 06:33:25 -07:00
|
|
|
// this causes clip-out bugs now mapped objs canbe opaque!!!
|
|
|
|
// // add 1 pixel of fuzz around the map region to ensure updates are correct
|
|
|
|
// x1 -= 1; y1 -= 1;
|
|
|
|
// x2 += 1; y2 += 1;
|
2010-01-25 03:04:32 -08:00
|
|
|
if (obj->cur.map->normal_geometry.x != x1) ch = 1;
|
|
|
|
if (obj->cur.map->normal_geometry.y != y1) ch = 1;
|
|
|
|
if (obj->cur.map->normal_geometry.w != (x2 - x1)) ch = 1;
|
|
|
|
if (obj->cur.map->normal_geometry.h != (y2 - y1)) ch = 1;
|
2009-11-03 07:41:36 -08:00
|
|
|
obj->cur.map->normal_geometry.x = x1;
|
|
|
|
obj->cur.map->normal_geometry.y = y1;
|
|
|
|
obj->cur.map->normal_geometry.w = (x2 - x1);
|
|
|
|
obj->cur.map->normal_geometry.h = (y2 - y1);
|
2010-01-25 03:04:32 -08:00
|
|
|
if (ch) _evas_map_calc_geom_change(obj);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
static inline Evas_Map *
|
2009-10-28 01:59:01 -07:00
|
|
|
_evas_map_new(int count)
|
2009-10-22 13:11:33 -07:00
|
|
|
{
|
2009-10-31 18:32:23 -07:00
|
|
|
int i;
|
2011-02-06 15:52:17 -08:00
|
|
|
int alloc;
|
|
|
|
Evas_Map *m;
|
|
|
|
|
|
|
|
/* Adjust allocation such that: at least 4 points, and always an even
|
|
|
|
* number: this allows the software engine to work efficiently */
|
|
|
|
alloc = (count < 4) ? 4 : count;
|
|
|
|
if (alloc & 0x1) alloc ++;
|
|
|
|
|
|
|
|
m = calloc(1, sizeof(Evas_Map) + (alloc * sizeof(Evas_Map_Point)));
|
2009-10-28 01:59:01 -07:00
|
|
|
if (!m) return NULL;
|
2009-10-22 13:11:33 -07:00
|
|
|
m->count = count;
|
2010-09-21 23:52:28 -07:00
|
|
|
m->persp.foc = 0;
|
2009-10-31 02:08:01 -07:00
|
|
|
m->alpha = 1;
|
|
|
|
m->smooth = 1;
|
2011-06-16 05:08:46 -07:00
|
|
|
m->magic = MAGIC_MAP;
|
2009-10-31 18:32:23 -07:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
m->points[i].r = 255;
|
|
|
|
m->points[i].g = 255;
|
|
|
|
m->points[i].b = 255;
|
|
|
|
m->points[i].a = 255;
|
|
|
|
}
|
2009-10-22 13:11:33 -07:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
_evas_map_copy(Evas_Map *dst, const Evas_Map *src)
|
|
|
|
{
|
|
|
|
if (dst->count != src->count)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
ERR("cannot copy map of different sizes: dst=%i, src=%i", dst->count, src->count);
|
|
|
|
return EINA_FALSE;
|
2009-10-22 13:11:33 -07:00
|
|
|
}
|
|
|
|
memcpy(dst->points, src->points, src->count * sizeof(Evas_Map_Point));
|
2009-10-31 02:08:01 -07:00
|
|
|
dst->smooth = src->smooth;
|
|
|
|
dst->alpha = src->alpha;
|
2010-09-21 23:52:28 -07:00
|
|
|
dst->persp = src->persp;
|
2009-10-22 13:11:33 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2009-10-31 18:32:23 -07:00
|
|
|
static inline Evas_Map *
|
|
|
|
_evas_map_dup(const Evas_Map *orig)
|
|
|
|
{
|
|
|
|
Evas_Map *copy = _evas_map_new(orig->count);
|
|
|
|
if (!copy) return NULL;
|
|
|
|
memcpy(copy->points, orig->points, orig->count * sizeof(Evas_Map_Point));
|
|
|
|
copy->smooth = orig->smooth;
|
|
|
|
copy->alpha = orig->alpha;
|
2010-09-21 23:52:28 -07:00
|
|
|
copy->persp = orig->persp;
|
2009-10-31 18:32:23 -07:00
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
static inline void
|
2010-04-12 01:23:53 -07:00
|
|
|
_evas_map_free(Evas_Object *obj, Evas_Map *m)
|
2009-10-22 13:11:33 -07:00
|
|
|
{
|
2010-04-12 01:23:53 -07:00
|
|
|
if (obj)
|
|
|
|
{
|
|
|
|
if (m->surface)
|
|
|
|
obj->layer->evas->engine.func->image_map_surface_free
|
|
|
|
(obj->layer->evas->engine.data.output, m->surface);
|
|
|
|
}
|
2011-06-16 18:16:16 -07:00
|
|
|
m->magic = 0;
|
2009-10-22 13:11:33 -07:00
|
|
|
free(m);
|
|
|
|
}
|
|
|
|
|
2011-06-16 04:48:41 -07:00
|
|
|
/****************************************************************************/
|
|
|
|
/* util functions for manipulating maps, so you don't need to know the math */
|
|
|
|
/****************************************************************************/
|
|
|
|
static inline void
|
|
|
|
_evas_map_util_points_populate(Evas_Map *m, const Evas_Coord x, const Evas_Coord y, const Evas_Coord w, const Evas_Coord h, const Evas_Coord z)
|
|
|
|
{
|
|
|
|
Evas_Map_Point *p = m->points;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
p[0].x = x;
|
|
|
|
p[0].y = y;
|
|
|
|
p[0].z = z;
|
|
|
|
p[0].u = 0.0;
|
|
|
|
p[0].v = 0.0;
|
|
|
|
|
|
|
|
p[1].x = x + w;
|
|
|
|
p[1].y = y;
|
|
|
|
p[1].z = z;
|
|
|
|
p[1].u = w;
|
|
|
|
p[1].v = 0.0;
|
|
|
|
|
|
|
|
p[2].x = x + w;
|
|
|
|
p[2].y = y + h;
|
|
|
|
p[2].z = z;
|
|
|
|
p[2].u = w;
|
|
|
|
p[2].v = h;
|
|
|
|
|
|
|
|
p[3].x = x;
|
|
|
|
p[3].y = y + h;
|
|
|
|
p[3].z = z;
|
|
|
|
p[3].u = 0.0;
|
|
|
|
p[3].v = h;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
p[i].px = p[i].x;
|
|
|
|
p[i].py = p[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-05 07:24:48 -08:00
|
|
|
Eina_Bool
|
|
|
|
evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y,
|
|
|
|
Evas_Coord *mx, Evas_Coord *my, int grab)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2011-02-06 15:52:17 -08:00
|
|
|
int i, j, edges, edge[m->count][2], douv;
|
2009-11-05 07:24:48 -08:00
|
|
|
Evas_Coord xe[2];
|
2009-12-21 07:52:12 -08:00
|
|
|
double u[2] = { 0.0, 0.0 };
|
|
|
|
double v[2] = { 0.0, 0.0 };
|
2009-11-05 07:24:48 -08:00
|
|
|
|
2011-02-06 15:52:17 -08:00
|
|
|
if (m->count < 4) return 0;
|
2009-11-05 07:24:48 -08:00
|
|
|
// FIXME need to handle grab mode and extrapolte coords outside
|
|
|
|
// map
|
|
|
|
if (grab)
|
|
|
|
{
|
|
|
|
Evas_Coord ymin, ymax;
|
2011-02-06 15:52:17 -08:00
|
|
|
|
2009-11-05 07:24:48 -08:00
|
|
|
ymin = m->points[0].y;
|
|
|
|
ymax = m->points[0].y;
|
|
|
|
for (i = 1; i < m->count; i++)
|
|
|
|
{
|
2011-02-06 15:52:17 -08:00
|
|
|
if (m->points[i].y < ymin) ymin = m->points[i].y;
|
|
|
|
else if (m->points[i].y > ymax) ymax = m->points[i].y;
|
2009-11-05 07:24:48 -08:00
|
|
|
}
|
|
|
|
if (y <= ymin) y = ymin + 1;
|
|
|
|
if (y >= ymax) y = ymax - 1;
|
|
|
|
}
|
|
|
|
edges = 0;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
j = (i + 1) % m->count;
|
|
|
|
if ((m->points[i].y <= y) && (m->points[j].y > y))
|
|
|
|
{
|
|
|
|
edge[edges][0] = i;
|
|
|
|
edge[edges][1] = j;
|
|
|
|
edges++;
|
|
|
|
}
|
|
|
|
else if ((m->points[j].y <= y) && (m->points[i].y > y))
|
|
|
|
{
|
|
|
|
edge[edges][0] = j;
|
|
|
|
edge[edges][1] = i;
|
|
|
|
edges++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
douv = 0;
|
|
|
|
if ((mx) || (my)) douv = 1;
|
|
|
|
for (i = 0; i < (edges - 1); i+= 2)
|
|
|
|
{
|
2010-01-21 22:51:27 -08:00
|
|
|
Evas_Coord yp, yd;
|
|
|
|
|
2009-11-05 07:24:48 -08:00
|
|
|
j = i + 1;
|
|
|
|
yd = m->points[edge[i][1]].y - m->points[edge[i][0]].y;
|
|
|
|
if (yd > 0)
|
|
|
|
{
|
|
|
|
yp = y - m->points[edge[i][0]].y;
|
|
|
|
xe[0] = m->points[edge[i][1]].x - m->points[edge[i][0]].x;
|
|
|
|
xe[0] = m->points[edge[i][0]].x + ((xe[0] * yp) / yd);
|
|
|
|
if (douv)
|
|
|
|
{
|
|
|
|
u[0] = m->points[edge[i][1]].u - m->points[edge[i][0]].u;
|
|
|
|
u[0] = m->points[edge[i][0]].u + ((u[0] * yp) / yd);
|
|
|
|
v[0] = m->points[edge[i][1]].v - m->points[edge[i][0]].v;
|
|
|
|
v[0] = m->points[edge[i][0]].v + ((v[0] * yp) / yd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xe[0] = m->points[edge[i][0]].x;
|
|
|
|
if (douv)
|
|
|
|
{
|
|
|
|
u[0] = m->points[edge[i][0]].u;
|
|
|
|
v[0] = m->points[edge[i][0]].v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
yd = m->points[edge[j][1]].y - m->points[edge[j][0]].y;
|
|
|
|
if (yd > 0)
|
|
|
|
{
|
|
|
|
yp = y - m->points[edge[j][0]].y;
|
|
|
|
xe[1] = m->points[edge[j][1]].x - m->points[edge[j][0]].x;
|
|
|
|
xe[1] = m->points[edge[j][0]].x + ((xe[1] * yp) / yd);
|
|
|
|
if (douv)
|
|
|
|
{
|
|
|
|
u[1] = m->points[edge[j][1]].u - m->points[edge[j][0]].u;
|
|
|
|
u[1] = m->points[edge[j][0]].u + ((u[1] * yp) / yd);
|
|
|
|
v[1] = m->points[edge[j][1]].v - m->points[edge[j][0]].v;
|
|
|
|
v[1] = m->points[edge[j][0]].v + ((v[1] * yp) / yd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xe[1] = m->points[edge[j][0]].x;
|
|
|
|
if (douv)
|
|
|
|
{
|
|
|
|
u[1] = m->points[edge[j][0]].u;
|
|
|
|
v[1] = m->points[edge[j][0]].v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (xe[0] > xe[1])
|
|
|
|
{
|
|
|
|
int ti;
|
2011-02-06 15:52:17 -08:00
|
|
|
|
2009-11-05 07:24:48 -08:00
|
|
|
ti = xe[0]; xe[0] = xe[1]; xe[1] = ti;
|
|
|
|
if (douv)
|
|
|
|
{
|
|
|
|
double td;
|
2011-02-06 15:52:17 -08:00
|
|
|
|
2009-11-05 07:24:48 -08:00
|
|
|
td = u[0]; u[0] = u[1]; u[1] = td;
|
|
|
|
td = v[0]; v[0] = v[1]; v[1] = td;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((x >= xe[0]) && (x < xe[1]))
|
|
|
|
{
|
|
|
|
if (douv)
|
|
|
|
{
|
2011-02-06 15:52:17 -08:00
|
|
|
if (mx)
|
|
|
|
*mx = u[0] + (((x - xe[0]) * (u[1] - u[0])) /
|
2009-11-05 07:24:48 -08:00
|
|
|
(xe[1] - xe[0]));
|
|
|
|
if (my)
|
2011-02-06 15:52:17 -08:00
|
|
|
*my = v[0] + (((x - xe[0]) * (v[1] - v[0])) /
|
2009-11-05 07:24:48 -08:00
|
|
|
(xe[1] - xe[0]));
|
|
|
|
}
|
2011-06-16 05:18:19 -07:00
|
|
|
return EINA_TRUE;
|
2009-11-05 07:24:48 -08:00
|
|
|
}
|
|
|
|
if (grab)
|
|
|
|
{
|
|
|
|
if (douv)
|
|
|
|
{
|
2011-02-06 15:52:17 -08:00
|
|
|
if (mx)
|
|
|
|
*mx = u[0] + (((x - xe[0]) * (u[1] - u[0])) /
|
2009-11-05 07:24:48 -08:00
|
|
|
(xe[1] - xe[0]));
|
|
|
|
if (my)
|
2011-02-06 15:52:17 -08:00
|
|
|
*my = v[0] + (((x - xe[0]) * (v[1] - v[0])) /
|
2009-11-05 07:24:48 -08:00
|
|
|
(xe[1] - xe[0]));
|
|
|
|
}
|
2011-06-16 05:18:19 -07:00
|
|
|
return EINA_TRUE;
|
2009-11-05 07:24:48 -08:00
|
|
|
}
|
|
|
|
}
|
2011-06-16 05:18:19 -07:00
|
|
|
return EINA_FALSE;
|
2009-11-05 07:24:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
evas_map_inside_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
return evas_map_coords_get(m, x, y, NULL, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2009-10-28 01:59:01 -07:00
|
|
|
EAPI void
|
|
|
|
evas_object_map_enable_set(Evas_Object *obj, Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2011-06-16 18:16:16 -07:00
|
|
|
|
2010-08-23 23:58:07 -07:00
|
|
|
enabled = !!enabled;
|
|
|
|
if (obj->cur.usemap == enabled) return;
|
|
|
|
obj->cur.usemap = enabled;
|
2009-10-28 01:59:01 -07:00
|
|
|
if (enabled)
|
|
|
|
{
|
|
|
|
if (!obj->cur.map)
|
|
|
|
obj->cur.map = _evas_map_new(4);
|
2010-08-31 15:16:08 -07:00
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2009-11-03 07:41:36 -08:00
|
|
|
// obj->cur.map->normal_geometry = obj->cur.geometry;
|
2009-10-28 01:59:01 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (obj->cur.map)
|
|
|
|
{
|
|
|
|
_evas_map_calc_geom_change(obj);
|
2010-08-31 15:16:08 -07:00
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2011-07-01 04:43:50 -07:00
|
|
|
//FIXME: Since the last frame is not updated when map is
|
2011-07-01 04:30:17 -07:00
|
|
|
//disabled, afterimage problem is happened in s/w rendering.
|
|
|
|
//Need to find out the fundamental reason then fix it.
|
|
|
|
evas_damage_rectangle_add(obj->layer->evas,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
obj->layer->evas->output.w,
|
|
|
|
obj->layer->evas->output.h);
|
2009-10-28 01:59:01 -07:00
|
|
|
}
|
|
|
|
}
|
2009-11-02 07:58:48 -08:00
|
|
|
_evas_map_calc_map_geometry(obj);
|
2010-03-27 22:40:42 -07:00
|
|
|
/* This is a bit heavy handed, but it fixes the case of same geometry, but
|
|
|
|
* changed colour or UV settings. */
|
|
|
|
evas_object_change(obj);
|
2009-10-28 01:59:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_object_map_enable_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2011-06-16 05:18:19 -07:00
|
|
|
return EINA_FALSE;
|
2009-10-28 01:59:01 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return obj->cur.usemap;
|
|
|
|
}
|
|
|
|
|
2010-01-18 01:46:45 -08:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_object_map_source_set(Evas_Object *obj, Evas_Object *src)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
cleanup: fix some "unused" errors from -Wextra.
As we're heading for a release we better remove as much errors as
possible and as the first step I'm removing warnings due unused
parameters, variables and functions. These tend to pollute real errors
spotted by -Wall and clang/llvm.
This does not fixes all, just the clear that could be set to
__UNUSED__, particularly to do (and I'd like some help from the
authors):
* src/lib/engines/common/evas_font_{draw,query}.c (tasn):
intl_props is just used while doing BIDI, but also used in other
#ifdef blocks :-/
* evas_map_* (raster):
huge amount of warnings, code is quite confusing and thus I'm not
touching it. I have no idea whenever the commented blocks or extra
parameters are intended to be used or no.
* src/modules/engines/fbevas_fb_main.c (raster?):
is fb_setvt() to be used? If not do you mind removing it?
* src/modules/engines/gl_{common,x11} (raster):
huge amount of warnings, code is quite nested and full of #ifdefs
that does not help to give a clear picture of what's going on.
* src/bin/evas_cserve_main.c (raster):
I could have ignored most of the errors, but is the code correct? I
mean, there is no unload of images being applied. If you confirm
none of those warnings are harmful I can flag them as unused.
* src/lib/engines/common_8 (dottedmag):
lots of unused functions that were acquired from common_16, they
are unused and if they will not, then they should be removed.
SVN revision: 52421
2010-09-18 12:17:41 -07:00
|
|
|
(void)src; /* method still needs to be implemented. */
|
2010-01-18 01:46:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
evas_object_map_source_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2010-05-13 13:24:06 -07:00
|
|
|
return NULL;
|
2010-01-18 01:46:45 -08:00
|
|
|
}
|
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
EAPI void
|
2009-10-22 13:11:33 -07:00
|
|
|
evas_object_map_set(Evas_Object *obj, const Evas_Map *map)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2011-06-16 18:16:16 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
if (!map)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2009-10-22 13:11:33 -07:00
|
|
|
if (obj->cur.map)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2009-10-31 02:08:01 -07:00
|
|
|
if (obj->cur.map->surface)
|
|
|
|
{
|
|
|
|
obj->layer->evas->engine.func->image_map_surface_free
|
|
|
|
(obj->layer->evas->engine.data.output,
|
|
|
|
obj->cur.map->surface);
|
|
|
|
obj->cur.map->surface = NULL;
|
|
|
|
}
|
2009-11-03 07:41:36 -08:00
|
|
|
obj->prev.geometry = obj->cur.map->normal_geometry;
|
2009-10-22 13:11:33 -07:00
|
|
|
if (!obj->prev.map)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
_evas_map_free(obj, obj->cur.map);
|
2009-10-22 13:11:33 -07:00
|
|
|
obj->cur.map = NULL;
|
2010-09-01 15:45:30 -07:00
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2009-10-22 08:47:30 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-04-12 01:23:53 -07:00
|
|
|
_evas_map_free(obj, obj->cur.map);
|
2009-10-22 13:11:33 -07:00
|
|
|
obj->cur.map = NULL;
|
2009-10-28 01:59:01 -07:00
|
|
|
if (!obj->cur.usemap) _evas_map_calc_geom_change(obj);
|
|
|
|
else _evas_map_calc_map_geometry(obj);
|
2010-08-31 15:16:08 -07:00
|
|
|
if (obj->cur.usemap)
|
2011-07-01 04:30:17 -07:00
|
|
|
{
|
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
2011-07-01 04:43:50 -07:00
|
|
|
//FIXME: Since the last frame is not updated when map is
|
|
|
|
//disabled, afterimage problem is happened in s/w
|
|
|
|
//rendering. Need to find out the fundamental reason
|
2011-07-01 04:30:17 -07:00
|
|
|
//then fix it.
|
|
|
|
evas_damage_rectangle_add(obj->layer->evas,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
obj->layer->evas->output.w,
|
|
|
|
obj->layer->evas->output.h);
|
|
|
|
}
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2011-02-06 15:52:17 -08:00
|
|
|
|
2011-06-16 18:16:16 -07:00
|
|
|
if ((obj->cur.map) && (obj->cur.map->count == map->count))
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2010-09-24 23:19:30 -07:00
|
|
|
Evas_Map *omap = obj->cur.map;
|
2011-02-06 15:52:17 -08:00
|
|
|
obj->cur.map = _evas_map_new(map->count);
|
|
|
|
memcpy(obj->cur.map, omap, sizeof(Evas_Map) + (map->count * sizeof(Evas_Map_Point)));
|
2010-09-24 23:19:30 -07:00
|
|
|
_evas_map_copy(obj->cur.map, map);
|
2011-01-03 02:12:17 -08:00
|
|
|
if (obj->prev.map == omap) obj->prev.map = NULL;
|
2010-09-24 23:19:30 -07:00
|
|
|
free(omap);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
2011-02-06 15:52:17 -08:00
|
|
|
else
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
if (obj->cur.map) evas_map_free(obj->cur.map);
|
2011-02-06 15:52:17 -08:00
|
|
|
obj->cur.map = _evas_map_dup(map);
|
|
|
|
if (obj->cur.usemap)
|
|
|
|
evas_object_mapped_clip_across_mark(obj);
|
|
|
|
}
|
2009-11-02 07:58:48 -08:00
|
|
|
_evas_map_calc_map_geometry(obj);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
EAPI const Evas_Map *
|
|
|
|
evas_object_map_get(const Evas_Object *obj)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2009-10-22 13:11:33 -07:00
|
|
|
return NULL;
|
2009-10-22 08:47:30 -07:00
|
|
|
MAGIC_CHECK_END();
|
2011-06-16 18:16:16 -07:00
|
|
|
|
|
|
|
return obj->cur.map;
|
2009-10-22 13:11:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Map *
|
2009-10-28 01:59:01 -07:00
|
|
|
evas_map_new(int count)
|
2009-10-22 13:11:33 -07:00
|
|
|
{
|
2011-06-02 02:49:17 -07:00
|
|
|
if (count != 4)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-02 02:49:17 -07:00
|
|
|
ERR("map point count (%i) != 4 is unsupported!", count);
|
2011-05-23 03:37:17 -07:00
|
|
|
return NULL;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
2011-06-16 18:16:16 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
return _evas_map_new(count);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
2009-10-31 02:08:01 -07:00
|
|
|
EAPI void
|
|
|
|
evas_map_smooth_set(Evas_Map *m, Eina_Bool enabled)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-31 02:08:01 -07:00
|
|
|
m->smooth = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_map_smooth_get(const Evas_Map *m)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-31 02:08:01 -07:00
|
|
|
return m->smooth;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_map_alpha_set(Evas_Map *m, Eina_Bool enabled)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-31 02:08:01 -07:00
|
|
|
m->alpha = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_map_alpha_get(const Evas_Map *m)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-31 02:08:01 -07:00
|
|
|
return m->alpha;
|
|
|
|
}
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
EAPI Evas_Map *
|
|
|
|
evas_map_dup(const Evas_Map *m)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
2011-06-16 05:18:19 -07:00
|
|
|
return NULL;
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
return _evas_map_dup(m);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-10-22 13:11:33 -07:00
|
|
|
evas_map_free(Evas_Map *m)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
_evas_map_free(NULL, m);
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
2011-02-06 15:52:17 -08:00
|
|
|
EAPI int
|
|
|
|
evas_map_count_get(const Evas_Map *m)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2011-02-06 15:52:17 -08:00
|
|
|
return m->count;
|
|
|
|
}
|
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
EAPI void
|
2009-10-28 01:59:01 -07:00
|
|
|
evas_map_point_coord_set(Evas_Map *m, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
Evas_Map_Point *p;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
if (idx >= m->count) return;
|
|
|
|
p = m->points + idx;
|
2010-09-21 23:52:28 -07:00
|
|
|
p->x = p->px = x;
|
|
|
|
p->y = p->py = y;
|
2009-10-22 13:11:33 -07:00
|
|
|
p->z = z;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-10-28 01:59:01 -07:00
|
|
|
evas_map_point_coord_get(const Evas_Map *m, int idx, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
goto error;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
const Evas_Map_Point *p;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
if (idx >= m->count) goto error;
|
|
|
|
p = m->points + idx;
|
|
|
|
if (x) *x = p->x;
|
|
|
|
if (y) *y = p->y;
|
|
|
|
if (z) *z = p->z;
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (x) *x = 0;
|
|
|
|
if (y) *y = 0;
|
|
|
|
if (z) *z = 0;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-10-28 01:59:01 -07:00
|
|
|
evas_map_point_image_uv_set(Evas_Map *m, int idx, double u, double v)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
Evas_Map_Point *p;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
if (idx >= m->count) return;
|
|
|
|
p = m->points + idx;
|
|
|
|
p->u = u;
|
|
|
|
p->v = v;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-10-28 01:59:01 -07:00
|
|
|
evas_map_point_image_uv_get(const Evas_Map *m, int idx, double *u, double *v)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
goto error;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
const Evas_Map_Point *p;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
if (idx >= m->count) goto error;
|
|
|
|
p = m->points + idx;
|
|
|
|
if (u) *u = p->u;
|
|
|
|
if (v) *v = p->v;
|
|
|
|
return;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (u) *u = 0.0;
|
|
|
|
if (v) *v = 0.0;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
|
2009-10-31 18:32:23 -07:00
|
|
|
EAPI void
|
|
|
|
evas_map_point_color_set(Evas_Map *m, int idx, int r, int g, int b, int a)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-31 18:32:23 -07:00
|
|
|
Evas_Map_Point *p;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-10-31 18:32:23 -07:00
|
|
|
if (idx >= m->count) return;
|
|
|
|
p = m->points + idx;
|
|
|
|
p->r = r;
|
|
|
|
p->g = g;
|
|
|
|
p->b = b;
|
|
|
|
p->a = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_map_point_color_get(const Evas_Map *m, int idx, int *r, int *g, int *b, int *a)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
const Evas_Map_Point *p;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-10-31 18:32:23 -07:00
|
|
|
if (idx >= m->count) return;
|
|
|
|
p = m->points + idx;
|
|
|
|
if (r) *r = p->r;
|
|
|
|
if (g) *g = p->g;
|
|
|
|
if (b) *b = p->b;
|
|
|
|
if (a) *a = p->a;
|
|
|
|
}
|
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
EAPI void
|
|
|
|
evas_map_util_points_populate_from_object_full(Evas_Map *m, const Evas_Object *obj, Evas_Coord z)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
if (m->count != 4)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
ERR("map has count=%d where 4 was expected.", m->count);
|
|
|
|
return;
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
_evas_map_util_points_populate(m, obj->cur.geometry.x, obj->cur.geometry.y,
|
2011-05-23 03:37:17 -07:00
|
|
|
obj->cur.geometry.w, obj->cur.geometry.h, z);
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_map_util_points_populate_from_object(Evas_Map *m, const Evas_Object *obj)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
if (m->count != 4)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
ERR("map has count=%d where 4 was expected.", m->count);
|
|
|
|
return;
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
_evas_map_util_points_populate(m, obj->cur.geometry.x, obj->cur.geometry.y,
|
2011-05-23 03:37:17 -07:00
|
|
|
obj->cur.geometry.w, obj->cur.geometry.h, 0);
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_map_util_points_populate_from_geometry(Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Evas_Coord z)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
if (m->count != 4)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
ERR("map has count=%d where 4 was expected.", m->count);
|
|
|
|
return;
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
_evas_map_util_points_populate(m, x, y, w, h, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_map_util_points_color_set(Evas_Map *m, int r, int g, int b, int a)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
Evas_Map_Point *p, *p_end;
|
2011-06-16 05:08:46 -07:00
|
|
|
|
2009-11-11 04:33:52 -08:00
|
|
|
p = m->points;
|
|
|
|
p_end = p + m->count;
|
|
|
|
for (; p < p_end; p++)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
p->r = r;
|
|
|
|
p->g = g;
|
|
|
|
p->b = b;
|
|
|
|
p->a = a;
|
2009-11-11 04:33:52 -08:00
|
|
|
}
|
|
|
|
}
|
2009-10-28 01:59:01 -07:00
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
EAPI void
|
2009-10-22 13:11:33 -07:00
|
|
|
evas_map_util_rotate(Evas_Map *m, double degrees, Evas_Coord cx, Evas_Coord cy)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
double r = (degrees * M_PI) / 180.0;
|
2009-10-22 13:11:33 -07:00
|
|
|
Evas_Map_Point *p, *p_end;
|
|
|
|
|
|
|
|
p = m->points;
|
2009-11-02 00:52:23 -08:00
|
|
|
p_end = p + m->count;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
|
|
|
for (; p < p_end; p++)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-01-15 23:49:49 -08:00
|
|
|
double x, y, xx, yy;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
2011-01-15 22:58:38 -08:00
|
|
|
x = p->x - cx;
|
|
|
|
y = p->y - cy;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
2011-06-16 01:46:16 -07:00
|
|
|
xx = x * cos(r);
|
|
|
|
yy = x * sin(r);
|
2011-06-16 03:03:37 -07:00
|
|
|
x = xx - (y * sin(r));
|
|
|
|
y = yy + (y * cos(r));
|
2009-10-22 13:11:33 -07:00
|
|
|
|
2011-01-15 23:49:49 -08:00
|
|
|
p->px = p->x = x + cx;
|
|
|
|
p->py = p->y = y + cy;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-10-22 13:11:33 -07:00
|
|
|
evas_map_util_zoom(Evas_Map *m, double zoomx, double zoomy, Evas_Coord cx, Evas_Coord cy)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-10-22 13:11:33 -07:00
|
|
|
Evas_Map_Point *p, *p_end;
|
|
|
|
|
|
|
|
p = m->points;
|
2009-11-02 00:52:23 -08:00
|
|
|
p_end = p + m->count;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
|
|
|
for (; p < p_end; p++)
|
2009-10-22 08:47:30 -07:00
|
|
|
{
|
2011-01-15 23:49:49 -08:00
|
|
|
double x, y;
|
2009-10-22 13:11:33 -07:00
|
|
|
|
|
|
|
x = p->x - cx;
|
|
|
|
y = p->y - cy;
|
|
|
|
|
2009-10-22 08:47:30 -07:00
|
|
|
x = (((double)x) * zoomx);
|
|
|
|
y = (((double)y) * zoomy);
|
2009-10-22 13:11:33 -07:00
|
|
|
|
2011-01-15 23:49:49 -08:00
|
|
|
p->px = p->x = x + cx;
|
|
|
|
p->py = p->y = y + cy;
|
2009-10-22 08:47:30 -07:00
|
|
|
}
|
|
|
|
}
|
2009-11-02 00:52:23 -08:00
|
|
|
|
|
|
|
EAPI void
|
2011-05-23 03:37:17 -07:00
|
|
|
evas_map_util_3d_rotate(Evas_Map *m, double dx, double dy, double dz,
|
2009-11-02 04:20:50 -08:00
|
|
|
Evas_Coord cx, Evas_Coord cy, Evas_Coord cz)
|
2009-11-02 00:52:23 -08:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
double rz = (dz * M_PI) / 180.0;
|
|
|
|
double rx = (dx * M_PI) / 180.0;
|
|
|
|
double ry = (dy * M_PI) / 180.0;
|
|
|
|
Evas_Map_Point *p, *p_end;
|
|
|
|
|
|
|
|
p = m->points;
|
|
|
|
p_end = p + m->count;
|
|
|
|
|
|
|
|
for (; p < p_end; p++)
|
|
|
|
{
|
|
|
|
double x, y, z, xx, yy, zz;
|
|
|
|
|
|
|
|
x = p->x - cx;
|
|
|
|
y = p->y - cy;
|
|
|
|
z = p->z - cz;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
if (rz != 0.0)
|
|
|
|
{
|
|
|
|
xx = x * cos(rz);
|
|
|
|
yy = x * sin(rz);
|
2011-06-16 03:03:37 -07:00
|
|
|
x = xx - (y * sin(rz));
|
|
|
|
y = yy + (y * cos(rz));
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ry != 0.0)
|
|
|
|
{
|
|
|
|
xx = x * cos(ry);
|
|
|
|
zz = x * sin(ry);
|
2011-06-16 03:03:37 -07:00
|
|
|
x = xx - (z * sin(ry));
|
|
|
|
z = zz + (z * cos(ry));
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
if (rx != 0.0)
|
|
|
|
{
|
|
|
|
zz = z * cos(rx);
|
|
|
|
yy = z * sin(rx);
|
2011-06-16 03:03:37 -07:00
|
|
|
z = zz - (y * sin(rx));
|
|
|
|
y = yy + (y * cos(rx));
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-01-15 23:49:49 -08:00
|
|
|
p->px = p->x = x + cx;
|
|
|
|
p->py = p->y = y + cy;
|
2009-11-02 04:20:50 -08:00
|
|
|
p->z = z + cz;
|
|
|
|
}
|
|
|
|
}
|
2009-11-02 00:52:23 -08:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
EAPI void
|
2011-05-23 03:37:17 -07:00
|
|
|
evas_map_util_3d_lighting(Evas_Map *m,
|
2009-11-02 04:20:50 -08:00
|
|
|
Evas_Coord lx, Evas_Coord ly, Evas_Coord lz,
|
2010-03-17 21:57:40 -07:00
|
|
|
int lr, int lg, int lb, int ar, int ag, int ab)
|
2009-11-02 04:20:50 -08:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-06-16 05:08:46 -07:00
|
|
|
int i;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
|
|
|
double x, y, z;
|
|
|
|
double nx, ny, nz, x1, y1, z1, x2, y2, z2, ln, br;
|
|
|
|
int h, j, mr, mg, mb;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
x = m->points[i].x;
|
|
|
|
y = m->points[i].y;
|
|
|
|
z = m->points[i].z;
|
|
|
|
// calc normal
|
2011-02-06 15:52:17 -08:00
|
|
|
h = (i - 1 + 4) % 4 + (i & ~0x3); // prev point
|
|
|
|
j = (i + 1) % 4 + (i & ~0x3); // next point
|
2009-11-02 04:20:50 -08:00
|
|
|
|
|
|
|
x1 = m->points[h].x - x;
|
|
|
|
y1 = m->points[h].y - y;
|
|
|
|
z1 = m->points[h].z - z;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
x2 = m->points[j].x - x;
|
|
|
|
y2 = m->points[j].y - y;
|
|
|
|
z2 = m->points[j].z - z;
|
|
|
|
nx = (y1 * z2) - (z1 * y2);
|
|
|
|
ny = (z1 * x2) - (x1 * z2);
|
|
|
|
nz = (x1 * y2) - (y1 * x2);
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
ln = (nx * nx) + (ny * ny) + (nz * nz);
|
|
|
|
ln = sqrt(ln);
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
if (ln != 0.0)
|
2009-11-02 00:52:23 -08:00
|
|
|
{
|
2009-11-02 04:20:50 -08:00
|
|
|
nx /= ln;
|
|
|
|
ny /= ln;
|
|
|
|
nz /= ln;
|
|
|
|
}
|
2011-02-06 15:52:17 -08:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
// calc point -> light vector
|
|
|
|
x = lx - x;
|
|
|
|
y = ly - y;
|
|
|
|
z = lz - z;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
ln = (x * x) + (y * y) + (z * z);
|
|
|
|
ln = sqrt(ln);
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
if (ln != 0.0)
|
|
|
|
{
|
|
|
|
x /= ln;
|
|
|
|
y /= ln;
|
|
|
|
z /= ln;
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
// brightness - tan (0.0 -> 1.0 brightness really)
|
|
|
|
br = (nx * x) + (ny * y) + (nz * z);
|
|
|
|
if (br < 0.0) br = 0.0;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 04:20:50 -08:00
|
|
|
mr = ar + ((lr - ar) * br);
|
|
|
|
mg = ag + ((lg - ag) * br);
|
|
|
|
mb = ab + ((lb - ab) * br);
|
2011-05-23 03:37:17 -07:00
|
|
|
if (m->points[i].a != 255)
|
2011-04-12 02:23:52 -07:00
|
|
|
{
|
|
|
|
mr = (mr * m->points[i].a) / 255;
|
|
|
|
mg = (mg * m->points[i].a) / 255;
|
|
|
|
mb = (mb * m->points[i].a) / 255;
|
|
|
|
}
|
2009-11-02 04:20:50 -08:00
|
|
|
m->points[i].r = (m->points[i].r * mr) / 255;
|
|
|
|
m->points[i].g = (m->points[i].g * mg) / 255;
|
|
|
|
m->points[i].b = (m->points[i].b * mb) / 255;
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-11-02 04:20:50 -08:00
|
|
|
evas_map_util_3d_perspective(Evas_Map *m,
|
|
|
|
Evas_Coord px, Evas_Coord py,
|
|
|
|
Evas_Coord z0, Evas_Coord foc)
|
2009-11-02 00:52:23 -08:00
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
Evas_Map_Point *p, *p_end;
|
|
|
|
|
|
|
|
p = m->points;
|
|
|
|
p_end = p + m->count;
|
|
|
|
|
2010-09-21 23:52:28 -07:00
|
|
|
m->persp.px = px;
|
|
|
|
m->persp.py = py;
|
|
|
|
m->persp.z0 = z0;
|
|
|
|
m->persp.foc = foc;
|
2011-06-17 00:12:20 -07:00
|
|
|
|
|
|
|
if (foc <= 0) return;
|
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
for (; p < p_end; p++)
|
|
|
|
{
|
2011-01-15 23:49:49 -08:00
|
|
|
double x, y, zz;
|
2009-11-02 00:52:23 -08:00
|
|
|
|
2011-06-17 00:12:20 -07:00
|
|
|
x = p->x - px;
|
|
|
|
y = p->y - py;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-06-17 00:12:20 -07:00
|
|
|
zz = ((p->z - z0) + foc);
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-06-17 00:12:20 -07:00
|
|
|
if (zz > 0)
|
|
|
|
{
|
|
|
|
x = (x * foc) / zz;
|
|
|
|
y = (y * foc) / zz;
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
2011-06-17 00:12:20 -07:00
|
|
|
|
|
|
|
p->x = px + x;
|
|
|
|
p->y = py + y;
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
evas_map_util_clockwise_get(Evas_Map *m)
|
|
|
|
{
|
2011-06-16 05:08:46 -07:00
|
|
|
MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
|
|
|
|
return EINA_FALSE;
|
|
|
|
MAGIC_CHECK_END();
|
2011-06-17 00:12:20 -07:00
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
int i, j, k, count;
|
|
|
|
long long c;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2011-06-16 05:18:19 -07:00
|
|
|
if (m->count < 3) return EINA_FALSE;
|
2011-05-23 03:37:17 -07:00
|
|
|
|
2009-11-02 00:52:23 -08:00
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < m->count; i++)
|
|
|
|
{
|
2011-05-23 03:37:17 -07:00
|
|
|
j = (i + 1) % m->count;
|
2009-11-02 00:52:23 -08:00
|
|
|
k = (i + 2) % m->count;
|
2011-05-23 03:37:17 -07:00
|
|
|
c =
|
2009-11-02 00:52:23 -08:00
|
|
|
((m->points[j].x - m->points[i].x) *
|
|
|
|
(m->points[k].y - m->points[j].y))
|
|
|
|
-
|
|
|
|
((m->points[j].y - m->points[i].y) *
|
|
|
|
(m->points[k].x - m->points[j].x));
|
|
|
|
if (c < 0) count--;
|
|
|
|
else if (c > 0) count++;
|
|
|
|
}
|
2011-06-16 05:18:19 -07:00
|
|
|
if (count > 0) return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
2009-11-02 00:52:23 -08:00
|
|
|
}
|