Lines Matching +full:- +full:- +full:local

31 #include "vnc-jobs.h"
33 #include "qemu/main-loop.h"
41 * - jobs queue lock: for each operation on the queue (push, pop, isEmpty?)
42 * - VncDisplay global lock: mainly used for framebuffer updates to avoid
45 * - VncState::output lock: used to make sure the output buffer is not corrupted
53 * and copy its output buffer in vs->output.
74 qemu_mutex_lock(&queue->mutex); in vnc_lock_queue()
79 qemu_mutex_unlock(&queue->mutex); in vnc_unlock_queue()
86 assert(vs->magic == VNC_MAGIC); in vnc_job_new()
87 job->vs = vs; in vnc_job_new()
89 QLIST_INIT(&job->rectangles); in vnc_job_new()
98 trace_vnc_job_add_rect(job->vs, job, x, y, w, h); in vnc_job_add_rect()
100 entry->rect.x = x; in vnc_job_add_rect()
101 entry->rect.y = y; in vnc_job_add_rect()
102 entry->rect.w = w; in vnc_job_add_rect()
103 entry->rect.h = h; in vnc_job_add_rect()
106 QLIST_INSERT_HEAD(&job->rectangles, entry, next); in vnc_job_add_rect()
114 if (queue->exit || QLIST_EMPTY(&job->rectangles)) { in vnc_job_push()
117 QTAILQ_INSERT_TAIL(&queue->jobs, job, next); in vnc_job_push()
118 qemu_cond_broadcast(&queue->cond); in vnc_job_push()
127 QTAILQ_FOREACH(job, &queue->jobs, next) { in vnc_has_job_locked()
128 if (job->vs == vs || !vs) { in vnc_has_job_locked()
139 qemu_cond_wait(&queue->cond, &queue->mutex); in vnc_jobs_join()
150 if (vs->jobs_buffer.offset) { in vnc_jobs_consume_buffer()
151 if (vs->ioc != NULL && buffer_empty(&vs->output)) { in vnc_jobs_consume_buffer()
152 if (vs->ioc_tag) { in vnc_jobs_consume_buffer()
153 g_source_remove(vs->ioc_tag); in vnc_jobs_consume_buffer()
155 if (vs->disconnecting == FALSE) { in vnc_jobs_consume_buffer()
156 vs->ioc_tag = qio_channel_add_watch( in vnc_jobs_consume_buffer()
157 vs->ioc, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_OUT, in vnc_jobs_consume_buffer()
161 buffer_move(&vs->output, &vs->jobs_buffer); in vnc_jobs_consume_buffer()
163 if (vs->job_update == VNC_STATE_UPDATE_FORCE) { in vnc_jobs_consume_buffer()
164 vs->force_update_offset = vs->output.offset; in vnc_jobs_consume_buffer()
166 vs->job_update = VNC_STATE_UPDATE_NONE; in vnc_jobs_consume_buffer()
168 flush = vs->ioc != NULL && vs->abort != true; in vnc_jobs_consume_buffer()
177 * Copy data for local use
179 static void vnc_async_encoding_start(VncState *orig, VncState *local) in vnc_async_encoding_start() argument
181 buffer_init(&local->output, "vnc-worker-output"); in vnc_async_encoding_start()
182 local->sioc = NULL; /* Don't do any network work on this thread */ in vnc_async_encoding_start()
183 local->ioc = NULL; /* Don't do any network work on this thread */ in vnc_async_encoding_start()
185 local->vnc_encoding = orig->vnc_encoding; in vnc_async_encoding_start()
186 local->features = orig->features; in vnc_async_encoding_start()
187 local->vd = orig->vd; in vnc_async_encoding_start()
188 local->lossy_rect = orig->lossy_rect; in vnc_async_encoding_start()
189 local->write_pixels = orig->write_pixels; in vnc_async_encoding_start()
190 local->client_pf = orig->client_pf; in vnc_async_encoding_start()
191 local->client_endian = orig->client_endian; in vnc_async_encoding_start()
192 local->tight = orig->tight; in vnc_async_encoding_start()
193 local->zlib = orig->zlib; in vnc_async_encoding_start()
194 local->hextile = orig->hextile; in vnc_async_encoding_start()
195 local->zrle = orig->zrle; in vnc_async_encoding_start()
196 local->client_width = orig->client_width; in vnc_async_encoding_start()
197 local->client_height = orig->client_height; in vnc_async_encoding_start()
200 static void vnc_async_encoding_end(VncState *orig, VncState *local) in vnc_async_encoding_end() argument
202 buffer_free(&local->output); in vnc_async_encoding_end()
203 orig->tight = local->tight; in vnc_async_encoding_end()
204 orig->zlib = local->zlib; in vnc_async_encoding_end()
205 orig->hextile = local->hextile; in vnc_async_encoding_end()
206 orig->zrle = local->zrle; in vnc_async_encoding_end()
207 orig->lossy_rect = local->lossy_rect; in vnc_async_encoding_end()
212 trace_vnc_job_clamp_rect(vs, job, rect->x, rect->y, rect->w, rect->h); in vnc_worker_clamp_rect()
214 if (rect->x >= vs->client_width) { in vnc_worker_clamp_rect()
217 rect->w = MIN(vs->client_width - rect->x, rect->w); in vnc_worker_clamp_rect()
218 if (rect->w == 0) { in vnc_worker_clamp_rect()
222 if (rect->y >= vs->client_height) { in vnc_worker_clamp_rect()
225 rect->h = MIN(vs->client_height - rect->y, rect->h); in vnc_worker_clamp_rect()
226 if (rect->h == 0) { in vnc_worker_clamp_rect()
230 trace_vnc_job_clamped_rect(vs, job, rect->x, rect->y, rect->w, rect->h); in vnc_worker_clamp_rect()
234 trace_vnc_job_discard_rect(vs, job, rect->x, rect->y, rect->w, rect->h); in vnc_worker_clamp_rect()
247 while (QTAILQ_EMPTY(&queue->jobs) && !queue->exit) { in vnc_worker_thread_loop()
248 qemu_cond_wait(&queue->cond, &queue->mutex); in vnc_worker_thread_loop()
250 /* Here job can only be NULL if queue->exit is true */ in vnc_worker_thread_loop()
251 job = QTAILQ_FIRST(&queue->jobs); in vnc_worker_thread_loop()
254 if (queue->exit) { in vnc_worker_thread_loop()
255 return -1; in vnc_worker_thread_loop()
258 assert(job->vs->magic == VNC_MAGIC); in vnc_worker_thread_loop()
260 vnc_lock_output(job->vs); in vnc_worker_thread_loop()
261 if (job->vs->ioc == NULL || job->vs->abort == true) { in vnc_worker_thread_loop()
262 vnc_unlock_output(job->vs); in vnc_worker_thread_loop()
265 if (buffer_empty(&job->vs->output)) { in vnc_worker_thread_loop()
271 buffer_move_empty(&vs.output, &job->vs->output); in vnc_worker_thread_loop()
273 vnc_unlock_output(job->vs); in vnc_worker_thread_loop()
275 /* Make a local copy of vs and switch output buffers */ in vnc_worker_thread_loop()
276 vnc_async_encoding_start(job->vs, &vs); in vnc_worker_thread_loop()
286 vnc_lock_display(job->vs->vd); in vnc_worker_thread_loop()
287 QLIST_FOREACH_SAFE(entry, &job->rectangles, next, tmp) { in vnc_worker_thread_loop()
290 if (job->vs->ioc == NULL) { in vnc_worker_thread_loop()
291 vnc_unlock_display(job->vs->vd); in vnc_worker_thread_loop()
293 vnc_async_encoding_end(job->vs, &vs); in vnc_worker_thread_loop()
297 if (vnc_worker_clamp_rect(&vs, job, &entry->rect)) { in vnc_worker_thread_loop()
298 n = vnc_send_framebuffer_update(&vs, entry->rect.x, entry->rect.y, in vnc_worker_thread_loop()
299 entry->rect.w, entry->rect.h); in vnc_worker_thread_loop()
308 vnc_unlock_display(job->vs->vd); in vnc_worker_thread_loop()
314 vnc_lock_output(job->vs); in vnc_worker_thread_loop()
315 if (job->vs->ioc != NULL) { in vnc_worker_thread_loop()
316 buffer_move(&job->vs->jobs_buffer, &vs.output); in vnc_worker_thread_loop()
318 vnc_async_encoding_end(job->vs, &vs); in vnc_worker_thread_loop()
320 qemu_bh_schedule(job->vs->bh); in vnc_worker_thread_loop()
324 vnc_async_encoding_end(job->vs, &vs); in vnc_worker_thread_loop()
326 vnc_unlock_output(job->vs); in vnc_worker_thread_loop()
330 QTAILQ_REMOVE(&queue->jobs, job, next); in vnc_worker_thread_loop()
332 qemu_cond_broadcast(&queue->cond); in vnc_worker_thread_loop()
342 qemu_cond_init(&queue->cond); in vnc_queue_init()
343 qemu_mutex_init(&queue->mutex); in vnc_queue_init()
344 QTAILQ_INIT(&queue->jobs); in vnc_queue_init()
350 qemu_cond_destroy(&queue->cond); in vnc_queue_clear()
351 qemu_mutex_destroy(&queue->mutex); in vnc_queue_clear()
360 qemu_thread_get_self(&queue->thread); in vnc_worker_thread()
380 qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread, q, in vnc_start_worker_thread()