summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_object_polygon.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-14 14:59:33 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-14 15:12:52 -0700
commit0ff7429ea741ad651acf9cb6cc79b7529ab19b9d (patch)
tree51b767208917961cc66e9c466f432877f4d8119e /src/lib/evas/canvas/evas_object_polygon.c
parente6a27e13b54a024ca849b9fd798398d51f2e27f8 (diff)
evas: move Evas_Polygon to become Efl_Canvas_Polygon.
TODO: add support for 2 points (aka line).
Diffstat (limited to '')
-rw-r--r--src/lib/evas/canvas/evas_object_polygon.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/lib/evas/canvas/evas_object_polygon.c b/src/lib/evas/canvas/evas_object_polygon.c
index a154e37cd2..d5cfe7ad6e 100644
--- a/src/lib/evas/canvas/evas_object_polygon.c
+++ b/src/lib/evas/canvas/evas_object_polygon.c
@@ -1,16 +1,16 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_private.h" 2#include "evas_private.h"
3 3
4#define MY_CLASS EVAS_POLYGON_CLASS 4#define MY_CLASS EFL_CANVAS_POLYGON_CLASS
5 5
6/* private magic number for polygon objects */ 6/* private magic number for polygon objects */
7static const char o_type[] = "polygon"; 7static const char o_type[] = "polygon";
8 8
9/* private struct for line object internal data */ 9/* private struct for line object internal data */
10typedef struct _Evas_Polygon_Data Evas_Polygon_Data; 10typedef struct _Efl_Canvas_Polygon_Data Efl_Canvas_Polygon_Data;
11typedef struct _Evas_Polygon_Point Evas_Polygon_Point; 11typedef struct _Efl_Canvas_Polygon_Point Efl_Canvas_Polygon_Point;
12 12
13struct _Evas_Polygon_Data 13struct _Efl_Canvas_Polygon_Data
14{ 14{
15 Eina_List *points; 15 Eina_List *points;
16 void *engine_data; 16 void *engine_data;
@@ -21,7 +21,7 @@ struct _Evas_Polygon_Data
21 Eina_Bool changed : 1; 21 Eina_Bool changed : 1;
22}; 22};
23 23
24struct _Evas_Polygon_Point 24struct _Efl_Canvas_Polygon_Point
25{ 25{
26 Evas_Coord x, y; 26 Evas_Coord x, y;
27}; 27};
@@ -95,15 +95,11 @@ static const Evas_Object_Func object_func =
95EAPI Evas_Object * 95EAPI Evas_Object *
96evas_object_polygon_add(Evas *e) 96evas_object_polygon_add(Evas *e)
97{ 97{
98 MAGIC_CHECK(e, Evas, MAGIC_EVAS); 98 return eo_add(MY_CLASS, e);
99 return NULL;
100 MAGIC_CHECK_END();
101 Evas_Object *eo_obj = eo_add(EVAS_POLYGON_CLASS, e);
102 return eo_obj;
103} 99}
104 100
105EOLIAN static Eo * 101EOLIAN static Eo *
106_evas_polygon_eo_base_constructor(Eo *eo_obj, Evas_Polygon_Data *class_data EINA_UNUSED) 102_efl_canvas_polygon_eo_base_constructor(Eo *eo_obj, Efl_Canvas_Polygon_Data *class_data EINA_UNUSED)
107{ 103{
108 eo_obj = eo_constructor(eo_super(eo_obj, MY_CLASS)); 104 eo_obj = eo_constructor(eo_super(eo_obj, MY_CLASS));
109 105
@@ -113,11 +109,11 @@ _evas_polygon_eo_base_constructor(Eo *eo_obj, Evas_Polygon_Data *class_data EINA
113} 109}
114 110
115EOLIAN static void 111EOLIAN static void
116_evas_polygon_point_add(Eo *eo_obj, Evas_Polygon_Data *_pd, Evas_Coord x, Evas_Coord y) 112_efl_canvas_polygon_point_add(Eo *eo_obj, Efl_Canvas_Polygon_Data *_pd, Evas_Coord x, Evas_Coord y)
117{ 113{
118 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 114 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
119 Evas_Polygon_Data *o = _pd; 115 Efl_Canvas_Polygon_Data *o = _pd;
120 Evas_Polygon_Point *p; 116 Efl_Canvas_Polygon_Point *p;
121 Evas_Coord min_x, max_x, min_y, max_y; 117 Evas_Coord min_x, max_x, min_y, max_y;
122 int is, was = 0; 118 int is, was = 0;
123 119
@@ -149,7 +145,7 @@ _evas_polygon_point_add(Eo *eo_obj, Evas_Polygon_Data *_pd, Evas_Coord x, Evas_C
149 } 145 }
150 } 146 }
151 147
152 p = malloc(sizeof(Evas_Polygon_Point)); 148 p = malloc(sizeof(Efl_Canvas_Polygon_Point));
153 if (!p) return; 149 if (!p) return;
154 p->x = x + o->offset.x; 150 p->x = x + o->offset.x;
155 p->y = y + o->offset.y; 151 p->y = y + o->offset.y;
@@ -220,10 +216,10 @@ _evas_polygon_point_add(Eo *eo_obj, Evas_Polygon_Data *_pd, Evas_Coord x, Evas_C
220} 216}
221 217
222EOLIAN static void 218EOLIAN static void
223_evas_polygon_points_clear(Eo *eo_obj, Evas_Polygon_Data *_pd) 219_efl_canvas_polygon_points_clear(Eo *eo_obj, Efl_Canvas_Polygon_Data *_pd)
224{ 220{
225 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 221 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
226 Evas_Polygon_Data *o = _pd; 222 Efl_Canvas_Polygon_Data *o = _pd;
227 void *list_data; 223 void *list_data;
228 int is, was; 224 int is, was;
229 225
@@ -275,7 +271,7 @@ evas_object_polygon_init(Evas_Object *eo_obj)
275} 271}
276 272
277EOLIAN static void 273EOLIAN static void
278_evas_polygon_eo_base_destructor(Eo *eo_obj, Evas_Polygon_Data *_pd EINA_UNUSED) 274_efl_canvas_polygon_eo_base_destructor(Eo *eo_obj, Efl_Canvas_Polygon_Data *_pd EINA_UNUSED)
279{ 275{
280 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 276 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
281 277
@@ -288,7 +284,7 @@ evas_object_polygon_free(Evas_Object *eo_obj EINA_UNUSED,
288 Evas_Object_Protected_Data *obj, 284 Evas_Object_Protected_Data *obj,
289 void *type_private_data) 285 void *type_private_data)
290{ 286{
291 Evas_Polygon_Data *o = type_private_data; 287 Efl_Canvas_Polygon_Data *o = type_private_data;
292 void *list_data; 288 void *list_data;
293 /* free obj */ 289 /* free obj */
294 EINA_LIST_FREE(o->points, list_data) 290 EINA_LIST_FREE(o->points, list_data)
@@ -306,9 +302,9 @@ evas_object_polygon_render(Evas_Object *eo_obj EINA_UNUSED,
306 void *type_private_data, 302 void *type_private_data,
307 void *output, void *context, void *surface, int x, int y, Eina_Bool do_async) 303 void *output, void *context, void *surface, int x, int y, Eina_Bool do_async)
308{ 304{
309 Evas_Polygon_Data *o = type_private_data; 305 Efl_Canvas_Polygon_Data *o = type_private_data;
310 Eina_List *l; 306 Eina_List *l;
311 Evas_Polygon_Point *p; 307 Efl_Canvas_Polygon_Point *p;
312 308
313 /* render object to surface with context, and offxet by x,y */ 309 /* render object to surface with context, and offxet by x,y */
314 obj->layer->evas->engine.func->context_color_set(output, 310 obj->layer->evas->engine.func->context_color_set(output,
@@ -351,7 +347,7 @@ evas_object_polygon_render_pre(Evas_Object *eo_obj,
351 Evas_Object_Protected_Data *obj, 347 Evas_Object_Protected_Data *obj,
352 void *type_private_data) 348 void *type_private_data)
353{ 349{
354 Evas_Polygon_Data *o = type_private_data; 350 Efl_Canvas_Polygon_Data *o = type_private_data;
355 int is_v, was_v; 351 int is_v, was_v;
356 352
357 /* dont pre-render the obj twice! */ 353 /* dont pre-render the obj twice! */
@@ -456,21 +452,21 @@ evas_object_polygon_render_post(Evas_Object *eo_obj,
456 452
457static unsigned int evas_object_polygon_id_get(Evas_Object *eo_obj) 453static unsigned int evas_object_polygon_id_get(Evas_Object *eo_obj)
458{ 454{
459 Evas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); 455 Efl_Canvas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
460 if (!o) return 0; 456 if (!o) return 0;
461 return MAGIC_OBJ_POLYGON; 457 return MAGIC_OBJ_POLYGON;
462} 458}
463 459
464static unsigned int evas_object_polygon_visual_id_get(Evas_Object *eo_obj) 460static unsigned int evas_object_polygon_visual_id_get(Evas_Object *eo_obj)
465{ 461{
466 Evas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); 462 Efl_Canvas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
467 if (!o) return 0; 463 if (!o) return 0;
468 return MAGIC_OBJ_SHAPE; 464 return MAGIC_OBJ_SHAPE;
469} 465}
470 466
471static void *evas_object_polygon_engine_data_get(Evas_Object *eo_obj) 467static void *evas_object_polygon_engine_data_get(Evas_Object *eo_obj)
472{ 468{
473 Evas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); 469 Efl_Canvas_Polygon_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
474 return o->engine_data; 470 return o->engine_data;
475} 471}
476 472
@@ -503,10 +499,10 @@ evas_object_polygon_is_inside(Evas_Object *eo_obj EINA_UNUSED,
503 void *type_private_data, 499 void *type_private_data,
504 Evas_Coord x, Evas_Coord y) 500 Evas_Coord x, Evas_Coord y)
505{ 501{
506 Evas_Polygon_Data *o = type_private_data; 502 Efl_Canvas_Polygon_Data *o = type_private_data;
507 int num_edges = 0; /* Number of edges we crossed */ 503 int num_edges = 0; /* Number of edges we crossed */
508 Eina_List *itr; 504 Eina_List *itr;
509 Evas_Polygon_Point *p; 505 Efl_Canvas_Polygon_Point *p;
510 506
511 if (!o->points) return 0; 507 if (!o->points) return 0;
512 508
@@ -524,7 +520,7 @@ evas_object_polygon_is_inside(Evas_Object *eo_obj EINA_UNUSED,
524 { 520 {
525 Evas_Coord line_y; 521 Evas_Coord line_y;
526 Eina_List *next = eina_list_next(itr); 522 Eina_List *next = eina_list_next(itr);
527 Evas_Polygon_Point *p_next; 523 Efl_Canvas_Polygon_Point *p_next;
528 /* Get the next, or if there's no next, take the first */ 524 /* Get the next, or if there's no next, take the first */
529 if (next) 525 if (next)
530 { 526 {
@@ -565,4 +561,16 @@ evas_object_polygon_was_inside(Evas_Object *eo_obj EINA_UNUSED,
565 return 1; 561 return 1;
566} 562}
567 563
568#include "canvas/evas_polygon.eo.c" 564EAPI void
565evas_object_polygon_point_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
566{
567 efl_canvas_polygon_point_add(obj, x, y);
568}
569
570EAPI void
571evas_object_polygon_points_clear(Evas_Object *obj)
572{
573 efl_canvas_polygon_points_clear(obj);
574}
575
576#include "canvas/efl_canvas_polygon.eo.c"