summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-01-17 13:32:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 17:33:17 +0900
commitf007cd5665e1020fa9ee0a2966bfbc279fa49c73 (patch)
tree2e4120d18d39f14ecaff100cf940457a24103b79 /src
parent0135b45c125c603f7ae96941dbeba9a22d75691b (diff)
Evas filters: Move font draw inside the filters functions
Since the filters will have to decide on which engine (SW, GL) to choose from to render the font and the effects, move the font draw call inside the filters module.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_text.c44
-rw-r--r--src/lib/evas/filters/evas_filter.c64
-rw-r--r--src/lib/evas/include/evas_filter.h4
3 files changed, 85 insertions, 27 deletions
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 4c48b9088a..af3c48844f 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -2131,9 +2131,11 @@ evas_object_text_render(Evas_Object *eo_obj EINA_UNUSED,
2131 int inbuf = 1; 2131 int inbuf = 1;
2132 int outbuf = 2; 2132 int outbuf = 2;
2133 int targetbuf; 2133 int targetbuf;
2134 RGBA_Image *input, *outputimg; // FIXME: This is engine dependent 2134 RGBA_Image *input, *outputimg = NULL; // FIXME: This is engine dependent
2135 void *filter_ctx; 2135 void *filter_ctx;
2136 static int gl_engine = -1;
2136 Eina_Bool ok; 2137 Eina_Bool ok;
2138 int ox = 0, oy = 0;
2137 2139
2138 /* NOTE: Font effect rendering is now done ENTIRELY on CPU. 2140 /* NOTE: Font effect rendering is now done ENTIRELY on CPU.
2139 * So we rely on cache/cache2 to allocate a real image buffer, 2141 * So we rely on cache/cache2 to allocate a real image buffer,
@@ -2142,6 +2144,10 @@ evas_object_text_render(Evas_Object *eo_obj EINA_UNUSED,
2142 * image to GL. 2144 * image to GL.
2143 */ 2145 */
2144 2146
2147 // FIXME. Disabled redraw for OpenGL.
2148 if (gl_engine == -1)
2149 gl_engine = !!strstr(obj->layer->evas->engine.module->definition->name, "gl");
2150
2145 W = obj->cur->geometry.w; 2151 W = obj->cur->geometry.w;
2146 H = obj->cur->geometry.h; 2152 H = obj->cur->geometry.h;
2147 X = obj->cur->geometry.x; 2153 X = obj->cur->geometry.x;
@@ -2205,39 +2211,29 @@ evas_object_text_render(Evas_Object *eo_obj EINA_UNUSED,
2205 // Output 2211 // Output
2206 targetbuf = evas_filter_buffer_image_new(filter, surface); 2212 targetbuf = evas_filter_buffer_image_new(filter, surface);
2207 2213
2214 // Context: FIXME it should be a sw context only
2208 filter_ctx = ENFN->context_new(ENDT); 2215 filter_ctx = ENFN->context_new(ENDT);
2209 ENFN->context_color_set(ENDT, filter_ctx, 255, 255, 255, 255); 2216 ENFN->context_color_set(ENDT, filter_ctx, 255, 255, 255, 255);
2210 2217
2211 // Alloc input now so we can draw text asap 2218 // Alloc input now so we can draw text asap
2212 evas_filter_buffer_data_set(filter, inbuf, NULL, W, H, EINA_TRUE); 2219 evas_filter_buffer_data_set(filter, inbuf, NULL, W, H, EINA_TRUE);
2213 input = evas_filter_buffer_backing_get(filter, inbuf);
2214 2220
2215 // Allocate output so we can keep it around 2221 // Allocate and steal output so we can keep it around
2216 evas_filter_buffer_data_set(filter, outbuf, NULL, W, H, EINA_FALSE); 2222 evas_filter_buffer_data_set(filter, outbuf, NULL, W, H, EINA_FALSE);
2217 outputimg = evas_filter_buffer_backing_get(filter, outbuf); 2223 if (!gl_engine)
2224 outputimg = evas_filter_buffer_backing_steal(filter, outbuf);
2218 o->cur.filter.output = outputimg; 2225 o->cur.filter.output = outputimg;
2219 2226
2220 // Render text to input buffer 2227 // Render text to input buffer
2221 { 2228 EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
2222 int ox, oy; 2229 if ((o->font) && (it->text_props.len > 0))
2223 ox = 0; 2230 {
2224 oy = 0; 2231 evas_filter_font_draw(filter, filter_ctx, inbuf, o->font,
2225 2232 sl + ox + it->x,
2226 EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it) 2233 st + oy + (int) o->max_ascent,
2227 if ((o->font) && (it->text_props.len > 0)) 2234 &it->text_props,
2228 { 2235 do_async);
2229 evas_font_draw_async_check(obj, output, 2236 }
2230 filter_ctx,
2231 input,
2232 o->font,
2233 sl + ox + it->x,
2234 st + oy + (int) o->max_ascent,
2235 W, H,
2236 W, H,
2237 &it->text_props,
2238 do_async);
2239 }
2240 }
2241 2237
2242 // FIXME: This final blend is not necessary. Needs to be removed. 2238 // FIXME: This final blend is not necessary. Needs to be removed.
2243 evas_filter_command_blend_add(filter, context, outbuf, targetbuf, 2239 evas_filter_command_blend_add(filter, context, outbuf, targetbuf,
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 05f9db21e1..61563c0e8e 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -518,6 +518,18 @@ evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid)
518 return buffer->backing; 518 return buffer->backing;
519} 519}
520 520
521void *
522evas_filter_buffer_backing_steal(Evas_Filter_Context *ctx, int bufid)
523{
524 Evas_Filter_Buffer *buffer;
525
526 buffer = _filter_buffer_get(ctx, bufid);
527 if (!buffer) return NULL;
528
529 buffer->allocated = EINA_FALSE;
530 return buffer->backing;
531}
532
521static Evas_Filter_Command * 533static Evas_Filter_Command *
522_command_new(Evas_Filter_Context *ctx, Evas_Filter_Mode mode, 534_command_new(Evas_Filter_Context *ctx, Evas_Filter_Mode mode,
523 Evas_Filter_Buffer *input, Evas_Filter_Buffer *mask, 535 Evas_Filter_Buffer *input, Evas_Filter_Buffer *mask,
@@ -1199,6 +1211,49 @@ evas_filter_fill_cpu_func_get(Evas_Filter_Command *cmd)
1199} 1211}
1200 1212
1201 1213
1214/* Font drawing stuff */
1215Eina_Bool
1216evas_filter_font_draw(Evas_Filter_Context *ctx, void *draw_context, int bufid,
1217 Evas_Font_Set *font, int x, int y,
1218 Evas_Text_Props *text_props, Eina_Bool do_async)
1219{
1220 Eina_Bool async_unref;
1221 Evas_Filter_Buffer *fb;
1222 void *surface;
1223
1224 fb = _filter_buffer_get(ctx, bufid);
1225 if (!fb) return EINA_FALSE;
1226
1227 surface = fb->backing;
1228 if (!surface) return EINA_FALSE;
1229
1230 if (!ctx->gl_engine)
1231 {
1232 // Copied from evas_font_draw_async_check
1233 async_unref = ENFN->font_draw(ENDT, draw_context, surface,
1234 font, x, y, fb->w, fb->h, fb->w, fb->h,
1235 text_props, do_async);
1236 if (do_async && async_unref)
1237 {
1238 evas_common_font_glyphs_ref(text_props->glyphs);
1239 evas_unref_queue_glyph_put(ctx->evas, text_props->glyphs);
1240 }
1241 }
1242 else
1243 {
1244 // FIXME/GL: Render in software only.
1245 // Copied from eng_font_draw in the software engine.
1246
1247 if (do_async) WRN("Async flag is ignored here!");
1248 evas_common_font_draw_prepare(text_props);
1249 evas_common_font_draw(surface, draw_context, x, y, text_props->glyphs);
1250 evas_common_cpu_end_opt();
1251 }
1252
1253 return EINA_TRUE;
1254}
1255
1256
1202/* Clip full input rect (0, 0, sw, sh) to target (dx, dy, dw, dh) 1257/* Clip full input rect (0, 0, sw, sh) to target (dx, dy, dw, dh)
1203 * and get source's clipped sx, sy as well as destination x, y, cols and rows */ 1258 * and get source's clipped sx, sy as well as destination x, y, cols and rows */
1204void 1259void
@@ -1286,10 +1341,13 @@ _filter_command_run(Evas_Filter_Command *cmd)
1286 return EINA_TRUE; 1341 return EINA_TRUE;
1287 } 1342 }
1288 1343
1289 if (!cmd->output->backing && !cmd->output->w && !cmd->output->h) 1344 if (!cmd->output->w && !cmd->output->h)
1290 { 1345 {
1291 cmd->output->w = cmd->ctx->w; 1346 if (!cmd->output->backing)
1292 cmd->output->h = cmd->ctx->h; 1347 {
1348 cmd->output->w = cmd->ctx->w;
1349 cmd->output->h = cmd->ctx->h;
1350 }
1293 } 1351 }
1294 1352
1295 if ((cmd->output->w <= 0) || (cmd->output->h <= 0)) 1353 if ((cmd->output->w <= 0) || (cmd->output->h <= 0))
diff --git a/src/lib/evas/include/evas_filter.h b/src/lib/evas/include/evas_filter.h
index 6c39e0e72d..1b68d8a557 100644
--- a/src/lib/evas/include/evas_filter.h
+++ b/src/lib/evas/include/evas_filter.h
@@ -2,6 +2,7 @@
2#define _EVAS_FILTER_H 2#define _EVAS_FILTER_H
3 3
4#include "evas_common_private.h" 4#include "evas_common_private.h"
5#include "evas_private.h"
5 6
6typedef struct _Evas_Filter_Context Evas_Filter_Context; 7typedef struct _Evas_Filter_Context Evas_Filter_Context;
7typedef struct _Evas_Filter_Command Evas_Filter_Command; 8typedef struct _Evas_Filter_Command Evas_Filter_Command;
@@ -106,10 +107,13 @@ int evas_filter_buffer_image_new(Evas_Filter_Context *ctx,
106int evas_filter_buffer_data_new(Evas_Filter_Context *ctx, void *data, int w, int h, Eina_Bool alpha_only); 107int evas_filter_buffer_data_new(Evas_Filter_Context *ctx, void *data, int w, int h, Eina_Bool alpha_only);
107#define evas_filter_buffer_alloc_new(ctx, w, h, a) evas_filter_buffer_data_new(ctx, NULL, w, h, a) 108#define evas_filter_buffer_alloc_new(ctx, w, h, a) evas_filter_buffer_data_new(ctx, NULL, w, h, a)
108void *evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid); 109void *evas_filter_buffer_backing_get(Evas_Filter_Context *ctx, int bufid);
110void *evas_filter_buffer_backing_steal(Evas_Filter_Context *ctx, int bufid);
109Eina_Bool evas_filter_buffer_data_set(Evas_Filter_Context *ctx, int bufid, void *data, int w, int h, Eina_Bool alpha_only); 111Eina_Bool evas_filter_buffer_data_set(Evas_Filter_Context *ctx, int bufid, void *data, int w, int h, Eina_Bool alpha_only);
110 112
111Eina_Bool evas_filter_run(Evas_Filter_Context *ctx, Eina_Bool do_async); 113Eina_Bool evas_filter_run(Evas_Filter_Context *ctx, Eina_Bool do_async);
112 114
115Eina_Bool evas_filter_font_draw(Evas_Filter_Context *ctx, void *draw_context, int bufid, Evas_Font_Set *font, int x, int y, Evas_Text_Props *text_props, Eina_Bool do_async);
116
113/** 117/**
114 * @brief Blend a source buffer into a destination buffer, allowing X,Y offsets, Alpha to RGBA conversion with color 118 * @brief Blend a source buffer into a destination buffer, allowing X,Y offsets, Alpha to RGBA conversion with color
115 * @param ctx Current filter chain 119 * @param ctx Current filter chain