diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-05-20 18:54:43 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-05-23 16:34:50 +0300 |
commit | eb5e7d0a31eed698909c23ab0ca89c8fd4929365 (patch) | |
tree | 6332d3f66107492795254d4fbc0f8f3beccfb156 /source/blender/editors | |
parent | 469ee7ff1529a1b28ce0b300835ebc42d5c5362f (diff) |
Cleanup: clarify what is scene linear color space in conversion conversion
* Rename ambiguous rgb to scene_linear in some places
* Precompute matrices to directly go to scene instead of through XYZ
* Make function signatures more consistent
Diffstat (limited to 'source/blender/editors')
9 files changed, 15 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9d7d76f0bdb..3e3b30a2c1e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6277,7 +6277,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); - IMB_colormanagement_srgb_to_scene_linear_v3(target); + IMB_colormanagement_srgb_to_scene_linear_v3(target, target); } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); @@ -6294,7 +6294,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); - IMB_colormanagement_scene_linear_to_srgb_v3(color); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color); BKE_brush_color_set(scene, brush, color); updated = true; } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 5b97a80d513..f14c6ad9924 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1895,14 +1895,14 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { if (!gamma) { - IMB_colormanagement_scene_linear_to_srgb_v3(color); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color); } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); } else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) { if (gamma) { - IMB_colormanagement_srgb_to_scene_linear_v3(color); + IMB_colormanagement_srgb_to_scene_linear_v3(color, color); } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index ab0a6039cdc..db1e5e653de 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -116,7 +116,7 @@ void ui_scene_linear_to_perceptual_space(uiBut *but, float rgb[3]) * assuming it is more perceptually linear than the scene linear * space for intuitive color picking. */ if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_scene_linear_to_color_picking_v3(rgb); + IMB_colormanagement_scene_linear_to_color_picking_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } } @@ -124,7 +124,7 @@ void ui_scene_linear_to_perceptual_space(uiBut *but, float rgb[3]) void ui_perceptual_to_scene_linear_space(uiBut *but, float rgb[3]) { if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_color_picking_to_scene_linear_v3(rgb); + IMB_colormanagement_color_picking_to_scene_linear_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } } @@ -208,7 +208,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but, * (coming from other applications, web, etc) */ copy_v3_v3(rgb_hex, rgb_scene_linear); if (from_but && !ui_but_is_color_gamma(from_but)) { - IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex); + IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex, rgb_hex); ui_color_picker_rgb_round(rgb_hex); } @@ -291,7 +291,7 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc /* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */ if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_srgb_to_scene_linear_v3(rgb); + IMB_colormanagement_srgb_to_scene_linear_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } @@ -777,7 +777,7 @@ static void ui_block_colorpicker(uiBlock *block, copy_v3_v3(rgb_hex, rgba_scene_linear); if (!ui_but_is_color_gamma(from_but)) { - IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex); + IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex, rgb_hex); ui_color_picker_rgb_round(rgb_hex); } diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 572e5b78b74..a313489885d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -359,9 +359,7 @@ void paint_brush_color_get(struct Scene *scene, } /* Gradient / Color-band colors are not considered #PROP_COLOR_GAMMA. * Brush colors are expected to be in sRGB though. */ - IMB_colormanagement_scene_linear_to_srgb_v3(color_gr); - - copy_v3_v3(color, color_gr); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color_gr); } else { copy_v3_v3(color, BKE_brush_color_get(scene, br)); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 747295f3de0..f13c34e2030 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -331,8 +331,7 @@ static Color vpaint_get_current_col(Scene *scene, VPaint *vp, bool secondary) float color[4]; const float *brush_color = secondary ? BKE_brush_secondary_color_get(scene, brush) : BKE_brush_color_get(scene, brush); - copy_v3_v3(color, brush_color); - IMB_colormanagement_srgb_to_scene_linear_v3(color); + IMB_colormanagement_srgb_to_scene_linear_v3(color, brush_color); color[3] = 1.0f; /* alpha isn't used, could even be removed to speedup paint a little */ diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c index 46940b619e6..644f14905ba 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_expand.c @@ -2001,7 +2001,7 @@ static void sculpt_expand_cache_initial_config_set(bContext *C, BKE_curvemapping_init(expand_cache->brush->curve); copy_v4_fl(expand_cache->fill_color, 1.0f); copy_v3_v3(expand_cache->fill_color, BKE_brush_color_get(ss->scene, expand_cache->brush)); - IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache->fill_color); + IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache->fill_color, expand_cache->fill_color); expand_cache->scene = CTX_data_scene(C); expand_cache->mtex = &expand_cache->brush->mtex; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c index f71a814aff4..26d18823b37 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c @@ -298,7 +298,7 @@ static int sculpt_color_filter_modal(bContext *C, wmOperator *op, const wmEvent float fill_color[3]; RNA_float_get_array(op->ptr, "fill_color", fill_color); - IMB_colormanagement_srgb_to_scene_linear_v3(fill_color); + IMB_colormanagement_srgb_to_scene_linear_v3(fill_color, fill_color); if (filter_strength < 0.0 && !ss->filter_cache->pre_smoothed_color) { sculpt_color_presmooth_init(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 5aa1dbef74c..8df1cc458d3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -780,8 +780,7 @@ static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent } float color_srgb[3]; - copy_v3_v3(color_srgb, active_vertex_color); - IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb); + IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb, active_vertex_color); BKE_brush_color_set(scene, brush, color_srgb); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 7a8a6e8e484..ac05652b058 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -124,7 +124,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, copy_v3_v3(brush_color, ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, brush) : BKE_brush_color_get(ss->scene, brush)); - IMB_colormanagement_srgb_to_scene_linear_v3(brush_color); + IMB_colormanagement_srgb_to_scene_linear_v3(brush_color, brush_color); BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { SCULPT_orig_vert_data_update(&orig_data, &vd); |