De-duplicate stamp callback

This commit is contained in:
Campbell Barton 2015-06-12 14:34:20 +02:00
parent 850bb80aef
commit 4fae3620d0

@ -2079,41 +2079,43 @@ void BKE_render_result_stamp_info(Scene *scene, Object *camera, struct RenderRes
}
}
void BKE_stamp_info_callback(void *data, const struct StampData *stamp_data, StampCallback callback)
{
if (!callback || !stamp_data) {
return;
}
#define CALL(member, value_str) \
if (stamp_data->member[0]) { \
callback(data, value_str, stamp_data->member); \
} ((void)0)
CALL(file, "File");
CALL(note, "Note");
CALL(date, "Date");
CALL(marker, "Marker");
CALL(time, "Time");
CALL(frame, "Frame");
CALL(camera, "Camera");
CALL(cameralens, "Lens");
CALL(scene, "Scene");
CALL(strip, "Strip");
CALL(rendertime, "RenderTime");
#undef CALL
}
/* wrap for callback only */
static void metadata_change_field(void *data, const char *propname, const char *propvalue)
{
IMB_metadata_change_field(data, propname, propvalue);
}
void BKE_imbuf_stamp_info(RenderResult *rr, struct ImBuf *ibuf)
{
struct StampData *stamp_data = rr->stamp_data;
if (!ibuf || !stamp_data) return;
if (stamp_data->file[0]) IMB_metadata_change_field(ibuf, "File", stamp_data->file);
if (stamp_data->note[0]) IMB_metadata_change_field(ibuf, "Note", stamp_data->note);
if (stamp_data->date[0]) IMB_metadata_change_field(ibuf, "Date", stamp_data->date);
if (stamp_data->marker[0]) IMB_metadata_change_field(ibuf, "Marker", stamp_data->marker);
if (stamp_data->time[0]) IMB_metadata_change_field(ibuf, "Time", stamp_data->time);
if (stamp_data->frame[0]) IMB_metadata_change_field(ibuf, "Frame", stamp_data->frame);
if (stamp_data->camera[0]) IMB_metadata_change_field(ibuf, "Camera", stamp_data->camera);
if (stamp_data->cameralens[0]) IMB_metadata_change_field(ibuf, "Lens", stamp_data->cameralens);
if (stamp_data->scene[0]) IMB_metadata_change_field(ibuf, "Scene", stamp_data->scene);
if (stamp_data->strip[0]) IMB_metadata_change_field(ibuf, "Strip", stamp_data->strip);
if (stamp_data->rendertime[0]) IMB_metadata_change_field(ibuf, "RenderTime", stamp_data->rendertime);
}
void BKE_stamp_info_callback(void *data, const struct StampData *stamp_data, StampCallback callback)
{
if (!callback || !stamp_data) return;
if (stamp_data->file[0]) callback(data, "File", stamp_data->file);
if (stamp_data->note[0]) callback(data, "Note", stamp_data->note);
if (stamp_data->date[0]) callback(data, "Date", stamp_data->date);
if (stamp_data->marker[0]) callback(data, "Marker", stamp_data->marker);
if (stamp_data->time[0]) callback(data, "Time", stamp_data->time);
if (stamp_data->frame[0]) callback(data, "Frame", stamp_data->frame);
if (stamp_data->camera[0]) callback(data, "Camera", stamp_data->camera);
if (stamp_data->cameralens[0]) callback(data, "Lens", stamp_data->cameralens);
if (stamp_data->scene[0]) callback(data, "Scene", stamp_data->scene);
if (stamp_data->strip[0]) callback(data, "Strip", stamp_data->strip);
if (stamp_data->rendertime[0]) callback(data, "RenderTime", stamp_data->rendertime);
BKE_stamp_info_callback(ibuf, stamp_data, metadata_change_field);
}