From 03eb4c640943d5eed29c88a4dc50b420906a4693 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 16 Dec 2016 17:04:05 +0900 Subject: [PATCH] evas: Fix issues with masking (make check) After a previous patch, mask_subrender worked differently, and didn't reset the object's cache clip color. This made evas_suite fail. But also it seems some other issues creeped in and it was necessary to fix the test case by adding data_updates (mistake!) and removing an invalid draw call. --- src/lib/evas/canvas/evas_render.c | 35 +++++++++++++++++++++++------------ src/tests/evas/evas_test_mask.c | 16 +++++++--------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c index a5806bd..e57fdc5 100644 --- a/src/lib/evas/canvas/evas_render.c +++ b/src/lib/evas/canvas/evas_render.c @@ -757,9 +757,11 @@ static void _evas_render_phase1_object_mapped_had_restack(Phase1_Context *p1ctx, Evas_Object_Protected_Data *obj, Eina_Bool map, - Eina_Bool obj_changed) + Eina_Bool obj_changed, + int level) { Evas_Object *eo_obj = obj->object; + (void) level; RD(level, " had map - restack objs\n"); _evas_render_prev_cur_clip_cache_add(p1ctx->e, obj); @@ -1099,7 +1101,7 @@ _evas_render_phase1_object_process(Phase1_Context *p1ctx, } else if (EINA_UNLIKELY(hmap && !can_map)) _evas_render_phase1_object_mapped_had_restack(p1ctx, obj, map, - obj_changed); + obj_changed, level); /* handle normal rendering. this object knows how to handle maps */ if (obj_changed) @@ -2370,16 +2372,11 @@ evas_render_mask_subrender(Evas_Public_Data *evas, Evas_Object_Protected_Data *prev_mask, int level, Eina_Bool do_async) { - int x, y, w, h, r, g, b, a; - Eina_Bool is_image, done = EINA_FALSE; + int x, y, w, h, r, g, b, a, cr, cg, cb, ca; + Eina_Bool is_image, done = EINA_FALSE, restore_state = EINA_FALSE; void *ctx; if (!mask) return; - if (!mask->mask->redraw && mask->mask->surface) - { - DBG("Requested mask redraw but the redraw flag is off."); - return; - } eina_evlog("+mask_subrender", mask->object, 0.0, NULL); RD(level, "evas_render_mask_subrender(%p, prev: %p, %s)\n", @@ -2396,14 +2393,24 @@ evas_render_mask_subrender(Evas_Public_Data *evas, g = mask->cur->color.g; b = mask->cur->color.b; a = mask->cur->color.a; - if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) - { + cr = mask->cur->cache.clip.r; + cg = mask->cur->cache.clip.g; + cb = mask->cur->cache.clip.b; + ca = mask->cur->cache.clip.a; + if ((r != 255) || (g != 255) || (b != 255) || (a != 255) || + (cr != 255) || (cg != 255) || (cb != 255) || (ca != 255)) + { + restore_state = EINA_TRUE; EINA_COW_STATE_WRITE_BEGIN(mask, state_write, cur) { state_write->color.r = 255; state_write->color.g = 255; state_write->color.b = 255; state_write->color.a = 255; + state_write->cache.clip.r = 255; + state_write->cache.clip.g = 255; + state_write->cache.clip.b = 255; + state_write->cache.clip.a = 255; } EINA_COW_STATE_WRITE_END(mask, state_write, cur); } @@ -2580,7 +2587,7 @@ evas_render_mask_subrender(Evas_Public_Data *evas, end: EINA_COW_WRITE_END(evas_object_mask_cow, mask->mask, mdata); - if ((r != 255) || (g != 255) || (b != 255) || (a != 255)) + if (restore_state) { EINA_COW_STATE_WRITE_BEGIN(mask, state_write, cur) { @@ -2588,6 +2595,10 @@ end: state_write->color.g = g; state_write->color.b = b; state_write->color.a = a; + state_write->cache.clip.r = cr; + state_write->cache.clip.g = cg; + state_write->cache.clip.b = cb; + state_write->cache.clip.a = ca; } EINA_COW_STATE_WRITE_END(mask, state_write, cur); } diff --git a/src/tests/evas/evas_test_mask.c b/src/tests/evas/evas_test_mask.c index b3dd17b..35d665e 100644 --- a/src/tests/evas/evas_test_mask.c +++ b/src/tests/evas/evas_test_mask.c @@ -147,20 +147,20 @@ START_TEST(evas_mask_test_compare_clip) evas_object_image_size_set(obj, 4, 4); evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888); evas_object_image_data_copy_set(obj, ref_data[0]); + evas_object_image_data_update_add(obj, 0, 0, 4, 4); evas_object_geometry_set(obj, 0, 0, W, H); evas_object_show(obj); - AUTODEL(obj); ecore_evas_manual_render(ee); refdata[0] = calloc(W * H, 4); memcpy(refdata[0], ecore_evas_buffer_pixels_get(ee), W * H * 4); evas_object_image_data_copy_set(obj, ref_data[1]); + evas_object_image_data_update_add(obj, 0, 0, 4, 4); ecore_evas_manual_render(ee); refdata[1] = calloc(W * H, 4); memcpy(refdata[1], ecore_evas_buffer_pixels_get(ee), W * H * 4); - - evas_object_hide(obj); + evas_object_del(obj); // Green background bg = evas_object_rectangle_add(e); @@ -182,6 +182,7 @@ START_TEST(evas_mask_test_compare_clip) evas_object_image_size_set(mask, 4, 4); evas_object_image_colorspace_set(mask, EVAS_COLORSPACE_ARGB8888); evas_object_image_data_copy_set(mask, mask_data); + evas_object_image_data_update_add(mask, 0, 0, 4, 4); evas_object_geometry_set(mask, 0, 0, W, H); evas_object_clip_set(rect, mask); evas_object_show(mask); @@ -197,12 +198,6 @@ START_TEST(evas_mask_test_compare_clip) evas_object_color_set(mask, 0x80, 0x80, 0x80, 0x80); ecore_evas_manual_render(ee); memcpy(data, ecore_evas_buffer_pixels_get(ee), W * H * 4); - - evas_object_image_data_copy_set(obj, ref_data[1]); - evas_object_show(obj); - ecore_evas_manual_render(ee); - refdata[1] = calloc(W * H, 4); - memcpy(refdata[1], ecore_evas_buffer_pixels_get(ee), W * H * 4); fail_if(_bgra_compare(data, refdata[1], W, H) != 0); // Now try again with a clip instead - this verifies clip == mask @@ -318,6 +313,7 @@ START_TEST(evas_mask_test_mask_of_mask) evas_object_image_size_set(mask0, 4, 4); evas_object_image_colorspace_set(mask0, EVAS_COLORSPACE_ARGB8888); evas_object_image_data_copy_set(mask0, mask_data[0]); + evas_object_image_data_update_add(mask0, 0, 0, 4, 4); evas_object_geometry_set(mask0, 0, 0, W, H); evas_object_show(mask0); AUTODEL(mask0); @@ -339,6 +335,7 @@ START_TEST(evas_mask_test_mask_of_mask) evas_object_image_size_set(mask1, 4, 4); evas_object_image_colorspace_set(mask1, EVAS_COLORSPACE_ARGB8888); evas_object_image_data_copy_set(mask1, mask_data[1]); + evas_object_image_data_update_add(mask1, 0, 0, 4, 4); evas_object_show(mask1); evas_object_size_hint_expand_set(mask1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -362,6 +359,7 @@ START_TEST(evas_mask_test_mask_of_mask) evas_object_image_size_set(obj, 4, 4); evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888); evas_object_image_data_copy_set(obj, mask_data[2]); + evas_object_image_data_update_add(obj, 0, 0, 4, 4); evas_object_geometry_set(obj, 0, 0, W, H); evas_object_show(obj); AUTODEL(obj); -- 2.7.4