static struct log_context *create_or_fetch_log_context(void *context) { pthread_mutex_lock(&log_contexts_mutex); for (size_t i = 0; i < active_log_contexts.num; i++) { if (context == active_log_contexts.array[i]->context) { pthread_mutex_unlock(&log_contexts_mutex); return active_log_contexts.array[i]; } } struct log_context *new_log_context = NULL; size_t cnt = cached_log_contexts.num; if (!!cnt) { new_log_context = cached_log_contexts.array[cnt - 1]; da_pop_back(cached_log_contexts); } if (!new_log_context) new_log_context = bzalloc(sizeof(struct log_context)); new_log_context->context = context; new_log_context->str[0] = '\0'; new_log_context->print_prefix = 1; da_push_back(active_log_contexts, &new_log_context); pthread_mutex_unlock(&log_contexts_mutex); return new_log_context; }
void device_projection_pop(device_t device) { struct matrix4 *end; if (!device->proj_stack.num) return; end = da_end(device->proj_stack); device->cur_proj = *end; da_pop_back(device->proj_stack); }
void gs_viewport_pop(void) { struct gs_rect *rect; if (!thread_graphics->viewport_stack.num) return; rect = da_end(thread_graphics->viewport_stack); gs_setviewport(rect->x, rect->y, rect->cx, rect->cy); da_pop_back(thread_graphics->viewport_stack); }