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:
-rw-r--r--intern/cycles/blender/blender_session.cpp34
-rw-r--r--intern/cycles/blender/blender_session.h3
-rw-r--r--source/blender/blenkernel/intern/image.c46
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/screen/area.c25
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c36
-rw-r--r--source/blender/editors/space_image/image_buttons.c28
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c56
-rw-r--r--source/blender/imbuf/IMB_metadata.h4
-rw-r--r--source/blender/imbuf/intern/metadata.c7
10 files changed, 224 insertions, 17 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 6e6d98b19dd..e8a0e6dce39 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -393,6 +393,28 @@ static void add_cryptomatte_layer(BL::RenderResult& b_rr, string name, string ma
render_add_metadata(b_rr, prefix+"manifest", manifest);
}
+void BlenderSession::stamp_view_layer_metadata_do(const string& prefix)
+{
+ BL::RenderResult b_rr = b_engine.get_result();
+ /* Configured number of samples for the view layer. */
+ b_rr.stamp_data_add_field((prefix + "samples").c_str(),
+ to_string(session->params.samples).c_str());
+ /* Store ranged samples information. */
+ if(session->tile_manager.range_num_samples != -1) {
+ b_rr.stamp_data_add_field(
+ (prefix + "range_start_sample").c_str(),
+ to_string(session->tile_manager.range_start_sample).c_str());
+ b_rr.stamp_data_add_field(
+ (prefix + "range_num_samples").c_str(),
+ to_string(session->tile_manager.range_num_samples).c_str());
+ }
+}
+
+void BlenderSession::stamp_view_layer_metadata(const string& view_layer_name)
+{
+ stamp_view_layer_metadata_do("cycles." + view_layer_name + ".");
+}
+
void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
{
b_depsgraph = b_depsgraph_;
@@ -408,9 +430,6 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
/* render each layer */
BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
- /* We do some special meta attributes when we only have single layer. */
- const bool is_single_layer = (b_scene.view_layers.length() == 1);
-
/* temporary render result to find needed passes and views */
BL::RenderResult b_rr = begin_render_result(b_engine, 0, 0, 1, 1, b_view_layer.name().c_str(), NULL);
BL::RenderResult::layers_iterator b_single_rlay;
@@ -525,14 +544,7 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
break;
}
- if(is_single_layer) {
- BL::RenderResult b_rr = b_engine.get_result();
- string num_aa_samples = string_printf("%d", session->params.samples);
- b_rr.stamp_data_add_field("Cycles Samples", num_aa_samples.c_str());
- /* TODO(sergey): Report whether we're doing resumable render
- * and also start/end sample if so.
- */
- }
+ stamp_view_layer_metadata(b_rlay_name);
/* Write cryptomatte metadata. */
if(scene->film->cryptomatte_passes & CRYPT_OBJECT) {
diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h
index 96ffc06a3db..9edc4887928 100644
--- a/intern/cycles/blender/blender_session.h
+++ b/intern/cycles/blender/blender_session.h
@@ -151,6 +151,9 @@ public:
static bool print_render_stats;
protected:
+ void stamp_view_layer_metadata(const string& view_layer_name);
+ void stamp_view_layer_metadata_do(const string& prefix);
+
void do_write_update_render_result(BL::RenderResult& b_rr,
BL::RenderLayer& b_rlay,
RenderTile& rtile,
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 3ba216dcc13..5428c921042 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -2094,6 +2094,24 @@ struct StampData *BKE_stamp_info_from_scene_static(Scene *scene)
return stamp_data;
}
+static const char *stamp_metadata_fields[] = {
+ "File",
+ "Note",
+ "Date",
+ "Marker",
+ "Time",
+ "Frame",
+ "FrameRange",
+ "Camera",
+ "Lens",
+ "Scene",
+ "Strip",
+ "RenderTime",
+ "Memory",
+ "Hostname",
+ NULL
+};
+
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
{
if ((callback == NULL) || (stamp_data == NULL)) {
@@ -2105,6 +2123,8 @@ void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCall
callback(data, value_str, stamp_data->member, sizeof(stamp_data->member)); \
} ((void)0)
+ /* TODO(sergey): Use stamp_metadata_fields somehow, or make it more generic
+ * meta information to avoid duplication. */
CALL(file, "File");
CALL(note, "Note");
CALL(date, "Date");
@@ -2177,6 +2197,30 @@ 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)) {
+ return;
+ }
+ RenderResult *rr = (RenderResult *)rr_v;
+ BKE_render_result_stamp_data(rr, field, value);
+}
+
void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf)
{
if (rr->stamp_data == NULL) {
@@ -2185,6 +2229,8 @@ void BKE_stamp_info_from_imbuf(RenderResult *rr, struct ImBuf *ibuf)
struct StampData *stamp_data = rr->stamp_data;
IMB_metadata_ensure(&ibuf->metadata);
BKE_stamp_info_callback(ibuf, stamp_data, metadata_get_field, true);
+ /* Copy render engine specific settings. */
+ IMB_metadata_foreach(ibuf, metadata_copy_custom_fields, rr);
}
bool BKE_imbuf_alpha_test(ImBuf *ibuf)
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index e3146668571..b5ea993900c 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -47,6 +47,7 @@ struct bContext;
struct bScreen;
struct rcti;
struct uiBlock;
+struct uiLayout;
struct wmEvent;
struct wmKeyConfig;
struct wmMsgBus;
@@ -98,6 +99,7 @@ void ED_region_visibility_change_update(struct bContext *C, struct ARegion *a
void ED_region_info_draw(struct ARegion *ar, const char *text, float fill_color[4], const bool full_redraw);
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw);
void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
+void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout);
void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
float ED_region_blend_alpha(struct ARegion *ar);
void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index cafe627372b..e8a393dfc37 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2756,7 +2756,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
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)) {
- BLF_position(fontid, xmin + ofs_x, ymin, 0.0f);
+ BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f);
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
@@ -2802,6 +2802,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
for (i = 5; i < 10; i++) {
if (metadata_is_valid(ibuf, str, i, 0)) {
count = 1;
+ break;
}
}
}
@@ -2886,6 +2887,28 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame,
GPU_matrix_pop();
}
+typedef struct MetadataPanelDrawContext {
+ uiLayout *layout;
+} MetadataPanelDrawContext;
+
+static void metadata_panel_draw_field(
+ const char *field,
+ const char *value,
+ void *ctx_v)
+{
+ MetadataPanelDrawContext *ctx = (MetadataPanelDrawContext *)ctx_v;
+ uiLayout *row = uiLayoutRow(ctx->layout, false);
+ uiItemL(row, field, ICON_NONE);
+ uiItemL(row, value, ICON_NONE);
+}
+
+void ED_region_image_metadata_panel_draw(ImBuf *ibuf, uiLayout *layout)
+{
+ MetadataPanelDrawContext ctx;
+ ctx.layout = layout;
+ IMB_metadata_foreach(ibuf, metadata_panel_draw_field, &ctx);
+}
+
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
{
float gridsize, gridstep = 1.0f / 32.0f;
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index 3810b60adf2..4b91d98718d 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -29,8 +29,9 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
@@ -43,7 +44,9 @@
#include "DEG_depsgraph.h"
+#include "ED_clip.h"
#include "ED_gpencil.h"
+#include "ED_screen.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -60,9 +63,38 @@
/* Panels */
-void ED_clip_buttons_register(ARegionType *UNUSED(art))
+static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+ return ED_space_clip_poll((bContext *)C);
+}
+
+static void metadata_panel_context_draw(const bContext *C, Panel *panel)
{
+ SpaceClip *space_clip = CTX_wm_space_clip(C);
+ /* NOTE: This might not be exactly the same image buffer as shown in the
+ * clip editor itself, since that might be coming from proxy, or being
+ * postprocessed (stabilized or undistored).
+ * Ideally we need to query metadata from an original image or movie without
+ * reading actual pixels to speed up the process. */
+ ImBuf *ibuf = ED_space_clip_get_buffer(space_clip);
+ if (ibuf != NULL) {
+ ED_region_image_metadata_panel_draw(ibuf, panel->layout);
+ IMB_freeImBuf(ibuf);
+ }
+}
+void ED_clip_buttons_register(ARegionType *art)
+{
+ PanelType *pt;
+
+ pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel metadata");
+ strcpy(pt->idname, "CLIP_PT_metadata");
+ strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->category, "Footage");
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->poll = metadata_panel_context_poll;
+ pt->draw = metadata_panel_context_draw;
+ BLI_addtail(&art->paneltypes, pt);
}
/********************* MovieClip Template ************************/
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index db0fa34879a..1a7e81f55aa 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1269,9 +1269,35 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
#undef MAX_IMAGE_INFO_LEN
-void image_buttons_register(ARegionType *UNUSED(art))
+static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
{
+ SpaceImage *space_image = CTX_wm_space_image(C);
+ return space_image != NULL && space_image->image != NULL;
+}
+static void metadata_panel_context_draw(const bContext *C, Panel *panel)
+{
+ void *lock;
+ SpaceImage *space_image = CTX_wm_space_image(C);
+ Image *image = space_image->image;
+ ImBuf *ibuf = BKE_image_acquire_ibuf(image, &space_image->iuser, &lock);
+ if (ibuf != NULL) {
+ ED_region_image_metadata_panel_draw(ibuf, panel->layout);
+ }
+ BKE_image_release_ibuf(image, ibuf, lock);
+}
+
+void image_buttons_register(ARegionType *art)
+{
+ PanelType *pt;
+
+ pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
+ strcpy(pt->idname, "IMAGE_PT_metadata");
+ strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->poll = metadata_panel_context_poll;
+ pt->draw = metadata_panel_context_draw;
+ BLI_addtail(&art->paneltypes, pt);
}
static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index abe6a58c9ef..39d674b421a 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -27,10 +27,12 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "BLT_translation.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_screen.h"
#include "ED_screen.h"
@@ -40,6 +42,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
#include "sequencer_intern.h"
@@ -55,11 +59,51 @@ static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNU
}
#endif
-void sequencer_buttons_register(ARegionType *UNUSED(art))
+static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+ SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
+ if (space_sequencer == NULL) {
+ return false;
+ }
+ return ED_space_sequencer_check_show_imbuf(space_sequencer);
+}
+
+static void metadata_panel_context_draw(const bContext *C, Panel *panel)
+{
+ /* Image buffer can not be acquired during render, similar to
+ * draw_image_seq(). */
+ if (G.is_rendering) {
+ return;
+ }
+ struct Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Scene *scene = CTX_data_scene(C);
+ SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
+ /* NOTE: We can only reliably show metadata for the original (current)
+ * frame when split view is used. */
+ const bool show_split = (
+ scene->ed &&
+ (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
+ (space_sequencer->mainb == SEQ_DRAW_IMG_IMBUF));
+ if (show_split &&
+ space_sequencer->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE)
+ {
+ return;
+ }
+ /* NOTE: We disable multiview for drawing, since we don't know what is the
+ * from the panel (is kind of all the views?). */
+ ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
+ if (ibuf != NULL) {
+ ED_region_image_metadata_panel_draw(ibuf, panel->layout);
+ IMB_freeImBuf(ibuf);
+ }
+}
+
+void sequencer_buttons_register(ARegionType *art)
{
-#if 0
PanelType *pt;
+#if 0
pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
strcpy(pt->idname, "SEQUENCER_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
@@ -69,6 +113,14 @@ void sequencer_buttons_register(ARegionType *UNUSED(art))
pt->poll = sequencer_grease_pencil_panel_poll;
BLI_addtail(&art->paneltypes, pt);
#endif
+
+ pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel metadata");
+ strcpy(pt->idname, "SEQUENCER_PT_metadata");
+ strcpy(pt->label, N_("Metadata"));
+ strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ pt->poll = metadata_panel_context_poll;
+ pt->draw = metadata_panel_context_draw;
+ BLI_addtail(&art->paneltypes, pt);
}
/* **************** operator to open/close properties view ************* */
diff --git a/source/blender/imbuf/IMB_metadata.h b/source/blender/imbuf/IMB_metadata.h
index df26682a466..72b5a95287c 100644
--- a/source/blender/imbuf/IMB_metadata.h
+++ b/source/blender/imbuf/IMB_metadata.h
@@ -66,4 +66,8 @@ void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const
void IMB_metadata_copy(struct ImBuf *dimb, struct ImBuf *simb);
struct IDProperty *IMB_anim_load_metadata(struct anim *anim);
+/* Invoke callback for every value stored in the metadata. */
+typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata);
+void IMB_metadata_foreach(struct ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata);
+
#endif /* __IMB_METADATA_H__ */
diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c
index 1601737ffc7..01b9abe6a38 100644
--- a/source/blender/imbuf/intern/metadata.c
+++ b/source/blender/imbuf/intern/metadata.c
@@ -102,3 +102,10 @@ void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const
IDP_AssignString(prop, value, METADATA_MAX_VALUE_LENGTH);
}
+
+void IMB_metadata_foreach(struct ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata)
+{
+ for (IDProperty *prop = ibuf->metadata->data.group.first; prop != NULL; prop = prop->next) {
+ callback(prop->name, IDP_String(prop), userdata);
+ }
+}