Blender  V3.3
COM_MetaData.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. */
3 
4 #pragma once
5 
6 #include <string>
7 
8 #include "BKE_cryptomatte.hh"
9 #include "BLI_map.hh"
10 
11 #include "MEM_guardedalloc.h"
12 
13 /* Forward declarations. */
14 struct RenderResult;
15 
16 namespace blender::compositor {
17 
18 /* Cryptomatte includes hash in its meta data keys. The hash is generated from the render
19  * layer/pass name. Compositing happens without the knowledge of the original layer and pass. The
20  * next keys are used to transfer the cryptomatte meta data in a neutral way. The file output node
21  * will generate a hash based on the layer name configured by the user.
22  *
23  * The `{hash}` has no special meaning except to make sure that the meta data stays unique. */
24 constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_HASH("cryptomatte/{hash}/hash");
25 constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_CONVERSION("cryptomatte/{hash}/conversion");
26 constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_MANIFEST("cryptomatte/{hash}/manifest");
27 constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/name");
28 
29 class MetaData {
30  private:
32  void add_cryptomatte_entry(const blender::StringRef layer_name,
33  const blender::StringRefNull key,
34  const blender::StringRef value);
35 
36  public:
37  void add(const blender::StringRef key, const blender::StringRef value);
45  void add_to_render_result(RenderResult *render_result) const;
46 #ifdef WITH_CXX_GUARDEDALLOC
47  MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
48 #endif
49 };
50 
52  std::unique_ptr<MetaData> meta_data;
53  std::string hash_key;
54  std::string conversion_key;
55  std::string manifest_key;
56 
58  void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name);
59  /* C type callback function (StampCallback). */
60  static void extract_cryptomatte_meta_data(void *_data,
61  const char *propname,
62  char *propvalue,
63  int UNUSED(len));
64 };
65 
66 } // namespace blender::compositor
#define UNUSED(x)
Read Guarded memory(de)allocation.
void add_to_render_result(RenderResult *render_result) const
Definition: COM_MetaData.cc:46
void add(const blender::StringRef key, const blender::StringRef value)
Definition: COM_MetaData.cc:12
void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name)
Definition: COM_MetaData.cc:24
int len
Definition: draw_manager.c:108
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_CONVERSION("cryptomatte/{hash}/conversion")
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_HASH("cryptomatte/{hash}/hash")
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_MANIFEST("cryptomatte/{hash}/manifest")
constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/name")
void add_meta_data(blender::StringRef key, blender::StringRefNull value)
Definition: COM_MetaData.cc:53
void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name)
Definition: COM_MetaData.cc:62
static void extract_cryptomatte_meta_data(void *_data, const char *propname, char *propvalue, int UNUSED(len))
Definition: COM_MetaData.cc:72