Blender V4.3
icons.cc File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <mutex>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
#include "DNA_gpencil_legacy_types.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
#include "BLI_linklist_lockfree.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_global.hh"
#include "BKE_icons.h"
#include "BKE_preview_image.hh"
#include "BKE_studiolight.h"
#include "BLI_sys_types.h"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"

Go to the source code of this file.

Classes

struct  DeferredIconDeleteNode
 

Enumerations

enum  { ICON_FLAG_MANAGED = (1 << 0) }
 

Functions

static void icon_free (void *val)
 
static void icon_free_data (int icon_id, Icon *icon)
 
static Iconicon_ghash_lookup (int icon_id)
 
static int get_next_free_id ()
 
void BKE_icons_init (int first_dyn_id)
 
void BKE_icons_free ()
 
void BKE_icons_deferred_free ()
 
void BKE_icon_changed (const int icon_id)
 
static Iconicon_create (int icon_id, int obj_type, void *obj)
 
static int icon_id_ensure_create_icon (ID *id)
 
int BKE_icon_id_ensure (ID *id)
 
static int icon_gplayer_color_ensure_create_icon (bGPDlayer *gpl)
 
int BKE_icon_gplayer_color_ensure (bGPDlayer *gpl)
 
int BKE_icon_preview_ensure (ID *id, PreviewImage *preview)
 
int BKE_icon_imbuf_create (ImBuf *ibuf)
 
ImBufBKE_icon_imbuf_get_buffer (int icon_id)
 
IconBKE_icon_get (const int icon_id)
 
bool BKE_icon_is_preview (const int icon_id)
 
bool BKE_icon_is_image (const int icon_id)
 
void BKE_icon_set (const int icon_id, Icon *icon)
 
static void icon_add_to_deferred_delete_queue (int icon_id)
 
void BKE_icon_id_delete (ID *id)
 
bool BKE_icon_delete (const int icon_id)
 
bool BKE_icon_delete_unmanaged (const int icon_id)
 
Geometry Icon
int BKE_icon_geom_ensure (Icon_Geom *geom)
 
Icon_GeomBKE_icon_geom_from_memory (uchar *data, size_t data_len)
 
Icon_GeomBKE_icon_geom_from_file (const char *filename)
 
Studio Light Icon
int BKE_icon_ensure_studio_light (StudioLight *sl, int id_type)
 

Variables

static CLG_LogRef LOG = {"bke.icons"}
 
static GHashgIcons = nullptr
 
static int gNextIconId = 1
 
static int gFirstIconId = 1
 
static std::mutex gIconMutex
 
static LockfreeLinkList g_icon_delete_queue
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Only allow non-managed icons to be removed (by Python for eg). Previews & ID's have their own functions to remove icons.

Enumerator
ICON_FLAG_MANAGED 

Definition at line 42 of file icons.cc.

Function Documentation

◆ BKE_icon_changed()

◆ BKE_icon_delete()

◆ BKE_icon_delete_unmanaged()

bool BKE_icon_delete_unmanaged ( const int icon_id)

◆ BKE_icon_ensure_studio_light()

int BKE_icon_ensure_studio_light ( StudioLight * sl,
int id_type )

Definition at line 586 of file icons.cc.

References get_next_free_id(), icon_create(), ICON_DATA_STUDIOLIGHT, and Icon::id_type.

Referenced by studiolight_create().

◆ BKE_icon_geom_ensure()

◆ BKE_icon_geom_from_file()

Icon_Geom * BKE_icon_geom_from_file ( const char * filename)

◆ BKE_icon_geom_from_memory()

Icon_Geom * BKE_icon_geom_from_memory ( uchar * data,
size_t data_len )

◆ BKE_icon_get()

◆ 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 313 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()

◆ 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 376 of file icons.cc.

References Icon::flag, get_next_free_id(), icon_create(), ICON_DATA_IMBUF, and ICON_FLAG_MANAGED.

Referenced by filelist_cache_preview_runf(), filelist_cache_previews_push(), and filelist_file_create_entry().

◆ BKE_icon_imbuf_get_buffer()

ImBuf * BKE_icon_imbuf_get_buffer ( int icon_id)

◆ BKE_icon_is_image()

bool BKE_icon_is_image ( const int icon_id)

◆ BKE_icon_is_preview()

bool BKE_icon_is_preview ( const 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 336 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, icon_id_ensure_create_icon(), LOG, and PreviewImage::runtime.

◆ 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 429 of file icons.cc.

References BLI_ghash_ensure_p(), CLOG_ERROR, gIconMutex, gIcons, 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 )

◆ BKE_icons_free()

void BKE_icons_free ( void )

◆ BKE_icons_init()

void BKE_icons_init ( int first_dyn_id)

◆ get_next_free_id()

◆ icon_add_to_deferred_delete_queue()

static void icon_add_to_deferred_delete_queue ( int icon_id)
static

◆ icon_create()

◆ icon_free()

◆ icon_free_data()

◆ icon_ghash_lookup()

static Icon * icon_ghash_lookup ( int icon_id)
static

◆ icon_gplayer_color_ensure_create_icon()

static int icon_gplayer_color_ensure_create_icon ( bGPDlayer * gpl)
static

◆ icon_id_ensure_create_icon()

static int icon_id_ensure_create_icon ( ID * id)
static

Variable Documentation

◆ g_icon_delete_queue

LockfreeLinkList g_icon_delete_queue
static

◆ gFirstIconId

int gFirstIconId = 1
static

Definition at line 57 of file icons.cc.

Referenced by BKE_icons_init(), and get_next_free_id().

◆ gIconMutex

◆ gIcons

◆ gNextIconId

int gNextIconId = 1
static

Definition at line 54 of file icons.cc.

Referenced by BKE_icons_init(), and get_next_free_id().

◆ LOG