EAPI Cutout_Rects*
evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc)
{
   Cutout_Rects*        res;
   int                  i;
   int                  j;

   if (!dc->clip.use) return NULL;
   if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL;

   res = evas_common_draw_context_cutouts_new();
   evas_common_draw_context_cutouts_add(res, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);

   for (i = 0; i < dc->cutout.active; ++i)
     {
        /* Don't loop on the element just added to the list as they are already correctly clipped. */
        int active = res->active;

        for (j = 0; j < active; )
          {
             if (evas_common_draw_context_cutout_split(res, j, dc->cutout.rects + i))
               ++j;
             else
               active--;
          }
     }
   return res;
}
Beispiel #2
0
EAPI void
evas_common_draw_context_add_cutout(RGBA_Draw_Context *dc, int x, int y, int w, int h)
{
//   if (dc->cutout.rects > 512) return;
   if (dc->clip.use)
     {
#if 1 // this is a bit faster
        int xa1, xa2, xb1, xb2;

        xa1 = x;
        xa2 = xa1 + w - 1;
        xb1 = dc->clip.x;
        if (xa2 < xb1) return;
        xb2 = xb1 + dc->clip.w - 1;
        if (xa1 >= xb2) return;
        if (xa2 > xb2) xa2 = xb2;
        if (xb1 > xa1) xa1 = xb1;
        x = xa1;
        w = xa2 - xa1 + 1;

        xa1 = y;
        xa2 = xa1 + h - 1;
        xb1 = dc->clip.y;
        if (xa2 < xb1) return;
        xb2 = xb1 + dc->clip.h - 1;
        if (xa1 >= xb2) return;
        if (xa2 > xb2) xa2 = xb2;
        if (xb1 > xa1) xa1 = xb1;
        y = xa1;
        h = xa2 - xa1 + 1;
#else
        RECTS_CLIP_TO_RECT(x, y, w, h,
			   dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
#endif
	if ((w < 1) || (h < 1)) return;
     }
   evas_common_draw_context_cutouts_add(&dc->cutout, x, y, w, h);
}
Beispiel #3
0
EAPI Cutout_Rects*
evas_common_draw_context_apply_cutouts(RGBA_Draw_Context *dc, Cutout_Rects *reuse)
{
   Cutout_Rects*        res = NULL;
   int                  i;
   int                  j;

   if (!dc->clip.use) return NULL;
   if ((dc->clip.w <= 0) || (dc->clip.h <= 0)) return NULL;


   if (!reuse)
     {
        res = evas_common_draw_context_cutouts_new();
     }
   else
     {
        evas_common_draw_context_cutouts_free(reuse);
        res = reuse;
     }
   evas_common_draw_context_cutouts_add(res, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);

   for (i = 0; i < dc->cutout.active; ++i)
     {
        /* Don't loop on the element just added to the list as they are already correctly clipped. */
        int active = res->active;

        for (j = 0; j < active; )
          {
             if (evas_common_draw_context_cutout_split(res, j, dc->cutout.rects + i))
               ++j;
             else
               active--;
          }
     }
   /* merge rects */
#define RI res->rects[i]
#define RJ res->rects[j]
   if (res->active > 1)
     {
        int found = 1;
        
        while (found)
          {
             found = 0;
             for (i = 0; i < res->active; i++)
               {
                  for (j = i + 1; j < res->active; j++)
                    {
                       /* skip empty rects we are removing */
                       if (RJ.w == 0) continue;
                       /* check if its same width, immediately above or below */
                       if ((RJ.w == RI.w) && (RJ.x == RI.x))
                         {
                            if ((RJ.y + RJ.h) == RI.y) /* above */
                              {
                                 RI.y = RJ.y;
                                 RI.h += RJ.h;
                                 RJ.w = 0;
                                 found = 1;
                              }
                            else if ((RI.y + RI.h) == RJ.y) /* below */
                              {
                                 RI.h += RJ.h;
                                 RJ.w = 0;
                                 found = 1;
                              }
                         }
                       /* check if its same height, immediately left or right */
                       else if ((RJ.h == RI.h) && (RJ.y == RI.y))
                         {
                            if ((RJ.x + RJ.w) == RI.x) /* left */
                              {
                                 RI.x = RJ.x;
                                 RI.w += RJ.w;
                                 RJ.w = 0;
                                 found = 1;
                              }
                            else if ((RI.x + RI.w) == RJ.x) /* right */
                              {
                                 RI.w += RJ.w;
                                 RJ.w = 0;
                                 found = 1;
                              }
                         }
                    }
               }
          }

        /* Repack the cutout */
        j = 0;
        for (i = 0; i < res->active; i++)
          {
             if (RI.w == 0) continue;
             if (i != j)
               RJ = RI;
             j++;
          }
        res->active = j;
        return res;
     }
   return res;
}