summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 11:22:36 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 17:33:18 +0900
commit71080b220e29228ce593d55b0329ce4862d3bb98 (patch)
treef25f11c4cbd63e7153cfd0929cbdfd5e071428a0
parent22e94df0f7b7e29725b685e6b0d541875d062d1b (diff)
Evas filters: Prevent buffer creation when running filter
In async mode, the filter runs in the render thread, so can't allocate buffers on the fly. This case should not happen, unless maybe a source has a null size (eg. it's invisible and not properly rendered).
-rw-r--r--src/lib/evas/filters/evas_filter.c80
-rw-r--r--src/lib/evas/filters/evas_filter_private.h1
2 files changed, 15 insertions, 66 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 0c8a6a3bd9..215f88fdef 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -347,68 +347,6 @@ _rgba_image_alloc(Evas_Filter_Buffer const *fb, void *data)
347 return image; 347 return image;
348} 348}
349 349
350/*
351Eina_Bool
352evas_filter_buffer_alloc(Evas_Filter_Buffer *fb, int w, int h)
353{
354 if (!fb) return EINA_FALSE;
355 INF("Allocate buffer %d: backing %p", fb->id, fb->backing);
356 if (fb->backing)
357 {
358 RGBA_Image *im;
359 int W, H;
360
361 if (fb->ctx->gl_engine)
362 {
363 // This needs to be counter-checked.
364 INF("Nope, gl engine is used");
365 return EINA_TRUE;
366 }
367
368 im = fb->backing;
369 if (!im->image.data)
370 {
371 if (fb->allocated)
372 fb->ENFN->image_free(fb->ENDT, im);
373 fb->allocated = EINA_FALSE;
374 fb->backing = NULL;
375 }
376 else
377 {
378 fb->ENFN->image_size_get(fb->ENDT, fb->backing, &W, &H);
379 if ((W == w) && (H == h))
380 {
381 INF("Nope, already fine");
382 return EINA_TRUE;
383 }
384
385 if (!fb->transient)
386 ERR("Buffer dimensions mismatch with external image!");
387 _filter_buffer_backing_free(fb);
388 }
389 }
390 if ((fb->w && (fb->w != w)) || (fb->h && (fb->h != h)))
391 {
392 ERR("Buffer dimensions mismatch!");
393 //return EINA_FALSE;
394 }
395 if (fb->allocated && fb->backing)
396 {
397 RGBA_Image *a = fb->backing;
398 INF("Already allocated. Is that true? backing %p and data %p", a, a?a->image.data:NULL);
399 return EINA_TRUE;
400 }
401 fb->w = w;
402 fb->h = h;
403
404 fb->backing = _rgba_image_alloc(fb, NULL);
405 fb->allocated = (fb->backing != NULL);
406 RGBA_Image *a = fb->backing;
407 INF("Allocated buf %d with backing %p data %p", fb->id, fb->backing, a?a->image.data:0);
408 return fb->allocated;
409}
410*/
411
412Eina_Bool 350Eina_Bool
413evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx, 351evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
414 unsigned w, unsigned h) 352 unsigned w, unsigned h)
@@ -516,7 +454,7 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
516 continue; 454 continue;
517 } 455 }
518 456
519 //DBG("Allocating buffer of size %ux%u", fb->w, fb->h); 457 //DBG("Allocating buffer of size %ux%u alpha %d", fb->w, fb->h, fb->alpha_only);
520 ie = (Image_Entry *) _rgba_image_alloc(fb, NULL); 458 ie = (Image_Entry *) _rgba_image_alloc(fb, NULL);
521 if (!ie) 459 if (!ie)
522 { 460 {
@@ -787,6 +725,12 @@ evas_filter_temporary_buffer_get(Evas_Filter_Context *ctx, int w, int h,
787 } 725 }
788 } 726 }
789 727
728 if (ctx->running && ctx->async)
729 {
730 ERR("Can not create a new buffer from this thread!");
731 return NULL;
732 }
733
790 buf = _buffer_new(ctx, w, h, alpha_only); 734 buf = _buffer_new(ctx, w, h, alpha_only);
791 buf->locked = EINA_TRUE; 735 buf->locked = EINA_TRUE;
792 INF("Created temporary buffer: %d", buf->id); 736 INF("Created temporary buffer: %d", buf->id);
@@ -1661,19 +1605,23 @@ _filter_chain_run(Evas_Filter_Context *ctx)
1661 Evas_Filter_Command *cmd; 1605 Evas_Filter_Command *cmd;
1662 Eina_Bool ok = EINA_TRUE; 1606 Eina_Bool ok = EINA_TRUE;
1663 1607
1608 ctx->running = EINA_TRUE;
1664 EINA_INLIST_FOREACH(ctx->commands, cmd) 1609 EINA_INLIST_FOREACH(ctx->commands, cmd)
1665 { 1610 {
1666 ok = _filter_command_run(cmd); 1611 ok = _filter_command_run(cmd);
1667 if (!ok) 1612 if (!ok)
1668 { 1613 {
1669 ERR("Filter processing failed!"); 1614 ERR("Filter processing failed!");
1670 return EINA_FALSE; 1615 goto end;
1671 } 1616 }
1672 } 1617 }
1673 1618
1674 if (!ok) return EINA_FALSE; 1619 if (!ok) goto end;
1620 ok = _filter_target_render(ctx);
1675 1621
1676 return _filter_target_render(ctx); 1622end:
1623 ctx->running = EINA_FALSE;
1624 return ok;
1677} 1625}
1678 1626
1679static void 1627static void
diff --git a/src/lib/evas/filters/evas_filter_private.h b/src/lib/evas/filters/evas_filter_private.h
index eeacd42ab6..544d76717c 100644
--- a/src/lib/evas/filters/evas_filter_private.h
+++ b/src/lib/evas/filters/evas_filter_private.h
@@ -66,6 +66,7 @@ struct _Evas_Filter_Context
66 66
67 Eina_Bool async : 1; 67 Eina_Bool async : 1;
68 Eina_Bool gl_engine : 1; 68 Eina_Bool gl_engine : 1;
69 Eina_Bool running : 1;
69}; 70};
70 71
71struct _Evas_Filter_Command 72struct _Evas_Filter_Command