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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-02-06 19:03:59 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-10-31 17:05:53 +0300
commit040ea955177bd5b1d8767e247aa0a3d68815c50b (patch)
tree749bd591bd5e9b580bfcdc311e8e48c8aeb7c59d /source
parenta6d2fd0215c4f4507281aaf37f456771841ee6b1 (diff)
Add ability to specify custom fields to be saved from render result
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c39
2 files changed, 40 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 01f5d332c30..57459412efc 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -70,6 +70,7 @@ void BKE_render_result_stamp_info(struct Scene *scene, struct Object *camera,
void BKE_imbuf_stamp_info(struct RenderResult *rr, struct ImBuf *ibuf);
void BKE_stamp_info_from_imbuf(struct RenderResult *rr, struct ImBuf *ibuf);
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip);
+void BKE_render_result_stamp_data(struct RenderResult *rr, const char *key, const char *value);
void BKE_stamp_data_free(struct StampData *stamp_data);
void BKE_image_stamp_buf(
struct Scene *scene, struct Object *camera, const struct StampData *stamp_data_template,
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 7706bf921f4..45c718fd5e4 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1607,6 +1607,14 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i
#define STAMP_NAME_SIZE ((MAX_ID_NAME - 2) + 16)
/* could allow access externally - 512 is for long names,
* STAMP_NAME_SIZE is for id names, allowing them some room for description */
+typedef struct StampDataCustomField {
+ struct StampDataCustomField *next, *prev;
+ /* TODO(sergey): Think of better size here, maybe dynamically allocated even. */
+ char key[512];
+ char value[512];
+ /* TODO(sergey): Support non-string values. */
+} StampDataCustomField;
+
typedef struct StampData {
char file[512];
char note[512];
@@ -1620,6 +1628,13 @@ typedef struct StampData {
char strip[STAMP_NAME_SIZE];
char rendertime[STAMP_NAME_SIZE];
char memory[STAMP_NAME_SIZE];
+
+ /* Custom fields are used to put extra meta information header from render
+ * engine to the result image.
+ *
+ * NOTE: This fields are not stamped onto the image. At least for now.
+ */
+ ListBase custom_fields;
} StampData;
#undef STAMP_NAME_SIZE
@@ -2121,14 +2136,38 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
CALL(rendertime, "RenderTime");
CALL(memory, "Memory");
+ for (StampDataCustomField *custom_field = stamp_data->custom_fields.first;
+ custom_field != NULL;
+ custom_field = custom_field->next)
+ {
+ if (noskip || custom_field->value[0]) {
+ callback(data, custom_field->key, custom_field->value, sizeof(custom_field->value));
+ }
+ }
+
#undef CALL
}
+void BKE_render_result_stamp_data(RenderResult *rr, const char *key, const char *value)
+{
+ StampData *stamp_data;
+ if (rr->stamp_data == NULL) {
+ rr->stamp_data = MEM_callocN(sizeof(StampData), "RenderResult.stamp_data");
+ }
+ stamp_data = rr->stamp_data;
+ StampDataCustomField *field = MEM_mallocN(sizeof(StampDataCustomField),
+ "StampData Custom Field");
+ BLI_strncpy(field->key, key, sizeof(field->key));
+ BLI_strncpy(field->value, value, sizeof(field->value));
+ BLI_addtail(&stamp_data->custom_fields, field);
+}
+
void BKE_stamp_data_free(struct StampData *stamp_data)
{
if (stamp_data == NULL) {
return;
}
+ BLI_freelistN(&stamp_data->custom_fields);
MEM_freeN(stamp_data);
}