|
Blender
V2.93
|
#include <cmath>#include <cstdlib>#include <cstring>#include <mutex>#include "CLG_log.h"#include "MEM_guardedalloc.h"#include "DNA_brush_types.h"#include "DNA_collection_types.h"#include "DNA_gpencil_types.h"#include "DNA_light_types.h"#include "DNA_material_types.h"#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_texture_types.h"#include "DNA_world_types.h"#include "BLI_fileops.h"#include "BLI_ghash.h"#include "BLI_linklist_lockfree.h"#include "BLI_string.h"#include "BLI_threads.h"#include "BLI_utildefines.h"#include "BLI_vector.hh"#include "BKE_global.h"#include "BKE_icons.h"#include "BKE_studiolight.h"#include "BLI_sys_types.h"#include "GPU_texture.h"#include "IMB_imbuf.h"#include "IMB_imbuf_types.h"#include "IMB_thumbs.h"#include "BLO_read_write.h"#include "atomic_ops.h"Go to the source code of this file.
Classes | |
| struct | DeferredIconDeleteNode |
Macros | |
| #define | ID_PRV_CASE(id_code, id_struct) |
Enumerations | |
| enum | { ICON_FLAG_MANAGED = (1 << 0) } |
Variables | |
| static CLG_LogRef | LOG = {"bke.icons"} |
| static GHash * | gIcons = nullptr |
| static int | gNextIconId = 1 |
| static int | gFirstIconId = 1 |
| static std::mutex | gIconMutex |
| static GHash * | gCachedPreviews = nullptr |
| static LockfreeLinkList | g_icon_delete_queue |
| #define ID_PRV_CASE | ( | id_code, | |
| id_struct | |||
| ) |
| anonymous enum |
| void BKE_icon_changed | ( | const int | icon_id | ) |
Definition at line 678 of file icons.cc.
References BKE_previewimg_id_get_p(), BLI_assert, G, ICON_DATA_ID, icon_ghash_lookup(), Icon_Geom::icon_id, Icon::id_type, NUM_ICON_SIZES, Icon::obj, Icon::obj_type, PRV_CHANGED, and PRV_UNFINISHED.
Referenced by area_move_apply_do(), area_split_apply(), ghost_event_proc(), icon_preview_imbuf_from_brush(), image_changed(), image_init_after_load(), image_replace_exec(), lamp_changed(), material_changed(), screen_area_join(), texture_changed(), and world_changed().
| bool BKE_icon_delete | ( | const int | icon_id | ) |
Remove icon and free data.
Definition at line 940 of file icons.cc.
References BLI_ghash_popkey(), gIconMutex, gIcons, icon_free(), icon_free_data(), Icon_Geom::icon_id, and POINTER_FROM_INT.
Referenced by BKE_gpencil_layer_delete(), BKE_previewimg_deferred_release(), filelist_cache_preview_freef(), filelist_cache_previews_clear(), filelist_cache_previews_update(), and filelist_entry_clear().
| bool BKE_icon_delete_unmanaged | ( | const int | icon_id | ) |
Definition at line 957 of file icons.cc.
References BLI_ghash_insert(), BLI_ghash_popkey(), Icon::flag, gIconMutex, gIcons, ICON_FLAG_MANAGED, icon_free(), icon_free_data(), Icon_Geom::icon_id, POINTER_FROM_INT, and UNLIKELY.
Referenced by bpy_app_icons_release().
| int BKE_icon_ensure_studio_light | ( | struct StudioLight * | sl, |
| int | id_type | ||
| ) |
Definition at line 1057 of file icons.cc.
References get_next_free_id(), icon_create(), ICON_DATA_STUDIOLIGHT, Icon_Geom::icon_id, and Icon::id_type.
Referenced by studiolight_create().
| int BKE_icon_geom_ensure | ( | struct Icon_Geom * | geom | ) |
Definition at line 985 of file icons.cc.
References BLI_assert, BLI_thread_is_main(), get_next_free_id(), icon_create(), ICON_DATA_GEOM, and Icon_Geom::icon_id.
Referenced by bpy_app_icons_new_triangles(), and bpy_app_icons_new_triangles_from_file().
| struct Icon_Geom* BKE_icon_geom_from_file | ( | const char * | filename | ) |
Definition at line 1040 of file icons.cc.
References BKE_icon_geom_from_memory(), BLI_assert, BLI_file_read_binary_as_mem(), BLI_thread_is_main(), and data.
Referenced by bpy_app_icons_new_triangles_from_file().
Definition at line 1001 of file icons.cc.
References ARRAY_SIZE, BLI_assert, BLI_thread_is_main(), Icon_Geom::colors, Icon_Geom::coords, Icon_Geom::coords_len, Icon_Geom::coords_range, data, Icon_Geom::icon_id, Icon_Geom::mem, and MEM_mallocN.
Referenced by BKE_icon_geom_from_file().
| Icon* BKE_icon_get | ( | const int | icon_id | ) |
Definition at line 881 of file icons.cc.
References BLI_assert, BLI_thread_is_main(), CLOG_ERROR, icon_ghash_lookup(), Icon_Geom::icon_id, and LOG.
Referenced by icon_draw_size(), ui_icon_ensure_deferred(), UI_icon_get_height(), UI_icon_get_theme_color(), UI_icon_get_width(), UI_icon_to_preview(), and ui_studiolight_kill_icon_preview_job().
| int BKE_icon_gplayer_color_ensure | ( | bGPDlayer * | gpl | ) |
Definition at line 785 of file icons.cc.
References BLI_assert, BLI_thread_is_main(), CLOG_ERROR, G, get_next_free_id(), icon_gplayer_color_ensure_create_icon(), bGPDlayer_Runtime::icon_id, LOG, and bGPDlayer::runtime.
| void BKE_icon_id_delete | ( | struct ID * | id | ) |
Definition at line 919 of file icons.cc.
References BKE_icons_deferred_free(), BLI_ghash_remove(), BLI_thread_is_main(), gIconMutex, gIcons, icon_add_to_deferred_delete_queue(), icon_free(), Icon_Geom::icon_id, and POINTER_FROM_INT.
Referenced by image_free_data(), light_free_data(), material_free_data(), texture_free_data(), and world_free_data().
| int BKE_icon_id_ensure | ( | struct ID * | id | ) |
Definition at line 740 of file icons.cc.
References BKE_previewimg_id_get_p(), BLI_assert, BLI_thread_is_main(), CLOG_ERROR, ELEM, G, get_next_free_id(), ID::icon_id, icon_id_ensure_create_icon(), id, and LOG.
Referenced by icon_preview_imbuf_from_brush(), image_changed(), image_init_after_load(), image_replace_exec(), lamp_changed(), material_changed(), texture_changed(), ui_id_brush_get_icon(), ui_id_icon_get(), ui_id_screen_get_icon(), and world_changed().
| int BKE_icon_imbuf_create | ( | ImBuf * | ibuf | ) |
Create an icon as owner or ibuf. The icon-ID is not stored in ibuf, it needs to be stored separately.
Definition at line 856 of file icons.cc.
References Icon::flag, get_next_free_id(), icon_create(), ICON_DATA_IMBUF, ICON_FLAG_MANAGED, and Icon_Geom::icon_id.
Referenced by filelist_cache_preview_runf(), and filelist_file_create_entry().
| ImBuf* BKE_icon_imbuf_get_buffer | ( | int | icon_id | ) |
Definition at line 866 of file icons.cc.
References CLOG_ERROR, ICON_DATA_IMBUF, icon_ghash_lookup(), Icon_Geom::icon_id, LOG, Icon::obj, and Icon::obj_type.
Referenced by filelist_file_getimage(), and filelist_getimage().
| int BKE_icon_preview_ensure | ( | ID * | id, |
| PreviewImage * | preview | ||
| ) |
Return icon id of given preview, or create new icon if not found.
Definition at line 811 of file icons.cc.
References BKE_previewimg_id_ensure(), BLI_assert, CLOG_ERROR, Icon::flag, G, get_next_free_id(), icon_create(), ICON_DATA_PREVIEW, ICON_FLAG_MANAGED, ID::icon_id, PreviewImage::icon_id, icon_id_ensure_create_icon(), id, and LOG.
| void BKE_icon_set | ( | const int | icon_id, |
| struct Icon * | icon | ||
| ) |
Definition at line 897 of file icons.cc.
References BLI_ghash_ensure_p(), CLOG_ERROR, gIconMutex, gIcons, Icon_Geom::icon_id, LOG, and POINTER_FROM_INT.
Referenced by def_internal_icon(), and def_internal_vicon().
| void BKE_icons_deferred_free | ( | void | ) |
Definition at line 229 of file icons.cc.
References BLI_ghash_remove(), BLI_linklist_lockfree_begin(), BLI_linklist_lockfree_clear(), g_icon_delete_queue, gIconMutex, gIcons, icon_free(), MEM_freeN, node, and POINTER_FROM_INT.
Referenced by BKE_icon_id_delete().
| void BKE_icons_free | ( | void | ) |
Definition at line 212 of file icons.cc.
References BKE_previewimg_freefunc(), BLI_assert, BLI_ghash_free(), BLI_linklist_lockfree_free(), BLI_thread_is_main(), g_icon_delete_queue, gCachedPreviews, gIcons, icon_free(), and MEM_freeN.
Referenced by UI_icons_free().
| void BKE_icons_init | ( | int | first_dyn_id | ) |
Definition at line 195 of file icons.cc.
References BLI_assert, BLI_ghash_int_new(), BLI_ghash_str_new(), BLI_linklist_lockfree_init(), BLI_thread_is_main(), g_icon_delete_queue, gCachedPreviews, gFirstIconId, gIcons, and gNextIconId.
Referenced by WM_init().
| void BKE_previewimg_blend_read | ( | BlendDataReader * | reader, |
| PreviewImage * | prv | ||
| ) |
Definition at line 651 of file icons.cc.
References BKE_previewimg_finish(), BLO_read_data_address, PreviewImage::flag, PreviewImage::gputexture, PreviewImage::icon_id, NUM_ICON_SIZES, PRV_CHANGED, PRV_UNFINISHED, PreviewImage::rect, and PreviewImage::tag.
Referenced by action_blend_read_data(), BKE_collection_blend_read_data(), BKE_screen_blend_read_data(), image_blend_read_data(), light_blend_read_data(), material_blend_read_data(), object_blend_read_data(), scene_blend_read_data(), texture_blend_read_data(), and world_blend_read_data().
| void BKE_previewimg_blend_write | ( | BlendWriter * | writer, |
| const PreviewImage * | prv | ||
| ) |
Definition at line 625 of file icons.cc.
References BLO_write_struct_at_address, BLO_write_uint32_array(), PreviewImage::h, PreviewImage::rect, USER_SAVE_PREVIEWS, and PreviewImage::w.
| PreviewImage* BKE_previewimg_cached_ensure | ( | const char * | name | ) |
Generate an empty PreviewImage, if not yet existing.
Definition at line 464 of file icons.cc.
References BKE_previewimg_create(), BLI_assert, BLI_ghash_ensure_p_ex(), BLI_strdup(), BLI_thread_is_main(), and gCachedPreviews.
Referenced by bpy_utils_previews_new().
| PreviewImage* BKE_previewimg_cached_get | ( | const char * | name | ) |
Definition at line 455 of file icons.cc.
References BLI_assert, BLI_ghash_lookup(), BLI_thread_is_main(), and gCachedPreviews.
| void BKE_previewimg_cached_release | ( | const char * | name | ) |
Definition at line 530 of file icons.cc.
References BKE_previewimg_deferred_release(), BLI_assert, BLI_ghash_popkey(), BLI_thread_is_main(), gCachedPreviews, and MEM_freeN.
| PreviewImage* BKE_previewimg_cached_thumbnail_read | ( | const char * | name, |
| const char * | path, | ||
| const int | source, | ||
| bool | force_update | ||
| ) |
Generate a PreviewImage from given file path, using thumbnails management, if not yet existing. Does not actually generate the preview, BKE_previewimg_ensure() must be called for that.
Definition at line 485 of file icons.cc.
References BKE_previewimg_clear(), BKE_previewimg_free(), BLI_assert, BLI_ghash_insert(), BLI_ghash_lookup_p(), BLI_strdup(), BLI_thread_is_main(), gCachedPreviews, previewimg_deferred_create(), PRV_DEFERRED_DATA, and STREQ.
Referenced by bpy_utils_previews_load().
| void BKE_previewimg_clear | ( | struct PreviewImage * | prv | ) |
Definition at line 315 of file icons.cc.
References BKE_previewimg_clear_single(), and NUM_ICON_SIZES.
Referenced by BKE_previewimg_cached_thumbnail_read(), lib_id_generate_preview_exec(), and previews_clear_exec().
| void BKE_previewimg_clear_single | ( | struct PreviewImage * | prv, |
| enum eIconSizes | size | ||
| ) |
Definition at line 303 of file icons.cc.
References PreviewImage::changed_timestamp, PreviewImage::flag, GPU_texture_free(), PreviewImage::gputexture, PreviewImage::h, MEM_SAFE_FREE, PRV_CHANGED, PRV_UNFINISHED, PRV_USER_EDITED, PreviewImage::rect, size(), and PreviewImage::w.
Referenced by BKE_previewimg_clear().
| PreviewImage* BKE_previewimg_copy | ( | const PreviewImage * | prv | ) |
Definition at line 322 of file icons.cc.
References PreviewImage::gputexture, MEM_dupallocN, NUM_ICON_SIZES, and PreviewImage::rect.
Referenced by BKE_previewimg_id_copy().
| PreviewImage* BKE_previewimg_create | ( | void | ) |
Definition at line 273 of file icons.cc.
References previewimg_create_ex().
Referenced by BKE_previewimg_cached_ensure(), BKE_previewimg_id_ensure(), and UI_icon_to_preview().
| void BKE_previewimg_deferred_release | ( | PreviewImage * | prv | ) |
Definition at line 440 of file icons.cc.
References BKE_icon_delete(), BKE_previewimg_freefunc(), PreviewImage::icon_id, PRV_TAG_DEFFERED_DELETE, PRV_TAG_DEFFERED_RENDERING, and PreviewImage::tag.
Referenced by BKE_previewimg_cached_release(), BKE_previewimg_id_custom_set(), and icon_preview_endjob().
| void BKE_previewimg_ensure | ( | PreviewImage * | prv, |
| const int | size | ||
| ) |
Handle deferred (lazy) loading/generation of preview image, if needed. For now, only used with file thumbnails.
Definition at line 543 of file icons.cc.
References PreviewImage::flag, PreviewImage::h, ICON_RENDER_DEFAULT_HEIGHT, ICON_SIZE_ICON, ICON_SIZE_PREVIEW, IMB_freeImBuf(), IMB_premultiply_alpha(), IMB_scaleImBuf(), IMB_thumb_manage(), MEM_dupallocN, PRV_CHANGED, PRV_DEFERRED_DATA, PRV_TAG_DEFFERED, PRV_UNFINISHED, PRV_USER_EDITED, ImBuf::rect, PreviewImage::rect, size(), PreviewImage::tag, THB_LARGE, PreviewImage::w, ImBuf::x, and ImBuf::y.
Referenced by BKE_previewimg_id_custom_set().
| void BKE_previewimg_finish | ( | PreviewImage * | prv, |
| const int | size | ||
| ) |
Definition at line 614 of file icons.cc.
References atomic_fetch_and_and_int16(), PreviewImage::flag, PRV_UNFINISHED, and size().
Referenced by BKE_previewimg_blend_read(), BLO_blendhandle_get_previews(), and icon_preview_endjob().
| void BKE_previewimg_free | ( | PreviewImage ** | prv | ) |
Definition at line 295 of file icons.cc.
References BKE_previewimg_freefunc().
Referenced by action_free_data(), BKE_previewimg_cached_thumbnail_read(), BKE_previewimg_id_free(), brush_free_data(), collection_free_data(), image_free_data(), light_free_data(), material_free_data(), object_free_data(), scene_free_data(), screen_free_data(), texture_free_data(), and world_free_data().
| void BKE_previewimg_freefunc | ( | void * | link | ) |
Definition at line 278 of file icons.cc.
References GPU_texture_free(), PreviewImage::gputexture, MEM_freeN, NUM_ICON_SIZES, and PreviewImage::rect.
Referenced by BKE_icons_free(), BKE_previewimg_deferred_release(), BKE_previewimg_free(), and IMB_thumb_load_blend().
Duplicate preview image from id and clear icon_id, to be used by datablock copy functions.
Definition at line 342 of file icons.cc.
References BKE_previewimg_copy(), BKE_previewimg_id_get_p(), BLI_assert, ELEM, and ID::icon_id.
| void BKE_previewimg_id_custom_set | ( | ID * | id, |
| const char * | path | ||
| ) |
Definition at line 414 of file icons.cc.
References BKE_previewimg_deferred_release(), BKE_previewimg_ensure(), BKE_previewimg_id_get_p(), NUM_ICON_SIZES, previewimg_deferred_create(), PRV_USER_EDITED, and THB_SOURCE_IMAGE.
Referenced by lib_id_load_custom_preview_exec().
| PreviewImage* BKE_previewimg_id_ensure | ( | ID * | id | ) |
Definition at line 400 of file icons.cc.
References BKE_previewimg_create(), and BKE_previewimg_id_get_p().
Referenced by BKE_icon_preview_ensure(), ED_preview_icon_render(), icon_draw_size(), previews_clear_exec(), ui_icon_ensure_deferred(), UI_icon_render_id(), UI_icon_to_preview(), and ui_id_icon_render().
| void BKE_previewimg_id_free | ( | ID * | id | ) |
Definition at line 392 of file icons.cc.
References BKE_previewimg_free(), and BKE_previewimg_id_get_p().
| PreviewImage* BKE_previewimg_id_get | ( | const ID * | id | ) |
Definition at line 386 of file icons.cc.
References BKE_previewimg_id_get_p().
| PreviewImage** BKE_previewimg_id_get_p | ( | const ID * | id | ) |
Definition at line 359 of file icons.cc.
References GS, id, ID_AC, ID_BR, ID_GR, ID_IM, ID_LA, ID_MA, ID_OB, ID_PRV_CASE, ID_SCE, ID_SCR, ID_TE, ID_WO, and ID::name.
Referenced by BKE_icon_changed(), BKE_icon_id_ensure(), BKE_previewimg_id_copy(), BKE_previewimg_id_custom_set(), BKE_previewimg_id_ensure(), BKE_previewimg_id_free(), and BKE_previewimg_id_get().
| bool BKE_previewimg_id_supports_jobs | ( | const ID * | id | ) |
| bool BKE_previewimg_is_finished | ( | const PreviewImage * | prv, |
| const int | size | ||
| ) |
Definition at line 620 of file icons.cc.
References PreviewImage::flag, PRV_UNFINISHED, and size().
| ImBuf* BKE_previewimg_to_imbuf | ( | PreviewImage * | prv, |
| const int | size | ||
| ) |
Create an ImBuf holding a copy of the preview image buffer in prv.
Definition at line 597 of file icons.cc.
References PreviewImage::h, IB_rect, IMB_allocImBuf(), ImBuf::rect, PreviewImage::rect, size(), w(), and PreviewImage::w.
Referenced by filelist_cache_preview_runf(), filelist_file_create_entry(), and IMB_thumb_load_blend().
|
static |
Definition at line 169 of file icons.cc.
References BLI_ghash_lookup(), gFirstIconId, gIconMutex, gIcons, gNextIconId, and POINTER_FROM_INT.
Referenced by BKE_icon_ensure_studio_light(), BKE_icon_geom_ensure(), BKE_icon_gplayer_color_ensure(), BKE_icon_id_ensure(), BKE_icon_imbuf_create(), and BKE_icon_preview_ensure().
|
static |
Definition at line 910 of file icons.cc.
References BLI_linklist_lockfree_insert(), g_icon_delete_queue, Icon_Geom::icon_id, MEM_mallocN, and node.
Referenced by BKE_icon_id_delete().
|
static |
Definition at line 708 of file icons.cc.
References BLI_ghash_insert(), Icon::drawinfo, Icon::drawinfo_free, Icon::flag, gIconMutex, gIcons, Icon_Geom::icon_id, Icon::id_type, MEM_mallocN, Icon::obj, Icon::obj_type, and POINTER_FROM_INT.
Referenced by BKE_icon_ensure_studio_light(), BKE_icon_geom_ensure(), BKE_icon_imbuf_create(), BKE_icon_preview_ensure(), icon_gplayer_color_ensure_create_icon(), and icon_id_ensure_create_icon().
|
static |
Definition at line 102 of file icons.cc.
References Icon_Geom::colors, Icon_Geom::coords, Icon::drawinfo, Icon::drawinfo_free, ICON_DATA_GEOM, if(), Icon_Geom::mem, MEM_freeN, Icon::obj, and Icon::obj_type.
Referenced by BKE_icon_delete(), BKE_icon_delete_unmanaged(), BKE_icon_id_delete(), BKE_icons_deferred_free(), and BKE_icons_free().
|
static |
Definition at line 130 of file icons.cc.
References BKE_studiolight_unset_icon_id(), BLI_assert, ICON_DATA_GEOM, ICON_DATA_GPLAYER, ICON_DATA_ID, ICON_DATA_IMBUF, ICON_DATA_PREVIEW, ICON_DATA_STUDIOLIGHT, Icon_Geom::icon_id, if(), IMB_freeImBuf(), Icon::obj, and Icon::obj_type.
Referenced by BKE_icon_delete(), and BKE_icon_delete_unmanaged().
|
static |
Definition at line 161 of file icons.cc.
References BLI_ghash_lookup(), gIconMutex, gIcons, Icon_Geom::icon_id, and POINTER_FROM_INT.
Referenced by BKE_icon_changed(), BKE_icon_get(), and BKE_icon_imbuf_get_buffer().
|
static |
Definition at line 770 of file icons.cc.
References BLI_assert, BLI_thread_is_main(), Icon::flag, icon_create(), ICON_DATA_GPLAYER, ICON_FLAG_MANAGED, bGPDlayer_Runtime::icon_id, and bGPDlayer::runtime.
Referenced by BKE_icon_gplayer_color_ensure().
|
static |
Definition at line 729 of file icons.cc.
References BLI_assert, BLI_thread_is_main(), Icon::flag, GS, icon_create(), ICON_DATA_ID, ICON_FLAG_MANAGED, ID::icon_id, id, Icon::id_type, and ID::name.
Referenced by BKE_icon_id_ensure(), and BKE_icon_preview_ensure().
|
static |
Definition at line 242 of file icons.cc.
References PreviewImage::changed_timestamp, PreviewImage::flag, MEM_mallocN, NUM_ICON_SIZES, PRV_CHANGED, PRV_TAG_DEFFERED, PRV_UNFINISHED, and PreviewImage::tag.
Referenced by BKE_previewimg_create(), and previewimg_deferred_create().
|
static |
Definition at line 259 of file icons.cc.
References previewimg_create_ex(), and PRV_DEFERRED_DATA.
Referenced by BKE_previewimg_cached_thumbnail_read(), and BKE_previewimg_id_custom_set().
|
static |
Definition at line 100 of file icons.cc.
Referenced by BKE_icons_deferred_free(), BKE_icons_free(), BKE_icons_init(), and icon_add_to_deferred_delete_queue().
|
static |
Definition at line 92 of file icons.cc.
Referenced by BKE_icons_free(), BKE_icons_init(), BKE_previewimg_cached_ensure(), BKE_previewimg_cached_get(), BKE_previewimg_cached_release(), and BKE_previewimg_cached_thumbnail_read().
|
static |
Definition at line 87 of file icons.cc.
Referenced by BKE_icons_init(), and get_next_free_id().
|
static |
Definition at line 89 of file icons.cc.
Referenced by BKE_icon_delete(), BKE_icon_delete_unmanaged(), BKE_icon_id_delete(), BKE_icon_set(), BKE_icons_deferred_free(), get_next_free_id(), icon_create(), and icon_ghash_lookup().
|
static |
Definition at line 81 of file icons.cc.
Referenced by BKE_icon_delete(), BKE_icon_delete_unmanaged(), BKE_icon_id_delete(), BKE_icon_set(), BKE_icons_deferred_free(), BKE_icons_free(), BKE_icons_init(), get_next_free_id(), icon_create(), and icon_ghash_lookup().
|
static |
Definition at line 84 of file icons.cc.
Referenced by BKE_icons_init(), and get_next_free_id().
|
static |
Definition at line 78 of file icons.cc.
Referenced by BKE_icon_get(), BKE_icon_gplayer_color_ensure(), BKE_icon_id_ensure(), BKE_icon_imbuf_get_buffer(), BKE_icon_preview_ensure(), and BKE_icon_set().