Skip to content

Commit e624779

Browse files
committed
A port of Blender's AgX to darktable
1 parent ab60bc5 commit e624779

File tree

9 files changed

+2433
-2
lines changed

9 files changed

+2433
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ output*png
2525
Brewfile.lock.json
2626
CMakeLists.txt.user
2727
workspace/
28+
cmake-build-debug/
29+
.idea/

data/darktableconfig.xml.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,6 +3520,7 @@
35203520
<enum>
35213521
<option>scene-referred (sigmoid)</option>
35223522
<option>scene-referred (filmic)</option>
3523+
<option>scene-referred (agx)</option>
35233524
<option>display-referred (legacy)</option>
35243525
<option>none</option>
35253526
</enum>
@@ -3851,6 +3852,34 @@
38513852
<shortdescription>active tab in tone equaliser module</shortdescription>
38523853
<longdescription>which of simple, advanced or masking tabs will show at startup</longdescription>
38533854
</dtconfig>
3855+
<dtconfig>
3856+
<name>plugins/darkroom/agx/enable_curve_tab</name>
3857+
<type>bool</type>
3858+
<default>false</default>
3859+
<shortdescription>whether to enable the curve tab</shortdescription>
3860+
<longdescription>if enabled, the settings tab will have fewer controls and will occupy less vertical space</longdescription>
3861+
</dtconfig>
3862+
<dtconfig>
3863+
<name>plugins/darkroom/agx/expand_curve_graph</name>
3864+
<type>bool</type>
3865+
<default>false</default>
3866+
<shortdescription>whether to expand the curve graph</shortdescription>
3867+
<longdescription>this is just to store whether to show the curve graph or not</longdescription>
3868+
</dtconfig>
3869+
<dtconfig>
3870+
<name>plugins/darkroom/agx/curve_graph_height</name>
3871+
<type min="100" max="300">int</type>
3872+
<default>200</default>
3873+
<shortdescription>height of agx graph in per cent</shortdescription>
3874+
<longdescription>height of agx graph in per cent</longdescription>
3875+
</dtconfig>
3876+
<dtconfig>
3877+
<name>plugins/darkroom/agx/expand_curve_advanced</name>
3878+
<type>bool</type>
3879+
<default>false</default>
3880+
<shortdescription>whether to show advanced curve parameters</shortdescription>
3881+
<longdescription>this is just to store whether to show advanced curve parameters or not</longdescription>
3882+
</dtconfig>
38543883
<dtconfig>
38553884
<name>plugins/lighttable/collect/windowheight</name>
38563885
<type>int</type>

