Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 5,162 Lines • ▼ Show 20 Lines | if (is_floatbuf) { | ||||
| straight_to_premul_v4_v4(pixel->pixel.f_pt, rgb_straight); | straight_to_premul_v4_v4(pixel->pixel.f_pt, rgb_straight); | ||||
| } | } | ||||
| else { | else { | ||||
| pixel->pixel.ch_pt[3] = pixel->origColor.ch_pt[3]; | pixel->pixel.ch_pt[3] = pixel->origColor.ch_pt[3]; | ||||
| } | } | ||||
| } | } | ||||
| /* Run this for single and multi-threaded painting. */ | /* Run this for single and multi-threaded painting. */ | ||||
| static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), | static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v) | ||||
| void *ph_v, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| /* First unpack args from the struct */ | /* First unpack args from the struct */ | ||||
| ProjPaintState *ps = ((ProjectHandle *)ph_v)->ps; | ProjPaintState *ps = ((ProjectHandle *)ph_v)->ps; | ||||
| ProjPaintImage *projImages = ((ProjectHandle *)ph_v)->projImages; | ProjPaintImage *projImages = ((ProjectHandle *)ph_v)->projImages; | ||||
| const float *lastpos = ((ProjectHandle *)ph_v)->prevmval; | const float *lastpos = ((ProjectHandle *)ph_v)->prevmval; | ||||
| const float *pos = ((ProjectHandle *)ph_v)->mval; | const float *pos = ((ProjectHandle *)ph_v)->mval; | ||||
| const int thread_index = ((ProjectHandle *)ph_v)->thread_index; | const int thread_index = ((ProjectHandle *)ph_v)->thread_index; | ||||
| struct ImagePool *pool = ((ProjectHandle *)ph_v)->pool; | struct ImagePool *pool = ((ProjectHandle *)ph_v)->pool; | ||||
| ▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | static bool project_paint_op(void *state, const float lastpos[2], const float pos[2]) | ||||
| struct ImagePool *image_pool; | struct ImagePool *image_pool; | ||||
| if (!project_bucket_iter_init(ps, pos)) { | if (!project_bucket_iter_init(ps, pos)) { | ||||
| return touch_any; | return touch_any; | ||||
| } | } | ||||
| if (ps->thread_tot > 1) { | if (ps->thread_tot > 1) { | ||||
| scheduler = BLI_task_scheduler_get(); | scheduler = BLI_task_scheduler_legacy_get(); | ||||
| task_pool = BLI_task_pool_create_suspended(scheduler, NULL, TASK_PRIORITY_HIGH); | task_pool = BLI_task_pool_legacy_create_suspended(scheduler, NULL, TASK_PRIORITY_HIGH); | ||||
| } | } | ||||
| image_pool = BKE_image_pool_new(); | image_pool = BKE_image_pool_new(); | ||||
| /* get the threads running */ | /* get the threads running */ | ||||
| for (a = 0; a < ps->thread_tot; a++) { | for (a = 0; a < ps->thread_tot; a++) { | ||||
| /* set defaults in handles */ | /* set defaults in handles */ | ||||
| Show All 18 Lines | for (i = 0; i < ps->image_tot; i++) { | ||||
| memcpy(handles[a].projImages[i].partRedrawRect, | memcpy(handles[a].projImages[i].partRedrawRect, | ||||
| ps->projImages[i].partRedrawRect, | ps->projImages[i].partRedrawRect, | ||||
| sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); | sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); | ||||
| } | } | ||||
| handles[a].pool = image_pool; | handles[a].pool = image_pool; | ||||
| if (task_pool != NULL) { | if (task_pool != NULL) { | ||||
| BLI_task_pool_push(task_pool, do_projectpaint_thread, &handles[a], false, NULL); | BLI_task_pool_legacy_push(task_pool, do_projectpaint_thread, &handles[a], false, NULL); | ||||
| } | } | ||||
| } | } | ||||
| if (task_pool != NULL) { /* wait for everything to be done */ | if (task_pool != NULL) { /* wait for everything to be done */ | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_legacy_work_and_wait(task_pool); | ||||
| BLI_task_pool_free(task_pool); | BLI_task_pool_legacy_free(task_pool); | ||||
| } | } | ||||
| else { | else { | ||||
| do_projectpaint_thread(NULL, &handles[0], 0); | do_projectpaint_thread(NULL, &handles[0]); | ||||
| } | } | ||||
| BKE_image_pool_free(image_pool); | BKE_image_pool_free(image_pool); | ||||
| /* move threaded bounds back into ps->projectPartialRedraws */ | /* move threaded bounds back into ps->projectPartialRedraws */ | ||||
| for (i = 0; i < ps->image_tot; i++) { | for (i = 0; i < ps->image_tot; i++) { | ||||
| int touch = 0; | int touch = 0; | ||||
| for (a = 0; a < ps->thread_tot; a++) { | for (a = 0; a < ps->thread_tot; a++) { | ||||
| ▲ Show 20 Lines • Show All 1,150 Lines • Show Last 20 Lines | |||||