summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_async_events.c
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@profusion.mobi>2012-12-18 16:26:44 +0000
committerLeandro Pereira <leandro@profusion.mobi>2012-12-18 16:26:44 +0000
commita7b4a3c12d737462b09a71f25c5624f1489dd659 (patch)
treed0d20b4ba7457b1e661ddf67c2c73e24203e31a6 /src/lib/evas/canvas/evas_async_events.c
parent645dcff9d203e6315e6672a8ecbda66bc9b9dc53 (diff)
evas: Async render
SVN revision: 81282
Diffstat (limited to 'src/lib/evas/canvas/evas_async_events.c')
-rw-r--r--src/lib/evas/canvas/evas_async_events.c75
1 files changed, 52 insertions, 23 deletions
diff --git a/src/lib/evas/canvas/evas_async_events.c b/src/lib/evas/canvas/evas_async_events.c
index 172b20f..209ba8e 100644
--- a/src/lib/evas/canvas/evas_async_events.c
+++ b/src/lib/evas/canvas/evas_async_events.c
@@ -105,33 +105,20 @@ evas_async_events_fd_get(void)
105 return _fd_read; 105 return _fd_read;
106} 106}
107 107
108EAPI int 108static int
109evas_async_events_process(void) 109_evas_async_events_process_single(void)
110{ 110{
111 Evas_Event_Async *ev; 111 Evas_Event_Async *ev;
112 int check; 112 int ret;
113 int count = 0;
114
115 if (_fd_read == -1) return 0;
116 113
117 _evas_async_events_fork_handle(); 114 ret = read(_fd_read, &ev, sizeof(Evas_Event_Async *));
118 115 if (ret == sizeof(Evas_Event_Async *))
119 do
120 { 116 {
121 check = read(_fd_read, &ev, sizeof (Evas_Event_Async *)); 117 if (ev->func) ev->func((void *)ev->target, ev->type, ev->event_info);
122 118 free(ev);
123 if (check == sizeof (Evas_Event_Async *)) 119 return 1;
124 {
125 if (ev->func) ev->func((void *)ev->target, ev->type, ev->event_info);
126 free(ev);
127 count++;
128 }
129 } 120 }
130 while (check > 0); 121 else if (ret < 0)
131
132 evas_cache_image_wakeup();
133
134 if (check < 0)
135 { 122 {
136 switch (errno) 123 switch (errno)
137 { 124 {
@@ -139,13 +126,55 @@ evas_async_events_process(void)
139 case EINVAL: 126 case EINVAL:
140 case EIO: 127 case EIO:
141 case EISDIR: 128 case EISDIR:
142 _fd_read = -1; 129 _fd_read = -1;
143 } 130 }
144 } 131 }
145 132
133 return ret;
134}
135
136EAPI int
137evas_async_events_process(void)
138{
139 int count = 0;
140
141 if (_fd_read == -1) return 0;
142
143 _evas_async_events_fork_handle();
144
145 while (_evas_async_events_process_single() > 0) count++;
146
147 evas_cache_image_wakeup();
148
146 return count; 149 return count;
147} 150}
148 151
152static void
153_evas_async_events_fd_blocking_set(Eina_Bool blocking)
154{
155 long flags = fcntl(_fd_read, F_GETFL);
156
157 if (blocking) flags &= ~O_NONBLOCK;
158 else flags |= O_NONBLOCK;
159
160 fcntl(_fd_read, F_SETFL, flags);
161}
162
163int
164evas_async_events_process_blocking(void)
165{
166 int ret;
167
168 _evas_async_events_fork_handle();
169
170 _evas_async_events_fd_blocking_set(EINA_TRUE);
171 ret = _evas_async_events_process_single();
172 evas_cache_image_wakeup(); /* FIXME: is this needed ? */
173 _evas_async_events_fd_blocking_set(EINA_FALSE);
174
175 return ret;
176}
177
149EAPI Eina_Bool 178EAPI Eina_Bool
150evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_info, Evas_Async_Events_Put_Cb func) 179evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_info, Evas_Async_Events_Put_Cb func)
151{ 180{