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:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-04-05 17:27:15 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-04-05 17:50:23 +0300
commitb0a767b85b0acacc40a414dd3f961b206a6b22f0 (patch)
treed26a65ede1ec7d0e20ec45838af8a3a78586e271 /source/blender/imbuf/intern/thumbs.c
parentf0f6c96a9204419c429c38915d9340d092b570c4 (diff)
IMB_metadata improvements
- Metadata handling is now separate from `ImBuf *`, allowing it to be used with a generic `IDProperty *`. - Merged `IMB_metadata_add_field()` and `IMB_metadata_change_field()` into a more robust `IMB_metadata_set_field()`. This new function doesn't return any status (it now always succeeds, and the previously existing return value was never checked anyway). - Removed `IMB_metadata_del_field()` as it was never actually used anywhere. - Use `IMB_metadata_ensure()` instead of having `IMB_metadata_set_field()` create the containing `IDProperty` for you. - Deduplicated function declarations, moved `intern/IMB_metadata.h` out of `intern/`. Note that this does mean that we have some extra `#include "IMB_metadata.h"` lines now, as the metadata functions are no longer declared in `IMB_imbuf.h`. - Deduplicated function declarations, all metadata-related declarations are now in imbuf/IMB_metadata.h. Part of: https://developer.blender.org/D2273 Reviewed by: @campbellbarton
Diffstat (limited to 'source/blender/imbuf/intern/thumbs.c')
-rw-r--r--source/blender/imbuf/intern/thumbs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 3c587684641..2fa5b5a0170 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -430,16 +430,17 @@ static ImBuf *thumb_create_ex(
IMB_scaleImBuf(img, ex, ey);
}
BLI_snprintf(desc, sizeof(desc), "Thumbnail for %s", uri);
- IMB_metadata_change_field(img, "Description", desc);
- IMB_metadata_change_field(img, "Software", "Blender");
- IMB_metadata_change_field(img, "Thumb::URI", uri);
- IMB_metadata_change_field(img, "Thumb::MTime", mtime);
+ IMB_metadata_ensure(&img->metadata);
+ IMB_metadata_set_field(img->metadata, "Software", "Blender");
+ IMB_metadata_set_field(img->metadata, "Thumb::URI", uri);
+ IMB_metadata_set_field(img->metadata, "Description", desc);
+ IMB_metadata_set_field(img->metadata, "Thumb::MTime", mtime);
if (use_hash) {
- IMB_metadata_change_field(img, "X-Blender::Hash", hash);
+ IMB_metadata_set_field(img->metadata, "X-Blender::Hash", hash);
}
if (ELEM(source, THB_SOURCE_IMAGE, THB_SOURCE_BLEND, THB_SOURCE_FONT)) {
- IMB_metadata_change_field(img, "Thumb::Image::Width", cwidth);
- IMB_metadata_change_field(img, "Thumb::Image::Height", cheight);
+ IMB_metadata_set_field(img->metadata, "Thumb::Image::Width", cwidth);
+ IMB_metadata_set_field(img->metadata, "Thumb::Image::Height", cheight);
}
img->ftype = IMB_FTYPE_PNG;
img->planes = 32;
@@ -589,7 +590,7 @@ ImBuf *IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source
const bool use_hash = thumbhash_from_path(file_path, source, thumb_hash);
- if (IMB_metadata_get_field(img, "Thumb::MTime", mtime, sizeof(mtime))) {
+ if (IMB_metadata_get_field(img->metadata, "Thumb::MTime", mtime, sizeof(mtime))) {
regenerate = (st.st_mtime != atol(mtime));
}
else {
@@ -598,7 +599,7 @@ ImBuf *IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source
}
if (use_hash && !regenerate) {
- if (IMB_metadata_get_field(img, "X-Blender::Hash", thumb_hash_curr, sizeof(thumb_hash_curr))) {
+ if (IMB_metadata_get_field(img->metadata, "X-Blender::Hash", thumb_hash_curr, sizeof(thumb_hash_curr))) {
regenerate = !STREQ(thumb_hash, thumb_hash_curr);
}
else {