Compare commits

...

6 Commits

8 changed files with 67 additions and 0 deletions

View File

@@ -3,8 +3,11 @@
#include "COM_MetaData.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "IMB_metadata.h"
#include "RE_pipeline.h"
namespace blender::compositor {
@@ -14,6 +17,17 @@ void MetaData::add(const blender::StringRef key, const blender::StringRef value)
entries_.add(key, value);
}
static void add_property(IDProperty *id_prop, void *user_data)
{
MetaData *meta_data = static_cast<MetaData *>(user_data);
meta_data->add(id_prop->name, IDP_String(id_prop));
}
void MetaData::add(IDProperty *id_prop)
{
IDP_foreach_property(id_prop, IDP_TYPE_FILTER_STRING, add_property, this);
}
void MetaData::add_cryptomatte_entry(const blender::StringRef layer_name,
const blender::StringRefNull key,
const blender::StringRef value)
@@ -50,6 +64,14 @@ void MetaData::add_to_render_result(RenderResult *render_result) const
}
}
void MetaData::add_to_id_prop(IDProperty *id_properties) const
{
BLI_assert(id_properties != nullptr);
for (Map<std::string, std::string>::Item entry : entries_.items()) {
IMB_metadata_set_field(id_properties, entry.key.c_str(), entry.value.c_str());
}
}
void MetaDataExtractCallbackData::add_meta_data(blender::StringRef key,
blender::StringRefNull value)
{

View File

@@ -43,6 +43,9 @@ class MetaData {
*/
void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name);
void add_to_render_result(RenderResult *render_result) const;
void add_to_id_prop(IDProperty *properties) const;
void add(IDProperty *properties);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
#endif

View File

@@ -610,6 +610,25 @@ class NodeOperation {
* The return parameter holds an instance or is an nullptr. */
virtual std::unique_ptr<MetaData> get_meta_data()
{
for (NodeOperationInput &input : inputs_) {
if (input.get_data_type() != DataType::Color) {
continue;
}
std::unique_ptr<MetaData> meta_data = input.get_reader()->get_meta_data();
if (meta_data.get()) {
return meta_data;
}
}
for (NodeOperationInput &input : inputs_) {
if (input.get_data_type() == DataType::Color) {
continue;
}
std::unique_ptr<MetaData> meta_data = input.get_reader()->get_meta_data();
if (meta_data.get()) {
return meta_data;
}
}
return std::unique_ptr<MetaData>();
}

View File

@@ -215,4 +215,13 @@ void ImageDepthOperation::update_memory_buffer_partial(MemoryBuffer *output,
}
}
std::unique_ptr<MetaData> ImageOperation::get_meta_data()
{
MetaData meta_data;
if (buffer_->metadata != nullptr) {
meta_data.add(buffer_->metadata);
}
return std::make_unique<MetaData>(meta_data);
}
} // namespace blender::compositor

View File

@@ -78,6 +78,7 @@ class ImageOperation : public BaseImageOperation {
void update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs) override;
std::unique_ptr<MetaData> get_meta_data() override;
};
class ImageAlphaOperation : public BaseImageOperation {
public:

View File

@@ -17,6 +17,7 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"
#include "RE_pipeline.h"
@@ -255,6 +256,12 @@ void OutputSingleLayerOperation::deinit_execution()
ibuf->mall |= IB_rectfloat;
ibuf->dither = rd_->dither_intensity;
std::unique_ptr<MetaData> metadata = image_input_->get_meta_data();
if (metadata.get() != nullptr) {
IMB_metadata_ensure(&ibuf->metadata);
metadata->add_to_id_prop(ibuf->metadata);
}
IMB_colormanagement_imbuf_for_write(ibuf, save_as_render_, false, &format_);
suffix = BKE_scene_multiview_view_suffix_get(rd_, view_name_);

View File

@@ -122,4 +122,9 @@ void ReadBufferOperation::update_memory_buffer()
buffer_ = this->get_memory_proxy()->get_buffer();
}
std::unique_ptr<MetaData> ReadBufferOperation::get_meta_data()
{
return get_memory_proxy()->get_write_buffer_operation()->get_meta_data();
}
} // namespace blender::compositor

View File

@@ -57,6 +57,7 @@ class ReadBufferOperation : public NodeOperation {
}
void read_resolution_from_write_buffer();
void update_memory_buffer();
std::unique_ptr<MetaData> get_meta_data() override;
};
} // namespace blender::compositor