234 memset(prv_img, 0,
sizeof(*prv_img));
236 if (deferred_data_size) {
250 const size_t deferred_data_size = strlen(filepath) + 2;
255 deferred_data[0] = source;
256 memcpy(&deferred_data[1], filepath, deferred_data_size - 1);
331 if (old_prv_p && *old_prv_p) {
332 BLI_assert(new_prv_p !=
nullptr &&
ELEM(*new_prv_p,
nullptr, *old_prv_p));
339 new_id->
icon_id = (*new_prv_p)->icon_id = 0;
346 #define ID_PRV_CASE(id_code, id_struct) \
348 return &((id_struct *)id)->preview; \
374 return prv_p ? *prv_p :
nullptr;
390 if (*prv_p ==
nullptr) {
451 void **key_p, **prv_p;
464 const char *filepath,
480 if (prv && force_update) {
482 if (((
int)prv_deferred_data[0] == source) &&
STREQ(&prv_deferred_data[1], filepath)) {
523 if (do_icon || do_preview) {
526 int source = prv_deferred_data[0];
527 char *filepath = &prv_deferred_data[1];
543 if (thumb->
x > thumb->
y) {
545 icon_h = (thumb->
y * icon_w) / thumb->
x + 1;
547 else if (thumb->
x < thumb->
y) {
549 icon_w = (thumb->
x * icon_h) / thumb->
y + 1;
569 const unsigned int w = prv->
w[
size];
570 const unsigned int h = prv->
h[
size];
571 const unsigned int *rect = prv->
rect[
size];
573 ImBuf *ima =
nullptr;
575 if (
w > 0 && h > 0 && rect) {
578 memcpy(ima->
rect, rect,
w * h *
sizeof(*ima->
rect));
601 if (prv ==
nullptr) {
607 if (prv_copy.
rect[0]) {
610 if (prv_copy.
rect[1]) {
617 if (prv ==
nullptr) {
639 Icon *icon =
nullptr;
658 if (p_prv && *p_prv) {
661 (*p_prv)->changed_timestamp[i]++;
704 if (!
id ||
G.background) {
721 if (p_prv && *p_prv) {
723 (*p_prv)->icon_id =
id->icon_id;
749 if (!gpl ||
G.background) {
783 preview->icon_id =
id->icon_id;
797 id->icon_id =
preview->icon_id;
836 Icon *icon =
nullptr;
872 const int icon_id =
id->icon_id;
956 std::unique_ptr<uchar> data_wrapper(std::move(
data));
960 const int div = 3 * 2 * 3;
966 const uchar header[4] = {
'V',
'C',
'O', 0};
967 uchar *p = data_wrapper.get();
968 if (memcmp(p, header,
ARRAY_SIZE(header)) != 0) {
980 geom->
coords =
reinterpret_cast<decltype(geom-
>coords)>(p);
981 geom->
colors =
reinterpret_cast<decltype(geom-
>colors)>(p + (data_len / 3));
984 geom->
mem = data_wrapper.release();
993 if (
data ==
nullptr) {
#define ICON_RENDER_DEFAULT_HEIGHT
void BKE_studiolight_unset_icon_id(StudioLight *sl, int icon_id)
#define BLI_assert_unreachable()
File and directory operations.
void * BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void ** BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_key, void ***r_val) ATTR_WARN_UNUSED_RESULT
void BLI_linklist_lockfree_free(LockfreeLinkList *list, LockfreeeLinkNodeFreeFP free_func)
void BLI_linklist_lockfree_clear(LockfreeLinkList *list, LockfreeeLinkNodeFreeFP free_func)
void BLI_linklist_lockfree_insert(LockfreeLinkList *list, LockfreeLinkNode *node)
void BLI_linklist_lockfree_init(LockfreeLinkList *list)
LockfreeLinkNode * BLI_linklist_lockfree_begin(LockfreeLinkList *list)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
int BLI_thread_is_main(void)
#define POINTER_FROM_INT(i)
void BLO_write_uint32_array(BlendWriter *writer, uint num, const uint32_t *data_ptr)
#define BLO_read_data_address(reader, ptr_p)
bool BLO_read_data_is_undo(BlendDataReader *reader)
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
#define CLOG_ERROR(clg_ref,...)
@ PRV_TAG_DEFFERED_DELETE
@ PRV_TAG_DEFFERED_RENDERING
#define PRV_DEFERRED_DATA(prv)
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
void GPU_texture_free(GPUTexture *tex)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_premultiply_alpha(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
struct ImBuf * IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source)
Read Guarded memory(de)allocation.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE int16_t atomic_fetch_and_and_int16(int16_t *p, int16_t b)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void BKE_previewimg_deferred_release(PreviewImage *prv)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
int BKE_icon_gplayer_color_ensure(bGPDlayer *gpl)
static PreviewImage * previewimg_deferred_create(const char *filepath, int source)
static LockfreeLinkList g_icon_delete_queue
PreviewImage * BKE_previewimg_cached_thumbnail_read(const char *name, const char *filepath, const int source, bool force_update)
void BKE_icon_id_delete(struct ID *id)
void BKE_previewimg_cached_release(const char *name)
void BKE_icon_changed(const int icon_id)
static int icon_id_ensure_create_icon(struct ID *id)
void BKE_icons_deferred_free()
static void icon_free(void *val)
static int get_next_free_id()
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
PreviewImage ** BKE_previewimg_id_get_p(const ID *id)
int BKE_icon_imbuf_create(ImBuf *ibuf)
bool BKE_previewimg_id_supports_jobs(const ID *id)
Icon * BKE_icon_get(const int icon_id)
static GHash * gCachedPreviews
static void icon_free_data(int icon_id, Icon *icon)
struct Icon_Geom * BKE_icon_geom_from_file(const char *filename)
void BKE_previewimg_freefunc(void *link)
static std::mutex gIconMutex
struct Icon_Geom * BKE_icon_geom_from_memory(uchar *data, size_t data_len)
void BKE_icon_set(const int icon_id, struct Icon *icon)
#define ID_PRV_CASE(id_code, id_struct)
static int icon_gplayer_color_ensure_create_icon(bGPDlayer *gpl)
bool BKE_previewimg_is_finished(const PreviewImage *prv, const int size)
void BKE_previewimg_clear(struct PreviewImage *prv)
void BKE_previewimg_free(PreviewImage **prv)
static PreviewImage * previewimg_create_ex(size_t deferred_data_size)
ImBuf * BKE_previewimg_to_imbuf(PreviewImage *prv, const int size)
static Icon * icon_create(int icon_id, int obj_type, void *obj)
PreviewImage * BKE_previewimg_cached_get(const char *name)
void BKE_previewimg_ensure(PreviewImage *prv, const int size)
PreviewImage * BKE_previewimg_cached_ensure(const char *name)
void BKE_previewimg_clear_single(struct PreviewImage *prv, enum eIconSizes size)
PreviewImage * BKE_previewimg_copy(const PreviewImage *prv)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
static Icon * icon_ghash_lookup(int icon_id)
int BKE_icon_geom_ensure(struct Icon_Geom *geom)
PreviewImage * BKE_previewimg_create()
void BKE_previewimg_id_custom_set(ID *id, const char *filepath)
PreviewImage * BKE_previewimg_id_get(const ID *id)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
static void icon_add_to_deferred_delete_queue(int icon_id)
void BKE_previewimg_finish(PreviewImage *prv, const int size)
PreviewImage * BKE_previewimg_id_ensure(ID *id)
bool BKE_icon_delete_unmanaged(const int icon_id)
void BKE_previewimg_id_free(ID *id)
int BKE_icon_id_ensure(struct ID *id)
ImBuf * BKE_icon_imbuf_get_buffer(int icon_id)
int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type)
void BKE_icons_init(int first_dyn_id)
bool BKE_icon_delete(const int icon_id)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
std::atomic< int > next_id
static const pxr::TfToken preview("preview", pxr::TfToken::Immortal)
struct DeferredIconDeleteNode * next
unsigned char(* colors)[4]
unsigned char(* coords)[2]
DrawInfoFreeFP drawinfo_free
short changed_timestamp[2]
struct GPUTexture * gputexture[2]
bGPDlayer_Runtime runtime