Mercurial > MadButterfly
comparison src/event.c @ 448:16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
mb_graph_engine is a layer to separate MadButterfly from Cairo.
It is only a set of macro mapping to cairo implementation, now.
But, it provides a oppotunities to replace cairo with other engines;
likes skia.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 04 Aug 2009 23:35:41 +0800 |
parents | 254854ed479c |
children | a417fd980228 |
comparison
equal
deleted
inserted
replaced
447:38aae921243f | 448:16116d84bc5e |
---|---|
2 * \brief Convenience functions for event relative work. | 2 * \brief Convenience functions for event relative work. |
3 */ | 3 */ |
4 #include <stdio.h> | 4 #include <stdio.h> |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #ifndef UNITTEST | 6 #ifndef UNITTEST |
7 #include <cairo.h> | 7 #include "mb_graph_engine.h" |
8 #include "mb_types.h" | 8 #include "mb_types.h" |
9 #include "mb_redraw_man.h" | 9 #include "mb_redraw_man.h" |
10 #include "mb_shapes.h" | 10 #include "mb_shapes.h" |
11 #endif | 11 #endif |
12 #include "../config.h" | 12 #include "../config.h" |
26 #include "mb_tools.h" | 26 #include "mb_tools.h" |
27 | 27 |
28 typedef float co_aix; | 28 typedef float co_aix; |
29 | 29 |
30 typedef struct shape shape_t; | 30 typedef struct shape shape_t; |
31 typedef struct cairo_surface cairo_surface_t; | 31 typedef struct cairo_surface mbe_surface_t; |
32 typedef struct coord coord_t; | 32 typedef struct coord coord_t; |
33 | 33 |
34 typedef struct cairo cairo_t; | 34 typedef struct cairo mbe_t; |
35 struct cairo { | 35 struct cairo { |
36 STAILQ(shape_t) drawed; | 36 STAILQ(shape_t) drawed; |
37 STAILQ(shape_t) clip_pathes; | 37 STAILQ(shape_t) clip_pathes; |
38 cairo_surface_t *tgt; | 38 mbe_surface_t *tgt; |
39 }; | 39 }; |
40 | 40 |
41 struct cairo_surface { | 41 struct cairo_surface { |
42 cairo_t *cr; | 42 mbe_t *cr; |
43 int w, h; | 43 int w, h; |
44 unsigned char *data; | 44 unsigned char *data; |
45 }; | 45 }; |
46 | 46 |
47 #define cairo_new_path(cr) do { STAILQ_CLEAN((cr)->drawed); } while(0) | 47 #define mbe_new_path(cr) do { STAILQ_CLEAN((cr)->drawed); } while(0) |
48 #define cairo_get_target(cr) (cr)->tgt | 48 #define mbe_get_target(cr) (cr)->tgt |
49 static | 49 static |
50 cairo_t *cairo_create(cairo_surface_t *target) { | 50 mbe_t *mbe_create(mbe_surface_t *target) { |
51 cairo_t *cr; | 51 mbe_t *cr; |
52 | 52 |
53 cr = (cairo_t *)malloc(sizeof(cairo_t)); | 53 cr = (mbe_t *)malloc(sizeof(mbe_t)); |
54 STAILQ_INIT(cr->drawed); | 54 STAILQ_INIT(cr->drawed); |
55 STAILQ_INIT(cr->clip_pathes); | 55 STAILQ_INIT(cr->clip_pathes); |
56 cr->tgt = target; | 56 cr->tgt = target; |
57 target->cr = cr; | 57 target->cr = cr; |
58 | 58 |
59 return cr; | 59 return cr; |
60 } | 60 } |
61 #define cairo_destroy(cr) do { free(cr); } while(0) | 61 #define mbe_destroy(cr) do { free(cr); } while(0) |
62 #define cairo_clip(cr) \ | 62 #define mbe_clip(cr) \ |
63 do { \ | 63 do { \ |
64 memcpy(&(cr)->clip_pathes, \ | 64 memcpy(&(cr)->clip_pathes, \ |
65 &(cr)->drawed, \ | 65 &(cr)->drawed, \ |
66 sizeof((cr)->drawed)); \ | 66 sizeof((cr)->drawed)); \ |
67 STAILQ_CLEAN((cr)->drawed); \ | 67 STAILQ_CLEAN((cr)->drawed); \ |
68 } while(0) | 68 } while(0) |
69 #define cairo_fill(cr) | 69 #define mbe_fill(cr) |
70 | 70 |
71 #define cairo_image_surface_get_width(surface) (surface)->w | 71 #define mbe_image_surface_get_width(surface) (surface)->w |
72 #define cairo_image_surface_get_height(surface) (surface)->h | 72 #define mbe_image_surface_get_height(surface) (surface)->h |
73 static | 73 static |
74 cairo_surface_t *cairo_image_surface_create(int format, int w, int h) { | 74 mbe_surface_t *mbe_image_surface_create(int format, int w, int h) { |
75 cairo_surface_t *surf; | 75 mbe_surface_t *surf; |
76 | 76 |
77 surf = (cairo_surface_t *)malloc(sizeof(cairo_surface_t)); | 77 surf = (mbe_surface_t *)malloc(sizeof(mbe_surface_t)); |
78 surf->w = w; | 78 surf->w = w; |
79 surf->h = h; | 79 surf->h = h; |
80 surf->data = (unsigned char *)malloc(h); | 80 surf->data = (unsigned char *)malloc(h); |
81 memset(surf->data, 0, h); | 81 memset(surf->data, 0, h); |
82 | 82 |
83 return surf; | 83 return surf; |
84 } | 84 } |
85 #define cairo_surface_destroy(surface) \ | 85 #define mbe_surface_destroy(surface) \ |
86 do { free((surface)->data); free(surface); } while(0) | 86 do { free((surface)->data); free(surface); } while(0) |
87 #define cairo_image_surface_get_stride(surface) 1 | 87 #define mbe_image_surface_get_stride(surface) 1 |
88 #define CAIRO_FORMAT_A1 1 | 88 #define CAIRO_FORMAT_A1 1 |
89 | 89 |
90 | 90 |
91 typedef struct _area area_t; | 91 typedef struct _area area_t; |
92 struct _area { | 92 struct _area { |
298 } | 298 } |
299 return cur; | 299 return cur; |
300 } | 300 } |
301 | 301 |
302 static | 302 static |
303 void shape_draw(shape_t *sh, cairo_t *cr) { | 303 void shape_draw(shape_t *sh, mbe_t *cr) { |
304 STAILQ_INS_TAIL(cr->drawed, shape_t, drawed_next, sh); | 304 STAILQ_INS_TAIL(cr->drawed, shape_t, drawed_next, sh); |
305 } | 305 } |
306 | 306 |
307 #define sh_path_draw(path, cr) shape_draw((shape_t *)path, cr) | 307 #define sh_path_draw(path, cr) shape_draw((shape_t *)path, cr) |
308 #define sh_text_draw(text, cr) shape_draw((shape_t *)text, cr) | 308 #define sh_text_draw(text, cr) shape_draw((shape_t *)text, cr) |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 | 329 |
330 struct redraw_man { | 330 struct redraw_man { |
331 cairo_t *cr; | 331 mbe_t *cr; |
332 coord_t *root_coord; | 332 coord_t *root_coord; |
333 int shape_gl_sz; | 333 int shape_gl_sz; |
334 shape_t *shape_gl[32]; | 334 shape_t *shape_gl[32]; |
335 STAILQ(shape_t) all_shapes; | 335 STAILQ(shape_t) all_shapes; |
336 }; | 336 }; |
364 #define rdman_get_root(rdman) ((rdman)->root_coord) | 364 #define rdman_get_root(rdman) ((rdman)->root_coord) |
365 | 365 |
366 static coord_t *rdman_coord_new_noparent(redraw_man_t *rdman); | 366 static coord_t *rdman_coord_new_noparent(redraw_man_t *rdman); |
367 | 367 |
368 static | 368 static |
369 redraw_man_t *redraw_man_new(cairo_t *cr, cairo_t *backend) { | 369 redraw_man_t *redraw_man_new(mbe_t *cr, mbe_t *backend) { |
370 redraw_man_t *rdman; | 370 redraw_man_t *rdman; |
371 | 371 |
372 rdman = O_ALLOC(redraw_man_t); | 372 rdman = O_ALLOC(redraw_man_t); |
373 redraw_man_init(rdman, cr, backend); | 373 redraw_man_init(rdman, cr, backend); |
374 return rdman; | 374 return rdman; |
378 redraw_man_destroy(rdman); \ | 378 redraw_man_destroy(rdman); \ |
379 free(rdman); \ | 379 free(rdman); \ |
380 } while(0) | 380 } while(0) |
381 | 381 |
382 static | 382 static |
383 int cairo_in_fill(cairo_t *cr, int x, int y) { | 383 int mbe_in_fill(mbe_t *cr, int x, int y) { |
384 shape_t *shape; | 384 shape_t *shape; |
385 int i; | 385 int i; |
386 | 386 |
387 for(shape = STAILQ_HEAD(cr->drawed); | 387 for(shape = STAILQ_HEAD(cr->drawed); |
388 shape != NULL; | 388 shape != NULL; |
393 return 1; | 393 return 1; |
394 } | 394 } |
395 return 0; | 395 return 0; |
396 } | 396 } |
397 | 397 |
398 #define cairo_in_stroke cairo_in_fill | 398 #define mbe_in_stroke mbe_in_fill |
399 | 399 |
400 static | 400 static |
401 void rdman_coord_init_noparent(redraw_man_t *rdman, coord_t *co) { | 401 void rdman_coord_init_noparent(redraw_man_t *rdman, coord_t *co) { |
402 memset(co, 0, sizeof(coord_t)); | 402 memset(co, 0, sizeof(coord_t)); |
403 MB_OBJ_INIT(&co->obj, MBO_COORD); | 403 MB_OBJ_INIT(&co->obj, MBO_COORD); |
472 | 472 |
473 return OK; | 473 return OK; |
474 } | 474 } |
475 | 475 |
476 static | 476 static |
477 void *cairo_image_surface_get_data(cairo_surface_t *surf) { | 477 void *mbe_image_surface_get_data(mbe_surface_t *surf) { |
478 cairo_t *cr; | 478 mbe_t *cr; |
479 shape_t *shape1, *shape2; | 479 shape_t *shape1, *shape2; |
480 co_aix x1, y1, x2, y2; | 480 co_aix x1, y1, x2, y2; |
481 int i, j; | 481 int i, j; |
482 | 482 |
483 cr = surf->cr; | 483 cr = surf->cr; |
531 | 531 |
532 /*! \brief Draw path of a shape. | 532 /*! \brief Draw path of a shape. |
533 * | 533 * |
534 * \note This function should be merged with what is in redraw_man.c. | 534 * \note This function should be merged with what is in redraw_man.c. |
535 */ | 535 */ |
536 static void draw_shape_path(shape_t *shape, cairo_t *cr) { | 536 static void draw_shape_path(shape_t *shape, mbe_t *cr) { |
537 switch(MBO_TYPE(shape)) { | 537 switch(MBO_TYPE(shape)) { |
538 case MBO_PATH: | 538 case MBO_PATH: |
539 sh_path_draw(shape, cr); | 539 sh_path_draw(shape, cr); |
540 break; | 540 break; |
541 #ifdef SH_TEXT | 541 #ifdef SH_TEXT |
561 * | 561 * |
562 * \note This function should not be called directly. Call | 562 * \note This function should not be called directly. Call |
563 * _shape_pos_is_in() insteaded. | 563 * _shape_pos_is_in() insteaded. |
564 */ | 564 */ |
565 static int _shape_pos_is_in_cairo(shape_t *shape, co_aix x, co_aix y, | 565 static int _shape_pos_is_in_cairo(shape_t *shape, co_aix x, co_aix y, |
566 int *in_stroke, cairo_t *cr) { | 566 int *in_stroke, mbe_t *cr) { |
567 draw_shape_path(shape, cr); | 567 draw_shape_path(shape, cr); |
568 if(shape->fill) { | 568 if(shape->fill) { |
569 if(cairo_in_fill(cr, x, y)) { | 569 if(mbe_in_fill(cr, x, y)) { |
570 *in_stroke = 0; | 570 *in_stroke = 0; |
571 return TRUE; | 571 return TRUE; |
572 } | 572 } |
573 } | 573 } |
574 if(shape->stroke) { | 574 if(shape->stroke) { |
575 if(cairo_in_stroke(cr, x, y)) { | 575 if(mbe_in_stroke(cr, x, y)) { |
576 *in_stroke = 1; | 576 *in_stroke = 1; |
577 return TRUE; | 577 return TRUE; |
578 } | 578 } |
579 } | 579 } |
580 return FALSE; | 580 return FALSE; |
582 | 582 |
583 /*! \brief Find all shapes whose bounding box include a specified position. | 583 /*! \brief Find all shapes whose bounding box include a specified position. |
584 */ | 584 */ |
585 static | 585 static |
586 int _shape_pos_is_in(shape_t *shape, co_aix x, co_aix y, | 586 int _shape_pos_is_in(shape_t *shape, co_aix x, co_aix y, |
587 int *in_stroke, cairo_t *cr) { | 587 int *in_stroke, mbe_t *cr) { |
588 int r; | 588 int r; |
589 | 589 |
590 r = sh_pos_is_in(shape, x, y); | 590 r = sh_pos_is_in(shape, x, y); |
591 if(!r) | 591 if(!r) |
592 return FALSE; | 592 return FALSE; |
593 | 593 |
594 r = _shape_pos_is_in_cairo(shape, x, y, in_stroke, cr); | 594 r = _shape_pos_is_in_cairo(shape, x, y, in_stroke, cr); |
595 cairo_new_path(cr); | 595 mbe_new_path(cr); |
596 if(!r) | 596 if(!r) |
597 return FALSE; | 597 return FALSE; |
598 | 598 |
599 return TRUE; | 599 return TRUE; |
600 } | 600 } |
602 /*! \brief Find first shape that is draw at a specified position. | 602 /*! \brief Find first shape that is draw at a specified position. |
603 */ | 603 */ |
604 static shape_t *_find_shape_in_pos(redraw_man_t *rdman, | 604 static shape_t *_find_shape_in_pos(redraw_man_t *rdman, |
605 co_aix x, co_aix y, int *in_stroke) { | 605 co_aix x, co_aix y, int *in_stroke) { |
606 shape_t *shape; | 606 shape_t *shape; |
607 cairo_t *cr; | 607 mbe_t *cr; |
608 int i, r; | 608 int i, r; |
609 | 609 |
610 cr = rdman_get_cr(rdman); | 610 cr = rdman_get_cr(rdman); |
611 for(i = rdman_shape_gl_len(rdman) - 1; i >= 0; i--) { | 611 for(i = rdman_shape_gl_len(rdman) - 1; i >= 0; i--) { |
612 shape = rdman_get_shape_gl(rdman, i); | 612 shape = rdman_get_shape_gl(rdman, i); |
665 } | 665 } |
666 return FALSE; | 666 return FALSE; |
667 } | 667 } |
668 | 668 |
669 static | 669 static |
670 cairo_t * _prepare_cairo_for_testing(redraw_man_t *rdman) { | 670 mbe_t * _prepare_mbe_for_testing(redraw_man_t *rdman) { |
671 cairo_surface_t *surface, *rdman_surface; | 671 mbe_surface_t *surface, *rdman_surface; |
672 cairo_t *cr; | 672 mbe_t *cr; |
673 int w, h; | 673 int w, h; |
674 | 674 |
675 rdman_surface = cairo_get_target(rdman_get_cr(rdman)); | 675 rdman_surface = mbe_get_target(rdman_get_cr(rdman)); |
676 w = cairo_image_surface_get_width(rdman_surface); | 676 w = mbe_image_surface_get_width(rdman_surface); |
677 h = cairo_image_surface_get_height(rdman_surface); | 677 h = mbe_image_surface_get_height(rdman_surface); |
678 | 678 |
679 surface = cairo_image_surface_create(CAIRO_FORMAT_A1, w, h); | 679 surface = mbe_image_surface_create(CAIRO_FORMAT_A1, w, h); |
680 if(surface == NULL) | 680 if(surface == NULL) |
681 return NULL; | 681 return NULL; |
682 | 682 |
683 cr = cairo_create(surface); | 683 cr = mbe_create(surface); |
684 if(cr == NULL) | 684 if(cr == NULL) |
685 cairo_surface_destroy(surface); | 685 mbe_surface_destroy(surface); |
686 | 686 |
687 return cr; | 687 return cr; |
688 } | 688 } |
689 | 689 |
690 static | 690 static |
691 void _release_cairo_for_testing(cairo_t *cr) { | 691 void _release_mbe_for_testing(mbe_t *cr) { |
692 cairo_destroy(cr); | 692 mbe_destroy(cr); |
693 } | 693 } |
694 | 694 |
695 static | 695 static |
696 void _draw_to_mask(shape_t *shape, cairo_t *cr) { | 696 void _draw_to_mask(shape_t *shape, mbe_t *cr) { |
697 if(sh_get_flags(shape, GEF_OV_DRAW)) | 697 if(sh_get_flags(shape, GEF_OV_DRAW)) |
698 return; | 698 return; |
699 | 699 |
700 draw_shape_path(shape, cr); | 700 draw_shape_path(shape, cr); |
701 cairo_clip(cr); | 701 mbe_clip(cr); |
702 | 702 |
703 sh_set_flags(shape, GEF_OV_DRAW); | 703 sh_set_flags(shape, GEF_OV_DRAW); |
704 } | 704 } |
705 | 705 |
706 static | 706 static |
707 int _fill_and_check(shape_t *shape, cairo_t *cr) { | 707 int _fill_and_check(shape_t *shape, mbe_t *cr) { |
708 int h, stride; | 708 int h, stride; |
709 cairo_surface_t *surface; | 709 mbe_surface_t *surface; |
710 unsigned char *data; | 710 unsigned char *data; |
711 int i, sz; | 711 int i, sz; |
712 | 712 |
713 draw_shape_path(shape, cr); | 713 draw_shape_path(shape, cr); |
714 cairo_fill(cr); | 714 mbe_fill(cr); |
715 | 715 |
716 surface = cairo_get_target(cr); | 716 surface = mbe_get_target(cr); |
717 data = cairo_image_surface_get_data(surface); | 717 data = mbe_image_surface_get_data(surface); |
718 | 718 |
719 h = cairo_image_surface_get_height(surface); | 719 h = mbe_image_surface_get_height(surface); |
720 stride = cairo_image_surface_get_stride(surface); | 720 stride = mbe_image_surface_get_stride(surface); |
721 | 721 |
722 sz = stride * h; | 722 sz = stride * h; |
723 for(i = 0; i < sz; i++) { | 723 for(i = 0; i < sz; i++) { |
724 if(data[i]) | 724 if(data[i]) |
725 return TRUE; | 725 return TRUE; |
736 * it not only check overlay of area. It also check overlay by | 736 * it not only check overlay of area. It also check overlay by |
737 * actually drawing on a cairo surface. | 737 * actually drawing on a cairo surface. |
738 */ | 738 */ |
739 static | 739 static |
740 int _is_obj_objs_overlay(mb_obj_t *obj, mb_obj_t *others_root, | 740 int _is_obj_objs_overlay(mb_obj_t *obj, mb_obj_t *others_root, |
741 cairo_t *cr) { | 741 mbe_t *cr) { |
742 area_t *area, *candi_area; | 742 area_t *area, *candi_area; |
743 coord_t *coord, *candi_coord, *root; | 743 coord_t *coord, *candi_coord, *root; |
744 shape_t *shape, *candi_shape; | 744 shape_t *shape, *candi_shape; |
745 int obj_is_shape; | 745 int obj_is_shape; |
746 int r; | 746 int r; |
827 * \todo Detect overlay in better way with cairo. | 827 * \todo Detect overlay in better way with cairo. |
828 * \note This function cost heavy on CPU power. | 828 * \note This function cost heavy on CPU power. |
829 */ | 829 */ |
830 int mb_objs_are_overlay(redraw_man_t *rdman, | 830 int mb_objs_are_overlay(redraw_man_t *rdman, |
831 mb_obj_t *obj1, mb_obj_t *obj2) { | 831 mb_obj_t *obj1, mb_obj_t *obj2) { |
832 cairo_t *cr; | 832 mbe_t *cr; |
833 area_t *area; | 833 area_t *area; |
834 shape_t *shape; | 834 shape_t *shape; |
835 coord_t *coord, *root; | 835 coord_t *coord, *root; |
836 int r; | 836 int r; |
837 | 837 |
838 cr = _prepare_cairo_for_testing(rdman); | 838 cr = _prepare_mbe_for_testing(rdman); |
839 | 839 |
840 if(IS_MBO_SHAPES(obj1)) { | 840 if(IS_MBO_SHAPES(obj1)) { |
841 shape = (shape_t *)obj1; | 841 shape = (shape_t *)obj1; |
842 r = _is_obj_objs_overlay(obj1, obj2, cr); | 842 r = _is_obj_objs_overlay(obj1, obj2, cr); |
843 goto out; | 843 goto out; |
860 } | 860 } |
861 r = FALSE; | 861 r = FALSE; |
862 | 862 |
863 out: | 863 out: |
864 _clear_ov_draw(obj2); /* marked by _is_obj_objs_overlay() */ | 864 _clear_ov_draw(obj2); /* marked by _is_obj_objs_overlay() */ |
865 _release_cairo_for_testing(cr); | 865 _release_mbe_for_testing(cr); |
866 return r; | 866 return r; |
867 } | 867 } |
868 | 868 |
869 #ifdef UNITTEST | 869 #ifdef UNITTEST |
870 | 870 |
871 #include <CUnit/Basic.h> | 871 #include <CUnit/Basic.h> |
872 | 872 |
873 static | 873 static |
874 redraw_man_t *_fake_rdman(void) { | 874 redraw_man_t *_fake_rdman(void) { |
875 redraw_man_t *rdman; | 875 redraw_man_t *rdman; |
876 cairo_t *cr, *backend; | 876 mbe_t *cr, *backend; |
877 cairo_surface_t *surf; | 877 mbe_surface_t *surf; |
878 | 878 |
879 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 879 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
880 cr = cairo_create(surf); | 880 cr = mbe_create(surf); |
881 backend = cairo_create(surf); | 881 backend = mbe_create(surf); |
882 rdman = redraw_man_new(cr, backend); | 882 rdman = redraw_man_new(cr, backend); |
883 | 883 |
884 return rdman; | 884 return rdman; |
885 } | 885 } |
886 | 886 |
887 static | 887 static |
888 void _free_fake_rdman(redraw_man_t *rdman) { | 888 void _free_fake_rdman(redraw_man_t *rdman) { |
889 cairo_surface_destroy(rdman->cr->tgt); | 889 mbe_surface_destroy(rdman->cr->tgt); |
890 cairo_destroy(rdman->cr); | 890 mbe_destroy(rdman->cr); |
891 free(rdman); | 891 free(rdman); |
892 } | 892 } |
893 | 893 |
894 static | 894 static |
895 void test_mb_obj_pos_is_in(void) { | 895 void test_mb_obj_pos_is_in(void) { |
936 static | 936 static |
937 void test_is_obj_objs_overlay(void) { | 937 void test_is_obj_objs_overlay(void) { |
938 redraw_man_t *rdman; | 938 redraw_man_t *rdman; |
939 coord_t *root, *coord1, *coord2; | 939 coord_t *root, *coord1, *coord2; |
940 shape_t *shape1, *shape2, *shape3; | 940 shape_t *shape1, *shape2, *shape3; |
941 cairo_t *cr; | 941 mbe_t *cr; |
942 cairo_surface_t *surf; | 942 mbe_surface_t *surf; |
943 int r; | 943 int r; |
944 | 944 |
945 rdman = _fake_rdman(); | 945 rdman = _fake_rdman(); |
946 CU_ASSERT(rdman != NULL); | 946 CU_ASSERT(rdman != NULL); |
947 | 947 |
960 | 960 |
961 shape_add_point(shape1, 3, 2); | 961 shape_add_point(shape1, 3, 2); |
962 shape_add_point(shape2, 5, 5); | 962 shape_add_point(shape2, 5, 5); |
963 shape_add_point(shape3, 4, 3); | 963 shape_add_point(shape3, 4, 3); |
964 | 964 |
965 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 965 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
966 cr = cairo_create(surf); | 966 cr = mbe_create(surf); |
967 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); | 967 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); |
968 CU_ASSERT(!r); | 968 CU_ASSERT(!r); |
969 cairo_destroy(cr); | 969 mbe_destroy(cr); |
970 cairo_surface_destroy(surf); | 970 mbe_surface_destroy(surf); |
971 sh_clear_flags(coord2, GEF_OV_DRAW); | 971 sh_clear_flags(coord2, GEF_OV_DRAW); |
972 | 972 |
973 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 973 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
974 cr = cairo_create(surf); | 974 cr = mbe_create(surf); |
975 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); | 975 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); |
976 CU_ASSERT(!r); | 976 CU_ASSERT(!r); |
977 cairo_destroy(cr); | 977 mbe_destroy(cr); |
978 cairo_surface_destroy(surf); | 978 mbe_surface_destroy(surf); |
979 sh_clear_flags(coord2, GEF_OV_DRAW); | 979 sh_clear_flags(coord2, GEF_OV_DRAW); |
980 | 980 |
981 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 981 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
982 cr = cairo_create(surf); | 982 cr = mbe_create(surf); |
983 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); | 983 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); |
984 CU_ASSERT(!r); | 984 CU_ASSERT(!r); |
985 cairo_destroy(cr); | 985 mbe_destroy(cr); |
986 cairo_surface_destroy(surf); | 986 mbe_surface_destroy(surf); |
987 sh_clear_flags(shape2, GEF_OV_DRAW); | 987 sh_clear_flags(shape2, GEF_OV_DRAW); |
988 | 988 |
989 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 989 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
990 cr = cairo_create(surf); | 990 cr = mbe_create(surf); |
991 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); | 991 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); |
992 CU_ASSERT(!r); | 992 CU_ASSERT(!r); |
993 cairo_destroy(cr); | 993 mbe_destroy(cr); |
994 cairo_surface_destroy(surf); | 994 mbe_surface_destroy(surf); |
995 sh_clear_flags(shape2, GEF_OV_DRAW); | 995 sh_clear_flags(shape2, GEF_OV_DRAW); |
996 | 996 |
997 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 997 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
998 cr = cairo_create(surf); | 998 cr = mbe_create(surf); |
999 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); | 999 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); |
1000 CU_ASSERT(!r); | 1000 CU_ASSERT(!r); |
1001 cairo_destroy(cr); | 1001 mbe_destroy(cr); |
1002 cairo_surface_destroy(surf); | 1002 mbe_surface_destroy(surf); |
1003 sh_clear_flags(shape3, GEF_OV_DRAW); | 1003 sh_clear_flags(shape3, GEF_OV_DRAW); |
1004 | 1004 |
1005 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1005 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1006 cr = cairo_create(surf); | 1006 cr = mbe_create(surf); |
1007 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); | 1007 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); |
1008 CU_ASSERT(!r); | 1008 CU_ASSERT(!r); |
1009 cairo_destroy(cr); | 1009 mbe_destroy(cr); |
1010 cairo_surface_destroy(surf); | 1010 mbe_surface_destroy(surf); |
1011 sh_clear_flags(shape3, GEF_OV_DRAW); | 1011 sh_clear_flags(shape3, GEF_OV_DRAW); |
1012 | 1012 |
1013 shape_add_point(shape1, 5, 5); | 1013 shape_add_point(shape1, 5, 5); |
1014 | 1014 |
1015 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1015 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1016 cr = cairo_create(surf); | 1016 cr = mbe_create(surf); |
1017 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); | 1017 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)coord2, cr); |
1018 CU_ASSERT(r); | 1018 CU_ASSERT(r); |
1019 cairo_destroy(cr); | 1019 mbe_destroy(cr); |
1020 cairo_surface_destroy(surf); | 1020 mbe_surface_destroy(surf); |
1021 sh_clear_flags(coord2, GEF_OV_DRAW); | 1021 sh_clear_flags(coord2, GEF_OV_DRAW); |
1022 | 1022 |
1023 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1023 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1024 cr = cairo_create(surf); | 1024 cr = mbe_create(surf); |
1025 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); | 1025 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)coord2, cr); |
1026 CU_ASSERT(r); | 1026 CU_ASSERT(r); |
1027 cairo_destroy(cr); | 1027 mbe_destroy(cr); |
1028 cairo_surface_destroy(surf); | 1028 mbe_surface_destroy(surf); |
1029 sh_clear_flags(coord2, GEF_OV_DRAW); | 1029 sh_clear_flags(coord2, GEF_OV_DRAW); |
1030 | 1030 |
1031 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1031 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1032 cr = cairo_create(surf); | 1032 cr = mbe_create(surf); |
1033 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); | 1033 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape2, cr); |
1034 CU_ASSERT(r); | 1034 CU_ASSERT(r); |
1035 cairo_destroy(cr); | 1035 mbe_destroy(cr); |
1036 cairo_surface_destroy(surf); | 1036 mbe_surface_destroy(surf); |
1037 sh_clear_flags(shape2, GEF_OV_DRAW); | 1037 sh_clear_flags(shape2, GEF_OV_DRAW); |
1038 | 1038 |
1039 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1039 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1040 cr = cairo_create(surf); | 1040 cr = mbe_create(surf); |
1041 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); | 1041 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape2, cr); |
1042 CU_ASSERT(r); | 1042 CU_ASSERT(r); |
1043 cairo_destroy(cr); | 1043 mbe_destroy(cr); |
1044 cairo_surface_destroy(surf); | 1044 mbe_surface_destroy(surf); |
1045 sh_clear_flags(shape2, GEF_OV_DRAW); | 1045 sh_clear_flags(shape2, GEF_OV_DRAW); |
1046 | 1046 |
1047 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1047 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1048 cr = cairo_create(surf); | 1048 cr = mbe_create(surf); |
1049 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); | 1049 r = _is_obj_objs_overlay((mb_obj_t *)shape1, (mb_obj_t *)shape3, cr); |
1050 CU_ASSERT(!r); | 1050 CU_ASSERT(!r); |
1051 cairo_destroy(cr); | 1051 mbe_destroy(cr); |
1052 cairo_surface_destroy(surf); | 1052 mbe_surface_destroy(surf); |
1053 sh_clear_flags(shape3, GEF_OV_DRAW); | 1053 sh_clear_flags(shape3, GEF_OV_DRAW); |
1054 | 1054 |
1055 surf = cairo_image_surface_create(CAIRO_FORMAT_A1, 100, 100); | 1055 surf = mbe_image_surface_create(CAIRO_FORMAT_A1, 100, 100); |
1056 cr = cairo_create(surf); | 1056 cr = mbe_create(surf); |
1057 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); | 1057 r = _is_obj_objs_overlay((mb_obj_t *)coord1, (mb_obj_t *)shape3, cr); |
1058 CU_ASSERT(r); | 1058 CU_ASSERT(r); |
1059 cairo_destroy(cr); | 1059 mbe_destroy(cr); |
1060 cairo_surface_destroy(surf); | 1060 mbe_surface_destroy(surf); |
1061 sh_clear_flags(shape3, GEF_OV_DRAW); | 1061 sh_clear_flags(shape3, GEF_OV_DRAW); |
1062 | 1062 |
1063 rdman_shape_free(rdman, shape1); | 1063 rdman_shape_free(rdman, shape1); |
1064 rdman_shape_free(rdman, shape2); | 1064 rdman_shape_free(rdman, shape2); |
1065 rdman_shape_free(rdman, shape3); | 1065 rdman_shape_free(rdman, shape3); |