Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/interface/interface.c7
-rw-r--r--source/blender/editors/interface/interface_handlers.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/editors/interface/interface_ops.c6
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c49
5 files changed, 29 insertions, 40 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 2a4dfc210b0..c63ffc87b8e 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3289,13 +3289,6 @@ void ui_block_cm_to_display_space_v3(uiBlock *block, float pixel[3])
IMB_colormanagement_scene_linear_to_display_v3(pixel, display);
}
-void ui_block_cm_to_scene_linear_v3(uiBlock *block, float pixel[3])
-{
- struct ColorManagedDisplay *display = ui_block_cm_display_get(block);
-
- IMB_colormanagement_display_to_scene_linear_v3(pixel, display);
-}
-
static uiBut *ui_but_alloc(const eButType type)
{
switch (type) {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3949c1e2d50..9dc1f1e4e24 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -64,6 +64,8 @@
#include "BKE_unit.h"
#include "BKE_paint.h"
+#include "IMB_colormanagement.h"
+
#include "ED_screen.h"
#include "ED_undo.h"
@@ -5313,7 +5315,7 @@ static int ui_do_but_COLOR(
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target);
- ui_block_cm_to_scene_linear_v3(but->block, target);
+ IMB_colormanagement_srgb_to_scene_linear_v3(target);
}
else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target);
@@ -5326,7 +5328,7 @@ static int ui_do_but_COLOR(
}
else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color);
- ui_block_cm_to_display_space_v3(but->block, color);
+ IMB_colormanagement_scene_linear_to_srgb_v3(color);
BKE_brush_color_set(scene, brush, color);
}
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 0ab92a633ad..24fb68dba0c 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -514,7 +514,6 @@ extern void ui_block_bounds_calc(uiBlock *block);
extern struct ColorManagedDisplay *ui_block_cm_display_get(uiBlock *block);
void ui_block_cm_to_display_space_v3(uiBlock *block, float pixel[3]);
-void ui_block_cm_to_scene_linear_v3(uiBlock *block, float pixel[3]);
/* interface_regions.c */
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index cc609216e9a..b4b59cae75b 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -53,6 +53,8 @@
#include "BKE_screen.h"
#include "BKE_text.h" /* for UI_OT_reports_to_text */
+#include "IMB_colormanagement.h"
+
#include "DEG_depsgraph.h"
#include "RNA_access.h"
@@ -1507,13 +1509,13 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
if (!gamma)
- ui_block_cm_to_display_space_v3(but->block, color);
+ IMB_colormanagement_scene_linear_to_srgb_v3(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)
- ui_block_cm_to_scene_linear_v3(but->block, color);
+ IMB_colormanagement_srgb_to_scene_linear_v3(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.c b/source/blender/editors/interface/interface_region_color_picker.c
index 7c2afaf1a92..082459925e0 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.c
@@ -188,26 +188,23 @@ static void ui_update_color_picker_buts_rgb(
UI_but_flag_disable(bt, UI_BUT_UNDO);
}
else if (STREQ(bt->str, "Hex: ")) {
- float rgb_gamma[3];
- unsigned char rgb_gamma_uchar[3];
+ float rgb_hex[3];
+ unsigned char rgb_hex_uchar[3];
double intpart;
char col[16];
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
-
- copy_v3_v3(rgb_gamma, rgb);
-
- if (!block->is_color_gamma_picker) {
- /* make a display version, for Hex code */
- ui_block_cm_to_display_space_v3(block, rgb_gamma);
+ copy_v3_v3(rgb_hex, rgb);
+ if (from_but && !ui_but_is_color_gamma(from_but)) {
+ IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex);
}
- if (rgb_gamma[0] > 1.0f) rgb_gamma[0] = modf(rgb_gamma[0], &intpart);
- if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart);
- if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
+ if (rgb_hex[0] > 1.0f) rgb_hex[0] = modf(rgb_hex[0], &intpart);
+ if (rgb_hex[1] > 1.0f) rgb_hex[1] = modf(rgb_hex[1], &intpart);
+ if (rgb_hex[2] > 1.0f) rgb_hex[2] = modf(rgb_hex[2], &intpart);
- rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
- BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((uint), rgb_gamma_uchar, ));
+ rgb_float_to_uchar(rgb_hex_uchar, rgb_hex);
+ BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, ));
strcpy(bt->poin, col);
}
@@ -287,9 +284,8 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc
hex_to_rgb(hexcol, rgb, rgb + 1, rgb + 2);
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
- if (!but->block->is_color_gamma_picker) {
- /* so we need to linearise it for Blender */
- ui_block_cm_to_scene_linear_v3(but->block, rgb);
+ if (!ui_but_is_color_gamma(but)) {
+ IMB_colormanagement_srgb_to_scene_linear_v3(rgb);
}
ui_update_color_picker_buts_rgb(NULL, but->block, cpicker, rgb);
@@ -546,21 +542,18 @@ static void ui_block_colorpicker(
rgba[3] = 1.0f;
}
- /* Hex color is in display space. This should actually be sRGB without any view
- * transform, as most other applications would expect this. */
- float rgb_gamma[3];
- unsigned char rgb_gamma_uchar[3];
+ /* Hex color is in sRGB space. */
+ float rgb_hex[3];
+ unsigned char rgb_hex_uchar[3];
- if (block->is_color_gamma_picker) {
- copy_v3_v3(rgb_gamma, rgba);
- }
- else {
- copy_v3_v3(rgb_gamma, rgba);
- ui_block_cm_to_display_space_v3(block, rgb_gamma);
+ copy_v3_v3(rgb_hex, rgba);
+
+ if (!ui_but_is_color_gamma(from_but)) {
+ IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex);
}
- rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
- BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((uint), rgb_gamma_uchar, ));
+ rgb_float_to_uchar(rgb_hex_uchar, rgb_hex);
+ BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, ));
yco = -3.0f * UI_UNIT_Y;
bt = uiDefBut(