diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2012-12-30 23:39:11 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2012-12-30 23:39:11 +0000 |
commit | f8ea554926295213004c4a7917ffb10cac7dfd8f (patch) | |
tree | 0b3eb193efe9dc550dc09109f09c24ef96d4ed06 /src/lib/evas/canvas/evas_async_events.c | |
parent | 493f9a9ff9ba1a37664fa68be35ae31c15ecaba7 (diff) |
efl: limit regression with async rendering.
NOTE: There is still an issue with text rendering, that
is still 4 times slower and impact all text object (text,
textblock and textgrid).
SVN revision: 81912
Diffstat (limited to 'src/lib/evas/canvas/evas_async_events.c')
-rw-r--r-- | src/lib/evas/canvas/evas_async_events.c | 84 |
1 files changed, 65 insertions, 19 deletions
diff --git a/src/lib/evas/canvas/evas_async_events.c b/src/lib/evas/canvas/evas_async_events.c index 209ba8e..fe81be0 100644 --- a/src/lib/evas/canvas/evas_async_events.c +++ b/src/lib/evas/canvas/evas_async_events.c | |||
@@ -15,6 +15,9 @@ static int _fd_write = -1; | |||
15 | static int _fd_read = -1; | 15 | static int _fd_read = -1; |
16 | static pid_t _fd_pid = 0; | 16 | static pid_t _fd_pid = 0; |
17 | 17 | ||
18 | static Eina_Lock async_lock; | ||
19 | static Eina_Inarray async_queue; | ||
20 | |||
18 | static int _init_evas_event = 0; | 21 | static int _init_evas_event = 0; |
19 | 22 | ||
20 | typedef struct _Evas_Event_Async Evas_Event_Async; | 23 | typedef struct _Evas_Event_Async Evas_Event_Async; |
@@ -71,6 +74,9 @@ evas_async_events_init(void) | |||
71 | 74 | ||
72 | fcntl(_fd_read, F_SETFL, O_NONBLOCK); | 75 | fcntl(_fd_read, F_SETFL, O_NONBLOCK); |
73 | 76 | ||
77 | eina_lock_new(&async_lock); | ||
78 | eina_inarray_step_set(&async_queue, sizeof (Eina_Inarray), sizeof (Evas_Event_Async), 16); | ||
79 | |||
74 | return _init_evas_event; | 80 | return _init_evas_event; |
75 | } | 81 | } |
76 | 82 | ||
@@ -85,6 +91,9 @@ evas_async_events_shutdown(void) | |||
85 | _fd_read = -1; | 91 | _fd_read = -1; |
86 | _fd_write = -1; | 92 | _fd_write = -1; |
87 | 93 | ||
94 | eina_lock_free(&async_lock); | ||
95 | eina_inarray_flush(&async_queue); | ||
96 | |||
88 | return _init_evas_event; | 97 | return _init_evas_event; |
89 | } | 98 | } |
90 | 99 | ||
@@ -108,15 +117,40 @@ evas_async_events_fd_get(void) | |||
108 | static int | 117 | static int |
109 | _evas_async_events_process_single(void) | 118 | _evas_async_events_process_single(void) |
110 | { | 119 | { |
111 | Evas_Event_Async *ev; | 120 | int wakeup; |
112 | int ret; | 121 | int ret; |
113 | 122 | ||
114 | ret = read(_fd_read, &ev, sizeof(Evas_Event_Async *)); | 123 | ret = read(_fd_read, &wakeup, sizeof(int)); |
115 | if (ret == sizeof(Evas_Event_Async *)) | 124 | if (ret == sizeof(int)) |
116 | { | 125 | { |
117 | if (ev->func) ev->func((void *)ev->target, ev->type, ev->event_info); | 126 | static Evas_Event_Async *memory = NULL; |
118 | free(ev); | 127 | static unsigned int memory_max = 0; |
119 | return 1; | 128 | Evas_Event_Async *ev; |
129 | unsigned int len; | ||
130 | unsigned int max; | ||
131 | |||
132 | eina_lock_take(&async_lock); | ||
133 | |||
134 | ev = async_queue.members; | ||
135 | async_queue.members = memory; | ||
136 | memory = ev; | ||
137 | |||
138 | max = async_queue.max; | ||
139 | async_queue.max = memory_max; | ||
140 | memory_max = max; | ||
141 | |||
142 | len = async_queue.len; | ||
143 | async_queue.len = 0; | ||
144 | |||
145 | eina_lock_release(&async_lock); | ||
146 | |||
147 | while (len > 0) | ||
148 | { | ||
149 | if (ev->func) ev->func((void *)ev->target, ev->type, ev->event_info); | ||
150 | ev++; | ||
151 | len--; | ||
152 | } | ||
153 | ret = 1; | ||
120 | } | 154 | } |
121 | else if (ret < 0) | 155 | else if (ret < 0) |
122 | { | 156 | { |
@@ -179,32 +213,44 @@ EAPI Eina_Bool | |||
179 | evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_info, Evas_Async_Events_Put_Cb func) | 213 | evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_info, Evas_Async_Events_Put_Cb func) |
180 | { | 214 | { |
181 | Evas_Event_Async *ev; | 215 | Evas_Event_Async *ev; |
182 | ssize_t check; | 216 | ssize_t check = sizeof (int); |
183 | Eina_Bool result = EINA_FALSE; | 217 | Eina_Bool result = EINA_FALSE; |
218 | int count; | ||
184 | 219 | ||
185 | if (!func) return 0; | 220 | if (!func) return 0; |
186 | if (_fd_write == -1) return 0; | 221 | if (_fd_write == -1) return 0; |
187 | 222 | ||
188 | _evas_async_events_fork_handle(); | 223 | _evas_async_events_fork_handle(); |
189 | |||
190 | ev = calloc(1, sizeof (Evas_Event_Async)); | ||
191 | if (!ev) return 0; | ||
192 | 224 | ||
193 | ev->func = func; | 225 | eina_lock_take(&async_lock); |
194 | ev->target = target; | 226 | |
195 | ev->type = type; | 227 | count = async_queue.len; |
196 | ev->event_info = event_info; | 228 | ev = eina_inarray_add(&async_queue); |
229 | if (ev) | ||
230 | { | ||
231 | ev->func = func; | ||
232 | ev->target = target; | ||
233 | ev->type = type; | ||
234 | ev->event_info = event_info; | ||
235 | } | ||
236 | |||
237 | eina_lock_release(&async_lock); | ||
197 | 238 | ||
198 | do | 239 | if (count == 0 && ev) |
199 | { | 240 | { |
200 | check = write(_fd_write, &ev, sizeof (Evas_Event_Async*)); | 241 | int wakeup = 1; |
242 | |||
243 | do | ||
244 | { | ||
245 | check = write(_fd_write, &wakeup, sizeof (int)); | ||
246 | } | ||
247 | while ((check != sizeof (int)) && | ||
248 | ((errno == EINTR) || (errno == EAGAIN))); | ||
201 | } | 249 | } |
202 | while ((check != sizeof (Evas_Event_Async*)) && | ||
203 | ((errno == EINTR) || (errno == EAGAIN))); | ||
204 | 250 | ||
205 | evas_cache_image_wakeup(); | 251 | evas_cache_image_wakeup(); |
206 | 252 | ||
207 | if (check == sizeof (Evas_Event_Async*)) | 253 | if (check == sizeof (int)) |
208 | result = EINA_TRUE; | 254 | result = EINA_TRUE; |
209 | else | 255 | else |
210 | { | 256 | { |