summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-01-24 10:54:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-07 17:33:17 +0900
commit95550feb3015dda2e077f8eed3e3deba1f099b56 (patch)
tree1a43d98e84e458225c73044e2be2e4bb3d6d43d9
parent2e401c2e912c78d57a9b1805d9adf1bfac69d7e0 (diff)
Evas filters: Fix memory leaks with buffers
In async rendering case, basically all buffers were leaked or freed from the wrong thread. Fix that :)
-rw-r--r--src/lib/evas/filters/evas_filter.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 2f7fe8bdfe..cfaa1fc730 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -532,11 +532,9 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
532 ie = fb->backing; 532 ie = fb->backing;
533 if (ie) 533 if (ie)
534 { 534 {
535 if (ctx->async) 535 // Not checking for async. It's also safe for sync rendering.
536 { 536 ie->references++;
537 ie->references++; 537 evas_unref_queue_image_put(ctx->evas, ie);
538 evas_unref_queue_image_put(ctx->evas, ie);
539 }
540 continue; 538 continue;
541 } 539 }
542 540
@@ -561,11 +559,9 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx,
561 } 559 }
562 560
563 fb->backing = ie; 561 fb->backing = ie;
564 if (ctx->async) 562 fb->allocated = (ie != NULL);
565 { 563 if (ctx->async && fb->allocated)
566 ie->references++; 564 evas_unref_queue_image_put(ctx->evas, ie);
567 evas_unref_queue_image_put(ctx->evas, ie);
568 }
569 } 565 }
570 566
571 return EINA_TRUE; 567 return EINA_TRUE;
@@ -609,6 +605,8 @@ _filter_buffer_data_set(Evas_Filter_Context *ctx, int bufid, void *data,
609 605
610 fb->backing = _rgba_image_alloc(fb, data); 606 fb->backing = _rgba_image_alloc(fb, data);
611 fb->allocated = (!data && (fb->backing != NULL)); 607 fb->allocated = (!data && (fb->backing != NULL));
608 if (ctx->async && fb->allocated)
609 evas_unref_queue_image_put(ctx->evas, fb->backing);
612 return fb->allocated; 610 return fb->allocated;
613} 611}
614 612
@@ -706,7 +704,14 @@ evas_filter_buffer_backing_steal(Evas_Filter_Context *ctx, int bufid)
706 if (buffer->glimage) 704 if (buffer->glimage)
707 return buffer->glimage; 705 return buffer->glimage;
708 else 706 else
709 return buffer->backing; 707 {
708 if (ctx->async)
709 {
710 Image_Entry *ie = buffer->backing;
711 if (ie) ie->references++;
712 }
713 return buffer->backing;
714 }
710} 715}
711 716
712Eina_Bool 717Eina_Bool
@@ -727,14 +732,25 @@ evas_filter_buffer_backing_release(Evas_Filter_Context *ctx, void *stolen_buffer
727 if (fb->delete_me) 732 if (fb->delete_me)
728 { 733 {
729 ctx->buffers = eina_list_remove_list(ctx->buffers, li); 734 ctx->buffers = eina_list_remove_list(ctx->buffers, li);
730 _buffer_free(fb); 735 if (ctx->async)
736 {
737 if (fb->allocated)
738 evas_unref_queue_image_put(ctx->evas, ie);
739 free(fb);
740 }
741 else
742 _buffer_free(fb);
731 return EINA_TRUE; 743 return EINA_TRUE;
732 } 744 }
733 return EINA_TRUE; 745 return EINA_TRUE;
734 } 746 }
735 } 747 }
736 748
737 _backing_free(ctx, ie); 749 if (ctx->async)
750 evas_unref_queue_image_put(ctx->evas, ie);
751 else
752 _backing_free(ctx, ie);
753
738 return EINA_TRUE; 754 return EINA_TRUE;
739} 755}
740 756