Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions
BKE_icons.h File Reference
#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
}
 

Functions

void BKE_icons_init (int first_dyn_id)
 
int BKE_icon_id_ensure (struct ID *id)
 
int BKE_icon_gplayer_color_ensure (struct bGPDlayer *gpl)
 
int BKE_icon_preview_ensure (struct ID *id, struct PreviewImage *preview)
 
int BKE_icon_imbuf_create (struct ImBuf *ibuf) ATTR_WARN_UNUSED_RESULT
 
struct ImBufBKE_icon_imbuf_get_buffer (int icon_id) ATTR_WARN_UNUSED_RESULT
 
struct IconBKE_icon_get (int icon_id)
 
void BKE_icon_set (int icon_id, struct Icon *icon)
 
void BKE_icon_id_delete (struct ID *id)
 
bool BKE_icon_delete (int icon_id)
 
bool BKE_icon_delete_unmanaged (int icon_id)
 
void BKE_icon_changed (int icon_id)
 
void BKE_icons_free (void)
 
void BKE_icons_deferred_free (void)
 
void BKE_previewimg_freefunc (void *link)
 
void BKE_previewimg_free (struct PreviewImage **prv)
 
void BKE_previewimg_clear (struct PreviewImage *prv)
 
void BKE_previewimg_clear_single (struct PreviewImage *prv, enum eIconSizes size)
 
struct PreviewImage ** BKE_previewimg_id_get_p (const struct ID *id)
 
struct PreviewImageBKE_previewimg_id_get (const struct ID *id)
 
bool BKE_previewimg_id_supports_jobs (const struct ID *id)
 
void BKE_previewimg_id_custom_set (struct ID *id, const char *filepath)
 
void BKE_previewimg_id_free (struct ID *id)
 
struct PreviewImageBKE_previewimg_create (void)
 
struct PreviewImageBKE_previewimg_copy (const struct PreviewImage *prv)
 
void BKE_previewimg_id_copy (struct ID *new_id, const struct ID *old_id)
 
struct PreviewImageBKE_previewimg_id_ensure (struct ID *id)
 
void BKE_previewimg_ensure (struct PreviewImage *prv, int size)
 
struct ImBufBKE_previewimg_to_imbuf (struct PreviewImage *prv, int size)
 
void BKE_previewimg_finish (struct PreviewImage *prv, int size)
 
bool BKE_previewimg_is_finished (const struct PreviewImage *prv, int size)
 
struct PreviewImageBKE_previewimg_cached_get (const char *name)
 
struct PreviewImageBKE_previewimg_cached_ensure (const char *name)
 
struct PreviewImageBKE_previewimg_cached_thumbnail_read (const char *name, const char *filepath, int source, bool force_update)
 
void BKE_previewimg_cached_release (const char *name)
 
void BKE_previewimg_deferred_release (struct PreviewImage *prv)
 
void BKE_previewimg_blend_write (struct BlendWriter *writer, const struct PreviewImage *prv)
 
void BKE_previewimg_blend_read (struct BlendDataReader *reader, struct PreviewImage *prv)
 
int BKE_icon_geom_ensure (struct Icon_Geom *geom)
 
struct Icon_GeomBKE_icon_geom_from_memory (uchar *data, size_t data_len)
 
struct Icon_GeomBKE_icon_geom_from_file (const char *filename)
 
struct ImBufBKE_icon_geom_rasterize (const struct Icon_Geom *geom, unsigned int size_x, unsigned int size_y)
 
void BKE_icon_geom_invert_lightness (struct Icon_Geom *geom)
 
int BKE_icon_ensure_studio_light (struct StudioLight *sl, int id_type)
 

Detailed Description

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.

Macro Definition Documentation

◆ ICON_RENDER_DEFAULT_HEIGHT

#define ICON_RENDER_DEFAULT_HEIGHT   32

Definition at line 253 of file BKE_icons.h.

Typedef Documentation

◆ DrawInfoFreeFP

typedef void(* DrawInfoFreeFP) (void *drawinfo)

Definition at line 23 of file BKE_icons.h.

◆ Icon

typedef struct Icon Icon

Definition at line 23 of file BKE_icons.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ICON_DATA_ID 

ID preview: obj is ID.

ICON_DATA_IMBUF 

Arbitrary Image buffer: obj is 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.

Function Documentation

◆ BKE_icon_changed()

void BKE_icon_changed ( int  icon_id)

◆ BKE_icon_delete()

bool BKE_icon_delete ( int  icon_id)

◆ BKE_icon_delete_unmanaged()

bool BKE_icon_delete_unmanaged ( int  icon_id)

◆ BKE_icon_ensure_studio_light()

