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();
}
예제 #2
0
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);
     }
}
예제 #3
0
END_TEST

START_TEST(eina_rectangle_position_test)
{
    Eina_Rectangle middle, top, down, right, left;
    EINA_RECTANGLE_SET(&middle, -1, -1, 2.0, 2.0);
    EINA_RECTANGLE_SET(&top,    -1, -2, 2.0, 2.0);
    EINA_RECTANGLE_SET(&right,   0, -1, 2.0, 2.0);
    EINA_RECTANGLE_SET(&left,   -2, -1, 2.0, 2.0);
    EINA_RECTANGLE_SET(&down,   -1,  0, 2.0, 2.0);

    ck_assert_int_eq(eina_rectangle_outside_position(&middle, &top), EINA_RECTANGLE_OUTSIDE_TOP) ;
    ck_assert_int_eq(eina_rectangle_outside_position(&middle, &down), EINA_RECTANGLE_OUTSIDE_BOTTOM) ;
    ck_assert_int_eq(eina_rectangle_outside_position(&middle, &right), EINA_RECTANGLE_OUTSIDE_RIGHT) ;
    ck_assert_int_eq(eina_rectangle_outside_position(&middle, &left), EINA_RECTANGLE_OUTSIDE_LEFT) ;

}
예제 #4
0
END_TEST

START_TEST(eina_matrix3_map_transform)
{
   double x = 2, y = 3, x1, y1;
   Eina_Matrix3 m;
   Eina_Rectangle r;
   Eina_Quad q;
   Eina_Bool ret;

   eina_init();

   eina_matrix3_values_set(&m,
                           0, 1, 0,
                           1, 0, 0,
                           0, 0, 1);

   eina_matrix3_point_transform(&m,
                                x, y,
                                &x1, &y1);
   fail_if(x1 != 3 || y1 != 2);

   EINA_RECTANGLE_SET(&r, 0, 0, 3, 4);
   eina_matrix3_rectangle_transform(&m, &r, &q);

   fail_if(q.x0 != 0 || q.y0 != 0 ||
           q.x1 != 0 || q.y1 != 3 ||
           q.x2 != 4 || q.y2 != 3 ||
           q.x3 != 4 || q.y3 != 0);

   eina_quad_coords_set(&q,
                        0.0, 0.0,
                        3.0, 0.0,
                        3.0, 3.0,
                        0.0, 3.0);
   ret = eina_matrix3_square_quad_map(&m, &q);
   fail_if(ret != EINA_TRUE);

   fail_if(m.xx != 3 || m.xy != 0 || m.xz != 0 ||
           m.yx != 0 || m.yy != 3 || m.yz != 0 ||
           m.zx != 0 || m.zy != 0 || m.zz != 1);

   ret = eina_matrix3_quad_square_map(&m, &q);
   fail_if(ret != EINA_TRUE);

   fail_if(q.x0 != 0 || q.y0 != 0 ||
           q.x1 != 3 || q.y1 != 0 ||
           q.x2 != 3 || q.y2 != 3 ||
           q.x3 != 0 || q.y3 != 3);

   eina_shutdown();
}
void
soft8_rectangle_draw(Soft8_Image * dst, RGBA_Draw_Context * dc,
                     int x, int y, int w, int h)
{
   Eina_Rectangle dr;
   Cutout_Rects *rects;
   Cutout_Rect *r;
   struct RGBA_Draw_Context_clip c_bkp;
   int i;

   /* handle cutouts here! */
   EINA_RECTANGLE_SET(&dr, x, y, w, h);

   if (_is_empty_rectangle(&dr))
      return;
   if (!
       (RECTS_INTERSECT
        (dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
      return;

   /* no cutouts - cut right to the chase */
   if (!dc->cutout.rects)
     {
        _soft8_rectangle_draw_int(dst, dc, dr);
        return;
     }

   c_bkp = dc->clip;

   evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w,
                                      dst->cache_entry.h);
   evas_common_draw_context_clip_clip(dc, x, y, w, h);
   /* our clip is 0 size.. abort */
   if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
     {
        dc->clip = c_bkp;
        return;
     }
   rects = evas_common_draw_context_apply_cutouts(dc);
   for (i = 0; i < rects->active; ++i)
     {
        r = rects->rects + i;
        evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
        _soft8_rectangle_draw_int(dst, dc, dr);
     }
   evas_common_draw_context_apply_clear_cutouts(rects);
   dc->clip = c_bkp;
}
예제 #6
0
파일: eina_rectangle.c 프로젝트: Limsik/e17
EAPI Eina_Rectangle *
eina_rectangle_new(int x, int y, int w, int h)
{
   Eina_Rectangle *rect;

   if (_eina_rectangles)
     {
        rect = eina_trash_pop(&_eina_rectangles);
        _eina_rectangles_count--;
     }
   else
      rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));

   if (!rect)
      return NULL;

   EINA_RECTANGLE_SET(rect, x, y, w, h);

   return rect;
}
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);
     }
}
예제 #8
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();
}
예제 #9
0
END_TEST

