summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-04-26 13:44:33 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-04-26 13:47:46 -0500
commit83adbadc892b6f98c036b8956d3f1466341a029c (patch)
tree39f01b71120f8533daf492451b2e324757a6a672 /src/lib/evas/common
parenta4ed205071da5e162633e86d624c8b6c9e652273 (diff)
evas: Add a function to block for render thread completion
This is needed by dmabuf engine fallback when it realizes it locally allocated a buffer, has been rendering to it, but the compositor can't use it. So the engine copies its buffer contents into a new wl_shm buffer and continues from there - however we need to make sure the async renderer has finished first, so we don't copy a partial buffer. This allows us to block for all previously submit actions in the render queue to complete.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_thread_render.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c
index 85955669ac..210404227e 100644
--- a/src/lib/evas/common/evas_thread_render.c
+++ b/src/lib/evas/common/evas_thread_render.c
@@ -72,6 +72,47 @@ evas_thread_queue_flush(Evas_Thread_Command_Cb cb, void *data)
72 evas_thread_queue_append(cb, data, EINA_TRUE); 72 evas_thread_queue_append(cb, data, EINA_TRUE);
73} 73}
74 74
75struct fence_stuff {
76 Eina_Lock lock;
77 Eina_Condition cond;
78};
79
80static void
81_evas_thread_queue_fence(void *data)
82{
83 struct fence_stuff *f;
84
85 f = data;
86
87 eina_lock_take(&f->lock);
88 eina_condition_signal(&f->cond);
89 eina_lock_release(&f->lock);
90}
91
92EAPI void
93evas_thread_queue_wait(void)
94{
95 struct fence_stuff f;
96
97 /* No shortcuts here - if the thread queue looks empty it could just mean
98 * it's being processed. Need a round trip.
99 */
100 if (!eina_lock_new(&f.lock)) return;
101 if (!eina_condition_new(&f.cond, &f.lock))
102 {
103 eina_lock_free(&f.lock);
104 return;
105 }
106
107 eina_lock_take(&f.lock);
108 evas_thread_queue_flush(_evas_thread_queue_fence, &f);
109 eina_condition_wait(&f.cond);
110 eina_lock_release(&f.lock);
111
112 eina_lock_free(&f.lock);
113 eina_condition_free(&f.cond);
114}
115
75static void* 116static void*
76evas_thread_worker_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED) 117evas_thread_worker_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
77{ 118{