From 4c4b44a575bb73f714329efaecf6fb4ea0d58c78 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 16 Jan 2014 14:38:11 +0900 Subject: [PATCH] Evas fitlers: Implement SLOW font draw to alpha targets Well, raster did some great job at optimizing font draw... but only to RGBA32 targets. In this font effects case, we also want to render text on ALPHA buffers. For now, reuse the existing alpha blending & glyph decompress functions. It's MUCH easier, and works. Definitely slower than decompressing on-the-fly and optimizing everything. But for now, this will not even be the performance bottleneck in an effect (blur will be a lot slower). --- src/lib/evas/common/evas_font_compress.c | 67 +++++++++++++++++------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/lib/evas/common/evas_font_compress.c b/src/lib/evas/common/evas_font_compress.c index a66e4761f4..1c615f9c7e 100644 --- a/src/lib/evas/common/evas_font_compress.c +++ b/src/lib/evas/common/evas_font_compress.c @@ -8,6 +8,7 @@ #include "evas_private.h" #include "evas_font_private.h" +#include "evas_blend_private.h" #ifdef EVAS_CSERVE2 # include "../cserve2/evas_cs2_private.h" @@ -449,8 +450,8 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret) int *iptr; if (!buf) return NULL; - *wret = fgo->bitmap.width; - *hret = fgo->bitmap.rows; + if (wret) *wret = fgo->bitmap.width; + if (hret) *hret = fgo->bitmap.rows; iptr = (int *)fgo->rle; if (*iptr > 0) // rle4 decompress_rle4(fgo->rle, buf, fgo->bitmap.width, @@ -488,37 +489,63 @@ evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, x1 = 0; x2 = w; if ((x + x1) < cx) x1 = cx - x; if ((x + x2) > (cx + cw)) x2 = cx + cw - x; - // build fast multiply + mask color tables to avoid compute. this works - // because of our very limited 4bit range of alpha values col = dc->col.col; - for (i = 0; i <= 0xf; i++) + if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8) { - v = (i << 4) | i; - coltab[i] = MUL_SYM(v, col); - tmp = (coltab[i] >> 24); - mtab[i] = 256 - (tmp + (tmp >> 7)); + // FIXME: Font draw not optimized for Alpha targets! SLOW! + // This is not pretty :) + + DATA8 *dst8 = dst_image->mask.data + x + (y * dst_pitch); + Alpha_Gfx_Func func; + DATA8 *src8; + int row; + + func = evas_common_alpha_func_get(dc->render_op); + src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); + if (!src8) return; + + for (row = y1; row < y2; row++) + { + DATA8 *d = dst8 + ((row - y1) * dst_pitch); + DATA8 *s = src8 + (row * w) + x1; + func(s, d, x2 - x1); + } + free(src8); } -#ifdef BUILD_MMX - if (evas_common_cpu_has_feature(CPU_FEATURE_MMX)) + else { + // build fast multiply + mask color tables to avoid compute. this works + // because of our very limited 4bit range of alpha values + for (i = 0; i <= 0xf; i++) + { + v = (i << 4) | i; + coltab[i] = MUL_SYM(v, col); + tmp = (coltab[i] >> 24); + mtab[i] = 256 - (tmp + (tmp >> 7)); + } +#ifdef BUILD_MMX + if (evas_common_cpu_has_feature(CPU_FEATURE_MMX)) + { #define MMX 1 #include "evas_font_compress_draw.c" #undef MMX - } - else + } + else #endif - + #ifdef BUILD_NEON - if (evas_common_cpu_has_feature(CPU_FEATURE_NEON)) - { + if (evas_common_cpu_has_feature(CPU_FEATURE_NEON)) + { #define NEON 1 #include "evas_font_compress_draw.c" #undef NEON - } - else + } + else #endif - - { + + // Plain C + { #include "evas_font_compress_draw.c" + } } }