Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/lineart/lineart_util.c
| Context not available. | |||||
| #include "lineart_intern.h" | #include "lineart_intern.h" | ||||
| /* Line art memory and list helper */ | /* Line art memory and list helper */ | ||||
| void *lineart_list_append_pointer_pool(ListBase *h, LineartStaticMemPool *smp, void *data) | void *lineart_list_append_pointer_pool(ListBase *h, LineartStaticMemPool *smp, void *data) | ||||
| { | { | ||||
| LinkData *lip; | LinkData *lip; | ||||
| if (h == NULL) { | if (h == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| lip = lineart_mem_aquire(smp, sizeof(LinkData)); | lip = lineart_mem_acquire(smp, sizeof(LinkData)); | ||||
| lip->data = data; | lip->data = data; | ||||
| BLI_addtail(h, lip); | BLI_addtail(h, lip); | ||||
| return lip; | return lip; | ||||
| } | } | ||||
| void *lineart_list_append_pointer_pool_sized(ListBase *h, | void *lineart_list_append_pointer_pool_sized(ListBase *h, | ||||
| LineartStaticMemPool *smp, | LineartStaticMemPool *smp, | ||||
| void *data, | void *data, | ||||
| int size) | int size) | ||||
| { | { | ||||
| LinkData *lip; | LinkData *lip; | ||||
| if (h == NULL) { | if (h == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| lip = lineart_mem_aquire(smp, size); | lip = lineart_mem_acquire(smp, size); | ||||
| lip->data = data; | lip->data = data; | ||||
| BLI_addtail(h, lip); | BLI_addtail(h, lip); | ||||
| return lip; | return lip; | ||||
| } | } | ||||
| void *lineart_list_pop_pointer_no_free(ListBase *h) | void *lineart_list_pop_pointer_no_free(ListBase *h) | ||||
| { | { | ||||
| LinkData *lip; | LinkData *lip; | ||||
| void *rev = 0; | void *rev = 0; | ||||
| if (h == NULL) { | if (h == NULL) { | ||||
| Context not available. | |||||
| if (set_size < LRT_MEMORY_POOL_64MB) { | if (set_size < LRT_MEMORY_POOL_64MB) { | ||||
| set_size = LRT_MEMORY_POOL_64MB; /* Prevent too many small allocations. */ | set_size = LRT_MEMORY_POOL_64MB; /* Prevent too many small allocations. */ | ||||
| } | } | ||||
| size_t total_size = size + sizeof(LineartStaticMemPoolNode); | size_t total_size = size + sizeof(LineartStaticMemPoolNode); | ||||
| LineartStaticMemPoolNode *smpn = MEM_callocN(total_size, "mempool"); | LineartStaticMemPoolNode *smpn = MEM_callocN(total_size, "mempool"); | ||||
| smpn->size = total_size; | smpn->size = total_size; | ||||
| smpn->used_byte = sizeof(LineartStaticMemPoolNode); | smpn->used_byte = sizeof(LineartStaticMemPoolNode); | ||||
| BLI_addhead(&smp->pools, smpn); | BLI_addhead(&smp->pools, smpn); | ||||
| return smpn; | return smpn; | ||||
| } | } | ||||
| void *lineart_mem_aquire(LineartStaticMemPool *smp, size_t size) | void *lineart_mem_acquire(LineartStaticMemPool *smp, size_t size) | ||||
| { | { | ||||
| LineartStaticMemPoolNode *smpn = smp->pools.first; | LineartStaticMemPoolNode *smpn = smp->pools.first; | ||||
| void *ret; | void *ret; | ||||
| if (!smpn || (smpn->used_byte + size) > smpn->size) { | if (!smpn || (smpn->used_byte + size) > smpn->size) { | ||||
| smpn = lineart_mem_new_static_pool(smp, size); | smpn = lineart_mem_new_static_pool(smp, size); | ||||
| } | } | ||||
| ret = ((unsigned char *)smpn) + smpn->used_byte; | ret = ((unsigned char *)smpn) + smpn->used_byte; | ||||
| smpn->used_byte += size; | smpn->used_byte += size; | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| void *lineart_mem_aquire_thread(LineartStaticMemPool *smp, size_t size) | void *lineart_mem_acquire_thread(LineartStaticMemPool *smp, size_t size) | ||||
| { | { | ||||
| void *ret; | void *ret; | ||||
| BLI_spin_lock(&smp->lock_mem); | BLI_spin_lock(&smp->lock_mem); | ||||
| LineartStaticMemPoolNode *smpn = smp->pools.first; | LineartStaticMemPoolNode *smpn = smp->pools.first; | ||||
| if (!smpn || (smpn->used_byte + size) > smpn->size) { | if (!smpn || (smpn->used_byte + size) > smpn->size) { | ||||
| smpn = lineart_mem_new_static_pool(smp, size); | smpn = lineart_mem_new_static_pool(smp, size); | ||||
| } | } | ||||
| Context not available. | |||||
| void lineart_prepend_edge_direct(LineartEdge **first, void *node) | void lineart_prepend_edge_direct(LineartEdge **first, void *node) | ||||
| { | { | ||||
| LineartEdge *e_n = (LineartEdge *)node; | LineartEdge *e_n = (LineartEdge *)node; | ||||
| e_n->next = (*first); | e_n->next = (*first); | ||||
| (*first) = e_n; | (*first) = e_n; | ||||
| } | } | ||||
| void lineart_prepend_pool(LinkNode **first, LineartStaticMemPool *smp, void *link) | void lineart_prepend_pool(LinkNode **first, LineartStaticMemPool *smp, void *link) | ||||
| { | { | ||||
| LinkNode *ln = lineart_mem_aquire_thread(smp, sizeof(LinkNode)); | LinkNode *ln = lineart_mem_acquire_thread(smp, sizeof(LinkNode)); | ||||
| ln->next = (*first); | ln->next = (*first); | ||||
| ln->link = link; | ln->link = link; | ||||
| (*first) = ln; | (*first) = ln; | ||||
| } | } | ||||
| /* =======================================================================[str] */ | /* =======================================================================[str] */ | ||||
| void lineart_matrix_perspective_44d( | void lineart_matrix_perspective_44d( | ||||
| double (*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax) | double (*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax) | ||||
| { | { | ||||
| Context not available. | |||||