48 return cached_previews_map;
87 if (*prv ==
nullptr) {
94 if ((*prv)->runtime->user_count > 0) {
95 (*prv)->runtime->user_count--;
96 if ((*prv)->runtime->user_count > 0) {
102 bool do_delete =
true;
129 prv->
runtime = MEM_new<bke::PreviewImageRuntime>(__func__);
136 if ((*prv)->runtime->icon_id) {
141 if ((*prv)->rect[i]) {
142 MEM_delete((*prv)->rect[i]);
144 if ((*prv)->runtime->gputexture[i]) {
149 MEM_delete((*prv)->runtime);
168 MEM_SAFE_DELETE(prv->
rect[size]);
172 prv->
h[size] = prv->
w[size] = 0;
191 PreviewImage *prv_img = MEM_new<PreviewImage>(__func__);
193 prv_img->
runtime = MEM_new<bke::PreviewImageRuntime>(__func__, *prv->
runtime);
197 prv_img->
rect[i] = MEM_dupalloc(prv->
rect[i]);
210 if (old_prv_p && *old_prv_p) {
211 BLI_assert(new_prv_p !=
nullptr &&
ELEM(*new_prv_p,
nullptr, *old_prv_p));
218 new_id->
icon_id = (*new_prv_p)->runtime->icon_id = 0;
224 switch (
GS(
id->name)) {
225#define ID_PRV_CASE(id_code, id_struct) \
227 return &((id_struct *)id)->preview; \
253 return prv_p ? *prv_p :
nullptr;
271 if (*prv_p ==
nullptr) {
318 const char *filepath,
321 const bool count_users)
337 if (prv && force_update) {
364 cache.
add(name, prv);
372 const char *dst_filepath,
373 const bool force_update,
374 const bool count_users)
404 if (!(do_icon || do_preview)) {
424 MEM_dupalloc<uint8_t>(thumb->
byte_data()));
428 if (thumb->
x > thumb->
y) {
430 icon_h = (thumb->
y * icon_w) / thumb->
x + 1;
432 else if (thumb->
x < thumb->
y) {
434 icon_w = (thumb->
x * icon_h) / thumb->
y + 1;
444 MEM_dupalloc<uint8_t>(thumb->
byte_data()));
479 const uint w = prv->
w[size];
480 const uint h = prv->
h[size];
483 ImBuf *ima =
nullptr;
485 if (
w > 0 && h > 0 && rect) {
514 bool do_delete =
false;
589 if (prv ==
nullptr) {
610 if (prv ==
nullptr) {
614 prv->
runtime = MEM_new<bke::PreviewImageRuntime>(__func__);
#define ICON_RENDER_DEFAULT_HEIGHT
ID and Library types, which are fundamental for SDNA.
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
std::optional< Value > pop_try(const Key &key)
ValueIterator values() const &
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
const Value * lookup_ptr_as(const ForwardKey &key) const
Value & lookup_or_add_cb_as(ForwardKey &&key, const CreateValueF &create_value)
Value lookup_default_as(const ForwardKey &key, ForwardValue &&...default_value) const
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
void BKE_previewimg_id_custom_set(ID *id, const char *filepath)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_previewimg_id_free(ID *id)
void BKE_preview_images_init()
PreviewImage * BKE_previewimg_cached_thumbnail_read(const char *name, const char *filepath, int source, bool force_update, bool count_users=false)
bool BKE_previewimg_render_restart(PreviewImage *prv, int size)
void BKE_previewimg_clear(PreviewImage *prv)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
void BKE_previewimg_clear_single(PreviewImage *prv, enum eIconSizes size)
bool BKE_previewimg_is_online(const PreviewImage *prv)
@ PRV_TAG_DEFERRED_INVALID
@ PRV_TAG_DEFERRED_RENDERING
@ PRV_TAG_RESTART_RENDERING
@ PRV_TAG_DEFERRED_DELETE
void BKE_previewimg_render_end(PreviewImage *prv, int size, PreviewImageRenderEndStatus status)
std::optional< int > BKE_previewimg_deferred_thumb_source_get(const PreviewImage *prv)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
bool BKE_previewimg_is_invalid(const PreviewImage *prv, int size)
PreviewImage * BKE_previewimg_online_thumbnail_read(const char *name, const char *dst_filepath, bool force_update, bool count_users=false)
void BKE_preview_images_free()
PreviewImage * BKE_previewimg_cached_ensure(const char *name)
bool BKE_previewimg_id_supports_jobs(const ID *id)
void BKE_previewimg_render_start(PreviewImage *prv, int size, bool using_job)
PreviewImage ** BKE_previewimg_id_get_p(const ID *id)
static PreviewImage * previewimg_deferred_create(const char *filepath, ThumbSource source)
bool BLO_read_data_is_undo(BlendDataReader *reader)
void IMB_freeImBuf(ImBuf *ibuf)
PreviewImageRenderEndStatus
@ PRV_RENDER_STATUS_CANCELLED
@ PRV_RENDER_STATUS_FAILED
static CachedPreviewMap & get_cached_previews_map()
PreviewImage * BKE_previewimg_id_ensure(ID *id)
void BLO_read_data_set_need_preview_render_restart(BlendDataReader *reader)
void BKE_previewimg_free(PreviewImage **prv)
Map< std::string, PreviewImage * > CachedPreviewMap
PreviewImage * BKE_previewimg_id_get(const ID *id)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
bool BKE_previewimg_is_finished(const PreviewImage *prv, int size)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, ImBufFlags flags)
PreviewImage * BKE_previewimg_create()
PreviewImage * BKE_previewimg_cached_get(const char *name)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
bool BKE_previewimg_is_rendering(const PreviewImage *prv, int size)
ImBuf * IMB_thumb_manage(const char *file_or_lib_path, ThumbSize size, ThumbSource source, const ThumbCancellationToken *cancel_token=nullptr)
std::optional< StringRefNull > BKE_previewimg_deferred_filepath_get(const PreviewImage *prv)
void GPU_texture_free(gpu::Texture *texture)
ID_Type GS(const char *name)
PreviewImage * BKE_previewimg_copy(const PreviewImage *prv)
void BKE_previewimg_cached_release(const char *name)
ImBuf * BKE_previewimg_to_imbuf(const PreviewImage *prv, int size)
void BKE_previewimg_ensure(PreviewImage *prv, int size)
bool IMB_scale(ImBuf *ibuf, int2 new_size, IMBScaleFilter filter, bool threaded=true)
bool BKE_icon_delete(int icon_id)
static bool previewimg_free_or_defer(PreviewImage **prv)
void IMB_premultiply_alpha(ImBuf *ibuf)
#define ID_PRV_CASE(id_code, id_struct)
void write_uint32_array(int64_t num, const uint32_t *data)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
bke::PreviewImageRuntime * runtime
short changed_timestamp[2]
int16_t tag[NUM_ICON_SIZES]
std::unique_ptr< PreviewDeferredLoadingData > deferred_loading_data
std::array< gpu::Texture *, NUM_ICON_SIZES > gputexture