From 2e76bb47bb0bac3c493f69e199af1ebb8f575d3f Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 16 Oct 2025 17:45:26 +0200 Subject: [PATCH] Refactor: BKE: Move icon header to C++ Was trying to use a C++ type (`blender::Span`) in the header but couldn't. I would rather not use a less safe raw pointer to a buffer. Pull Request: https://projects.blender.org/blender/blender/pulls/148214 --- .../intern/asset_representation.cc | 2 +- .../blenkernel/{BKE_icons.h => BKE_icons.hh} | 34 +++++++++---------- source/blender/blenkernel/CMakeLists.txt | 2 +- .../blenkernel/intern/gpencil_legacy.cc | 2 +- source/blender/blenkernel/intern/icons.cc | 2 +- .../blenkernel/intern/icons_rasterize.cc | 2 +- source/blender/blenkernel/intern/image.cc | 2 +- source/blender/blenkernel/intern/light.cc | 2 +- source/blender/blenkernel/intern/material.cc | 2 +- .../blenkernel/intern/preview_image.cc | 2 +- .../blender/blenkernel/intern/studiolight.cc | 2 +- source/blender/blenkernel/intern/texture.cc | 2 +- source/blender/blenkernel/intern/world.cc | 2 +- .../editors/animation/anim_asset_ops.cc | 2 +- .../blender/editors/asset/intern/asset_ops.cc | 2 +- .../editors/interface/interface_icons.cc | 2 +- .../editors/interface/views/grid_view.cc | 2 +- .../blender/editors/render/render_preview.cc | 2 +- .../blender/editors/render/render_update.cc | 2 +- source/blender/editors/screen/screen_edit.cc | 2 +- source/blender/editors/screen/screen_ops.cc | 2 +- .../editors/space_file/filelist/filelist.cc | 2 +- .../blender/editors/space_image/image_ops.cc | 2 +- source/blender/makesrna/intern/rna_ID.cc | 2 +- .../makesrna/intern/rna_annotations.cc | 2 +- source/blender/makesrna/intern/rna_brush.cc | 2 +- .../blender/makesrna/intern/rna_main_api.cc | 2 +- source/blender/makesrna/intern/rna_space.cc | 2 +- source/blender/python/intern/bpy_app_icons.cc | 2 +- .../windowmanager/intern/wm_init_exit.cc | 2 +- .../blender/windowmanager/intern/wm_window.cc | 2 +- 31 files changed, 46 insertions(+), 48 deletions(-) rename source/blender/blenkernel/{BKE_icons.h => BKE_icons.hh} (74%) diff --git a/source/blender/asset_system/intern/asset_representation.cc b/source/blender/asset_system/intern/asset_representation.cc index 9e2f6d60014..9b993c54a3a 100644 --- a/source/blender/asset_system/intern/asset_representation.cc +++ b/source/blender/asset_system/intern/asset_representation.cc @@ -11,7 +11,7 @@ #include "BLI_path_utils.hh" #include "BKE_blendfile.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_preview_image.hh" #include "DNA_ID.h" diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.hh similarity index 74% rename from source/blender/blenkernel/BKE_icons.h rename to source/blender/blenkernel/BKE_icons.hh index c4102b719e0..8742b0536cc 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.hh @@ -78,41 +78,41 @@ void BKE_icons_init(int first_dyn_id); /** * Return icon id for library object or create new icon if not found. */ -int BKE_icon_id_ensure(struct ID *id); +int BKE_icon_id_ensure(ID *id); /** * Return icon id for Grease Pencil layer (color preview) or create new icon if not found. */ -int BKE_icon_gplayer_color_ensure(struct bGPDlayer *gpl); +int BKE_icon_gplayer_color_ensure(bGPDlayer *gpl); /** * Return icon id of given preview, or create new icon if not found. */ -int BKE_icon_preview_ensure(struct ID *id, struct PreviewImage *preview); +int BKE_icon_preview_ensure(ID *id, PreviewImage *preview); /** * Create an icon as owner or \a ibuf. The icon-ID is not stored in \a ibuf, * it needs to be stored separately. * \note Transforms ownership of \a ibuf to the newly created icon. */ -int BKE_icon_imbuf_create(struct ImBuf *ibuf) ATTR_WARN_UNUSED_RESULT; -struct ImBuf *BKE_icon_imbuf_get_buffer(int icon_id) ATTR_WARN_UNUSED_RESULT; +int BKE_icon_imbuf_create(ImBuf *ibuf) ATTR_WARN_UNUSED_RESULT; +ImBuf *BKE_icon_imbuf_get_buffer(int icon_id) ATTR_WARN_UNUSED_RESULT; /** * Retrieve icon for id. */ -struct Icon *BKE_icon_get(int icon_id); +Icon *BKE_icon_get(int icon_id); /** * Set icon for id if not already defined. * Used for inserting the internal icons. */ -void BKE_icon_set(int icon_id, struct Icon *icon); +void BKE_icon_set(int icon_id, Icon *icon); /** * Remove icon and free data if library object becomes invalid. */ -void BKE_icon_id_delete(struct ID *id); +void BKE_icon_id_delete(ID *id); /** * Remove icon and free data. @@ -128,22 +128,20 @@ void BKE_icon_changed(int icon_id); /** * Free all icons. */ -void BKE_icons_free(void); +void BKE_icons_free(); /** * Free all icons marked for deferred deletion. */ -void BKE_icons_deferred_free(void); +void BKE_icons_deferred_free(); -int BKE_icon_geom_ensure(struct Icon_Geom *geom); -struct Icon_Geom *BKE_icon_geom_from_memory(uchar *data, size_t data_len); -struct Icon_Geom *BKE_icon_geom_from_file(const char *filename); +int BKE_icon_geom_ensure(Icon_Geom *geom); +Icon_Geom *BKE_icon_geom_from_memory(uchar *data, size_t data_len); +Icon_Geom *BKE_icon_geom_from_file(const char *filename); -struct ImBuf *BKE_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); +ImBuf *BKE_icon_geom_rasterize(const Icon_Geom *geom, unsigned int size_x, unsigned int size_y); +void BKE_icon_geom_invert_lightness(Icon_Geom *geom); -int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type); +int BKE_icon_ensure_studio_light(StudioLight *sl, int id_type); #define ICON_RENDER_DEFAULT_HEIGHT 32 diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c3fdc0bfddb..941a0811e44 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -419,7 +419,7 @@ set(SRC BKE_grease_pencil.hh BKE_grease_pencil_legacy_convert.hh BKE_grease_pencil_vertex_groups.hh - BKE_icons.h + BKE_icons.hh BKE_id_hash.hh BKE_idprop.hh BKE_idtype.hh diff --git a/source/blender/blenkernel/intern/gpencil_legacy.cc b/source/blender/blenkernel/intern/gpencil_legacy.cc index 9cef66f7301..7a5baaf11f3 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_legacy.cc @@ -41,7 +41,7 @@ #include "BKE_colortools.hh" #include "BKE_deform.hh" #include "BKE_gpencil_legacy.h" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_image.hh" #include "BKE_lib_id.hh" diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index fe984a819c3..f1cc8e1ea66 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -25,7 +25,7 @@ #include "BLI_utildefines.h" #include "BKE_global.hh" /* only for G.background test */ -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_preview_image.hh" #include "BKE_studiolight.h" diff --git a/source/blender/blenkernel/intern/icons_rasterize.cc b/source/blender/blenkernel/intern/icons_rasterize.cc index 9218e7da727..b43fec7923c 100644 --- a/source/blender/blenkernel/intern/icons_rasterize.cc +++ b/source/blender/blenkernel/intern/icons_rasterize.cc @@ -14,7 +14,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */ diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index f9493f003c4..cf530fb65fc 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -76,7 +76,7 @@ #include "BKE_bpath.hh" #include "BKE_colortools.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" diff --git a/source/blender/blenkernel/intern/light.cc b/source/blender/blenkernel/intern/light.cc index 948dbfb66ae..21e9f15f6df 100644 --- a/source/blender/blenkernel/intern/light.cc +++ b/source/blender/blenkernel/intern/light.cc @@ -24,7 +24,7 @@ #include "BLI_math_matrix_types.hh" #include "BLI_utildefines.h" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index 6901a846094..c38a755df6f 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -52,7 +52,7 @@ #include "BKE_displist.h" #include "BKE_editmesh.hh" #include "BKE_grease_pencil.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_image.hh" #include "BKE_lib_id.hh" diff --git a/source/blender/blenkernel/intern/preview_image.cc b/source/blender/blenkernel/intern/preview_image.cc index 8da548e5ca4..0762617a273 100644 --- a/source/blender/blenkernel/intern/preview_image.cc +++ b/source/blender/blenkernel/intern/preview_image.cc @@ -20,7 +20,7 @@ #include "DNA_texture_types.h" #include "DNA_world_types.h" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BLI_ghash.h" #include "BLI_string.h" diff --git a/source/blender/blenkernel/intern/studiolight.cc b/source/blender/blenkernel/intern/studiolight.cc index 5c2328cd1f1..b399be0db42 100644 --- a/source/blender/blenkernel/intern/studiolight.cc +++ b/source/blender/blenkernel/intern/studiolight.cc @@ -9,7 +9,7 @@ #include "BKE_studiolight.h" #include "BKE_appdir.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BLI_dynstr.h" #include "BLI_fileops.h" diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index 5449cf08294..60b22ed1ddd 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -39,7 +39,7 @@ #include "BKE_brush.hh" #include "BKE_colorband.hh" #include "BKE_colortools.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_image.hh" #include "BKE_lib_id.hh" diff --git a/source/blender/blenkernel/intern/world.cc b/source/blender/blenkernel/intern/world.cc index 1ed970b247f..082e744e0d5 100644 --- a/source/blender/blenkernel/intern/world.cc +++ b/source/blender/blenkernel/intern/world.cc @@ -23,7 +23,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" diff --git a/source/blender/editors/animation/anim_asset_ops.cc b/source/blender/editors/animation/anim_asset_ops.cc index 9f8b93b39a1..0d11e009cf5 100644 --- a/source/blender/editors/animation/anim_asset_ops.cc +++ b/source/blender/editors/animation/anim_asset_ops.cc @@ -9,7 +9,7 @@ #include "BKE_context.hh" #include "BKE_fcurve.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_lib_id.hh" #include "BKE_preferences.h" #include "BKE_report.hh" diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index 6e0a5a73247..378db445174 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -14,7 +14,7 @@ #include "BKE_bpath.hh" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_preferences.h" diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 6f3e35e1215..cf5aca96719 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -31,7 +31,7 @@ #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_paint.hh" #include "BKE_preview_image.hh" #include "BKE_studiolight.h" diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index cad15c46917..be7ae78f307 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -13,7 +13,7 @@ #include #include "BKE_context.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BLI_index_range.hh" diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 30d24c78133..56f06fea819 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -53,7 +53,7 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idprop.hh" #include "BKE_image.hh" #include "BKE_layer.hh" diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc index b9d1701a8d8..02e43658176 100644 --- a/source/blender/editors/render/render_update.cc +++ b/source/blender/editors/render/render_update.cc @@ -30,7 +30,7 @@ #include "BKE_brush.hh" #include "BKE_context.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_main.hh" #include "BKE_main_invariants.hh" #include "BKE_material.hh" diff --git a/source/blender/editors/screen/screen_edit.cc b/source/blender/editors/screen/screen_edit.cc index 0e152c5f125..d5e5885e2f8 100644 --- a/source/blender/editors/screen/screen_edit.cc +++ b/source/blender/editors/screen/screen_edit.cc @@ -23,7 +23,7 @@ #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_image.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 1966d60c50f..3014c998b94 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -37,7 +37,7 @@ #include "BKE_editmesh.hh" #include "BKE_fcurve.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_library.hh" diff --git a/source/blender/editors/space_file/filelist/filelist.cc b/source/blender/editors/space_file/filelist/filelist.cc index 90245f03b46..03fb683d692 100644 --- a/source/blender/editors/space_file/filelist/filelist.cc +++ b/source/blender/editors/space_file/filelist/filelist.cc @@ -52,7 +52,7 @@ #include "BKE_blendfile.hh" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_idtype.hh" #include "BKE_main.hh" #include "BKE_preferences.h" diff --git a/source/blender/editors/space_image/image_ops.cc b/source/blender/editors/space_image/image_ops.cc index bb8e6011dd8..21f0d37f9cc 100644 --- a/source/blender/editors/space_image/image_ops.cc +++ b/source/blender/editors/space_image/image_ops.cc @@ -39,7 +39,7 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_image.hh" #include "BKE_image_format.hh" #include "BKE_image_save.hh" diff --git a/source/blender/makesrna/intern/rna_ID.cc b/source/blender/makesrna/intern/rna_ID.cc index dcbfe2c8567..5d069398c34 100644 --- a/source/blender/makesrna/intern/rna_ID.cc +++ b/source/blender/makesrna/intern/rna_ID.cc @@ -218,7 +218,7 @@ const IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = { # include "BKE_anim_data.hh" # include "BKE_global.hh" /* XXX, remove me */ -# include "BKE_icons.h" +# include "BKE_icons.hh" # include "BKE_idprop.hh" # include "BKE_idtype.hh" # include "BKE_lib_override.hh" diff --git a/source/blender/makesrna/intern/rna_annotations.cc b/source/blender/makesrna/intern/rna_annotations.cc index d01fd71c519..b627da2ae2e 100644 --- a/source/blender/makesrna/intern/rna_annotations.cc +++ b/source/blender/makesrna/intern/rna_annotations.cc @@ -29,7 +29,7 @@ # include "BKE_animsys.h" # include "BKE_gpencil_legacy.h" -# include "BKE_icons.h" +# include "BKE_icons.hh" # include "BKE_report.hh" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_brush.cc b/source/blender/makesrna/intern/rna_brush.cc index cbbcd0809d2..d8ce4e05987 100644 --- a/source/blender/makesrna/intern/rna_brush.cc +++ b/source/blender/makesrna/intern/rna_brush.cc @@ -372,7 +372,7 @@ static EnumPropertyItem rna_enum_gpencil_brush_modes_items[] = { # include "BKE_colorband.hh" # include "BKE_context.hh" # include "BKE_gpencil_legacy.h" -# include "BKE_icons.h" +# include "BKE_icons.hh" # include "BKE_layer.hh" # include "BKE_material.hh" # include "BKE_paint.hh" diff --git a/source/blender/makesrna/intern/rna_main_api.cc b/source/blender/makesrna/intern/rna_main_api.cc index 6f3db9533e0..d7dd7b944a9 100644 --- a/source/blender/makesrna/intern/rna_main_api.cc +++ b/source/blender/makesrna/intern/rna_main_api.cc @@ -29,7 +29,7 @@ # include "BKE_displist.h" # include "BKE_gpencil_legacy.h" # include "BKE_grease_pencil.hh" -# include "BKE_icons.h" +# include "BKE_icons.hh" # include "BKE_idtype.hh" # include "BKE_image.hh" # include "BKE_lattice.hh" diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index 446d526e6c7..e418bd0bd8a 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -634,7 +634,7 @@ static const EnumPropertyItem spreadsheet_table_id_type_items[] = { # include "BKE_brush.hh" # include "BKE_context.hh" # include "BKE_global.hh" -# include "BKE_icons.h" +# include "BKE_icons.hh" # include "BKE_idprop.hh" # include "BKE_image.hh" # include "BKE_key.hh" diff --git a/source/blender/python/intern/bpy_app_icons.cc b/source/blender/python/intern/bpy_app_icons.cc index 706c1f17128..06d69b5d22a 100644 --- a/source/blender/python/intern/bpy_app_icons.cc +++ b/source/blender/python/intern/bpy_app_icons.cc @@ -12,7 +12,7 @@ #include "MEM_guardedalloc.h" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "../generic/py_capi_utils.hh" #include "../generic/python_compat.hh" /* IWYU pragma: keep. */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index 0384f18c1e7..e416306c44f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -36,7 +36,7 @@ #include "BKE_blendfile.hh" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_image.hh" #include "BKE_keyconfig.h" #include "BKE_lib_remap.hh" diff --git a/source/blender/windowmanager/intern/wm_window.cc b/source/blender/windowmanager/intern/wm_window.cc index 8c360da2619..f6880410ec3 100644 --- a/source/blender/windowmanager/intern/wm_window.cc +++ b/source/blender/windowmanager/intern/wm_window.cc @@ -45,7 +45,7 @@ #include "BKE_blender_version.h" #include "BKE_context.hh" #include "BKE_global.hh" -#include "BKE_icons.h" +#include "BKE_icons.hh" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_report.hh"