Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/image.c
| Show First 20 Lines • Show All 1,742 Lines • ▼ Show 20 Lines | typedef struct StampData { | ||||
| char marker[512]; | char marker[512]; | ||||
| char time[512]; | char time[512]; | ||||
| char frame[512]; | char frame[512]; | ||||
| char camera[STAMP_NAME_SIZE]; | char camera[STAMP_NAME_SIZE]; | ||||
| char cameralens[STAMP_NAME_SIZE]; | char cameralens[STAMP_NAME_SIZE]; | ||||
| char scene[STAMP_NAME_SIZE]; | char scene[STAMP_NAME_SIZE]; | ||||
| char strip[STAMP_NAME_SIZE]; | char strip[STAMP_NAME_SIZE]; | ||||
| char rendertime[STAMP_NAME_SIZE]; | char rendertime[STAMP_NAME_SIZE]; | ||||
| char memory[STAMP_NAME_SIZE]; | |||||
| } StampData; | } StampData; | ||||
| #undef STAMP_NAME_SIZE | #undef STAMP_NAME_SIZE | ||||
| static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix) | static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix) | ||||
| { | { | ||||
| char text[256]; | char text[256]; | ||||
| struct tm *tl; | struct tm *tl; | ||||
| time_t t; | time_t t; | ||||
| ▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | else { | ||||
| if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { | if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { | ||||
| BLI_timecode_string_from_time_simple(text, sizeof(text), stats->lastframetime); | BLI_timecode_string_from_time_simple(text, sizeof(text), stats->lastframetime); | ||||
| BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text); | BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text); | ||||
| } | } | ||||
| else { | else { | ||||
| stamp_data->rendertime[0] = '\0'; | stamp_data->rendertime[0] = '\0'; | ||||
| } | } | ||||
| if (stats && (scene->r.stamp & R_STAMP_MEMORY)) { | |||||
| BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), do_prefix ? "Peak Memory %.2fM" : "%.2fM", stats->mem_peak); | |||||
| } | |||||
| else { | |||||
| stamp_data->memory[0] = '\0'; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* Will always add prefix. */ | /* Will always add prefix. */ | ||||
| static void stampdata_from_template(StampData *stamp_data, | static void stampdata_from_template(StampData *stamp_data, | ||||
| const Scene *scene, | const Scene *scene, | ||||
| const StampData *stamp_data_template) | const StampData *stamp_data_template) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | else { | ||||
| stamp_data->strip[0] = '\0'; | stamp_data->strip[0] = '\0'; | ||||
| } | } | ||||
| if (scene->r.stamp & R_STAMP_RENDERTIME) { | if (scene->r.stamp & R_STAMP_RENDERTIME) { | ||||
| BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), "RenderTime %s", stamp_data_template->rendertime); | BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), "RenderTime %s", stamp_data_template->rendertime); | ||||
| } | } | ||||
| else { | else { | ||||
| stamp_data->rendertime[0] = '\0'; | stamp_data->rendertime[0] = '\0'; | ||||
| } | } | ||||
| if (scene->r.stamp & R_STAMP_MEMORY) { | |||||
| BLI_snprintf(stamp_data->memory, sizeof(stamp_data->memory), "Peak Memory %s", stamp_data_template->memory); | |||||
| } | |||||
| else { | |||||
| stamp_data->memory[0] = '\0'; | |||||
| } | |||||
| } | } | ||||
| void BKE_image_stamp_buf( | void BKE_image_stamp_buf( | ||||
| Scene *scene, Object *camera, const StampData *stamp_data_template, | Scene *scene, Object *camera, const StampData *stamp_data_template, | ||||
| unsigned char *rect, float *rectf, int width, int height, int channels) | unsigned char *rect, float *rectf, int width, int height, int channels) | ||||
| { | { | ||||
| struct StampData stamp_data; | struct StampData stamp_data; | ||||
| float w, h, pad; | float w, h, pad; | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if (TEXT_SIZE_CHECK(stamp_data.rendertime, w, h)) { | ||||
| BLF_position(mono, x, y + y_ofs, 0.0); | BLF_position(mono, x, y + y_ofs, 0.0); | ||||
| BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX); | BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX); | ||||
| /* the extra pixel for background. */ | /* the extra pixel for background. */ | ||||
| y -= BUFF_MARGIN_Y * 2; | y -= BUFF_MARGIN_Y * 2; | ||||
| } | } | ||||
| /* Top left corner, below File, Date, Rendertime */ | /* Top left corner, below File, Date, Rendertime */ | ||||
| if (TEXT_SIZE_CHECK(stamp_data.memory, w, h)) { | |||||
| y -= h; | |||||
| /* and space for background. */ | |||||
| buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, | |||||
| 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); | |||||
| BLF_position(mono, x, y + y_ofs, 0.0); | |||||
| BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX); | |||||
| /* the extra pixel for background. */ | |||||
| y -= BUFF_MARGIN_Y * 2; | |||||
| } | |||||
| /* Top left corner, below File, Date, Memory, Rendertime */ | |||||
| BLF_enable(mono, BLF_WORD_WRAP); | BLF_enable(mono, BLF_WORD_WRAP); | ||||
| if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) { | if (TEXT_SIZE_CHECK_WORD_WRAP(stamp_data.note, w, h)) { | ||||
| y -= h; | y -= h; | ||||
| /* and space for background. */ | /* and space for background. */ | ||||
| buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, | buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, | ||||
| 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); | 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | #define CALL(member, value_str) \ | ||||
| CALL(marker, "Marker"); | CALL(marker, "Marker"); | ||||
| CALL(time, "Time"); | CALL(time, "Time"); | ||||
| CALL(frame, "Frame"); | CALL(frame, "Frame"); | ||||
| CALL(camera, "Camera"); | CALL(camera, "Camera"); | ||||
| CALL(cameralens, "Lens"); | CALL(cameralens, "Lens"); | ||||
| CALL(scene, "Scene"); | CALL(scene, "Scene"); | ||||
| CALL(strip, "Strip"); | CALL(strip, "Strip"); | ||||
| CALL(rendertime, "RenderTime"); | CALL(rendertime, "RenderTime"); | ||||
| CALL(memory, "Memory"); | |||||
| #undef CALL | #undef CALL | ||||
| } | } | ||||
| /* wrap for callback only */ | /* wrap for callback only */ | ||||
| static void metadata_change_field(void *data, const char *propname, char *propvalue, int UNUSED(len)) | static void metadata_change_field(void *data, const char *propname, char *propvalue, int UNUSED(len)) | ||||
| { | { | ||||
| IMB_metadata_change_field(data, propname, propvalue); | IMB_metadata_change_field(data, propname, propvalue); | ||||
| ▲ Show 20 Lines • Show All 2,600 Lines • Show Last 20 Lines | |||||