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:
authorBrecht Van Lommel <brecht@blender.org>2022-03-11 20:21:05 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-03-22 16:15:20 +0300
commit3b5224b57c3cfc39a7998ecfc482e13bd6940e68 (patch)
tree1111ceb0a6501b7de81d4e0e59b6d424c9773665 /source/blender/compositor/operations
parent2ebcb7fab3e237b7d00de3088c34780cd24f397b (diff)
Cleanup: refactor passing of color management settings for image save
Make a copy of ImageFormatData that contains the effective color management settings, and pass that along to the various functions. This will make it possible to add more complex logic later. For compositing nodes, passing along view and display settings through many functions made it harder to add additional settings, so just get those from the scene now. Differential Revision: https://developer.blender.org/D14401
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc47
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h10
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cc31
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h10
4 files changed, 35 insertions, 63 deletions
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc
index 4da11cc9053..aeaf6b659e3 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc
@@ -17,24 +17,16 @@ namespace blender::compositor {
/************************************ OpenEXR Singlelayer Multiview ******************************/
OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
+ const Scene *scene,
const RenderData *rd,
const bNodeTree *tree,
DataType datatype,
ImageFormatData *format,
const char *path,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
const char *view_name,
const bool save_as_render)
- : OutputSingleLayerOperation(rd,
- tree,
- datatype,
- format,
- path,
- view_settings,
- display_settings,
- view_name,
- save_as_render)
+ : OutputSingleLayerOperation(
+ scene, rd, tree, datatype, format, path, view_name, save_as_render)
{
}
@@ -68,7 +60,7 @@ void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filenam
/* prepare the file with all the channels */
- if (!IMB_exr_begin_write(exrhandle, filename, width, height, format_->exr_codec, nullptr)) {
+ if (!IMB_exr_begin_write(exrhandle, filename, width, height, format_.exr_codec, nullptr)) {
printf("Error Writing Singlelayer Multiview Openexr\n");
IMB_exr_close(exrhandle);
}
@@ -104,7 +96,7 @@ void OutputOpenExrSingleLayerMultiViewOperation::deinit_execution()
datatype_,
view_name_,
width,
- format_->depth == R_IMF_CHAN_DEPTH_16,
+ format_.depth == R_IMF_CHAN_DEPTH_16,
output_buffer_);
/* memory can only be freed after we write all views to the file */
@@ -247,25 +239,17 @@ void OutputOpenExrMultiLayerMultiViewOperation::deinit_execution()
/******************************** Stereo3D ******************************/
-OutputStereoOperation::OutputStereoOperation(const RenderData *rd,
+OutputStereoOperation::OutputStereoOperation(const Scene *scene,
+ const RenderData *rd,
const bNodeTree *tree,
DataType datatype,
ImageFormatData *format,
const char *path,
const char *name,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
const char *view_name,
const bool save_as_render)
- : OutputSingleLayerOperation(rd,
- tree,
- datatype,
- format,
- path,
- view_settings,
- display_settings,
- view_name,
- save_as_render)
+ : OutputSingleLayerOperation(
+ scene, rd, tree, datatype, format, path, view_name, save_as_render)
{
BLI_strncpy(name_, name, sizeof(name_));
channels_ = get_datatype_size(datatype);
@@ -317,7 +301,7 @@ void OutputStereoOperation::deinit_execution()
1,
channels_ * width * height,
buf,
- format_->depth == R_IMF_CHAN_DEPTH_16);
+ format_.depth == R_IMF_CHAN_DEPTH_16);
image_input_ = nullptr;
output_buffer_ = nullptr;
@@ -332,7 +316,7 @@ void OutputStereoOperation::deinit_execution()
/* get rectf from EXR */
for (i = 0; i < 2; i++) {
float *rectf = IMB_exr_channel_rect(exrhandle, nullptr, name_, names[i]);
- ibuf[i] = IMB_allocImBuf(width, height, format_->planes, 0);
+ ibuf[i] = IMB_allocImBuf(width, height, format_.planes, 0);
ibuf[i]->channels = channels_;
ibuf[i]->rect_float = rectf;
@@ -340,24 +324,23 @@ void OutputStereoOperation::deinit_execution()
ibuf[i]->dither = rd_->dither_intensity;
/* do colormanagement in the individual views, so it doesn't need to do in the stereo */
- IMB_colormanagement_imbuf_for_write(
- ibuf[i], true, false, view_settings_, display_settings_, format_);
+ IMB_colormanagement_imbuf_for_write(ibuf[i], true, false, &format_);
IMB_prepare_write_ImBuf(IMB_isfloat(ibuf[i]), ibuf[i]);
}
/* create stereo buffer */
- ibuf[2] = IMB_stereo3d_ImBuf(format_, ibuf[0], ibuf[1]);
+ ibuf[2] = IMB_stereo3d_ImBuf(&format_, ibuf[0], ibuf[1]);
BKE_image_path_from_imformat(filename,
path_,
BKE_main_blendfile_path_from_global(),
rd_->cfra,
- format_,
+ &format_,
(rd_->scemode & R_EXTENSION) != 0,
true,
nullptr);
- BKE_imbuf_write(ibuf[2], filename, format_);
+ BKE_imbuf_write(ibuf[2], filename, &format_);
/* imbuf knows which rects are not part of ibuf */
for (i = 0; i < 3; i++) {
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
index 6d36db3b777..69f4011d340 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
@@ -18,13 +18,12 @@ namespace blender::compositor {
class OutputOpenExrSingleLayerMultiViewOperation : public OutputSingleLayerOperation {
private:
public:
- OutputOpenExrSingleLayerMultiViewOperation(const RenderData *rd,
+ OutputOpenExrSingleLayerMultiViewOperation(const Scene *scene,
+ const RenderData *rd,
const bNodeTree *tree,
DataType datatype,
ImageFormatData *format,
const char *path,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
const char *view_name,
bool save_as_render);
@@ -54,14 +53,13 @@ class OutputStereoOperation : public OutputSingleLayerOperation {
size_t channels_;
public:
- OutputStereoOperation(const RenderData *rd,
+ OutputStereoOperation(const Scene *scene,
+ const RenderData *rd,
const bNodeTree *tree,
DataType datatype,
struct ImageFormatData *format,
const char *path,
const char *name,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
const char *view_name,
bool save_as_render);
void *get_handle(const char *filename);
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc
index 67c92a3bcb0..cde1496546e 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cc
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc
@@ -200,16 +200,14 @@ static void write_buffer_rect(rcti *rect,
}
}
-OutputSingleLayerOperation::OutputSingleLayerOperation(
- const RenderData *rd,
- const bNodeTree *tree,
- DataType datatype,
- ImageFormatData *format,
- const char *path,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
- const char *view_name,
- const bool save_as_render)
+OutputSingleLayerOperation::OutputSingleLayerOperation(const Scene *scene,
+ const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const char *view_name,
+ const bool save_as_render)
{
rd_ = rd;
tree_ = tree;
@@ -220,11 +218,9 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(
datatype_ = datatype;
image_input_ = nullptr;
- format_ = format;
+ BKE_image_format_init_for_write(&format_, scene, format);
BLI_strncpy(path_, path, sizeof(path_));
- view_settings_ = view_settings;
- display_settings_ = display_settings;
view_name_ = view_name;
save_as_render_ = save_as_render;
}
@@ -245,7 +241,7 @@ void OutputSingleLayerOperation::deinit_execution()
if (this->get_width() * this->get_height() != 0) {
int size = get_datatype_size(datatype_);
- ImBuf *ibuf = IMB_allocImBuf(this->get_width(), this->get_height(), format_->planes, 0);
+ ImBuf *ibuf = IMB_allocImBuf(this->get_width(), this->get_height(), format_.planes, 0);
char filename[FILE_MAX];
const char *suffix;
@@ -254,8 +250,7 @@ void OutputSingleLayerOperation::deinit_execution()
ibuf->mall |= IB_rectfloat;
ibuf->dither = rd_->dither_intensity;
- IMB_colormanagement_imbuf_for_write(
- ibuf, save_as_render_, false, view_settings_, display_settings_, format_);
+ IMB_colormanagement_imbuf_for_write(ibuf, save_as_render_, false, &format_);
suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_);
@@ -263,12 +258,12 @@ void OutputSingleLayerOperation::deinit_execution()
path_,
BKE_main_blendfile_path_from_global(),
rd_->cfra,
- format_,
+ &format_,
(rd_->scemode & R_EXTENSION) != 0,
true,
suffix);
- if (0 == BKE_imbuf_write(ibuf, filename, format_)) {
+ if (0 == BKE_imbuf_write(ibuf, filename, &format_)) {
printf("Cannot save Node File Output to %s\n", filename);
}
else {
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index 51240082a80..98b7e77cc21 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -20,27 +20,23 @@ class OutputSingleLayerOperation : public MultiThreadedOperation {
const RenderData *rd_;
const bNodeTree *tree_;
- ImageFormatData *format_;
+ ImageFormatData format_;
char path_[FILE_MAX];
float *output_buffer_;
DataType datatype_;
SocketReader *image_input_;
- const ColorManagedViewSettings *view_settings_;
- const ColorManagedDisplaySettings *display_settings_;
-
const char *view_name_;
bool save_as_render_;
public:
- OutputSingleLayerOperation(const RenderData *rd,
+ OutputSingleLayerOperation(const Scene *scene,
+ const RenderData *rd,
const bNodeTree *tree,
DataType datatype,
ImageFormatData *format,
const char *path,
- const ColorManagedViewSettings *view_settings,
- const ColorManagedDisplaySettings *display_settings,
const char *view_name,
bool save_as_render);