summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-05-06 16:12:48 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-08-08 18:32:25 -0700
commit250777a16e5dc44c6aba4d2ce7ff5c76efb58df0 (patch)
tree8af19069293d5b26b23511308061f287e392b412
parent0f5854708527365ab248990b385f65e2f7ab6160 (diff)
evas/render: clamp mask surface size to clipper size
there's no point in allocating a massive mask surface if it's going to be clipped to a smaller size, so instead just allocate the smaller size and position it where the clipped size would be this can only be enabled if the clipper is known to not be changing size, as performance would be impacted if the clipper was forcing a full mask redraw due to regular resizing Reviewed-by: Hermet Park <hermetpark@gmail.com> Differential Revision: https://phab.enlightenment.org/D8841
-rw-r--r--src/lib/evas/canvas/evas_render.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c
index 0a8d8a6748..b0179ba7cf 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -279,6 +279,29 @@ _evas_clip_changes_free(const void *container EINA_UNUSED, void *data, void *fda
279 return EINA_TRUE; 279 return EINA_TRUE;
280} 280}
281 281
282static inline Eina_Rectangle
283_evas_render_smallest_static_clipped_geometry_get(const Evas_Object_Protected_State *state)
284{
285 int cx, cy, cw, ch;
286
287 cx = state->geometry.x;
288 cy = state->geometry.y;
289 cw = state->geometry.w;
290 ch = state->geometry.h;
291 while (state->clipper && state->has_fixed_size)
292 {
293 /* walk up the clipper tree as long as the clippers are static */
294 RECTS_CLIP_TO_RECT(cx, cy, cw, ch,
295 state->clipper->cur->geometry.x,
296 state->clipper->cur->geometry.y,
297 state->clipper->cur->geometry.w,
298 state->clipper->cur->geometry.h);
299 if (!state->clipper) break;
300 state = state->clipper->cur;
301 }
302 return (Eina_Rectangle){cx, cy, cw, ch};
303}
304
282static Eina_Bool 305static Eina_Bool
283_evas_render_had_map(Evas_Object_Protected_Data *obj) 306_evas_render_had_map(Evas_Object_Protected_Data *obj)
284{ 307{
@@ -1756,9 +1779,10 @@ _evas_render_mapped_mask(Evas_Public_Data *evas, Evas_Object_Protected_Data *obj
1756 1779
1757 if (mask->mask->surface) 1780 if (mask->mask->surface)
1758 { 1781 {
1782 Eina_Rectangle clip = _evas_render_smallest_static_clipped_geometry_get(mask->cur);
1759 ENFN->context_clip_image_set(ENC, ctx, mask->mask->surface, 1783 ENFN->context_clip_image_set(ENC, ctx, mask->mask->surface,
1760 mask->cur->geometry.x + off_x, 1784 clip.x + off_x,
1761 mask->cur->geometry.y + off_y, 1785 clip.y + off_y,
1762 evas, do_async); 1786 evas, do_async);
1763 } 1787 }
1764} 1788}
@@ -2400,6 +2424,14 @@ evas_render_mask_subrender(Evas_Public_Data *evas,
2400 y = mask->cur->geometry.y; 2424 y = mask->cur->geometry.y;
2401 w = mask->cur->geometry.w; 2425 w = mask->cur->geometry.w;
2402 h = mask->cur->geometry.h; 2426 h = mask->cur->geometry.h;
2427 if (mask->cur->clipper && mask->cur->has_fixed_size)
2428 {
2429 Eina_Rectangle clip = _evas_render_smallest_static_clipped_geometry_get(mask->cur);
2430 x = clip.x;
2431 y = clip.y;
2432 w = clip.w;
2433 h = clip.h;
2434 }
2403 2435
2404 r = mask->cur->color.r; 2436 r = mask->cur->color.r;
2405 g = mask->cur->color.g; 2437 g = mask->cur->color.g;
@@ -2464,7 +2496,7 @@ evas_render_mask_subrender(Evas_Public_Data *evas,
2464 { 2496 {
2465 int fx, fy, fw, fh; 2497 int fx, fy, fw, fh;
2466 evas_object_image_fill_get(mask->object, &fx, &fy, &fw, &fh); 2498 evas_object_image_fill_get(mask->object, &fx, &fy, &fw, &fh);
2467 if ((fx == 0) && (fy == 0) && (fw == w) && (fh == h)) 2499 if ((fx == 0) && (fy == 0) && (fw == mask->cur->geometry.w) && (fh == mask->cur->geometry.h))
2468 filled = EINA_TRUE; 2500 filled = EINA_TRUE;
2469 } 2501 }
2470 2502
@@ -2530,16 +2562,17 @@ evas_render_mask_subrender(Evas_Public_Data *evas,
2530 ctx = ENFN->context_new(ENC); 2562 ctx = ENFN->context_new(ENC);
2531 if (prev_mask) 2563 if (prev_mask)
2532 { 2564 {
2565 Eina_Rectangle pclip = _evas_render_smallest_static_clipped_geometry_get(prev_mask->cur);
2533 ENFN->context_clip_image_set(ENC, ctx, 2566 ENFN->context_clip_image_set(ENC, ctx,
2534 prev_mask->mask->surface, 2567 prev_mask->mask->surface,
2535 prev_mask->cur->geometry.x - x, 2568 pclip.x - x,
2536 prev_mask->cur->geometry.y - y, 2569 pclip.y - y,
2537 evas, do_async); 2570 evas, do_async);
2538 ENFN->context_clip_set(ENC, ctx, 2571 ENFN->context_clip_set(ENC, ctx,
2539 prev_mask->cur->geometry.x - x, 2572 pclip.x - x,
2540 prev_mask->cur->geometry.y - y, 2573 pclip.y - y,
2541 prev_mask->cur->geometry.w, 2574 pclip.w,
2542 prev_mask->cur->geometry.h); 2575 pclip.h);
2543 } 2576 }
2544 2577
2545 if (EINA_LIKELY(!mask->is_smart)) 2578 if (EINA_LIKELY(!mask->is_smart))
@@ -2994,10 +3027,11 @@ evas_render_updates_internal_loop(Evas *eo_e, Evas_Public_Data *evas,
2994 3027
2995 if (mask->mask->surface) 3028 if (mask->mask->surface)
2996 { 3029 {
3030 Eina_Rectangle clip = _evas_render_smallest_static_clipped_geometry_get(mask->cur);
2997 ENFN->context_clip_image_set(ENC, context, 3031 ENFN->context_clip_image_set(ENC, context,
2998 mask->mask->surface, 3032 mask->mask->surface,
2999 mask->cur->geometry.x + off_x, 3033 clip.x + off_x,
3000 mask->cur->geometry.y + off_y, 3034 clip.y + off_y,
3001 evas, do_async); 3035 evas, do_async);
3002 } 3036 }
3003 } 3037 }