Blender
V3.3
|
#include <stdio.h>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
#include "BLI_hash_md5.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_system.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "DNA_space_types.h"
#include "BLO_readfile.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"
#include "IMB_thumbs.h"
#include <ctype.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.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] & use_mask)) |
Functions | |
static bool | get_thumb_dir (char *dir, ThumbSize size) |
static bool | thumbhash_from_path (const char *UNUSED(path), 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_len, char *r_name, int name_len, ThumbSize size) |
static void | thumbname_from_uri (const char *uri, char *thumb, const int thumb_len) |
static bool | thumbpath_from_uri (const char *uri, char *path, const int path_len, ThumbSize size) |
void | IMB_thumb_makedirs (void) |
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 *filepath, ThumbSize size) |
void | IMB_thumb_delete (const char *filepath, ThumbSize size) |
ImBuf * | IMB_thumb_manage (const char *filepath, ThumbSize size, ThumbSource source) |
void | IMB_thumb_locks_acquire (void) |
void | IMB_thumb_locks_release (void) |
void | IMB_thumb_path_lock (const char *path) |
void | IMB_thumb_path_unlock (const char *path) |
Variables | |
static struct IMBThumbLocks | thumb_locks = {0} |
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 | UnsafeCharacterSet { UNSAFE_ALL = 0x1 , UNSAFE_ALLOW_PLUS = 0x2 , UNSAFE_PATH = 0x8 , UNSAFE_HOST = 0x10 , UNSAFE_SLASHES = 0x20 } |
static const unsigned char | acceptable [96] |
static const char | hex [17] = "0123456789abcdef" |
static void | escape_uri_string (const char *string, char *escaped_string, int escaped_string_size, UnsafeCharacterSet mask) |
#define ACCEPTABLE | ( | a | ) | ((a) >= 32 && (a) < 128 && (acceptable[(a)-32] & use_mask)) |
enum UnsafeCharacterSet |
|
static |
Definition at line 160 of file thumbs.c.
References ACCEPTABLE, BLI_assert, Freestyle::c, hex, and mask().
Referenced by uri_from_filename().
Definition at line 68 of file thumbs.c.
References BLI_getenv(), BLI_strncpy_rlen(), conv_utf_16_to_8(), FILE_MAX, SEP_STR, size(), THB_FAIL, THB_LARGE, THB_NORMAL, THUMBNAILS, and void.
Referenced by IMB_thumb_makedirs(), thumb_create_ex(), and thumbpathname_from_uri().
ImBuf* IMB_thumb_create | ( | const char * | filepath, |
ThumbSize | size, | ||
ThumbSource | source, | ||
struct ImBuf * | img | ||
) |
Create thumbnail for file and returns new imbuf for thumbnail.
Definition at line 468 of file thumbs.c.
References NULL, size(), thumb_create_ex(), THUMB_DEFAULT_HASH, thumbname_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by wm_file_write().
Delete all thumbs for the file.
Definition at line 498 of file thumbs.c.
References BLI_delete(), BLI_exists(), BLI_path_ncmp, FILE_MAX, size(), thumbpath_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by IMB_thumb_manage(), and wm_file_write().
Definition at line 639 of file thumbs.c.
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, NULL, and thumb_locks.
Referenced by filelist_cache_preview_ensure_running().
Definition at line 655 of file thumbs.c.
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, NULL, and thumb_locks.
Referenced by filelist_cache_previews_free().
Create the necessary directories to store the thumbnails.
Definition at line 288 of file thumbs.c.
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 * | filepath, |
ThumbSize | size, | ||
ThumbSource | source | ||
) |
Create the thumb if necessary and manage failed and old thumbs.
Definition at line 516 of file thumbs.c.
References BLI_delete(), BLI_exists(), BLI_file_older(), BLI_path_ncmp, BLI_stat(), BLO_library_path_explode(), 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, NULL, size(), usdtokens::st(), 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(), and filelist_cache_preview_runf().
void IMB_thumb_path_lock | ( | const char * | path | ) |
Definition at line 670 of file thumbs.c.
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, NULL, and thumb_locks.
Referenced by filelist_cache_preview_runf().
void IMB_thumb_path_unlock | ( | const char * | path | ) |
Definition at line 686 of file thumbs.c.
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, NULL, and thumb_locks.
Referenced by filelist_cache_preview_runf().
Read thumbnail for file and returns new imbuf for thumbnail.
Definition at line 482 of file thumbs.c.
References FILE_MAX, IB_metadata, IB_rect, IMB_loadiffname(), NULL, size(), thumbpath_from_uri(), uri_from_filename(), and URI_MAX.
Referenced by filelist_cache_preview_runf().
|
static |
Definition at line 305 of file thumbs.c.
References blender::math::abs(), BLI_assert_unreachable, BLI_path_ncmp, BLI_rename(), BLI_snprintf(), BLI_stat(), ELEM, FILE_MAX, 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_scaleImBuf(), IMB_TC_NONE, IMB_thumb_load_blend(), IMB_thumb_load_font(), IMB_thumb_load_image(), MAX2, ImBuf::metadata, MIN2, NULL, ImBuf::planes, PREVIEW_RENDER_DEFAULT_HEIGHT, PREVIEW_RENDER_LARGE_HEIGHT, ImBuf::rect, ImBuf::rect_float, size(), THB_FAIL, THB_LARGE, THB_NORMAL, THB_SOURCE_BLEND, THB_SOURCE_FONT, THB_SOURCE_IMAGE, THB_SOURCE_MOVIE, URI_MAX, ImBuf::x, and ImBuf::y.
Referenced by IMB_thumb_create(), and thumb_create_or_fail().
|
static |
Definition at line 441 of file thumbs.c.
References hash, IMB_freeImBuf(), NULL, size(), THB_FAIL, and thumb_create_ex().
Referenced by IMB_thumb_manage().
|
static |
Definition at line 204 of file thumbs.c.
References IMB_thumb_load_font_get_hash(), and THB_SOURCE_FONT.
Referenced by IMB_thumb_manage().
|
static |
Definition at line 278 of file thumbs.c.
References NULL, THB_FAIL, and thumbpathname_from_uri().
Referenced by IMB_thumb_create().
|
static |
Definition at line 283 of file thumbs.c.
References NULL, size(), and thumbpathname_from_uri().
Referenced by IMB_thumb_delete(), IMB_thumb_manage(), and IMB_thumb_read().
|
static |
Definition at line 247 of file thumbs.c.
References BLI_hash_md5_buffer(), BLI_hash_md5_to_hexdigest(), BLI_snprintf(), FILE_MAX, get_thumb_dir(), and size().
Referenced by IMB_thumb_manage(), thumbname_from_uri(), and thumbpath_from_uri().
|
static |
Definition at line 215 of file thumbs.c.
References BLI_snprintf(), BLI_str_replace_char(), BLI_strncpy(), escape_uri_string(), FILE_MAX, 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 156 of file thumbs.c.
Referenced by blender::bke::cryptomatte::cryptomatte_layer_name_hash(), escape_uri_string(), blender::bke::cryptomatte::CryptomatteHash::from_hex_encoded(), hasSeparatingPlane(), blender::bke::cryptomatte::CryptomatteHash::hex_encoded(), blender::ed::asset::index::AssetLibraryIndex::index_file_path(), blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path(), Freestyle::SceneHash::toString(), blender::meshintersect::trunc_ptr(), and xkb_map_gkey_or_scan_code().
|
static |
Referenced by IMB_thumb_locks_acquire(), IMB_thumb_locks_release(), IMB_thumb_path_lock(), and IMB_thumb_path_unlock().