END_TEST

START_TEST(eina_rectangle_intersect)
{
   Eina_Rectangle r1, r2, r3, r4, rd;

   fail_if(!eina_init());

   EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50);
   EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20);
   EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10);
   EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50);

   rd = r1;

   fail_if(eina_rectangle_intersection(&rd, &r3));
   fail_if(!eina_rectangle_intersection(&rd, &r2));

   fail_if(rd.x != r2.x
	   || rd.y != r2.y
	   || rd.w != r2.w
	   || rd.h != r2.h);

   rd = r1;

   fail_if(!eina_rectangle_intersection(&rd, &r4));

   fail_if(rd.x != 30
	   || rd.y != 30
	   || rd.w != 30
	   || rd.h != 30);

   eina_shutdown();
}
EAPI void
evas_common_rectangle_draw_do(const Cutout_Rects *reuse,
                              const Eina_Rectangle *clip,
                              RGBA_Image *dst, RGBA_Draw_Context *dc,
                              int x, int y, int w, int h)
{
   Eina_Rectangle area;
   Cutout_Rect *r;
   int i;

   if (!reuse)
     {
        evas_common_draw_context_clip_clip(dc,
					   clip->x, clip->y,
					   clip->w, clip->h);
        rectangle_draw_internal(dst, dc, x, y, w, h);
        return ;
     }

   for (i = 0; i < reuse->active; ++i)
     {
        r = reuse->rects + i;

        EINA_RECTANGLE_SET(&area, r->x, r->y, r->w, r->h);
        if (!eina_rectangle_intersection(&area, clip)) continue ;
        evas_common_draw_context_set_clip(dc, area.x, area.y, area.w, area.h);
        rectangle_draw_internal(dst, dc, x, y, w, h);
     }
}
EAPI void
evas_common_scale_rgba_in_to_out_clip_sample_do(const Cutout_Rects *reuse,
                                                const Eina_Rectangle *clip,
                                                RGBA_Image *src, RGBA_Image *dst,
                                                RGBA_Draw_Context *dc,
                                                int src_region_x, int src_region_y,
                                                int src_region_w, int src_region_h,
                                                int dst_region_x, int dst_region_y,
                                                int dst_region_w, int dst_region_h)
{
   Eina_Rectangle area;
   Cutout_Rect *r;
   int i;

   if (!reuse)
     {
        evas_common_draw_context_clip_clip(dc, clip->x, clip->y, clip->w, clip->h);
        scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
                                                  src_region_x, src_region_y,
                                                  src_region_w, src_region_h,
                                                  dst_region_x, dst_region_y,
                                                  dst_region_w, dst_region_h);
        return;
     }

   for (i = 0; i < reuse->active; ++i)
     {
        r = reuse->rects + i;

        EINA_RECTANGLE_SET(&area, r->x, r->y, r->w, r->h);
        if (!eina_rectangle_intersection(&area, clip)) continue ;
        evas_common_draw_context_set_clip(dc, area.x, area.y, area.w, area.h);
        scale_rgba_in_to_out_clip_sample_internal(src, dst, dc,
                                                  src_region_x, src_region_y,
                                                  src_region_w, src_region_h,
                                                  dst_region_x, dst_region_y,
                                                  dst_region_w, dst_region_h);
     }
}
示例#4
0
END_TEST

START_TEST(eina_rectangle_union_intersect)
{
   Eina_Rectangle r1, r2, r3, r4, r5, r6, r7, r8, rd;

   fail_if(!eina_init());

   EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50);
   EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20);
   EINA_RECTANGLE_SET(&r3, 0,   0, 10, 10);
   EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50);
   EINA_RECTANGLE_SET(&r5, 10, 10, 0, 0);
   EINA_RECTANGLE_SET(&r6, 30, 30, 0, 0);
   EINA_RECTANGLE_SET(&r7, 10, 10, 5, 0);
   EINA_RECTANGLE_SET(&r8, 10, 10, 0, 5);


   rd = r1;

   fail_if(eina_rectangle_intersection(&rd, &r3));
   fail_if(!eina_rectangle_intersection(&rd, &r2));

   fail_if(rd.x != r2.x
           || rd.y != r2.y
           || rd.w != r2.w
           || rd.h != r2.h);

   rd = r1;

   fail_if(!eina_rectangle_intersection(&rd, &r4));

   fail_if(rd.x != 30
           || rd.y != 30
           || rd.w != 30
           || rd.h != 30);

   rd = r1;
   eina_rectangle_union(&rd, &r2);
   fail_if(rd.x != r1.x
           || rd.y != r1.y
           || rd.w != r1.w
           || rd.h != r1.h);

   rd = r6;
   fail_if(eina_rectangle_intersection(&rd, &r5));

   rd = r7;
   fail_if(eina_rectangle_intersection(&rd, &r3));

   rd = r8;
   fail_if(eina_rectangle_intersection(&rd, &r3));

   rd = r1;
   eina_rectangle_union(&rd, &r3);
   fail_if(rd.x != 0
           || rd.y != 0
           || rd.w != 60
           || rd.h != 60);

   rd = r3;
   eina_rectangle_union(&rd, &r4);
   fail_if(rd.x != 0
           || rd.y != 0
           || rd.w != 80
           || rd.h != 80);

   rd = r5;
   eina_rectangle_union(&rd, &r6);
   fail_if(rd.x != 10
           || rd.y != 10
           || rd.w != 20
           || rd.h != 20);

   eina_shutdown();
}