Index: source/blender/blenkernel/intern/colortools.c =================================================================== --- source/blender/blenkernel/intern/colortools.c (révision 28698) +++ source/blender/blenkernel/intern/colortools.c (copie de travail) @@ -948,8 +948,6 @@ if (scopes->ok == 1 ) return; - if (scopes->hist.ymax == 0.f) scopes->hist.ymax = 1.f; - /* hmmmm */ if (!(ELEM(ibuf->channels, 3, 4))) return; scopes->hist.channels = 3; @@ -1028,9 +1026,6 @@ rgb[c] = rc[c] * INV_255; } - /* we still need luma for histogram */ - luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114 * rgb[2]; - /* check for min max */ if(ycc_mode == -1 ) { for (c=0; c<3; c++) { @@ -1046,6 +1041,10 @@ if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c]; } } + + /* we still need luma for histogram */ + luma = (ycc_mode == BLI_YCC_JFIF_0_255)? ycc[0]:(0.299*rgb[0] + 0.587*rgb[1] + 0.114 * rgb[2]); + /* increment count for histo*/ bin_r[ get_bin_float(rgb[0]) ] += 1; bin_g[ get_bin_float(rgb[1]) ] += 1; @@ -1122,8 +1121,9 @@ scopes->wavefrm_alpha=0.3; scopes->vecscope_alpha=0.3; scopes->wavefrm_height= 100; - scopes->vecscope_height= 100; + scopes->vecscope_height= 150; scopes->hist.height= 100; + scopes->hist.ymax= 1.0f; scopes->ok= 0; scopes->waveform_1 = NULL; scopes->waveform_2 = NULL; Index: source/blender/editors/space_image/space_image.c =================================================================== --- source/blender/editors/space_image/space_image.c (révision 28698) +++ source/blender/editors/space_image/space_image.c (copie de travail) @@ -411,6 +411,8 @@ ar->alignment= RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; + simage->sample_line_hist.height=100; + /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -621,7 +623,9 @@ break; case NC_SPACE: if(wmn->data == ND_SPACE_IMAGE) { - image_scopes_tag_refresh(sa); + /* NA_EDITED send at end of scopes updates job, no refresh in this case */ + if(wmn->action != NA_EDITED) + image_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); } break; @@ -831,6 +835,100 @@ /* *********************** scopes region ************************ */ +/* scope job manager */ +typedef struct ScopeJob { + SpaceImage *sima; + Scene *scene; + Scopes tmp_scopes; +} ScopeJob; + +static void scope_freejob(void *sjv) +{ + ScopeJob *sj= sjv; + + scopes_free(&sj->tmp_scopes); + MEM_freeN(sj); +} + + +static void scope_endjob(void *sjv) +{ + ScopeJob *sj= sjv; + SpaceImage *sima= sj->sima; + int i; + + for(i=0; i<3; i++) { + sima->scopes.minmax[i][0] = sj->tmp_scopes.minmax[i][0]; + sima->scopes.minmax[i][1] = sj->tmp_scopes.minmax[i][1]; + } + + for(i=0; i<256; i++) { + sima->scopes.hist.data_luma[i] = sj->tmp_scopes.hist.data_luma[i]; + sima->scopes.hist.data_r[i] = sj->tmp_scopes.hist.data_r[i]; + sima->scopes.hist.data_g[i] = sj->tmp_scopes.hist.data_g[i]; + sima->scopes.hist.data_b[i] = sj->tmp_scopes.hist.data_b[i]; + } + sima->scopes.hist.channels = sj->tmp_scopes.hist.channels; + sima->scopes.hist.x_resolution = sj->tmp_scopes.hist.x_resolution; + + SWAP(float *, sima->scopes.waveform_1, sj->tmp_scopes.waveform_1 ); + SWAP(float *, sima->scopes.waveform_2, sj->tmp_scopes.waveform_2 ); + SWAP(float *, sima->scopes.waveform_3, sj->tmp_scopes.waveform_3 ); + SWAP(float *, sima->scopes.vecscope, sj->tmp_scopes.vecscope ); + sima->scopes.waveform_tot = sj->tmp_scopes.waveform_tot; + sima->scopes.ok = sj->tmp_scopes.ok; +} + +/* only this runs inside thread */ +static void scope_startjob(void *sjv, short *stop, short *do_update) +{ + ScopeJob *sj= sjv; + SpaceImage *sima= sj->sima; + Scene *scene = sj->scene; + void *lock; + + ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); + if(ibuf) { + scopes_update(&sj->tmp_scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT ); + } + ED_space_image_release_buffer(sima, lock); + + /* to prevent looping when no image opened */ + sima->scopes.ok= 1; +} + +/* setup and start the scope job */ +void image_scope_job(const bContext *C, ARegion *ar) +{ + SpaceImage *sima= CTX_wm_space_image(C); + wmJob *steve; + ScopeJob *sj; + + /* do not start job if scope is up to date to avoid looping */ + if (sima->scopes.ok==1) return; + + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sima, 0); + sj= MEM_callocN(sizeof(ScopeJob), "scope job"); + + /* customdata for scope thread */ + sj->sima= sima; + sj->scene= CTX_data_scene(C); + + sj->tmp_scopes.accuracy = sima->scopes.accuracy; + sj->tmp_scopes.sample_full = sima->scopes.sample_full; + sj->tmp_scopes.wavefrm_mode = sima->scopes.wavefrm_mode; + sj->tmp_scopes.ok = sima->scopes.ok; + /* say that the non up to date scopes is ok so it draws (avoid flickering on frame change) */ + sima->scopes.ok= 1; + + /* setup job */ + WM_jobs_customdata(steve, sj, scope_freejob); + WM_jobs_timer(steve, 0.1, 0, NC_SPACE|ND_SPACE_IMAGE|NA_EDITED); + WM_jobs_callbacks(steve, scope_startjob, NULL, NULL, scope_endjob); + + WM_jobs_start(CTX_wm_manager(C), steve); +} + /* add handlers, stuff you only do once or on area/region changes */ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) { @@ -844,15 +942,8 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) { - SpaceImage *sima= CTX_wm_space_image(C); - Scene *scene= CTX_data_scene(C); - void *lock; - ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { - scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT ); - } - ED_space_image_release_buffer(sima, lock); - + /* end of job will trigger a redraw */ + image_scope_job(C, ar); ED_region_panels(C, ar, 1, NULL, -1); } Index: source/blender/editors/interface/interface_templates.c =================================================================== --- source/blender/editors/interface/interface_templates.c (révision 28698) +++ source/blender/editors/interface/interface_templates.c (copie de travail) @@ -1466,7 +1466,7 @@ hist = (Histogram *)cptr.data; - hist->height= (hist->height<=0)?100:hist->height; + hist->height= (hist->height<25)?25:hist->height; bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -1503,7 +1503,7 @@ block= uiLayoutAbsoluteBlock(layout); - scopes->wavefrm_height= (scopes->wavefrm_height<=0)?100:scopes->wavefrm_height; + scopes->wavefrm_height= (scopes->wavefrm_height<25)?25:scopes->wavefrm_height; bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); @@ -1539,7 +1539,7 @@ block= uiLayoutAbsoluteBlock(layout); - scopes->vecscope_height= (scopes->vecscope_height<=0)?100:scopes->vecscope_height; + scopes->vecscope_height= (scopes->vecscope_height<25)?25:scopes->vecscope_height; bt= uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); Index: source/blender/editors/interface/interface_handlers.c =================================================================== --- source/blender/editors/interface/interface_handlers.c (révision 28698) +++ source/blender/editors/interface/interface_handlers.c (copie de travail) @@ -3513,6 +3513,7 @@ /* scale histogram values */ yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5; hist->ymax += dy * yfac; + if (hist->ymax == 0.f) hist->ymax = 1.f; CLAMP(hist->ymax, 1.f, 100.f); }