|
Blender
V2.93
|
#include "BLI_compiler_attrs.h"Go to the source code of this file.
Classes | |
| struct | Icon |
| struct | Icon_Geom |
Macros | |
| #define | ICON_RENDER_DEFAULT_HEIGHT 32 |
Typedefs | |
| typedef void(* | DrawInfoFreeFP) (void *drawinfo) |
| typedef struct Icon | Icon |
Enumerations | |
| enum | { ICON_DATA_ID = 0 , ICON_DATA_IMBUF , ICON_DATA_PREVIEW , ICON_DATA_GEOM , ICON_DATA_STUDIOLIGHT , ICON_DATA_GPLAYER } |
Resizable Icons for Blender
There is some thread safety for this API but it is rather weak. Registering or unregistering icons is thread safe, changing data of icons from multiple threads is not. Practically this should be fine since only the main thread modifies icons. Should that change, more locks or a different design need to be introduced.
Definition in file BKE_icons.h.
| #define ICON_RENDER_DEFAULT_HEIGHT 32 |
Definition at line 202 of file BKE_icons.h.
| typedef void(* DrawInfoFreeFP) (void *drawinfo) |
Definition at line 39 of file BKE_icons.h.
Definition at line 39 of file BKE_icons.h.
| anonymous enum |
| Enumerator | |
|---|---|
| ICON_DATA_ID | |
| ICON_DATA_IMBUF | |
| ICON_DATA_PREVIEW | Preview: obj is PreviewImage |
| ICON_DATA_GEOM | 2D triangles: obj is Icon_Geom |
| ICON_DATA_STUDIOLIGHT | Studiolight |
| ICON_DATA_GPLAYER | GPencil Layer color preview (annotations): obj is bGPDlayer |
Definition at line 41 of file BKE_icons.h.
| 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().
| void BKE_icon_geom_invert_lightness | ( | struct Icon_Geom * | geom | ) |
Definition at line 143 of file icons_rasterize.c.
References Icon_Geom::colors, Icon_Geom::coords_len, hsl_to_rgb(), length(), rgb_float_to_uchar(), rgb_to_hsl_v(), and rgb_uchar_to_float().
Referenced by icon_draw_size().
| struct ImBuf* BKE_icon_geom_rasterize | ( | const struct Icon_Geom * | geom, |
| const unsigned int | size_x, | ||
| const unsigned int | size_y | ||
| ) |
Definition at line 84 of file icons_rasterize.c.
References col, Icon_Geom::colors, Icon_Geom::coords, Icon_Geom::coords_len, max_ii(), pos, and rect_size().
Referenced by icon_draw_size().
| struct 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 | ( | struct 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().
| struct 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 | ( | struct BlendDataReader * | reader, |
| struct 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 | ( | struct BlendWriter * | writer, |
| const struct PreviewImage * | prv | ||
| ) |
| struct 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().
| struct 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.
| struct 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().
| struct PreviewImage* BKE_previewimg_copy | ( | const struct PreviewImage * | prv | ) |
Referenced by UI_icon_to_preview().
| struct 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 | ( | struct 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 | ( | struct 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 | ( | struct 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().
| void BKE_previewimg_id_custom_set | ( | struct 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().
| struct PreviewImage* BKE_previewimg_id_ensure | ( | struct 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 | ( | struct ID * | id | ) |
Definition at line 392 of file icons.cc.
References BKE_previewimg_free(), and BKE_previewimg_id_get_p().
| struct PreviewImage* BKE_previewimg_id_get | ( | const struct ID * | id | ) |
Referenced by BKE_asset_metadata_preview_get_from_id(), and lib_id_generate_preview_exec().
| struct PreviewImage** BKE_previewimg_id_get_p | ( | const struct ID * | id | ) |
Referenced by lib_id_preview_editing_poll().
| bool BKE_previewimg_id_supports_jobs | ( | const struct ID * | id | ) |
Referenced by duplicate_ids(), ED_preview_shader_job(), and icon_set_image().
| bool BKE_previewimg_is_finished | ( | const struct PreviewImage * | prv, |
| const int | size | ||
| ) |
Referenced by filelist_cache_preview_runf(), filelist_file_create_entry(), and icon_preview_startjob_all_sizes().
| struct 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().