diff options
author | Stefan Werner <stewreo@gmail.com> | 2017-04-20 23:41:26 +0300 |
---|---|---|
committer | Stefan Werner <stewreo@gmail.com> | 2017-04-20 23:41:26 +0300 |
commit | aeda1a16f3e40b01da9afd573f1811a5212bdf34 (patch) | |
tree | 31358c34d205cd7d4927d81a6b66083b45a7c1db /source/blender/editors/interface | |
parent | b628f765b09154fcdc9b58496e1c59c03b729e50 (diff) |
D2607: Switch eye dropper to use linear color space internally
This switches the internal color representation of the eye dropper from display space to linear. Any time a linear color is requested and the color is picked from a linear object, the result is now precise to the bit as the color gets patched through directly. Color space conversion now only happens when a color is picked from non-linear display space objects or when the color is requested to be returned in non-linear space.
In addition, this patch changes the DifferenceMatte node to interpret a tolerance of 0.0 to accept colors that are identical bit by bit, as apposed to simply refusing all colors.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index f3859154dfb..eab609ebe84 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -225,7 +225,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op) return false; } - if (RNA_property_subtype(eye->prop) == PROP_COLOR) { + if (RNA_property_subtype(eye->prop) != PROP_COLOR) { const char *display_device; float col[4]; @@ -235,7 +235,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op) /* store inital color */ RNA_property_float_get_array(&eye->ptr, eye->prop, col); if (eye->display) { - IMB_colormanagement_scene_linear_to_display_v3(col, eye->display); + IMB_colormanagement_display_to_scene_linear_v3(col, eye->display); } copy_v3_v3(eye->init_col, col); } @@ -266,6 +266,8 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int /* we could use some clever */ wmWindow *win = CTX_wm_window(C); ScrArea *sa = BKE_screen_find_area_xy(win->screen, SPACE_TYPE_ANY, mx, my); + const char *display_device = CTX_data_scene(C)->display_settings.display_device; + struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); if (sa) { if (sa->spacetype == SPACE_IMAGE) { @@ -275,7 +277,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; - if (ED_space_image_color_sample(CTX_data_scene(C), sima, ar, mval, r_col)) { + if (ED_space_image_color_sample(sima, ar, mval, r_col)) { return; } } @@ -287,7 +289,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; - if (ED_space_node_color_sample(CTX_data_scene(C), snode, ar, mval, r_col)) { + if (ED_space_node_color_sample(snode, ar, mval, r_col)) { return; } } @@ -299,7 +301,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; - if (ED_space_clip_color_sample(CTX_data_scene(C), sc, ar, mval, r_col)) { + if (ED_space_clip_color_sample(sc, ar, mval, r_col)) { return; } } @@ -310,6 +312,8 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int glReadBuffer(GL_FRONT); glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col); glReadBuffer(GL_BACK); + + IMB_colormanagement_display_to_scene_linear_v3(r_col, display); } /* sets the sample color RGB, maintaining A */ @@ -320,10 +324,10 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 /* to maintain alpha */ RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv); - /* convert from display space to linear rgb space */ + /* convert from linear rgb space to display space */ if (eye->display) { copy_v3_v3(col_conv, col); - IMB_colormanagement_display_to_scene_linear_v3(col_conv, eye->display); + IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display); } else { copy_v3_v3(col_conv, col); |