START_TEST(eina_matrix3_map_transform)
{
   double x = 2, y = 3, x1, y1;
   Eina_Matrix3 m;
   Eina_Rectangle r;
   Eina_Quad q;
   Eina_Bool ret;

   eina_init();

   eina_matrix3_values_set(&m,
                           0, 1, 0,
                           1, 0, 0,
                           0, 0, 1);

   eina_matrix3_point_transform(&m,
                                x, y,
                                &x1, &y1);
   fail_if(!EINA_DBL_EQ(x1, 3) ||
           !EINA_DBL_EQ(y1, 2));

   EINA_RECTANGLE_SET(&r, 0, 0, 3, 4);
   eina_matrix3_rectangle_transform(&m, &r, &q);

   fail_if(!EINA_DBL_EQ(q.x0, 0) ||
           !EINA_DBL_EQ(q.y0, 0) ||
           !EINA_DBL_EQ(q.x1, 0) ||
           !EINA_DBL_EQ(q.y1, 3) ||
           !EINA_DBL_EQ(q.x2, 4) ||
           !EINA_DBL_EQ(q.y2, 3) ||
           !EINA_DBL_EQ(q.x3, 4) ||
           !EINA_DBL_EQ(q.y3, 0));

   eina_quad_coords_set(&q,
                        0.0, 0.0,
                        3.0, 0.0,
                        3.0, 3.0,
                        0.0, 3.0);
   ret = eina_matrix3_square_quad_map(&m, &q);
   fail_if(ret != EINA_TRUE);

   fail_if(!MATRIX3_CMP(m.xx, m.xy, m.xz,
                        m.yx, m.yy, m.yz,
                        m.zx, m.zy, m.zz,
                        3, 0, 0,
                        0, 3, 0,
                        0, 0, 1));

   ret = eina_matrix3_quad_square_map(&m, &q);
   fail_if(ret != EINA_TRUE);

   fail_if(!EINA_DBL_EQ(q.x0, 0) ||
           !EINA_DBL_EQ(q.y0, 0) ||
           !EINA_DBL_EQ(q.x1, 3) ||
           !EINA_DBL_EQ(q.y1, 0) ||
           !EINA_DBL_EQ(q.x2, 3) ||
           !EINA_DBL_EQ(q.y2, 3) ||
           !EINA_DBL_EQ(q.x3, 0) ||
           !EINA_DBL_EQ(q.y3, 3));

   eina_shutdown();
}
예제 #10
0
파일: eina_rectangle.c 프로젝트: Limsik/e17
static Eina_List *
_eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
{
   Eina_Rectangle *r;
   Eina_List *l;

   EINA_LIST_FOREACH(empty, l, r)
   {
      if (r->w >= w && r->h >= h)
        {
           /* Remove l from empty */
           empty = eina_list_remove_list(empty, l);
           /* Remember x and y */
           *x = r->x;
           *y = r->y;
           /* Split r in 2 rectangle if needed (only the empty one) and insert them */
           if (r->w == w)
             {
                r->y += h;
                r->h -= h;
             }
           else if (r->h == h)
             {
                r->x += w;
                r->w -= w;
             }
           else
             {
                int rx1, ry1, rw1, rh1;
                int x2, y2, w2, h2;

                rx1 = r->x + w;
                ry1 = r->y;
                rw1 = r->w - w;
                /* h1 could be h or r->h */
                x2 = r->x;
                y2 = r->y + h;
                /* w2 could be w or r->w */
                h2 = r->h - h;

                if (rw1 * r->h > h2 * r->w)
                  {
                     rh1 = r->h;
                     w2 = w;
                  }
                else
                  {
                     rh1 = h;
                     w2 = r->w;
                  }

                EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
                empty = _eina_rectangle_merge_list(empty, r);

                r = eina_rectangle_new(x2, y2, w2, h2);
             }

           if (r)
             {
                empty = _eina_rectangle_merge_list(empty, r); /* Return empty */

             }

           return empty;
        }
   }

   *x = -1;
   *y = -1;
   return empty;
}