Blender
V3.3
|
#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 253 of file BKE_icons.h.
Definition at line 23 of file BKE_icons.h.
Definition at line 23 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 25 of file BKE_icons.h.
void BKE_icon_changed | ( | int | icon_id | ) |
Report changes - icon needs to be recalculated.
Definition at line 637 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, and PRV_CHANGED.
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_aligned(), screen_area_join_ex(), texture_changed(), and world_changed().
bool BKE_icon_delete | ( | int | icon_id | ) |
Remove icon and free data.
Definition at line 888 of file icons.cc.
References BLI_ghash_popkey(), gIconMutex, gIcons, icon_free(), icon_free_data(), Icon_Geom::icon_id, lock, and POINTER_FROM_INT.
Referenced by BKE_gpencil_layer_delete(), BKE_previewimg_deferred_release(), filelist_cache_previews_clear(), filelist_cache_previews_update(), and filelist_entry_clear().
bool BKE_icon_delete_unmanaged | ( | int | icon_id | ) |
Definition at line 905 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, lock, 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 1005 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 933 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 988 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 949 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().
Definition at line 129 of file icons_rasterize.c.
References Icon_Geom::colors, Icon_Geom::coords_len, hsl_to_rgb(), blender::math::length(), usdtokens::rgb(), 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, |
unsigned int | size_x, | ||
unsigned int | size_y | ||
) |
Definition at line 70 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 | ( | int | icon_id | ) |
Retrieve icon for id.
Definition at line 832 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 | ) |
Return icon id for Grease Pencil layer (color preview) or create new icon if not found.
Definition at line 744 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.
Remove icon and free data if library object becomes invalid.
Definition at line 870 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, lock, 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 | ) |
Return icon id for library object or create new icon if not found.
Definition at line 699 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 | ( | struct 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 807 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(), filelist_cache_previews_push(), and filelist_file_create_entry().
struct ImBuf* BKE_icon_imbuf_get_buffer | ( | int | icon_id | ) |
Definition at line 817 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 | ( | struct ID * | id, |
struct PreviewImage * | preview | ||
) |
Return icon id of given preview, or create new icon if not found.
Definition at line 767 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, icon_id_ensure_create_icon(), id, LOG, and usdtokens::preview().
Set icon for id if not already defined. Used for inserting the internal icons.
Definition at line 848 of file icons.cc.
References BLI_ghash_ensure_p(), CLOG_ERROR, gIconMutex, gIcons, Icon_Geom::icon_id, lock, LOG, and POINTER_FROM_INT.
Referenced by def_internal_icon(), and def_internal_vicon().
Free all icons marked for deferred deletion.
Definition at line 217 of file icons.cc.
References BLI_ghash_remove(), BLI_linklist_lockfree_begin(), BLI_linklist_lockfree_clear(), g_icon_delete_queue, gIconMutex, gIcons, icon_free(), lock, MEM_freeN, node, and POINTER_FROM_INT.
Referenced by BKE_icon_id_delete().
Free all icons.
Definition at line 200 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 183 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 615 of file icons.cc.
References BLO_read_data_address, BLO_read_data_is_undo(), PreviewImage::flag, PreviewImage::gputexture, PreviewImage::icon_id, NUM_ICON_SIZES, PRV_RENDERING, 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(), ntreeBlendReadData(), 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 446 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 440 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 508 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 * | filepath, | ||
int | source, | ||
bool | force_update | ||
) |
Generate a PreviewImage from given filepath
, using thumbnails management, if not yet existing. Does not actually generate the preview, BKE_previewimg_ensure() must be called for that.
Definition at line 463 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 | ) |
Clear the preview image or icon, but does not free it.
Definition at line 303 of file icons.cc.
References BKE_previewimg_clear_single(), and NUM_ICON_SIZES.
Referenced by BKE_previewimg_cached_thumbnail_read(), ED_asset_generate_preview(), lib_id_generate_preview_exec(), and previews_clear_exec().
void BKE_previewimg_clear_single | ( | struct PreviewImage * | prv, |
enum eIconSizes | size | ||
) |
Clear the preview image or icon at a specific size.
Definition at line 291 of file icons.cc.
References PreviewImage::changed_timestamp, PreviewImage::flag, GPU_texture_free(), PreviewImage::gputexture, PreviewImage::h, MEM_SAFE_FREE, PRV_CHANGED, PRV_USER_EDITED, PreviewImage::rect, size(), and PreviewImage::w.
Referenced by BKE_previewimg_clear(), and ED_preview_restart_queue_work().
struct PreviewImage* BKE_previewimg_copy | ( | const struct PreviewImage * | prv | ) |
Create a copy of the preview image.
Referenced by UI_icon_to_preview().
struct PreviewImage* BKE_previewimg_create | ( | void | ) |
Create a new preview image.
Definition at line 261 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 425 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 | ( | struct PreviewImage * | prv, |
int | size | ||
) |
Handle deferred (lazy) loading/generation of preview image, if needed. For now, only used with file thumbnails.
Definition at line 517 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_RENDERING, PRV_TAG_DEFFERED, 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, |
int | size | ||
) |
Definition at line 584 of file icons.cc.
References atomic_fetch_and_and_int16(), PreviewImage::flag, PRV_RENDERING, and size().
Referenced by blo_blendhandle_read_preview_rects(), and icon_preview_endjob().
void BKE_previewimg_free | ( | struct PreviewImage ** | prv | ) |
Free the preview image.
Definition at line 283 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(), ntree_free_data(), object_free_data(), scene_free_data(), screen_free_data(), texture_free_data(), and world_free_data().
Free the preview image for use in list.
Definition at line 266 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_from_blend_id().
Duplicate preview image from id and clear icon_id, to be used by data-block copy functions.
Referenced by action_copy_data(), brush_copy_data(), collection_copy_data(), image_copy_data(), light_copy_data(), material_copy_data(), ntree_copy_data(), object_copy_data(), scene_copy_data(), texture_copy_data(), and world_copy_data().
Trigger deferred loading of a custom image file into the preview buffer.
Definition at line 399 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 | ) |
Retrieve existing or create new preview image.
Definition at line 385 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(), lib_id_generate_preview_from_object_exec(), previews_clear_exec(), ui_icon_ensure_deferred(), UI_icon_render_id(), UI_icon_to_preview(), and ui_id_icon_render().
Free the preview image belonging to the id.
Definition at line 377 of file icons.cc.
References BKE_previewimg_free(), and BKE_previewimg_id_get_p().
Referenced by lib_id_generate_preview_from_object_exec().
struct PreviewImage* BKE_previewimg_id_get | ( | const struct ID * | id | ) |
struct PreviewImage** BKE_previewimg_id_get_p | ( | const struct ID * | id | ) |
Get the preview from any pointer.
Referenced by ED_preview_id_is_supported(), and lib_id_preview_editing_poll().
Referenced by duplicate_ids(), ED_preview_shader_job(), and icon_set_image().
bool BKE_previewimg_is_finished | ( | const struct PreviewImage * | prv, |
int | size | ||
) |
struct ImBuf* BKE_previewimg_to_imbuf | ( | struct PreviewImage * | prv, |
int | size | ||
) |
Create an ImBuf holding a copy of the preview image buffer in prv.
Definition at line 567 of file icons.cc.
References PreviewImage::h, IB_rect, IMB_allocImBuf(), ImBuf::rect, PreviewImage::rect, size(), w(), and PreviewImage::w.
Referenced by filelist_cache_previews_push(), filelist_file_create_entry(), and imb_thumb_load_from_blend_id().