src/common/iop_order.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ const dt_iop_order_entry_t legacy_order[] = {
140140
{ {44.0f }, "lowlight", 0},
141141
{ {45.0f }, "monochrome", 0},
142142
{ {45.3f }, "sigmoid", 0},
143+
{ {45.5f }, "agx", 0},
143144
{ {46.0f }, "filmic", 0},
144145
{ {46.5f }, "filmicrgb", 0},
145146
{ {47.0f }, "colisa", 0},
@@ -253,6 +254,7 @@ const dt_iop_order_entry_t v30_order[] = {
253254
// on camera JPEG default look
254255
{ {45.0f }, "filmic", 0}, // same, but different (parametric) approach
255256
{ {45.3f }, "sigmoid", 0},
257+
{ {45.5f }, "agx", 0},
256258
{ {46.0f }, "filmicrgb", 0}, // same, upgraded
257259
{ {36.0f }, "lut3d", 0}, // apply a creative style or film emulation, possibly non-linear
258260
{ {47.0f }, "colisa", 0}, // edit contrast while damaging colour
@@ -370,6 +372,7 @@ const dt_iop_order_entry_t v50_order[] = {
370372
// on camera JPEG default look
371373
{ {45.0f }, "filmic", 0}, // same, but different (parametric) approach
372374
{ {45.3f }, "sigmoid", 0},
375+
{ {45.5f }, "agx", 0},
373376
{ {46.0f }, "filmicrgb", 0}, // same, upgraded
374377
{ {36.0f }, "lut3d", 0}, // apply a creative style or film emulation, possibly non-linear
375378
{ {47.0f }, "colisa", 0}, // edit contrast while damaging colour
@@ -487,6 +490,7 @@ const dt_iop_order_entry_t v30_jpg_order[] = {
487490
{ { 44.0f }, "basecurve", 0 }, // conversion from scene-referred to display referred, reverse-engineered
488491
// on camera JPEG default look
489492
{ { 45.0f }, "filmic", 0 }, // same, but different (parametric) approach
493+
{ {45.5f }, "agx", 0},
490494
{ { 45.3f }, "sigmoid", 0},
491495
{ { 46.0f }, "filmicrgb", 0 }, // same, upgraded
492496
{ { 36.0f }, "lut3d", 0 }, // apply a creative style or film emulation, possibly non-linear
@@ -608,6 +612,7 @@ const dt_iop_order_entry_t v50_jpg_order[] = {
608612
// on camera JPEG default look
609613
{ { 45.0f }, "filmic", 0 }, // same, but different (parametric) approach
610614
{ { 45.3f }, "sigmoid", 0},
615+
{ {45.5f }, "agx", 0},
611616
{ { 46.0f }, "filmicrgb", 0 }, // same, upgraded
612617
{ { 36.0f }, "lut3d", 0 }, // apply a creative style or film emulation, possibly non-linear
613618
{ { 47.0f }, "colisa", 0 }, // edit contrast while damaging colour
@@ -1177,6 +1182,7 @@ GList *dt_ioppr_get_iop_order_list(const dt_imgid_t imgid,
11771182
_insert_before(iop_order_list, "colorbalance", "diffuse");
11781183
_insert_before(iop_order_list, "nlmeans", "blurs");
11791184
_insert_before(iop_order_list, "filmicrgb", "sigmoid");
1185+
_insert_before(iop_order_list, "filmicrgb", "agx");
11801186
_insert_before(iop_order_list, "colorbalancergb", "colorequal");
11811187
_insert_before(iop_order_list, "highlights", "rasterfile");
11821188
}

src/common/iop_profile.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,96 @@ void dt_ioppr_get_export_profile_type(struct dt_develop_t *dev,
10971097
"[dt_ioppr_get_export_profile_type] can't find colorout iop");
10981098
}
10991099

1100+
/**
1101+
* Get the export profile settings configured in the colorout module.
1102+
* This retrieves the settings as configured in the GUI, regardless of the
1103+
* current pipeline type (display, export, etc.).
1104+
*
1105+
* @param dev develop struct
1106+
* @param profile_type pointer to store the profile type
1107+
* @param profile_filename buffer to store the filename (supply size)
1108+
* @param filename_size size of the profile_filename buffer
1109+
* @param profile_intent pointer to store the rendering intent
1110+
* @return TRUE if colorout module and parameters were found, FALSE otherwise
1111+
*/
1112+
gboolean dt_ioppr_get_configured_export_profile_settings(
1113+
struct dt_develop_t *dev,
1114+
dt_colorspaces_color_profile_type_t *profile_type,
1115+
char *profile_filename,
1116+
size_t filename_size,
1117+
dt_iop_color_intent_t *profile_intent)
1118+
{
1119+
// Initialize output parameters to default/invalid values
1120+
if (profile_type) *profile_type = DT_COLORSPACE_NONE;
1121+
if (profile_filename) profile_filename[0] = '\0';
1122+
if (profile_intent) *profile_intent = DT_INTENT_PERCEPTUAL; // Default intent
1123+
1124+
dt_iop_module_so_t *colorout_so = NULL;
1125+
// Find the colorout module SO (should be loaded)
1126+
for(const GList *modules = darktable.iop; modules; modules = g_list_next(modules))
1127+
{
1128+
dt_iop_module_so_t *module_so = modules->data;
1129+
if(dt_iop_module_is(module_so, "colorout"))
1130+
{
1131+
colorout_so = module_so;
1132+
break;
1133+
}
1134+
}
1135+
1136+
if (!colorout_so || !colorout_so->get_p)
1137+
{
1138+
// colorout module SO not found or doesn't support get_p
1139+
dt_print(DT_DEBUG_ALWAYS, "[get_configured_export_profile_settings] colorout SO or get_p not found.");
1140+
return FALSE;
1141+
}
1142+
1143+
dt_iop_module_t *colorout = NULL;
1144+
// Find the colorout instance in the current pipeline (dev->iop)
1145+
// Start from the end, as colorout is usually last
1146+
for(const GList *modules = g_list_last(dev->iop); modules; modules = g_list_previous(modules))
1147+
{
1148+
dt_iop_module_t *module = modules->data;
1149+
if(dt_iop_module_is(module->so, "colorout"))
1150+
{
1151+
colorout = module;
1152+
break;
1153+
}
1154+
}
1155+
1156+
if (!colorout)
1157+
{
1158+
// colorout module instance not found in this pipeline
1159+
dt_print(DT_DEBUG_ALWAYS, "[get_configured_export_profile_settings] colorout module not found in pipe.");
1160+
return FALSE;
1161+
}
1162+
1163+
// Get pointers to the parameter values using introspection
1164+
dt_colorspaces_color_profile_type_t *_type = colorout_so->get_p(colorout->params, "type");
1165+
char *_filename = colorout_so->get_p(colorout->params, "filename");
1166+
dt_iop_color_intent_t *_intent = colorout_so->get_p(colorout->params, "intent");
1167+
1168+
// Check if all expected parameters were successfully retrieved
1169+
if (_type && _filename && _intent)
1170+
{
1171+
// Populate the output parameters
1172+
if (profile_type) *profile_type = *_type;
1173+
if (profile_filename && filename_size > 0) g_strlcpy(profile_filename, _filename, filename_size);
1174+
if (profile_intent) *profile_intent = *_intent;
1175+
1176+
dt_print(DT_DEBUG_DEV,
1177+
"[get_configured_export_profile_settings] Retrieved export profile: type=%d, filename='%s', intent=%d",
1178+
*profile_type, profile_filename, *profile_intent);
1179+
return TRUE; // Success
1180+
}
1181+
else
1182+
{
1183+
dt_print(DT_DEBUG_ALWAYS,
1184+
"[get_configured_export_profile_settings] Failed to get colorout parameters via get_p.");
1185+
// Even on failure, the output parameters were initialized to default/invalid
1186+
return FALSE;
1187+
}
1188+
}
1189+
11001190
void dt_ioppr_get_histogram_profile_type(dt_colorspaces_color_profile_type_t *profile_type,
11011191
const char **profile_filename)
11021192
{

src/common/iop_profile.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ void dt_ioppr_get_input_profile_type(struct dt_develop_t *dev,
145145
void dt_ioppr_get_export_profile_type(struct dt_develop_t *dev,
146146
dt_colorspaces_color_profile_type_t *profile_type,
147147
const char **profile_filename);
148+
/**
149+
* @see dt_ioppr_get_configured_export_profile_settings()
150+
*/
151+
gboolean dt_ioppr_get_configured_export_profile_settings(
152+
struct dt_develop_t *dev,
153+
dt_colorspaces_color_profile_type_t *profile_type,
154+
char *profile_filename,
155+
size_t filename_size,
156+
dt_iop_color_intent_t *profile_intent);
157+
148158
/** returns the current setting of the histogram profile */
149159
void dt_ioppr_get_histogram_profile_type(dt_colorspaces_color_profile_type_t *profile_type,
150160
const char **profile_filename);

src/common/utility.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ gboolean dt_str_commasubstring(const char *list,
11621162
gboolean dt_is_scene_referred(void)
11631163
{
11641164
return dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (filmic)")
1165-
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (sigmoid)");
1165+
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (sigmoid)")
1166+
|| dt_conf_is_equal("plugins/darkroom/workflow", "scene-referred (agx)");
11661167
}
11671168

11681169
gboolean dt_is_display_referred(void)

src/iop/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ add_iop(cacorrectrgb "cacorrectrgb.c")
152152
add_iop(diffuse "diffuse.c")
153153
add_iop(blurs "blurs.c")
154154
add_iop(sigmoid "sigmoid.c")
155+
add_iop(agx "agx.c")
155156
add_iop(primaries "primaries.c")
156157
add_iop(colorequal "colorequal.c")
157158
add_iop(rasterfile "rasterfile.c")

0 commit comments

Comments
 (0)