int BKE_icon_ensure_studio_light ( struct StudioLight sl,
int  id_type 
)

◆ BKE_icon_geom_ensure()

int BKE_icon_geom_ensure ( struct Icon_Geom geom)

◆ BKE_icon_geom_from_file()

struct Icon_Geom* BKE_icon_geom_from_file ( const char *  filename)

◆ BKE_icon_geom_from_memory()

struct Icon_Geom* BKE_icon_geom_from_memory ( uchar data,
size_t  data_len 
)

◆ BKE_icon_geom_invert_lightness()

void BKE_icon_geom_invert_lightness ( struct Icon_Geom geom)

◆ BKE_icon_geom_rasterize()

struct ImBuf* BKE_icon_geom_rasterize ( const struct Icon_Geom geom,
unsigned int  size_x,
unsigned int  size_y 
)

◆ BKE_icon_get()

struct Icon* BKE_icon_get ( int  icon_id)

◆ BKE_icon_gplayer_color_ensure()

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.

◆ BKE_icon_id_delete()

void BKE_icon_id_delete ( struct ID id)

◆ BKE_icon_id_ensure()

int BKE_icon_id_ensure ( struct ID id)

◆ BKE_icon_imbuf_create()

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.

Note
Transforms ownership of ibuf to the newly created icon.

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().

◆ BKE_icon_imbuf_get_buffer()

struct ImBuf* BKE_icon_imbuf_get_buffer ( int  icon_id)

◆ BKE_icon_preview_ensure()

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().

◆ BKE_icon_set()

void BKE_icon_set ( int  icon_id,
struct Icon icon 
)

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().

◆ BKE_icons_deferred_free()

void BKE_icons_deferred_free ( void  )

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().

◆ BKE_icons_free()

void BKE_icons_free ( void  )

◆ BKE_icons_init()

void BKE_icons_init ( int  first_dyn_id)

◆ BKE_previewimg_blend_read()

void BKE_previewimg_blend_read ( struct BlendDataReader reader,
struct PreviewImage prv 
)

◆ BKE_previewimg_blend_write()

void BKE_previewimg_blend_write ( struct BlendWriter writer,
const struct PreviewImage prv 
)

◆ BKE_previewimg_cached_ensure()

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().

◆ BKE_previewimg_cached_get()

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.

◆ BKE_previewimg_cached_release()

void BKE_previewimg_cached_release ( const char *  name)

◆ BKE_previewimg_cached_thumbnail_read()

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().

◆ BKE_previewimg_clear()

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().

◆ BKE_previewimg_clear_single()

void BKE_previewimg_clear_single ( struct PreviewImage prv,
enum eIconSizes  size 
)

◆ BKE_previewimg_copy()

struct PreviewImage* BKE_previewimg_copy ( const struct PreviewImage prv)

Create a copy of the preview image.

Referenced by UI_icon_to_preview().

◆ BKE_previewimg_create()

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().

◆ BKE_previewimg_deferred_release()

void BKE_previewimg_deferred_release ( struct PreviewImage prv)

◆ BKE_previewimg_ensure()

void BKE_previewimg_ensure ( struct PreviewImage prv,
int  size 
)

◆ BKE_previewimg_finish()

void BKE_previewimg_finish ( struct PreviewImage prv,
int  size 
)

◆ BKE_previewimg_free()

void BKE_previewimg_free ( struct PreviewImage **  prv)

◆ BKE_previewimg_freefunc()

void BKE_previewimg_freefunc ( void link)

◆ BKE_previewimg_id_copy()

void BKE_previewimg_id_copy ( struct ID new_id,
const struct ID old_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().

◆ BKE_previewimg_id_custom_set()

void BKE_previewimg_id_custom_set ( struct ID id,
const char *  filepath 
)

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().

◆ BKE_previewimg_id_ensure()

struct PreviewImage* BKE_previewimg_id_ensure ( struct ID id)

◆ BKE_previewimg_id_free()

void BKE_previewimg_id_free ( struct ID id)

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().

◆ BKE_previewimg_id_get()

struct PreviewImage* BKE_previewimg_id_get ( const struct ID id)

◆ BKE_previewimg_id_get_p()

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().

◆ BKE_previewimg_id_supports_jobs()

bool BKE_previewimg_id_supports_jobs ( const struct ID id)

◆ BKE_previewimg_is_finished()

bool BKE_previewimg_is_finished ( const struct PreviewImage prv,
int  size 
)

◆ BKE_previewimg_to_imbuf()

struct ImBuf* BKE_previewimg_to_imbuf ( struct PreviewImage prv,
int  size 
)

Create an ImBuf holding a copy of the preview image buffer in prv.

Note
The returned image buffer has to be free'd (IMB_freeImBuf()).

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().