summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2011-06-16 12:08:46 +0000
committerChunEon Park <hermet@hermet.pe.kr>2011-06-16 12:08:46 +0000
commit81672eac1c4b8f98e3c187e42b59adef3c4e3011 (patch)
tree6e694932cf4ab745abcea1d175e2b36d2aeaa85c /legacy
parenteac7a5832dea9488a46077f02f023040130ef16e (diff)
evas/evas_map - added magic check
SVN revision: 60390
Diffstat (limited to '')
-rw-r--r--legacy/evas/src/lib/canvas/evas_map.c140
-rw-r--r--legacy/evas/src/lib/include/evas_private.h2
-rw-r--r--legacy/evas/src/lib/main.c2
3 files changed, 104 insertions, 40 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_map.c b/legacy/evas/src/lib/canvas/evas_map.c
index b86390aff4..ea04fdb231 100644
--- a/legacy/evas/src/lib/canvas/evas_map.c
+++ b/legacy/evas/src/lib/canvas/evas_map.c
@@ -119,6 +119,7 @@ _evas_map_new(int count)
119 m->persp.foc = 0; 119 m->persp.foc = 0;
120 m->alpha = 1; 120 m->alpha = 1;
121 m->smooth = 1; 121 m->smooth = 1;
122 m->magic = MAGIC_MAP;
122 for (i = 0; i < count; i++) 123 for (i = 0; i < count; i++)
123 { 124 {
124 m->points[i].r = 255; 125 m->points[i].r = 255;
@@ -212,6 +213,10 @@ Eina_Bool
212evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, 213evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y,
213 Evas_Coord *mx, Evas_Coord *my, int grab) 214 Evas_Coord *mx, Evas_Coord *my, int grab)
214{ 215{
216 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
217 return EINA_FALSE;
218 MAGIC_CHECK_END();
219
215 int i, j, edges, edge[m->count][2], douv; 220 int i, j, edges, edge[m->count][2], douv;
216 Evas_Coord xe[2]; 221 Evas_Coord xe[2];
217 double u[2] = { 0.0, 0.0 }; 222 double u[2] = { 0.0, 0.0 };
@@ -489,57 +494,82 @@ evas_map_new(int count)
489EAPI void 494EAPI void
490evas_map_smooth_set(Evas_Map *m, Eina_Bool enabled) 495evas_map_smooth_set(Evas_Map *m, Eina_Bool enabled)
491{ 496{
492 if (!m) return; 497 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
498 return;
499 MAGIC_CHECK_END();
500
493 m->smooth = enabled; 501 m->smooth = enabled;
494} 502}
495 503
496EAPI Eina_Bool 504EAPI Eina_Bool
497evas_map_smooth_get(const Evas_Map *m) 505evas_map_smooth_get(const Evas_Map *m)
498{ 506{
499 if (!m) return 0; 507 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
508 return EINA_FALSE;
509 MAGIC_CHECK_END();
510
500 return m->smooth; 511 return m->smooth;
501} 512}
502 513
503EAPI void 514EAPI void
504evas_map_alpha_set(Evas_Map *m, Eina_Bool enabled) 515evas_map_alpha_set(Evas_Map *m, Eina_Bool enabled)
505{ 516{
506 if (!m) return; 517 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
518 return;
519 MAGIC_CHECK_END();
520
507 m->alpha = enabled; 521 m->alpha = enabled;
508} 522}
509 523
510EAPI Eina_Bool 524EAPI Eina_Bool
511evas_map_alpha_get(const Evas_Map *m) 525evas_map_alpha_get(const Evas_Map *m)
512{ 526{
513 if (!m) return 0; 527 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
528 return EINA_FALSE;
529 MAGIC_CHECK_END();
530
514 return m->alpha; 531 return m->alpha;
515} 532}
516 533
517EAPI Evas_Map * 534EAPI Evas_Map *
518evas_map_dup(const Evas_Map *m) 535evas_map_dup(const Evas_Map *m)
519{ 536{
520 if (!m) return NULL; 537 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
538 return;
539 MAGIC_CHECK_END();
540
521 return _evas_map_dup(m); 541 return _evas_map_dup(m);
522} 542}
523 543
524EAPI void 544EAPI void
525evas_map_free(Evas_Map *m) 545evas_map_free(Evas_Map *m)
526{ 546{
527 if (!m) return; 547 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
548 return;
549 MAGIC_CHECK_END();
550
528 _evas_map_free(NULL, m); 551 _evas_map_free(NULL, m);
529} 552}
530 553
531EAPI int 554EAPI int
532evas_map_count_get(const Evas_Map *m) 555evas_map_count_get(const Evas_Map *m)
533{ 556{
534 if (!m) return -1; 557 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
558 return -1;
559 MAGIC_CHECK_END();
560
535 return m->count; 561 return m->count;
536} 562}
537 563
538EAPI void 564EAPI void
539evas_map_point_coord_set(Evas_Map *m, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z) 565evas_map_point_coord_set(Evas_Map *m, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z)
540{ 566{
567 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
568 return;
569 MAGIC_CHECK_END();
570
541 Evas_Map_Point *p; 571 Evas_Map_Point *p;
542 if (!m) return; 572
543 if (idx >= m->count) return; 573 if (idx >= m->count) return;
544 p = m->points + idx; 574 p = m->points + idx;
545 p->x = p->px = x; 575 p->x = p->px = x;
@@ -550,9 +580,12 @@ evas_map_point_coord_set(Evas_Map *m, int idx, Evas_Coord x, Evas_Coord y, Evas_
550EAPI void 580EAPI void
551evas_map_point_coord_get(const Evas_Map *m, int idx, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z) 581evas_map_point_coord_get(const Evas_Map *m, int idx, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z)
552{ 582{
583 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
584 goto error;
585 MAGIC_CHECK_END();
586
553 const Evas_Map_Point *p; 587 const Evas_Map_Point *p;
554 588
555 if (!m) goto error;
556 if (idx >= m->count) goto error; 589 if (idx >= m->count) goto error;
557 p = m->points + idx; 590 p = m->points + idx;
558 if (x) *x = p->x; 591 if (x) *x = p->x;
@@ -569,8 +602,12 @@ evas_map_point_coord_get(const Evas_Map *m, int idx, Evas_Coord *x, Evas_Coord *
569EAPI void 602EAPI void
570evas_map_point_image_uv_set(Evas_Map *m, int idx, double u, double v) 603evas_map_point_image_uv_set(Evas_Map *m, int idx, double u, double v)
571{ 604{
605 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
606 return;
607 MAGIC_CHECK_END();
608
572 Evas_Map_Point *p; 609 Evas_Map_Point *p;
573 if (!m) return; 610
574 if (idx >= m->count) return; 611 if (idx >= m->count) return;
575 p = m->points + idx; 612 p = m->points + idx;
576 p->u = u; 613 p->u = u;
@@ -580,8 +617,12 @@ evas_map_point_image_uv_set(Evas_Map *m, int idx, double u, double v)
580EAPI void 617EAPI void
581evas_map_point_image_uv_get(const Evas_Map *m, int idx, double *u, double *v) 618evas_map_point_image_uv_get(const Evas_Map *m, int idx, double *u, double *v)
582{ 619{
620 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
621 goto error;
622 MAGIC_CHECK_END();
623
583 const Evas_Map_Point *p; 624 const Evas_Map_Point *p;
584 if (!m) goto error; 625
585 if (idx >= m->count) goto error; 626 if (idx >= m->count) goto error;
586 p = m->points + idx; 627 p = m->points + idx;
587 if (u) *u = p->u; 628 if (u) *u = p->u;
@@ -596,8 +637,12 @@ evas_map_point_image_uv_get(const Evas_Map *m, int idx, double *u, double *v)
596EAPI void 637EAPI void
597evas_map_point_color_set(Evas_Map *m, int idx, int r, int g, int b, int a) 638evas_map_point_color_set(Evas_Map *m, int idx, int r, int g, int b, int a)
598{ 639{
640 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
641 return;
642 MAGIC_CHECK_END();
643
599 Evas_Map_Point *p; 644 Evas_Map_Point *p;
600 if (!m) return; 645
601 if (idx >= m->count) return; 646 if (idx >= m->count) return;
602 p = m->points + idx; 647 p = m->points + idx;
603 p->r = r; 648 p->r = r;
@@ -609,8 +654,12 @@ evas_map_point_color_set(Evas_Map *m, int idx, int r, int g, int b, int a)
609EAPI void 654EAPI void
610evas_map_point_color_get(const Evas_Map *m, int idx, int *r, int *g, int *b, int *a) 655evas_map_point_color_get(const Evas_Map *m, int idx, int *r, int *g, int *b, int *a)
611{ 656{
657 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
658 return;
659 MAGIC_CHECK_END();
660
612 const Evas_Map_Point *p; 661 const Evas_Map_Point *p;
613 if (!m) return; 662
614 if (idx >= m->count) return; 663 if (idx >= m->count) return;
615 p = m->points + idx; 664 p = m->points + idx;
616 if (r) *r = p->r; 665 if (r) *r = p->r;
@@ -625,11 +674,7 @@ evas_map_util_points_populate_from_object_full(Evas_Map *m, const Evas_Object *o
625 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); 674 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
626 return; 675 return;
627 MAGIC_CHECK_END(); 676 MAGIC_CHECK_END();
628 if (!m) 677
629 {
630 ERR("map == NULL");
631 return;
632 }
633 if (m->count != 4) 678 if (m->count != 4)
634 { 679 {
635 ERR("map has count=%d where 4 was expected.", m->count); 680 ERR("map has count=%d where 4 was expected.", m->count);
@@ -642,14 +687,14 @@ evas_map_util_points_populate_from_object_full(Evas_Map *m, const Evas_Object *o
642EAPI void 687EAPI void
643evas_map_util_points_populate_from_object(Evas_Map *m, const Evas_Object *obj) 688evas_map_util_points_populate_from_object(Evas_Map *m, const Evas_Object *obj)
644{ 689{
690 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
691 return;
692 MAGIC_CHECK_END();
693
645 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); 694 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
646 return; 695 return;
647 MAGIC_CHECK_END(); 696 MAGIC_CHECK_END();
648 if (!m) 697
649 {
650 ERR("map == NULL");
651 return;
652 }
653 if (m->count != 4) 698 if (m->count != 4)
654 { 699 {
655 ERR("map has count=%d where 4 was expected.", m->count); 700 ERR("map has count=%d where 4 was expected.", m->count);
@@ -662,11 +707,10 @@ evas_map_util_points_populate_from_object(Evas_Map *m, const Evas_Object *obj)
662EAPI void 707EAPI void
663evas_map_util_points_populate_from_geometry(Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Evas_Coord z) 708evas_map_util_points_populate_from_geometry(Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Evas_Coord z)
664{ 709{
665 if (!m) 710 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
666 { 711 return;
667 ERR("map == NULL"); 712 MAGIC_CHECK_END();
668 return; 713
669 }
670 if (m->count != 4) 714 if (m->count != 4)
671 { 715 {
672 ERR("map has count=%d where 4 was expected.", m->count); 716 ERR("map has count=%d where 4 was expected.", m->count);
@@ -678,12 +722,12 @@ evas_map_util_points_populate_from_geometry(Evas_Map *m, Evas_Coord x, Evas_Coor
678EAPI void 722EAPI void
679evas_map_util_points_color_set(Evas_Map *m, int r, int g, int b, int a) 723evas_map_util_points_color_set(Evas_Map *m, int r, int g, int b, int a)
680{ 724{
725 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
726 return;
727 MAGIC_CHECK_END();
728
681 Evas_Map_Point *p, *p_end; 729 Evas_Map_Point *p, *p_end;
682 if (!m) 730
683 {
684 ERR("map == NULL");
685 return;
686 }
687 p = m->points; 731 p = m->points;
688 p_end = p + m->count; 732 p_end = p + m->count;
689 for (; p < p_end; p++) 733 for (; p < p_end; p++)
@@ -698,10 +742,13 @@ evas_map_util_points_color_set(Evas_Map *m, int r, int g, int b, int a)
698EAPI void 742EAPI void
699evas_map_util_rotate(Evas_Map *m, double degrees, Evas_Coord cx, Evas_Coord cy) 743evas_map_util_rotate(Evas_Map *m, double degrees, Evas_Coord cx, Evas_Coord cy)
700{ 744{
745 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
746 return;
747 MAGIC_CHECK_END();
748
701 double r = (degrees * M_PI) / 180.0; 749 double r = (degrees * M_PI) / 180.0;
702 Evas_Map_Point *p, *p_end; 750 Evas_Map_Point *p, *p_end;
703 751
704 if (!m) return;
705 p = m->points; 752 p = m->points;
706 p_end = p + m->count; 753 p_end = p + m->count;
707 754
@@ -725,9 +772,12 @@ evas_map_util_rotate(Evas_Map *m, double degrees, Evas_Coord cx, Evas_Coord cy)
725EAPI void 772EAPI void
726evas_map_util_zoom(Evas_Map *m, double zoomx, double zoomy, Evas_Coord cx, Evas_Coord cy) 773evas_map_util_zoom(Evas_Map *m, double zoomx, double zoomy, Evas_Coord cx, Evas_Coord cy)
727{ 774{
775 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
776 return;
777 MAGIC_CHECK_END();
778
728 Evas_Map_Point *p, *p_end; 779 Evas_Map_Point *p, *p_end;
729 780
730 if (!m) return;
731 p = m->points; 781 p = m->points;
732 p_end = p + m->count; 782 p_end = p + m->count;
733 783
@@ -750,12 +800,15 @@ EAPI void
750evas_map_util_3d_rotate(Evas_Map *m, double dx, double dy, double dz, 800evas_map_util_3d_rotate(Evas_Map *m, double dx, double dy, double dz,
751 Evas_Coord cx, Evas_Coord cy, Evas_Coord cz) 801 Evas_Coord cx, Evas_Coord cy, Evas_Coord cz)
752{ 802{
803 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
804 return;
805 MAGIC_CHECK_END();
806
753 double rz = (dz * M_PI) / 180.0; 807 double rz = (dz * M_PI) / 180.0;
754 double rx = (dx * M_PI) / 180.0; 808 double rx = (dx * M_PI) / 180.0;
755 double ry = (dy * M_PI) / 180.0; 809 double ry = (dy * M_PI) / 180.0;
756 Evas_Map_Point *p, *p_end; 810 Evas_Map_Point *p, *p_end;
757 811
758 if (!m) return;
759 p = m->points; 812 p = m->points;
760 p_end = p + m->count; 813 p_end = p + m->count;
761 814
@@ -802,9 +855,11 @@ evas_map_util_3d_lighting(Evas_Map *m,
802 Evas_Coord lx, Evas_Coord ly, Evas_Coord lz, 855 Evas_Coord lx, Evas_Coord ly, Evas_Coord lz,
803 int lr, int lg, int lb, int ar, int ag, int ab) 856 int lr, int lg, int lb, int ar, int ag, int ab)
804{ 857{
805 int i; 858 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
859 return;
860 MAGIC_CHECK_END();
806 861
807 if (!m) return; 862 int i;
808 863
809 for (i = 0; i < m->count; i++) 864 for (i = 0; i < m->count; i++)
810 { 865 {
@@ -879,9 +934,12 @@ evas_map_util_3d_perspective(Evas_Map *m,
879 Evas_Coord px, Evas_Coord py, 934 Evas_Coord px, Evas_Coord py,
880 Evas_Coord z0, Evas_Coord foc) 935 Evas_Coord z0, Evas_Coord foc)
881{ 936{
937 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
938 return;
939 MAGIC_CHECK_END();
940
882 Evas_Map_Point *p, *p_end; 941 Evas_Map_Point *p, *p_end;
883 942
884 if (!m) return;
885 p = m->points; 943 p = m->points;
886 p_end = p + m->count; 944 p_end = p + m->count;
887 945
@@ -915,10 +973,12 @@ evas_map_util_3d_perspective(Evas_Map *m,
915EAPI Eina_Bool 973EAPI Eina_Bool
916evas_map_util_clockwise_get(Evas_Map *m) 974evas_map_util_clockwise_get(Evas_Map *m)
917{ 975{
976 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
977 return EINA_FALSE;
978 MAGIC_CHECK_END();
918 int i, j, k, count; 979 int i, j, k, count;
919 long long c; 980 long long c;
920 981
921 if (!m) return 0;
922 if (m->count < 3) return 0; 982 if (m->count < 3) return 0;
923 983
924 count = 0; 984 count = 0;
diff --git a/legacy/evas/src/lib/include/evas_private.h b/legacy/evas/src/lib/include/evas_private.h
index 00c76e3fe4..3a1fef8cb5 100644
--- a/legacy/evas/src/lib/include/evas_private.h
+++ b/legacy/evas/src/lib/include/evas_private.h
@@ -68,6 +68,7 @@ OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */
68#define MAGIC_OBJ_CONTAINER 0x72777774 68#define MAGIC_OBJ_CONTAINER 0x72777774
69#define MAGIC_OBJ_CUSTOM 0x72777775 69#define MAGIC_OBJ_CUSTOM 0x72777775
70#define MAGIC_EVAS_GL 0x72777776 70#define MAGIC_EVAS_GL 0x72777776
71#define MAGIC_MAP 0x72777777
71 72
72#ifdef MAGIC_DEBUG 73#ifdef MAGIC_DEBUG
73# define MAGIC_CHECK_FAILED(o, t, m) \ 74# define MAGIC_CHECK_FAILED(o, t, m) \
@@ -376,6 +377,7 @@ struct _Evas_Map_Point
376 377
377struct _Evas_Map 378struct _Evas_Map
378{ 379{
380 DATA32 magic;
379 int count; // num of points 381 int count; // num of points
380 Evas_Coord_Rectangle normal_geometry; // bounding box of map geom actually 382 Evas_Coord_Rectangle normal_geometry; // bounding box of map geom actually
381 void *surface; // surface holding map if needed 383 void *surface; // surface holding map if needed
diff --git a/legacy/evas/src/lib/main.c b/legacy/evas/src/lib/main.c
index 6e1aa51e53..422eb8c950 100644
--- a/legacy/evas/src/lib/main.c
+++ b/legacy/evas/src/lib/main.c
@@ -147,6 +147,8 @@ evas_debug_magic_string_get(DATA32 magic)
147 case MAGIC_OBJ_SMART: 147 case MAGIC_OBJ_SMART:
148 return "Evas_Object (Smart)"; 148 return "Evas_Object (Smart)";
149 break; 149 break;
150 case MAGIC_MAP:
151 return "Evas_Map";
150 default: 152 default:
151 return "<UNKNOWN>"; 153 return "<UNKNOWN>";
152 }; 154 };