From: Michal Szczecinski Date: Wed, 30 Oct 2024 14:10:24 +0000 (+0100) Subject: evas: support 9-patch files with grayscale defined borders X-Git-Tag: accepted/tizen/unified/20241108.105431^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified;p=platform%2Fupstream%2Fefl.git evas: support 9-patch files with grayscale defined borders Fixed 9-patch images support. In some files used in Tizen we noticed black or grayscale defined 9-patch borders. This patch fixed issue with loading them. Change-Id: I1becf164cee8705201a3d03ab93b8fc5ce644798 --- diff --git a/src/modules/evas/image_loaders/webp/evas_image_load_webp.c b/src/modules/evas/image_loaders/webp/evas_image_load_webp.c index d1478d3..bb1551d 100644 --- a/src/modules/evas/image_loaders/webp/evas_image_load_webp.c +++ b/src/modules/evas/image_loaders/webp/evas_image_load_webp.c @@ -180,12 +180,15 @@ _evas_image_webp_update_y_content(Eina_Rectangle *r, int index) r->h = index - r->y; } } -//TIZEN_ONLY(20240215): Support 9-patch files with non-black borders +//TIZEN_ONLY(20241030): evas: support 9-patch files with grayscale defined borders static inline Eina_Bool -_is_color(DATA32 *ptr) +_is_grayscale(DATA32 *ptr) { - if (*ptr == 0) return EINA_FALSE; - return EINA_TRUE; + uint8_t r = (*ptr >> 16) & 0xFF; + uint8_t g = (*ptr >> 8) & 0xFF; + uint8_t b = (*ptr) & 0xFF; + uint8_t a = (*ptr >> 24) & 0xFF; + return (r == g) && (g == b) && (a == 0xFF); } static Eina_Bool @@ -420,9 +423,9 @@ evas_image_load_file_head_with_data_webp(void *loader_data, for (i = 1; i < image_w - 1; i++, src_ptr1++, src_ptr2++) { - //TIZEN_ONLY(20240215): Support 9-patch files with non-black borders - Eina_Bool bp1 = _is_color(src_ptr1); - Eina_Bool bp2 = _is_color(src_ptr2); + //TIZEN_ONLY(20241030): evas: support 9-patch files with grayscale defined borders + Eina_Bool bp1 = _is_grayscale(src_ptr1); + Eina_Bool bp2 = _is_grayscale(src_ptr2); // Updating horizontal area where content can be located if (bp2) @@ -468,9 +471,9 @@ evas_image_load_file_head_with_data_webp(void *loader_data, for (i = 1; i < image_h - 1; i++, src_ptr1 += image_w, src_ptr2 += image_w) { - //TIZEN_ONLY(20240215): Support 9-patch files with non-black borders - Eina_Bool bp1 = _is_color(src_ptr1); - Eina_Bool bp2 = _is_color(src_ptr2); + //TIZEN_ONLY(20241030): evas: support 9-patch files with grayscale defined borders + Eina_Bool bp1 = _is_grayscale(src_ptr1); + Eina_Bool bp2 = _is_grayscale(src_ptr2); // Updating vertical area where content can be located if (bp2)