57 if (other.deferred_loading_data) {
59 *other.deferred_loading_data);
69 prv->
runtime->deferred_loading_data =
70 std::make_unique<blender::bke::PreviewDeferredLoadingData>();
71 prv->
runtime->deferred_loading_data->filepath = filepath;
72 prv->
runtime->deferred_loading_data->source = source;
85 prv->
runtime = MEM_new<blender::bke::PreviewImageRuntime>(__func__);
93 if ((*prv)->rect[i]) {
96 if ((*prv)->runtime->gputexture[i]) {
101 MEM_delete((*prv)->runtime);
134 if (prv->
runtime->gputexture[size]) {
139 prv->
flag[
size] &= ~PRV_USER_EDITED;
157 *prv_img = blender::dna::shallow_copy(*prv);
158 prv_img->
runtime = MEM_new<blender::bke::PreviewImageRuntime>(__func__, *prv->
runtime);
164 prv_img->
runtime->gputexture[i] =
nullptr;
175 if (old_prv_p && *old_prv_p) {
176 BLI_assert(new_prv_p !=
nullptr &&
ELEM(*new_prv_p,
nullptr, *old_prv_p));
183 new_id->
icon_id = (*new_prv_p)->runtime->icon_id = 0;
189 switch (
GS(id->name)) {
190#define ID_PRV_CASE(id_code, id_struct) \
192 return &((id_struct *)id)->preview; \
218 return prv_p ? *prv_p :
nullptr;
236 if (*prv_p ==
nullptr) {
296 void **key_p, **prv_p;
309 const char *filepath,
326 if (prv && force_update) {
327 if (prv->
runtime->deferred_loading_data &&
328 (prv->
runtime->deferred_loading_data->source == source) &&
329 (prv->
runtime->deferred_loading_data->filepath == filepath))
367 if (!prv->
runtime->deferred_loading_data) {
374 if (!(do_icon || do_preview)) {
380 *prv->
runtime->deferred_loading_data;
398 if (thumb->
x > thumb->
y) {
400 icon_h = (thumb->
y * icon_w) / thumb->
x + 1;
402 else if (thumb->
x < thumb->
y) {
404 icon_w = (thumb->
x * icon_h) / thumb->
y + 1;
421 if (!prv->
runtime->deferred_loading_data) {
425 return prv->
runtime->deferred_loading_data->filepath.c_str();
430 if (!prv->
runtime->deferred_loading_data) {
434 return prv->
runtime->deferred_loading_data->source;
443 ImBuf *ima =
nullptr;
445 if (
w > 0 && h > 0 && rect) {
471 if (prv ==
nullptr) {
475 PreviewImage prv_copy = blender::dna::shallow_copy(*prv);
478 if (prv_copy.
rect[0]) {
481 if (prv_copy.
rect[1]) {
488 if (prv ==
nullptr) {
492 prv->
runtime = MEM_new<blender::bke::PreviewImageRuntime>(__func__);
502 prv->
flag[i] &= ~PRV_RENDERING;
bool BKE_icon_delete(int icon_id)
#define ICON_RENDER_DEFAULT_HEIGHT
void BKE_previewimg_deferred_release(PreviewImage *prv)
PreviewImage * BKE_previewimg_id_get(const ID *id)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
void BKE_previewimg_ensure(PreviewImage *prv, int size)
bool BKE_previewimg_is_finished(const PreviewImage *prv, int size)
PreviewImage * BKE_previewimg_cached_thumbnail_read(const char *name, const char *filepath, int source, bool force_update)
std::optional< int > BKE_previewimg_deferred_thumb_source_get(const PreviewImage *prv)
void BKE_previewimg_cached_release(const char *name)
PreviewImage * BKE_previewimg_create()
bool BKE_previewimg_id_supports_jobs(const ID *id)
void BKE_preview_images_init()
PreviewImage * BKE_previewimg_id_ensure(ID *id)
void BKE_previewimg_freefunc(void *link)
PreviewImage ** BKE_previewimg_id_get_p(const ID *id)
void BKE_previewimg_clear_single(PreviewImage *prv, enum eIconSizes size)
const char * BKE_previewimg_deferred_filepath_get(const PreviewImage *prv)
void BKE_preview_images_free()
void BKE_previewimg_free(PreviewImage **prv)
PreviewImage * BKE_previewimg_copy(const PreviewImage *prv)
ImBuf * BKE_previewimg_to_imbuf(PreviewImage *prv, int size)
PreviewImage * BKE_previewimg_cached_get(const char *name)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
void BKE_previewimg_id_custom_set(ID *id, const char *filepath)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
PreviewImage * BKE_previewimg_cached_ensure(const char *name)
void BKE_previewimg_finish(PreviewImage *prv, int size)
void BKE_previewimg_clear(PreviewImage *prv)
void BKE_previewimg_id_free(ID *id)
void ** BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp) ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
bool BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_key, void ***r_val) ATTR_WARN_UNUSED_RESULT
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
int BLI_thread_is_main(void)
void BLO_write_uint32_array(BlendWriter *writer, uint num, const uint32_t *data_ptr)
bool BLO_read_data_is_undo(BlendDataReader *reader)
void BLO_read_uint32_array(BlendDataReader *reader, int array_size, uint32_t **ptr_p)
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
ID and Library types, which are fundamental for SDNA.
@ PRV_TAG_DEFFERED_DELETE
@ PRV_TAG_DEFFERED_RENDERING
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 *texture)
void IMB_premultiply_alpha(ImBuf *ibuf)
bool IMB_scale(ImBuf *ibuf, unsigned int newx, unsigned int newy, IMBScaleFilter filter, bool threaded=true)
ImBuf * IMB_thumb_manage(const char *file_or_lib_path, ThumbSize size, ThumbSource source)
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.
struct ImBuf * IMB_allocImBuf(unsigned int, unsigned int, unsigned char, unsigned int)
void IMB_freeImBuf(ImBuf *)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
static GHash * gCachedPreviews
static PreviewImage * previewimg_deferred_create(const char *filepath, ThumbSource source)
#define ID_PRV_CASE(id_code, id_struct)
ImBufByteBuffer byte_buffer
PreviewImageRuntimeHandle * runtime
short changed_timestamp[2]
std::unique_ptr< PreviewDeferredLoadingData > deferred_loading_data