summaryrefslogtreecommitdiff
path: root/src/static_libs
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-17 20:34:16 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-04-14 11:26:42 +0900
commitb6df13b02448621e5264152e2db1de370c7a6529 (patch)
treed4d38efa7a8c7eeca4bcd7c884e9052135721c7a /src/static_libs
parent09ff5f419ec102e65dc37cabf53d9854c6da978e (diff)
evas filters: Move curve to software generic (3/8)
This moves the RGBA premul/unpremul functions to static_libs/draw.
Diffstat (limited to 'src/static_libs')
-rw-r--r--src/static_libs/draw/draw.h3
-rw-r--r--src/static_libs/draw/draw_convert.c90
-rw-r--r--src/static_libs/draw/draw_main_neon.c1
3 files changed, 94 insertions, 0 deletions
diff --git a/src/static_libs/draw/draw.h b/src/static_libs/draw/draw.h
index b3393d2..f25f66d 100644
--- a/src/static_libs/draw/draw.h
+++ b/src/static_libs/draw/draw.h
@@ -26,6 +26,9 @@ Draw_Func_ARGB_Mix3 efl_draw_func_argb_mix3_get (Efl_Gfx_Render_Op op, uint3
26Draw_Func_Alpha efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_Bool has_mask); 26Draw_Func_Alpha efl_draw_alpha_func_get (Efl_Gfx_Render_Op op, Eina_Bool has_mask);
27Cspace_Convert_Func efl_draw_convert_func_get (Efl_Gfx_Colorspace origcs, Efl_Gfx_Colorspace dstcs, Eina_Bool *region_can); 27Cspace_Convert_Func efl_draw_convert_func_get (Efl_Gfx_Colorspace origcs, Efl_Gfx_Colorspace dstcs, Eina_Bool *region_can);
28 28
29int efl_draw_argb_premul(uint32_t *data, unsigned int len);
30void efl_draw_argb_unpremul(uint32_t *data, unsigned int len);
31
29 32
30/* common sw draw helpers */ 33/* common sw draw helpers */
31 34
diff --git a/src/static_libs/draw/draw_convert.c b/src/static_libs/draw/draw_convert.c
index 4e29d9e..1c65f4d 100644
--- a/src/static_libs/draw/draw_convert.c
+++ b/src/static_libs/draw/draw_convert.c
@@ -2,6 +2,10 @@
2#include "draw_private.h" 2#include "draw_private.h"
3#include "../rg_etc/rg_etc1.h" 3#include "../rg_etc/rg_etc1.h"
4 4
5#ifdef BUILD_NEON
6#include <arm_neon.h>
7#endif
8
5#if DIV_USING_BITSHIFT 9#if DIV_USING_BITSHIFT
6# define DEFINE_DIVIDER(div) const int pow2 = _pow2_geq((div) << 10); const int numerator = (1 << pow2) / (div); 10# define DEFINE_DIVIDER(div) const int pow2 = _pow2_geq((div) << 10); const int numerator = (1 << pow2) / (div);
7# define DIVIDE(val) (((val) * numerator) >> pow2) 11# define DIVIDE(val) (((val) * numerator) >> pow2)
@@ -526,3 +530,89 @@ efl_draw_convert_func_get(Efl_Gfx_Colorspace srccs, Efl_Gfx_Colorspace dstcs,
526 if (region_can) *region_can = EINA_FALSE; 530 if (region_can) *region_can = EINA_FALSE;
527 return NULL; 531 return NULL;
528} 532}
533
534int
535efl_draw_argb_premul(uint32_t *data, unsigned int len)
536{
537 uint32_t *de = data + len;
538 int nas = 0;
539
540#ifdef BUILD_NEON
541 if (eina_cpu_features_get() & EINA_CPU_NEON)
542 {
543 uint8x8_t mask_0x00 = vdup_n_u8(0);
544 uint8x8_t mask_0x01 = vdup_n_u8(1);
545 uint8x8_t mask_0xff = vdup_n_u8(255);
546 uint8x8_t cmp;
547 uint64x1_t tmp;
548
549 while (data <= de - 8)
550 {
551 uint8x8x4_t rgba = vld4_u8((uint8_t *) data);
552
553 cmp = vand_u8(vorr_u8(vceq_u8(rgba.val[3], mask_0xff),
554 vceq_u8(rgba.val[3], mask_0x00)),
555 mask_0x01);
556 tmp = vpaddl_u32(vpaddl_u16(vpaddl_u8(cmp)));
557 nas += vget_lane_u32(vreinterpret_u32_u64(tmp), 0);
558
559 uint16x8x4_t lrgba;
560 lrgba.val[0] = vmovl_u8(rgba.val[0]);
561 lrgba.val[1] = vmovl_u8(rgba.val[1]);
562 lrgba.val[2] = vmovl_u8(rgba.val[2]);
563 lrgba.val[3] = vaddl_u8(rgba.val[3], mask_0x01);
564
565 rgba.val[0] = vshrn_n_u16(vmlaq_u16(lrgba.val[0], lrgba.val[0],
566 lrgba.val[3]), 8);
567 rgba.val[1] = vshrn_n_u16(vmlaq_u16(lrgba.val[1], lrgba.val[1],
568 lrgba.val[3]), 8);
569 rgba.val[2] = vshrn_n_u16(vmlaq_u16(lrgba.val[2], lrgba.val[2],
570 lrgba.val[3]), 8);
571 vst4_u8((uint8_t *) data, rgba);
572 data += 8;
573 }
574 }
575#endif
576
577 while (data < de)
578 {
579 uint32_t a = 1 + (*data >> 24);
580
581 *data = (*data & 0xff000000) +
582 (((((*data) >> 8) & 0xff) * a) & 0xff00) +
583 (((((*data) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff);
584 data++;
585
586 if ((a == 1) || (a == 256))
587 nas++;
588 }
589
590 return nas;
591}
592
593void
594efl_draw_argb_unpremul(uint32_t *data, unsigned int len)
595{
596 uint32_t *de = data + len;
597 uint32_t p_val = 0x00000000, p_res = 0x00000000;
598
599 while (data < de)
600 {
601 uint32_t a = (*data >> 24);
602
603 if (p_val == *data) *data = p_res;
604 else
605 {
606 p_val = *data;
607 if ((a > 0) && (a < 255))
608 *data = DRAW_ARGB_JOIN(a,
609 (R_VAL(data) * 255) / a,
610 (G_VAL(data) * 255) / a,
611 (B_VAL(data) * 255) / a);
612 else if (a == 0)
613 *data = 0x00000000;
614 p_res = *data;
615 }
616 data++;
617 }
618}
diff --git a/src/static_libs/draw/draw_main_neon.c b/src/static_libs/draw/draw_main_neon.c
index 24b3d01..1c3a911 100644
--- a/src/static_libs/draw/draw_main_neon.c
+++ b/src/static_libs/draw/draw_main_neon.c
@@ -217,6 +217,7 @@ void
217efl_draw_neon_init(void) 217efl_draw_neon_init(void)
218{ 218{
219#ifdef BUILD_NEON 219#ifdef BUILD_NEON
220 if (getenv("EVAS_CPU_NO_NEON")) return; // compat with evas env vars
220 if (eina_cpu_features_get() & EINA_CPU_NEON) 221 if (eina_cpu_features_get() & EINA_CPU_NEON)
221 { 222 {
222 // update the comp_function table for solid color 223 // update the comp_function table for solid color