|
Blender V4.3
|
#include <algorithm>#include <cstdio>#include <cstdlib>#include "MEM_guardedalloc.h"#include "BKE_blendfile.hh"#include "BLI_fileops.h"#include "BLI_ghash.h"#include "BLI_hash_md5.hh"#include "BLI_path_utils.hh"#include "BLI_string.h"#include "BLI_string_utils.hh"#include "BLI_system.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "DNA_space_types.h"#include "IMB_imbuf.hh"#include "IMB_imbuf_types.hh"#include "IMB_metadata.hh"#include "IMB_thumbs.hh"#include <cctype>#include <cstring>#include <ctime>#include <sys/stat.h>#include <sys/types.h>Go to the source code of this file.
Classes | |
| struct | IMBThumbLocks |
Macros | |
| #define | USE_FREEDESKTOP |
| #define | THUMBNAILS "thumbnails" |
| #define | URI_MAX (FILE_MAX * 3 + 8) |
| #define | ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a)-32] & mask)) |
Functions | |
| static bool | get_thumb_dir (char *dir, ThumbSize size) |
| static bool | thumbhash_from_path (const char *, ThumbSource source, char *r_hash) |
| static bool | uri_from_filename (const char *path, char *uri) |
| static bool | thumbpathname_from_uri (const char *uri, char *r_path, const int path_maxncpy, char *r_name, int name_maxncpy, ThumbSize size) |
| static void | thumbname_from_uri (const char *uri, char *thumb, const int thumb_maxncpy) |
| static bool | thumbpath_from_uri (const char *uri, char *path, const int path_maxncpy, ThumbSize size) |
| void | IMB_thumb_makedirs () |
| static ImBuf * | thumb_create_ex (const char *file_path, const char *uri, const char *thumb, const bool use_hash, const char *hash, const char *blen_group, const char *blen_id, ThumbSize size, ThumbSource source, ImBuf *img) |
| static ImBuf * | thumb_create_or_fail (const char *file_path, const char *uri, const char *thumb, const bool use_hash, const char *hash, const char *blen_group, const char *blen_id, ThumbSize size, ThumbSource source) |
| ImBuf * | IMB_thumb_create (const char *filepath, ThumbSize size, ThumbSource source, ImBuf *img) |
| ImBuf * | IMB_thumb_read (const char *file_or_lib_path, ThumbSize size) |
| void | IMB_thumb_delete (const char *file_or_lib_path, ThumbSize size) |
| ImBuf * | IMB_thumb_manage (const char *file_or_lib_path, ThumbSize size, ThumbSource source) |
| void | IMB_thumb_locks_acquire () |
| void | IMB_thumb_locks_release () |
| void | IMB_thumb_path_lock (const char *path) |
| void | IMB_thumb_path_unlock (const char *path) |
Variables | |
| static struct IMBThumbLocks | thumb_locks = {nullptr} |
Escape URI String | |
The following code is adapted from function g_escape_uri_string from the gnome glib Source: http://svn.gnome.org/viewcvs/glib/trunk/glib/gconvert.c?view=markup released under the Gnu General Public License. | |
| enum | eUnsafeCharacterSet { UNSAFE_ALL = 0x1 , UNSAFE_ALLOW_PLUS = 0x2 , UNSAFE_PATH = 0x8 , UNSAFE_HOST = 0x10 , UNSAFE_SLASHES = 0x20 } |
| static const uchar | acceptable [96] |
| static const char | hex [17] = "0123456789abcdef" |
| static void | escape_uri_string (const char *string, char *escaped_string, const int escaped_string_size, const eUnsafeCharacterSet mask) |
| #define ACCEPTABLE | ( | a | ) | ((a) >= 32 && (a) < 128 && (acceptable[(a)-32] & mask)) |
Referenced by escape_uri_string().
| #define THUMBNAILS "thumbnails" |
Definition at line 64 of file thumbs.cc.
Referenced by get_thumb_dir().
Definition at line 69 of file thumbs.cc.
Referenced by IMB_thumb_create(), IMB_thumb_delete(), IMB_thumb_manage(), IMB_thumb_read(), thumb_create_ex(), and uri_from_filename().
| enum eUnsafeCharacterSet |
|
static |
Definition at line 163 of file thumbs.cc.
References ACCEPTABLE, BLI_assert, and hex.
Referenced by uri_from_filename().
|
static |
Definition at line 71 of file thumbs.cc.
References BLI_getenv(), BLI_strncpy_rlen(), conv_utf_16_to_8(), FILE_MAX, SEP_STR, THB_FAIL, THB_LARGE, THB_NORMAL, and THUMBNAILS.
Referenced by IMB_thumb_makedirs(), thumb_create_ex(), and thumbpathname_from_uri().
| ImBuf * IMB_thumb_create | ( | const char * | filepath, |
| ThumbSize | size, | ||
| ThumbSource | source, | ||
| ImBuf * | img ) |
Create thumbnail for file and returns new ImBuf for thumbnail.
| filepath | File path (but not a library path!) to the thumbnail to be created. |
Definition at line 485 of file thumbs.cc.
References thumb_create_ex(), THUMB_DEFAULT_HASH, thumbname_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by wm_file_write().
| void IMB_thumb_delete | ( | const char * | file_or_lib_path, |
| ThumbSize | size ) |
Delete all thumbs for the file.
| file_or_lib_path | File path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be deleted. |
Definition at line 515 of file thumbs.cc.
References BLI_delete(), BLI_exists(), BLI_path_ncmp, FILE_MAX, thumbpath_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by IMB_thumb_manage(), and wm_file_write().
| void IMB_thumb_locks_acquire | ( | ) |
Definition at line 671 of file thumbs.cc.
References BLI_assert, BLI_condition_init(), BLI_gset_str_new(), BLI_thread_lock(), BLI_thread_unlock(), IMBThumbLocks::cond, IMBThumbLocks::lock_counter, LOCK_IMAGE, IMBThumbLocks::locked_paths, and thumb_locks.
Referenced by filelist_cache_preview_ensure_running().
| void IMB_thumb_locks_release | ( | ) |
Definition at line 687 of file thumbs.cc.
References BLI_assert, BLI_condition_end(), BLI_gset_free(), BLI_thread_lock(), BLI_thread_unlock(), IMBThumbLocks::cond, IMBThumbLocks::lock_counter, LOCK_IMAGE, IMBThumbLocks::locked_paths, MEM_freeN(), and thumb_locks.
Referenced by filelist_cache_previews_free().
| void IMB_thumb_makedirs | ( | ) |
Create the necessary directories to store the thumbnails.
Definition at line 298 of file thumbs.cc.
References BLI_dir_create_recursive(), FILE_MAX, get_thumb_dir(), THB_FAIL, THB_LARGE, and THB_NORMAL.
Referenced by ED_file_init().
| ImBuf * IMB_thumb_manage | ( | const char * | file_or_lib_path, |
| ThumbSize | size, | ||
| ThumbSource | source ) |
Create the thumb if necessary and manage failed and old thumbs. Will not attempt to (re)create thumbnails of offline files. In this case only a preexisting thumbnail is returned, or null if none was found.
| file_or_lib_path | File path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be created/managed. |
Definition at line 533 of file thumbs.cc.
References BKE_blendfile_library_path_explode(), BLI_delete(), BLI_exists(), BLI_file_attributes(), BLI_file_older(), BLI_path_ncmp, BLI_stat(), FILE_ATTR_OFFLINE, FILE_MAX, FILE_MAX_LIBEXTRA, IB_metadata, IB_rect, IMB_freeImBuf(), imb_freerectfloatImBuf(), IMB_loadiffname(), IMB_metadata_get_field(), IMB_rect_from_float(), IMB_thumb_delete(), ImBuf::metadata, STREQ, THB_FAIL, THB_LARGE, THB_NORMAL, THB_SOURCE_BLEND, thumb_create_or_fail(), thumbhash_from_path(), thumbpath_from_uri(), thumbpathname_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by BKE_previewimg_ensure(), file_draw_tooltip_custom_func(), and filelist_cache_preview_runf().
| void IMB_thumb_path_lock | ( | const char * | path | ) |
Definition at line 702 of file thumbs.cc.
References BLI_assert, BLI_condition_wait_global_mutex(), BLI_gset_add(), BLI_strdup(), BLI_thread_lock(), BLI_thread_unlock(), IMBThumbLocks::cond, IMBThumbLocks::lock_counter, LOCK_IMAGE, IMBThumbLocks::locked_paths, and thumb_locks.
Referenced by filelist_cache_preview_runf().
| void IMB_thumb_path_unlock | ( | const char * | path | ) |
Definition at line 718 of file thumbs.cc.
References BLI_assert, BLI_assert_unreachable, BLI_condition_notify_all(), BLI_gset_remove(), BLI_thread_lock(), BLI_thread_unlock(), IMBThumbLocks::cond, IMBThumbLocks::lock_counter, LOCK_IMAGE, IMBThumbLocks::locked_paths, MEM_freeN(), and thumb_locks.
Referenced by filelist_cache_preview_runf().
Read thumbnail for file and returns new ImBuf for thumbnail.
| file_or_lib_path | File path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be read. |
Definition at line 499 of file thumbs.cc.
References FILE_MAX, IB_metadata, IB_rect, IMB_loadiffname(), thumbpath_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by file_draw_tooltip_custom_func(), and uiTemplateRecentFiles_tooltip_func().
|
static |
Definition at line 315 of file thumbs.cc.
References abs(), BLI_assert_unreachable, BLI_path_extension_check(), BLI_path_ncmp, BLI_rename_overwrite(), BLI_stat(), Box, ImBuf::byte_buffer, ImBufByteBuffer::data, ImBufFloatBuffer::data, ELEM, FILE_MAX, ImBuf::float_buffer, ImBuf::ftype, get_thumb_dir(), hash, IB_metadata, IB_rect, IMB_allocImBuf(), IMB_anim_absolute(), IMB_anim_previewframe(), IMB_free_anim(), IMB_freeImBuf(), imb_freerectfloatImBuf(), IMB_FTYPE_PNG, IMB_metadata_ensure(), IMB_metadata_set_field(), IMB_open_anim(), IMB_PROXY_NONE, IMB_rect_from_float(), IMB_saveiff(), IMB_scale(), IMB_TC_NONE, IMB_thumb_load_blend(), IMB_thumb_load_font(), IMB_thumb_load_image(), ImBuf::metadata, ImBuf::planes, PREVIEW_RENDER_DEFAULT_HEIGHT, PREVIEW_RENDER_LARGE_HEIGHT, SNPRINTF, THB_FAIL, THB_LARGE, THB_NORMAL, THB_SOURCE_BLEND, THB_SOURCE_FONT, THB_SOURCE_IMAGE, THB_SOURCE_MOVIE, THB_SOURCE_OBJECT_IO, URI_MAX, ImBuf::x, and ImBuf::y.
Referenced by IMB_thumb_create(), and thumb_create_or_fail().
|
static |
Definition at line 458 of file thumbs.cc.
References hash, IMB_freeImBuf(), THB_FAIL, and thumb_create_ex().
Referenced by IMB_thumb_manage().
|
static |
Definition at line 204 of file thumbs.cc.
References IMB_thumb_load_font_get_hash(), and THB_SOURCE_FONT.
Referenced by IMB_thumb_manage().
|
static |
Definition at line 288 of file thumbs.cc.
References THB_FAIL, and thumbpathname_from_uri().
Referenced by IMB_thumb_create().
|
static |
Definition at line 293 of file thumbs.cc.
References thumbpathname_from_uri().
Referenced by IMB_thumb_delete(), IMB_thumb_manage(), and IMB_thumb_read().
|
static |
Definition at line 253 of file thumbs.cc.
References BLI_hash_md5_buffer(), BLI_hash_md5_to_hexdigest(), BLI_snprintf(), FILE_MAX, and get_thumb_dir().
Referenced by IMB_thumb_manage(), thumbname_from_uri(), and thumbpath_from_uri().
|
static |
Definition at line 215 of file thumbs.cc.
References BLI_path_is_unc(), BLI_path_is_win32_drive(), BLI_path_slash_skip(), BLI_string_replace_char(), escape_uri_string(), FILE_MAX, SNPRINTF, STRNCPY, UNSAFE_PATH, and URI_MAX.
Referenced by IMB_thumb_create(), IMB_thumb_delete(), IMB_thumb_manage(), and IMB_thumb_read().
|
static |
|
static |
Definition at line 159 of file thumbs.cc.
Referenced by escape_uri_string(), hasSeparatingPlane(), and Freestyle::SceneHash::toString().
|
static |
Referenced by IMB_thumb_locks_acquire(), IMB_thumb_locks_release(), IMB_thumb_path_lock(), and IMB_thumb_path_unlock().