diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-02-07 12:08:01 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-02-07 13:55:07 +0300 |
commit | 9c68ac0448b69b9d05380dc8665fb1f6a28f2edf (patch) | |
tree | 9f1f89343017460d40b2f71f6612c10fe22708b9 /source/blender | |
parent | 0885484aa60336f601c0ea8042f82172198ec7ef (diff) |
Show all useful metadata fields in editors
Is available when doing "View -> Show Metadata". Will draw all the
fields which are not part of the stamp at the bottom of the image.
Couple of hand-picked fields are ignored, since those are not very
useful to be seen.
Aimed to ease review of rendered shots.
Reviewers: brecht
Reviewed By: brecht
Subscribers: fsiddi
Differential Revision: https://developer.blender.org/D4316
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 28 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 70 |
3 files changed, 86 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index a50036b1b9b..f3b4409a04b 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -61,6 +61,7 @@ void BKE_render_result_stamp_info(struct Scene *scene, struct Object *camera, * The caller is responsible for freeing the allocated memory. */ struct StampData *BKE_stamp_info_from_scene_static(struct Scene *scene); +bool BKE_stamp_is_known_field(const char *field_name); 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); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5428c921042..fe99863827e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2112,6 +2112,20 @@ static const char *stamp_metadata_fields[] = { NULL }; +/* Check whether the given metadata field name translates to a known field of + * a stamp. */ +bool BKE_stamp_is_known_field(const char *field_name) +{ + int i = 0; + while (stamp_metadata_fields[i] != NULL) { + if (STREQ(field_name, stamp_metadata_fields[i])) { + return true; + } + i++; + } + return false; +} + void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip) { if ((callback == NULL) || (stamp_data == NULL)) { @@ -2197,24 +2211,12 @@ void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf) BKE_stamp_info_callback(ibuf, stamp_data, metadata_set_field, false); } -BLI_INLINE bool metadata_is_copyable(const char *field_name) -{ - int i = 0; - while (stamp_metadata_fields[i] != NULL) { - if (STREQ(field_name, stamp_metadata_fields[i])) { - return false; - } - i++; - } - return true; -} - static void metadata_copy_custom_fields( const char *field, const char *value, void *rr_v) { - if (!metadata_is_copyable(field)) { + if (BKE_stamp_is_known_field(field)) { return; } RenderResult *rr = (RenderResult *)rr_v; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e8a393dfc37..96aa7a15c45 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -35,6 +35,7 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_screen.h" #include "BKE_workspace.h" @@ -2678,6 +2679,45 @@ BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int off return (IMB_metadata_get_field(ibuf->metadata, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) && r_str[0]); } +BLI_INLINE bool metadata_is_custom_drawable(const char *field) +{ + /* Metadata field stored by Blender for multilayer EXR images. Is rather + * useless to be viewed all the time. Can still be seen in the Metadata + * panel. */ + if (STREQ(field, "BlenderMultiChannel")) { + return false; + } + /* Is almost always has value "scanlineimage", also useless to be seen + * all the time. */ + if (STREQ(field, "type")) { + return false; + } + return !BKE_stamp_is_known_field(field); +} + +typedef struct MetadataCustomDrawContext { + int fontid; + int xmin, ymin; + int vertical_offset; + int current_y; +} MetadataCustomDrawContext; + +static void metadata_custom_draw_fields( + const char *field, + const char *value, + void *ctx_v) +{ + if (!metadata_is_custom_drawable(field)) { + return; + } + MetadataCustomDrawContext *ctx = (MetadataCustomDrawContext *)ctx_v; + char temp_str[MAX_METADATA_STR]; + BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: %s", field, value); + BLF_position(ctx->fontid, ctx->xmin, ctx->ymin + ctx->current_y, 0.0f); + BLF_draw(ctx->fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + ctx->current_y += ctx->vertical_offset; +} + static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top) { char temp_str[MAX_METADATA_STR]; @@ -2752,7 +2792,16 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const } } else { + MetadataCustomDrawContext ctx; + ctx.fontid = fontid; + ctx.xmin = xmin; + ctx.ymin = ymin; + ctx.vertical_offset = vertical_offset; + ctx.current_y = ofs_y; + ctx.vertical_offset = vertical_offset; + IMB_metadata_foreach(ibuf, metadata_custom_draw_fields, &ctx); int ofs_x = 0; + ofs_y = ctx.current_y; for (i = 5; i < 10; i++) { len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]); if (metadata_is_valid(ibuf, temp_str, i, len)) { @@ -2765,6 +2814,23 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const } } +typedef struct MetadataCustomCountContext { + int count; +} MetadataCustomCountContext; + +static void metadata_custom_count_fields( + const char *field, + const char *UNUSED(value), + void *ctx_v) +{ + if (!metadata_is_custom_drawable(field)) { + return; + } + MetadataCustomCountContext *ctx = (MetadataCustomCountContext *)ctx_v; + ctx->count++; +} + + static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) { const float height = BLF_height_max(fontid); @@ -2805,6 +2871,10 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) break; } } + MetadataCustomCountContext ctx; + ctx.count = 0; + IMB_metadata_foreach(ibuf, metadata_custom_count_fields, &ctx); + count += ctx.count; } if (count) { |