#define MY_CLASS_NAME "Evas_Text"
+#ifdef EVAS_CSERVE2
+# include "evas_cs2_private.h"
+#endif
+
/* save typing */
#define ENFN obj->layer->evas->engine.func
#define ENDT obj->layer->evas->engine.data.output
void *filter_ctx;
Eina_Bool ok;
+ /* NOTE: Font effect rendering is now done ENTIRELY on CPU.
+ * So we rely on cache/cache2 to allocate a real image buffer,
+ * that we can draw to. The OpenGL texture will be created only
+ * after the rendering has been done, as we simply push the output
+ * image to GL.
+ */
+
W = obj->cur->geometry.w;
H = obj->cur->geometry.h;
X = obj->cur->geometry.x;
filter_ctx = ENFN->context_new(ENDT);
ENFN->context_color_set(ENDT, filter_ctx, 255, 255, 255, 255);
- // Alloc input now
+ // Alloc input now so we can draw text asap
evas_filter_buffer_data_set(filter, inbuf, NULL, W, H, EINA_TRUE);
input = evas_filter_buffer_backing_get(filter, inbuf);
// Allocate output so we can keep it around
- outputimg = ENFN->image_new_from_copied_data
- (ENDT, W, H, NULL, EINA_TRUE, EVAS_COLORSPACE_ARGB8888);
- memset(outputimg->image.data, 0, W * H * sizeof(DATA32));
- evas_filter_buffer_data_set
- (filter, outbuf, outputimg->image.data, W, H, EINA_FALSE);
+ evas_filter_buffer_data_set(filter, outbuf, NULL, W, H, EINA_FALSE);
+ outputimg = evas_filter_buffer_backing_get(filter, outbuf);
o->cur.filter.output = outputimg;
// Render text to input buffer
#include "evas_private.h"
#include "evas_filter_private.h"
+#ifdef EVAS_CSERVE2
+# include "evas_cs2_private.h"
+#endif
+
static void _buffer_free(Evas_Filter_Buffer *fb);
static void _command_del(Evas_Filter_Context *ctx, Evas_Filter_Command *cmd);
{
Evas_Filter_Context *ctx;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(evas, NULL);
+
ctx = calloc(1, sizeof(Evas_Filter_Context));
if (!ctx) return NULL;
ctx->evas = evas;
+ ctx->gl_engine = !!strstr(evas->engine.module->definition->name, "gl");
+
return ctx;
}
// Note: don't reset post_run, as it it set by the client
}
+static void
+_filter_buffer_backing_free(Evas_Filter_Buffer *fb)
+{
+ void *backing;
+ if (!fb) return;
+
+ backing = fb->backing;
+ fb->backing = NULL;
+
+ if (!fb->allocated) return;
+ fb->allocated = EINA_FALSE;
+
+ if (!backing) return;
+
+ if (!fb->ctx->gl_engine)
+ fb->ENFN->image_free(fb->ENDT, backing);
+ else
+ {
+ if (!evas_cserve2_use_get())
+ evas_cache_image_drop(backing);
+ else
+ evas_cache2_image_close(backing);
+ }
+}
+
/** @hidden private bind proxy to context */
void
evas_filter_context_proxy_bind(Evas_Filter_Context *ctx, Evas_Object *eo_proxy,
if (source->proxy->surface && !source->proxy->redraw)
{
INF("Source already rendered");
- if (fb->backing && fb->allocated)
- fb->ENFN->image_free(fb->ENDT, fb->backing);
+ _filter_buffer_backing_free(fb);
fb->backing = source->proxy->surface;
fb->w = source->cur->geometry.w;
fb->h = source->cur->geometry.h;
{
INF("Source needs to be rendered");
_proxy_subrender(ctx->evas->evas, fb->source, eo_obj, obj, do_async);
- if (fb->backing && fb->allocated)
- fb->ENFN->image_free(fb->ENDT, fb->backing);
+ _filter_buffer_backing_free(fb);
fb->backing = source->proxy->surface;
fb->w = source->cur->geometry.w;
fb->h = source->cur->geometry.h;
size_t sz;
cspace = fb->alpha_only ? EVAS_COLORSPACE_GRY8 : EVAS_COLORSPACE_ARGB8888;
- if (!data)
+ if (!fb->ctx->gl_engine)
{
- image = fb->ENFN->image_new_from_copied_data
- (fb->ENDT, fb->w, fb->h, NULL, EINA_TRUE, cspace);
+ if (!data)
+ {
+ image = fb->ENFN->image_new_from_copied_data
+ (fb->ENDT, fb->w, fb->h, NULL, EINA_TRUE, cspace);
+ }
+ else
+ {
+ image = fb->ENFN->image_new_from_data
+ (fb->ENDT, fb->w, fb->h, data, EINA_TRUE, cspace);
+ }
}
else
{
- image = fb->ENFN->image_new_from_data
- (fb->ENDT, fb->w, fb->h, data, EINA_TRUE, cspace);
+ WRN("EXPERIMENTAL OpenGL support. VERY HACKISH!");
+ // FIXME: Directly calling the alloc functions since we want to use sw surfaces.
+
+ if (!data)
+ {
+ if (!evas_cserve2_use_get())
+ image = (RGBA_Image *) evas_cache_image_copied_data
+ (evas_common_image_cache_get(), fb->w, fb->h, NULL, EINA_TRUE, cspace);
+ else
+ image = (RGBA_Image *) evas_cache2_image_copied_data
+ (evas_common_image_cache2_get(), fb->w, fb->h, NULL, EINA_TRUE, cspace);
+ }
+ else
+ {
+ if (!evas_cserve2_use_get())
+ image = (RGBA_Image *) evas_cache_image_data
+ (evas_common_image_cache_get(), fb->w, fb->h, data, EINA_TRUE, cspace);
+ else
+ image = (RGBA_Image *) evas_cache2_image_data
+ (evas_common_image_cache2_get(), fb->w, fb->h, data, EINA_TRUE, cspace);
+ }
}
if (!image) return EINA_FALSE;
//return EINA_FALSE;
return EINA_TRUE;
}
- fb->ENFN->image_free(fb->ENDT, fb->backing);
- fb->backing = NULL;
- fb->allocated = EINA_FALSE;
+ _filter_buffer_backing_free(fb);
}
if ((fb->w && (fb->w != w)) || (fb->h && (fb->h != h)))
{
fb = _filter_buffer_get(ctx, bufid);
if (!fb) return EINA_FALSE;
- if (fb->allocated)
- fb->ENFN->image_free(fb->ENDT, fb->backing);
- fb->allocated = EINA_FALSE;
- fb->backing = NULL;
+ _filter_buffer_backing_free(fb);
if (w <= 0 || h <= 0)
return EINA_FALSE;
static void
_buffer_free(Evas_Filter_Buffer *fb)
{
- if (!fb) return;
- if (fb->allocated)
- fb->ENFN->image_free(fb->ENDT, fb->backing);
+ _filter_buffer_backing_free(fb);
free(fb);
}
// FIXME: Must call engine function, not CPU directly.
if (strncmp(cmd->ctx->evas->engine.module->definition->name, "software", 8))
- CRI("Only the software engine is supported for now.");
+ WRN("EXPERIMENTAL OpenGL support! ALL HELL WILL BREAK LOOSE!");
switch (cmd->mode)
{