forked from enlightenment/efl
evas: Add internal context_dup function
This will simplify some code related to clipping and masking.
This commit is contained in:
parent
bcbf7d14e6
commit
69cbbc2184
|
@ -5,6 +5,7 @@
|
|||
EAPI void evas_common_draw_init (void);
|
||||
|
||||
EAPI RGBA_Draw_Context *evas_common_draw_context_new (void);
|
||||
EAPI RGBA_Draw_Context *evas_common_draw_context_dup (RGBA_Draw_Context *dc);
|
||||
EAPI void evas_common_draw_context_free (RGBA_Draw_Context *dc);
|
||||
EAPI void evas_common_draw_context_font_ext_set (RGBA_Draw_Context *dc,
|
||||
void *data,
|
||||
|
|
|
@ -11,6 +11,20 @@ evas_common_draw_context_cutouts_new(void)
|
|||
return rects;
|
||||
}
|
||||
|
||||
static void
|
||||
evas_common_draw_context_cutouts_dup(Cutout_Rects *rects2, const Cutout_Rects *rects)
|
||||
{
|
||||
if (!rects) return;
|
||||
rects2->active = rects->active;
|
||||
rects2->max = rects->max;
|
||||
if (rects->max > 0)
|
||||
{
|
||||
const size_t sz = sizeof(Cutout_Rect) * rects->max;
|
||||
rects2->rects = malloc(sz);
|
||||
memcpy(rects2->rects, rects->rects, sz);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_common_draw_context_cutouts_free(Cutout_Rects* rects)
|
||||
{
|
||||
|
@ -81,6 +95,18 @@ evas_common_draw_context_new(void)
|
|||
return dc;
|
||||
}
|
||||
|
||||
EAPI RGBA_Draw_Context *
|
||||
evas_common_draw_context_dup(RGBA_Draw_Context *dc)
|
||||
{
|
||||
RGBA_Draw_Context *dc2;
|
||||
|
||||
if (!dc) return evas_common_draw_context_new();
|
||||
dc2 = calloc(1, sizeof(RGBA_Draw_Context));
|
||||
memcpy(dc2, dc, sizeof(RGBA_Draw_Context));
|
||||
evas_common_draw_context_cutouts_dup(&dc2->cutout, &dc->cutout);
|
||||
return dc2;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_common_draw_context_free(RGBA_Draw_Context *dc)
|
||||
{
|
||||
|
|
|
@ -1263,6 +1263,7 @@ struct _Evas_Func
|
|||
void (*output_dump) (void *data);
|
||||
|
||||
void *(*context_new) (void *data);
|
||||
void *(*context_dup) (void *data, void *context);
|
||||
Eina_Bool (*canvas_alpha_get) (void *data, void *context);
|
||||
void (*context_free) (void *data, void *context);
|
||||
void (*context_clip_set) (void *data, void *context, int x, int y, int w, int h);
|
||||
|
|
|
@ -2182,6 +2182,18 @@ eng_context_free(void *data, void *context)
|
|||
evas_common_draw_context_free(context);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_context_dup(void *data EINA_UNUSED, void *context)
|
||||
{
|
||||
RGBA_Draw_Context *ctx;
|
||||
|
||||
ctx = evas_common_draw_context_dup(context);
|
||||
if (ctx->clip.mask)
|
||||
evas_gl_common_image_ref(ctx->clip.mask);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_3d_use(void *data)
|
||||
{
|
||||
|
@ -2565,6 +2577,7 @@ module_open(Evas_Module *em)
|
|||
ORD(context_clip_image_set);
|
||||
ORD(context_clip_image_unset);
|
||||
ORD(context_clip_image_get);
|
||||
ORD(context_dup);
|
||||
ORD(context_free);
|
||||
|
||||
ORD(rectangle_draw);
|
||||
|
|
|
@ -438,6 +438,26 @@ eng_context_new(void *data EINA_UNUSED)
|
|||
return evas_common_draw_context_new();
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_context_dup(void *data EINA_UNUSED, void *context)
|
||||
{
|
||||
RGBA_Draw_Context *ctx;
|
||||
|
||||
ctx = evas_common_draw_context_dup(context);
|
||||
if (ctx->clip.mask)
|
||||
{
|
||||
Image_Entry *im = ctx->clip.mask;
|
||||
#ifdef EVAS_CSERVE2
|
||||
if (evas_cserve2_use_get())
|
||||
evas_cache2_image_ref(im);
|
||||
else
|
||||
#endif
|
||||
evas_cache_image_ref(im);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_clip_set(void *data EINA_UNUSED, void *context, int x, int y, int w, int h)
|
||||
{
|
||||
|
@ -3787,6 +3807,7 @@ static Evas_Func func =
|
|||
eng_output_dump,
|
||||
/* draw context virtual methods */
|
||||
eng_context_new,
|
||||
eng_context_dup,
|
||||
eng_canvas_alpha_get,
|
||||
eng_context_free,
|
||||
eng_context_clip_set,
|
||||
|
|
Loading…
Reference in New Issue