Blender  V3.3
interface_icons.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <math.h>
9 #include <stdlib.h>
10 #include <string.h>
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "GPU_batch.h"
15 #include "GPU_batch_presets.h"
16 #include "GPU_immediate.h"
17 #include "GPU_matrix.h"
18 #include "GPU_shader_shared.h"
19 #include "GPU_state.h"
20 #include "GPU_texture.h"
21 
22 #include "BLI_blenlib.h"
23 #include "BLI_fileops_types.h"
24 #include "BLI_math_color_blend.h"
25 #include "BLI_math_vector.h"
26 #include "BLI_utildefines.h"
27 
28 #include "DNA_brush_types.h"
29 #include "DNA_collection_types.h"
30 #include "DNA_curve_types.h"
31 #include "DNA_dynamicpaint_types.h"
32 #include "DNA_gpencil_types.h"
33 #include "DNA_object_types.h"
34 #include "DNA_screen_types.h"
35 #include "DNA_sequence_types.h"
36 #include "DNA_space_types.h"
37 
38 #include "RNA_access.h"
39 #include "RNA_prototypes.h"
40 
41 #include "BKE_appdir.h"
42 #include "BKE_context.h"
43 #include "BKE_global.h"
44 #include "BKE_icons.h"
45 #include "BKE_paint.h"
46 #include "BKE_studiolight.h"
47 
48 #include "IMB_imbuf.h"
49 #include "IMB_imbuf_types.h"
50 #include "IMB_thumbs.h"
51 
52 #include "BIF_glutil.h"
53 
54 #include "ED_datafiles.h"
55 #include "ED_keyframes_draw.h"
56 #include "ED_keyframes_keylist.h"
57 #include "ED_render.h"
58 
59 #include "UI_interface.h"
60 #include "UI_interface_icons.h"
61 
62 #include "WM_api.h"
63 #include "WM_types.h"
64 
65 #include "interface_intern.h"
66 
67 #ifndef WITH_HEADLESS
68 # define ICON_GRID_COLS 26
69 # define ICON_GRID_ROWS 30
70 
71 # define ICON_MONO_BORDER_OUTSET 2
72 # define ICON_GRID_MARGIN 10
73 # define ICON_GRID_W 32
74 # define ICON_GRID_H 32
75 #endif /* WITH_HEADLESS */
76 
77 typedef struct IconImage {
78  int w;
79  int h;
84 
85 typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
86 
87 #define ICON_TYPE_PREVIEW 0
88 #define ICON_TYPE_COLOR_TEXTURE 1
89 #define ICON_TYPE_MONO_TEXTURE 2
90 #define ICON_TYPE_BUFFER 3
91 #define ICON_TYPE_IMBUF 4
92 #define ICON_TYPE_VECTOR 5
93 #define ICON_TYPE_GEOM 6
94 #define ICON_TYPE_EVENT 7 /* draw keymap entries using custom renderer. */
95 #define ICON_TYPE_GPLAYER 8
96 #define ICON_TYPE_BLANK 9
97 
98 typedef struct DrawInfo {
99  int type;
100 
101  union {
102  /* type specific data */
103  struct {
106  struct {
108  bool inverted;
109  } geom;
110  struct {
113  struct {
114  int x, y, w, h;
117  struct {
118  /* Can be packed into a single int. */
119  short event_type;
120  short event_value;
121  int icon;
122  /* Allow lookups. */
123  struct DrawInfo *next;
124  } input;
125  } data;
127 
128 typedef struct IconTexture {
129  struct GPUTexture *tex[2];
131  int w;
132  int h;
133  float invw;
134  float invh;
136 
137 typedef struct IconType {
138  int type;
141 
142 /* ******************* STATIC LOCAL VARS ******************* */
143 /* Static here to cache results of icon directory scan, so it's not
144  * scanning the file-system each time the menu is drawn. */
145 static struct ListBase iconfilelist = {NULL, NULL};
146 static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f};
147 
148 #ifndef WITH_HEADLESS
149 
150 static const IconType icontypes[] = {
151 # define DEF_ICON(name) {ICON_TYPE_MONO_TEXTURE, 0},
152 # define DEF_ICON_SCENE(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SCENE},
153 # define DEF_ICON_COLLECTION(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_COLLECTION},
154 # define DEF_ICON_OBJECT(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT},
155 # define DEF_ICON_OBJECT_DATA(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_OBJECT_DATA},
156 # define DEF_ICON_MODIFIER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_MODIFIER},
157 # define DEF_ICON_SHADING(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_SHADING},
158 # define DEF_ICON_FOLDER(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FOLDER},
159 # define DEF_ICON_FUND(name) {ICON_TYPE_MONO_TEXTURE, TH_ICON_FUND},
160 # define DEF_ICON_VECTOR(name) {ICON_TYPE_VECTOR, 0},
161 # define DEF_ICON_COLOR(name) {ICON_TYPE_COLOR_TEXTURE, 0},
162 # define DEF_ICON_BLANK(name) {ICON_TYPE_BLANK, 0},
163 # include "UI_icons.h"
164 };
165 
166 /* **************************************************** */
167 
169  ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
170 {
171  Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
172 
173  new_icon->obj = NULL; /* icon is not for library object */
174  new_icon->id_type = 0;
175 
176  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
177  di->type = type;
178 
180  di->data.texture.theme_color = theme_color;
181  di->data.texture.x = xofs;
182  di->data.texture.y = yofs;
183  di->data.texture.w = size;
184  di->data.texture.h = size;
185  }
186  else if (type == ICON_TYPE_BUFFER) {
187  IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img");
188  iimg->w = size;
189  iimg->h = size;
190 
191  /* icon buffers can get initialized runtime now, via datatoc */
192  if (bbuf) {
193  int y, imgsize;
194 
195  iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect");
196 
197  /* Here we store the rect in the icon - same as before */
198  if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) {
199  memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
200  }
201  else {
202  /* this code assumes square images */
203  imgsize = bbuf->x;
204  for (y = 0; y < size; y++) {
205  memcpy(
206  &iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
207  }
208  }
209  }
210  di->data.buffer.image = iimg;
211  }
212 
214  new_icon->drawinfo = di;
215 
216  BKE_icon_set(icon_id, new_icon);
217 
218  return di;
219 }
220 
221 static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
222 {
223  Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
224 
225  new_icon->obj = NULL; /* icon is not for library object */
226  new_icon->id_type = 0;
227 
228  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
229  di->type = ICON_TYPE_VECTOR;
230  di->data.vector.func = drawFunc;
231 
232  new_icon->drawinfo_free = NULL;
233  new_icon->drawinfo = di;
234 
235  BKE_icon_set(icon_id, new_icon);
236 }
237 
238 /* Vector Icon Drawing Routines */
239 
240 /* Utilities */
241 
243  int x, int y, int w, int h, float alpha, short key_type, short handle_type)
244 {
245  /* Initialize dummy theme state for Action Editor - where these colors are defined
246  * (since we're doing this off-screen, free from any particular space_id). */
247  struct bThemeState theme_state;
248 
249  UI_Theme_Store(&theme_state);
251 
252  /* The "x" and "y" given are the bottom-left coordinates of the icon,
253  * while the #draw_keyframe_shape() function needs the midpoint for the keyframe. */
254  const float xco = x + w / 2 + 0.5f;
255  const float yco = y + h / 2 + 0.5f;
256 
258  KeyframeShaderBindings sh_bindings;
261  sh_bindings.color_id = GPU_vertformat_attr_add(
264  format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
266 
269  immUniform1f("outline_scale", 1.0f);
270  immUniform2f("ViewportSize", -1.0f, -1.0f);
272 
273  /* draw keyframe
274  * - size: (default icon size == 16, default dopesheet icon size == 10)
275  * - sel: true unless in handletype icons (so that "keyframe" state shows the iconic yellow icon)
276  */
277  const bool sel = (handle_type == KEYFRAME_HANDLE_NONE);
278 
280  yco,
281  (10.0f / 16.0f) * h,
282  sel,
283  key_type,
285  alpha,
286  &sh_bindings,
287  handle_type,
289 
290  immEnd();
291  GPU_program_point_size(false);
293 
294  UI_Theme_Restore(&theme_state);
295 }
296 
297 static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha)
298 {
300 }
301 
302 static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha)
303 {
305 }
306 
307 static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha)
308 {
310 }
311 
312 static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha)
313 {
315 }
316 
317 static void vicon_keytype_moving_hold_draw(int x, int y, int w, int h, float alpha)
318 {
320 }
321 
322 static void vicon_handletype_free_draw(int x, int y, int w, int h, float alpha)
323 {
325 }
326 
327 static void vicon_handletype_aligned_draw(int x, int y, int w, int h, float alpha)
328 {
330 }
331 
332 static void vicon_handletype_vector_draw(int x, int y, int w, int h, float alpha)
333 {
335 }
336 
337 static void vicon_handletype_auto_draw(int x, int y, int w, int h, float alpha)
338 {
340 }
341 
342 static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float alpha)
343 {
345 }
346 
347 static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha))
348 {
349  bTheme *btheme = UI_GetTheme();
350  const ThemeWireColor *cs = &btheme->tarm[index];
351 
352  /* Draw three bands of color: One per color
353  * x-----a-----b-----c
354  * | N | S | A |
355  * x-----a-----b-----c
356  */
357  const int a = x + w / 3;
358  const int b = x + w / 3 * 2;
359  const int c = x + w;
360 
364 
365  /* XXX: Include alpha into this... */
366  /* normal */
368  immRecti(pos, x, y, a, y + h);
369 
370  /* selected */
372  immRecti(pos, a, y, b, y + h);
373 
374  /* active */
376  immRecti(pos, b, y, c, y + h);
377 
379 }
380 
381 # define DEF_ICON_VECTOR_COLORSET_DRAW_NTH(prefix, index) \
382  static void vicon_colorset_draw_##prefix(int x, int y, int w, int h, float alpha) \
383  { \
384  vicon_colorset_draw(index, x, y, w, h, alpha); \
385  }
386 
407 
408 # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
409 
411  short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
412 {
413  bTheme *btheme = UI_GetTheme();
414  const ThemeCollectionColor *collection_color = &btheme->collection_color[color_tag];
415 
416  const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
417 
419  x, y, ICON_OUTLINER_COLLECTION, aspect, 1.0f, 0.0f, collection_color->color, true);
420 }
421 
422 # define DEF_ICON_COLLECTION_COLOR_DRAW(index, color) \
423  static void vicon_collection_color_draw_##index(int x, int y, int w, int h, float alpha) \
424  { \
425  vicon_collection_color_draw(color, x, y, w, h, alpha); \
426  }
427 
436 
437 # undef DEF_ICON_COLLECTION_COLOR_DRAW
438 
440  short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
441 {
442  bTheme *btheme = UI_GetTheme();
443  const ThemeStripColor *strip_color = &btheme->strip_color[color_tag];
444 
445  const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
446 
447  UI_icon_draw_ex(x, y, ICON_SNAP_FACE, aspect, 1.0f, 0.0f, strip_color->color, true);
448 }
449 
450 # define DEF_ICON_STRIP_COLOR_DRAW(index, color) \
451  static void vicon_strip_color_draw_##index(int x, int y, int w, int h, float alpha) \
452  { \
453  vicon_strip_color_draw(color, x, y, w, h, alpha); \
454  }
455 
465 
466 # undef DEF_ICON_STRIP_COLOR_DRAW
467 
468 # define ICON_INDIRECT_DATA_ALPHA 0.6f
469 
471  int x, int y, int w, int UNUSED(h), float alpha)
472 {
473  const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
474 
476  x, y, ICON_LIBRARY_DATA_DIRECT, aspect, ICON_INDIRECT_DATA_ALPHA * alpha, 0.0f, NULL, false);
477 }
478 
480  int x, int y, int w, int UNUSED(h), float alpha)
481 {
482  const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
483 
485  y,
486  ICON_LIBRARY_DATA_OVERRIDE,
487  aspect,
488  ICON_INDIRECT_DATA_ALPHA * alpha * 0.75f,
489  0.0f,
490  NULL,
491  false);
492 }
493 
494 /* Dynamically render icon instead of rendering a plain color to a texture/buffer
495  * This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
496  * but it works in a very similar way.
497  */
498 static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
499 {
500  bGPDlayer *gpl = (bGPDlayer *)icon->obj;
501 
502  /* Just draw a colored rect - Like for vicon_colorset_draw() */
503  /* TODO: Make this have rounded corners, and maybe be a bit smaller.
504  * However, UI_draw_roundbox_aa() draws the colors too dark, so can't be used.
505  */
509 
511  immRecti(pos, x, y, x + w - 1, y + h - 1);
512 
514 }
515 
516 static void init_brush_icons(void)
517 {
518 
519 # define INIT_BRUSH_ICON(icon_id, name) \
520  { \
521  uchar *rect = (uchar *)datatoc_##name##_png; \
522  const int size = datatoc_##name##_png_size; \
523  DrawInfo *di; \
524 \
525  di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_BUFFER, 0); \
526  di->data.buffer.image->datatoc_rect = rect; \
527  di->data.buffer.image->datatoc_size = size; \
528  } \
529  ((void)0)
530  /* end INIT_BRUSH_ICON */
531 
532  const int w = 96; /* warning, brush size hardcoded in C, but it gets scaled */
533 
534  INIT_BRUSH_ICON(ICON_BRUSH_BLOB, blob);
535  INIT_BRUSH_ICON(ICON_BRUSH_BLUR, blur);
536  INIT_BRUSH_ICON(ICON_BRUSH_CLAY, clay);
537  INIT_BRUSH_ICON(ICON_BRUSH_CLAY_STRIPS, claystrips);
538  INIT_BRUSH_ICON(ICON_BRUSH_CLONE, clone);
539  INIT_BRUSH_ICON(ICON_BRUSH_CREASE, crease);
540  INIT_BRUSH_ICON(ICON_BRUSH_SCULPT_DRAW, draw);
541  INIT_BRUSH_ICON(ICON_BRUSH_FILL, fill);
542  INIT_BRUSH_ICON(ICON_BRUSH_FLATTEN, flatten);
543  INIT_BRUSH_ICON(ICON_BRUSH_GRAB, grab);
544  INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate);
545  INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer);
546  INIT_BRUSH_ICON(ICON_BRUSH_MASK, mask);
547  INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix);
548  INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge);
549  INIT_BRUSH_ICON(ICON_BRUSH_PAINT_SELECT, paint_select);
550  INIT_BRUSH_ICON(ICON_BRUSH_PINCH, pinch);
551  INIT_BRUSH_ICON(ICON_BRUSH_SCRAPE, scrape);
552  INIT_BRUSH_ICON(ICON_BRUSH_SMEAR, smear);
553  INIT_BRUSH_ICON(ICON_BRUSH_SMOOTH, smooth);
554  INIT_BRUSH_ICON(ICON_BRUSH_SNAKE_HOOK, snake_hook);
555  INIT_BRUSH_ICON(ICON_BRUSH_SOFTEN, soften);
556  INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw);
557  INIT_BRUSH_ICON(ICON_BRUSH_TEXFILL, texfill);
558  INIT_BRUSH_ICON(ICON_BRUSH_TEXMASK, texmask);
559  INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb);
560  INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist);
561 
562  /* grease pencil sculpt */
563  INIT_BRUSH_ICON(ICON_GPBRUSH_SMOOTH, gp_brush_smooth);
564  INIT_BRUSH_ICON(ICON_GPBRUSH_THICKNESS, gp_brush_thickness);
565  INIT_BRUSH_ICON(ICON_GPBRUSH_STRENGTH, gp_brush_strength);
566  INIT_BRUSH_ICON(ICON_GPBRUSH_GRAB, gp_brush_grab);
567  INIT_BRUSH_ICON(ICON_GPBRUSH_PUSH, gp_brush_push);
568  INIT_BRUSH_ICON(ICON_GPBRUSH_TWIST, gp_brush_twist);
569  INIT_BRUSH_ICON(ICON_GPBRUSH_PINCH, gp_brush_pinch);
570  INIT_BRUSH_ICON(ICON_GPBRUSH_RANDOMIZE, gp_brush_randomize);
571  INIT_BRUSH_ICON(ICON_GPBRUSH_CLONE, gp_brush_clone);
572  INIT_BRUSH_ICON(ICON_GPBRUSH_WEIGHT, gp_brush_weight);
573 
574  /* grease pencil drawing brushes */
575  INIT_BRUSH_ICON(ICON_GPBRUSH_PENCIL, gp_brush_pencil);
576  INIT_BRUSH_ICON(ICON_GPBRUSH_PEN, gp_brush_pen);
577  INIT_BRUSH_ICON(ICON_GPBRUSH_INK, gp_brush_ink);
578  INIT_BRUSH_ICON(ICON_GPBRUSH_INKNOISE, gp_brush_inknoise);
579  INIT_BRUSH_ICON(ICON_GPBRUSH_BLOCK, gp_brush_block);
580  INIT_BRUSH_ICON(ICON_GPBRUSH_MARKER, gp_brush_marker);
581  INIT_BRUSH_ICON(ICON_GPBRUSH_FILL, gp_brush_fill);
582  INIT_BRUSH_ICON(ICON_GPBRUSH_AIRBRUSH, gp_brush_airbrush);
583  INIT_BRUSH_ICON(ICON_GPBRUSH_CHISEL, gp_brush_chisel);
584  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_SOFT, gp_brush_erase_soft);
585  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_HARD, gp_brush_erase_hard);
586  INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_STROKE, gp_brush_erase_stroke);
587 
588  /* Curves sculpt. */
589  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_ADD, curves_sculpt_add);
590  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_COMB, curves_sculpt_comb);
591  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_CUT, curves_sculpt_cut);
592  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_DELETE, curves_sculpt_delete);
593  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_DENSITY, curves_sculpt_density);
594  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_GROW_SHRINK, curves_sculpt_grow_shrink);
595  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_PINCH, curves_sculpt_pinch);
596  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_PUFF, curves_sculpt_puff);
597  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_SLIDE, curves_sculpt_slide);
598  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_SMOOTH, curves_sculpt_smooth);
599  INIT_BRUSH_ICON(ICON_BRUSH_CURVES_SNAKE_HOOK, curves_sculpt_snake_hook);
600 
601 # undef INIT_BRUSH_ICON
602 }
603 
605 
606 int UI_icon_from_event_type(short event_type, short event_value)
607 {
608  if (event_type == EVT_RIGHTSHIFTKEY) {
609  event_type = EVT_LEFTSHIFTKEY;
610  }
611  else if (event_type == EVT_RIGHTCTRLKEY) {
612  event_type = EVT_LEFTCTRLKEY;
613  }
614  else if (event_type == EVT_RIGHTALTKEY) {
615  event_type = EVT_LEFTALTKEY;
616  }
617 
619  do {
620  if (di->data.input.event_type == event_type) {
621  return di->data.input.icon;
622  }
623  } while ((di = di->data.input.next));
624 
625  if (event_type == LEFTMOUSE) {
626  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_LMB : ICON_MOUSE_LMB_DRAG;
627  }
628  if (event_type == MIDDLEMOUSE) {
629  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_MMB : ICON_MOUSE_MMB_DRAG;
630  }
631  if (event_type == RIGHTMOUSE) {
632  return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_RMB : ICON_MOUSE_RMB_DRAG;
633  }
634 
635  return ICON_NONE;
636 }
637 
638 int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4])
639 {
640  if (r_icon_mod) {
641  memset(r_icon_mod, 0x0, sizeof(int[4]));
642  int i = 0;
643  if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) {
644  r_icon_mod[i++] = ICON_EVENT_CTRL;
645  }
646  if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) {
647  r_icon_mod[i++] = ICON_EVENT_ALT;
648  }
649  if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) {
650  r_icon_mod[i++] = ICON_EVENT_SHIFT;
651  }
652  if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) {
653  r_icon_mod[i++] = ICON_EVENT_OS;
654  }
655  }
656  return UI_icon_from_event_type(kmi->type, kmi->val);
657 }
658 
659 static void init_event_icons(void)
660 {
661  DrawInfo *di_next = NULL;
662 
663 # define INIT_EVENT_ICON(icon_id, type, value) \
664  { \
665  DrawInfo *di = def_internal_icon(NULL, icon_id, 0, 0, w, ICON_TYPE_EVENT, 0); \
666  di->data.input.event_type = type; \
667  di->data.input.event_value = value; \
668  di->data.input.icon = icon_id; \
669  di->data.input.next = di_next; \
670  di_next = di; \
671  } \
672  ((void)0)
673  /* end INIT_EVENT_ICON */
674 
675  const int w = 16; /* DUMMY */
676 
677  INIT_EVENT_ICON(ICON_EVENT_A, EVT_AKEY, KM_ANY);
678  INIT_EVENT_ICON(ICON_EVENT_B, EVT_BKEY, KM_ANY);
679  INIT_EVENT_ICON(ICON_EVENT_C, EVT_CKEY, KM_ANY);
680  INIT_EVENT_ICON(ICON_EVENT_D, EVT_DKEY, KM_ANY);
681  INIT_EVENT_ICON(ICON_EVENT_E, EVT_EKEY, KM_ANY);
682  INIT_EVENT_ICON(ICON_EVENT_F, EVT_FKEY, KM_ANY);
683  INIT_EVENT_ICON(ICON_EVENT_G, EVT_GKEY, KM_ANY);
684  INIT_EVENT_ICON(ICON_EVENT_H, EVT_HKEY, KM_ANY);
685  INIT_EVENT_ICON(ICON_EVENT_I, EVT_IKEY, KM_ANY);
686  INIT_EVENT_ICON(ICON_EVENT_J, EVT_JKEY, KM_ANY);
687  INIT_EVENT_ICON(ICON_EVENT_K, EVT_KKEY, KM_ANY);
688  INIT_EVENT_ICON(ICON_EVENT_L, EVT_LKEY, KM_ANY);
689  INIT_EVENT_ICON(ICON_EVENT_M, EVT_MKEY, KM_ANY);
690  INIT_EVENT_ICON(ICON_EVENT_N, EVT_NKEY, KM_ANY);
691  INIT_EVENT_ICON(ICON_EVENT_O, EVT_OKEY, KM_ANY);
692  INIT_EVENT_ICON(ICON_EVENT_P, EVT_PKEY, KM_ANY);
693  INIT_EVENT_ICON(ICON_EVENT_Q, EVT_QKEY, KM_ANY);
694  INIT_EVENT_ICON(ICON_EVENT_R, EVT_RKEY, KM_ANY);
695  INIT_EVENT_ICON(ICON_EVENT_S, EVT_SKEY, KM_ANY);
696  INIT_EVENT_ICON(ICON_EVENT_T, EVT_TKEY, KM_ANY);
697  INIT_EVENT_ICON(ICON_EVENT_U, EVT_UKEY, KM_ANY);
698  INIT_EVENT_ICON(ICON_EVENT_V, EVT_VKEY, KM_ANY);
699  INIT_EVENT_ICON(ICON_EVENT_W, EVT_WKEY, KM_ANY);
700  INIT_EVENT_ICON(ICON_EVENT_X, EVT_XKEY, KM_ANY);
701  INIT_EVENT_ICON(ICON_EVENT_Y, EVT_YKEY, KM_ANY);
702  INIT_EVENT_ICON(ICON_EVENT_Z, EVT_ZKEY, KM_ANY);
703  INIT_EVENT_ICON(ICON_EVENT_SHIFT, EVT_LEFTSHIFTKEY, KM_ANY);
704  INIT_EVENT_ICON(ICON_EVENT_CTRL, EVT_LEFTCTRLKEY, KM_ANY);
705  INIT_EVENT_ICON(ICON_EVENT_ALT, EVT_LEFTALTKEY, KM_ANY);
706  INIT_EVENT_ICON(ICON_EVENT_OS, EVT_OSKEY, KM_ANY);
707  INIT_EVENT_ICON(ICON_EVENT_F1, EVT_F1KEY, KM_ANY);
708  INIT_EVENT_ICON(ICON_EVENT_F2, EVT_F2KEY, KM_ANY);
709  INIT_EVENT_ICON(ICON_EVENT_F3, EVT_F3KEY, KM_ANY);
710  INIT_EVENT_ICON(ICON_EVENT_F4, EVT_F4KEY, KM_ANY);
711  INIT_EVENT_ICON(ICON_EVENT_F5, EVT_F5KEY, KM_ANY);
712  INIT_EVENT_ICON(ICON_EVENT_F6, EVT_F6KEY, KM_ANY);
713  INIT_EVENT_ICON(ICON_EVENT_F7, EVT_F7KEY, KM_ANY);
714  INIT_EVENT_ICON(ICON_EVENT_F8, EVT_F8KEY, KM_ANY);
715  INIT_EVENT_ICON(ICON_EVENT_F9, EVT_F9KEY, KM_ANY);
716  INIT_EVENT_ICON(ICON_EVENT_F10, EVT_F10KEY, KM_ANY);
717  INIT_EVENT_ICON(ICON_EVENT_F11, EVT_F11KEY, KM_ANY);
718  INIT_EVENT_ICON(ICON_EVENT_F12, EVT_F12KEY, KM_ANY);
719  INIT_EVENT_ICON(ICON_EVENT_ESC, EVT_ESCKEY, KM_ANY);
720  INIT_EVENT_ICON(ICON_EVENT_TAB, EVT_TABKEY, KM_ANY);
721  INIT_EVENT_ICON(ICON_EVENT_PAGEUP, EVT_PAGEUPKEY, KM_ANY);
722  INIT_EVENT_ICON(ICON_EVENT_PAGEDOWN, EVT_PAGEDOWNKEY, KM_ANY);
723  INIT_EVENT_ICON(ICON_EVENT_RETURN, EVT_RETKEY, KM_ANY);
724  INIT_EVENT_ICON(ICON_EVENT_SPACEKEY, EVT_SPACEKEY, KM_ANY);
725 
726  g_di_event_list = di_next;
727 
728 # undef INIT_EVENT_ICON
729 }
730 
731 static void icon_verify_datatoc(IconImage *iimg)
732 {
733  /* if it has own rect, things are all OK */
734  if (iimg->rect) {
735  return;
736  }
737 
738  if (iimg->datatoc_rect) {
740  iimg->datatoc_rect, iimg->datatoc_size, IB_rect, NULL, "<matcap icon>");
741  /* w and h were set on initialize */
742  if (bbuf->x != iimg->h && bbuf->y != iimg->w) {
743  IMB_scaleImBuf(bbuf, iimg->w, iimg->h);
744  }
745 
746  iimg->rect = bbuf->rect;
747  bbuf->rect = NULL;
748  IMB_freeImBuf(bbuf);
749  }
750 }
751 
753  int resolution_divider,
754  float border_intensity)
755 {
756  ImBuf *result = IMB_dupImBuf(buf);
757  const float border_sharpness = 16.0 / (resolution_divider * resolution_divider);
758 
759  float blurred_alpha_buffer[(ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) *
761  const int icon_width = (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) / resolution_divider;
762  const int icon_height = (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) / resolution_divider;
763 
764  for (int y = 0; y < ICON_GRID_ROWS; y++) {
765  for (int x = 0; x < ICON_GRID_COLS; x++) {
766  const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
767  if (icontype.type != ICON_TYPE_MONO_TEXTURE) {
768  continue;
769  }
770 
773  sx = sx / resolution_divider;
774  sy = sy / resolution_divider;
775 
776  /* blur the alpha channel and store it in blurred_alpha_buffer */
777  const int blur_size = 2 / resolution_divider;
778  for (int bx = 0; bx < icon_width; bx++) {
779  const int asx = MAX2(bx - blur_size, 0);
780  const int aex = MIN2(bx + blur_size + 1, icon_width);
781  for (int by = 0; by < icon_height; by++) {
782  const int asy = MAX2(by - blur_size, 0);
783  const int aey = MIN2(by + blur_size + 1, icon_height);
784 
785  /* blur alpha channel */
786  const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
787  float alpha_accum = 0.0;
788  uint alpha_samples = 0;
789  for (int ax = asx; ax < aex; ax++) {
790  for (int ay = asy; ay < aey; ay++) {
791  const int offset_read = (sy + ay) * buf->x + (sx + ax);
792  const uint color_read = buf->rect[offset_read];
793  const float alpha_read = ((color_read & 0xff000000) >> 24) / 255.0;
794  alpha_accum += alpha_read;
795  alpha_samples += 1;
796  }
797  }
798  blurred_alpha_buffer[write_offset] = alpha_accum / alpha_samples;
799  }
800  }
801 
802  /* apply blurred alpha */
803  for (int bx = 0; bx < icon_width; bx++) {
804  for (int by = 0; by < icon_height; by++) {
805  const int blurred_alpha_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx;
806  const int offset_write = (sy + by) * buf->x + (sx + bx);
807  const float blurred_alpha = blurred_alpha_buffer[blurred_alpha_offset];
808  const float border_srgb[4] = {
809  0, 0, 0, MIN2(1.0, blurred_alpha * border_sharpness) * border_intensity};
810 
811  const uint color_read = buf->rect[offset_write];
812  const uchar *orig_color = (uchar *)&color_read;
813 
814  float border_rgba[4];
815  float orig_rgba[4];
816  float dest_rgba[4];
817  float dest_srgb[4];
818 
819  srgb_to_linearrgb_v4(border_rgba, border_srgb);
820  srgb_to_linearrgb_uchar4(orig_rgba, orig_color);
821  blend_color_interpolate_float(dest_rgba, orig_rgba, border_rgba, 1.0 - orig_rgba[3]);
822  linearrgb_to_srgb_v4(dest_srgb, dest_rgba);
823 
824  const uint alpha_mask = ((uint)(dest_srgb[3] * 255)) << 24;
825  const uint cpack = rgb_to_cpack(dest_srgb[0], dest_srgb[1], dest_srgb[2]) | alpha_mask;
826  result->rect[offset_write] = cpack;
827  }
828  }
829  }
830  }
831  return result;
832 }
833 
834 static void free_icons_textures(void)
835 {
836  if (icongltex.num_textures > 0) {
837  for (int i = 0; i < 2; i++) {
838  if (icongltex.tex[i]) {
840  icongltex.tex[i] = NULL;
841  }
842  }
844  }
845 }
846 
848 {
849  bTheme *btheme = UI_GetTheme();
850  ImBuf *b16buf = NULL, *b32buf = NULL, *b16buf_border = NULL, *b32buf_border = NULL;
851  const float icon_border_intensity = btheme->tui.icon_border_intensity;
852  const bool need_icons_with_border = icon_border_intensity > 0.0f;
853 
854  if (b16buf == NULL) {
857  IB_rect,
858  NULL,
859  "<blender icons>");
860  }
861  if (b16buf) {
862  if (need_icons_with_border) {
863  b16buf_border = create_mono_icon_with_border(b16buf, 2, icon_border_intensity);
864  IMB_premultiply_alpha(b16buf_border);
865  }
866  IMB_premultiply_alpha(b16buf);
867  }
868 
869  if (b32buf == NULL) {
872  IB_rect,
873  NULL,
874  "<blender icons>");
875  }
876  if (b32buf) {
877  if (need_icons_with_border) {
878  b32buf_border = create_mono_icon_with_border(b32buf, 1, icon_border_intensity);
879  IMB_premultiply_alpha(b32buf_border);
880  }
881  IMB_premultiply_alpha(b32buf);
882  }
883 
884  if (b16buf && b32buf) {
885  /* Free existing texture if any. */
887 
888  /* Allocate OpenGL texture. */
889  icongltex.num_textures = need_icons_with_border ? 2 : 1;
890 
891  /* Note the filter and LOD bias were tweaked to better preserve icon
892  * sharpness at different UI scales. */
893  if (icongltex.tex[0] == NULL) {
894  icongltex.w = b32buf->x;
895  icongltex.h = b32buf->y;
896  icongltex.invw = 1.0f / b32buf->x;
897  icongltex.invh = 1.0f / b32buf->y;
898 
899  icongltex.tex[0] = GPU_texture_create_2d("icons", b32buf->x, b32buf->y, 2, GPU_RGBA8, NULL);
902  }
903 
904  if (need_icons_with_border && icongltex.tex[1] == NULL) {
906  "icons_border", b32buf_border->x, b32buf_border->y, 2, GPU_RGBA8, NULL);
907  GPU_texture_update_mipmap(icongltex.tex[1], 0, GPU_DATA_UBYTE, b32buf_border->rect);
908  GPU_texture_update_mipmap(icongltex.tex[1], 1, GPU_DATA_UBYTE, b16buf_border->rect);
909  }
910  }
911 
912  IMB_freeImBuf(b16buf);
913  IMB_freeImBuf(b32buf);
914  IMB_freeImBuf(b16buf_border);
915  IMB_freeImBuf(b32buf_border);
916 }
917 
918 static void init_internal_icons(void)
919 {
920 # if 0 /* temp disabled */
921  if ((btheme != NULL) && btheme->tui.iconfile[0]) {
922  char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
923  char iconfilestr[FILE_MAX];
924 
925  if (icondir) {
926  BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
927 
928  /* if the image is missing bbuf will just be NULL */
929  bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL);
930 
931  if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
932  printf(
933  "\n***WARNING***\n"
934  "Icons file '%s' too small.\n"
935  "Using built-in Icons instead\n",
936  iconfilestr);
937  IMB_freeImBuf(bbuf);
938  bbuf = NULL;
939  }
940  }
941  else {
942  printf("%s: 'icons' data path not found, continuing\n", __func__);
943  }
944  }
945 # endif
946 
947  /* Define icons. */
948  for (int y = 0; y < ICON_GRID_ROWS; y++) {
949  /* Row W has monochrome icons. */
950  for (int x = 0; x < ICON_GRID_COLS; x++) {
951  const IconType icontype = icontypes[y * ICON_GRID_COLS + x];
953  continue;
954  }
955 
960  ICON_GRID_W,
961  icontype.type,
962  icontype.theme_color);
963  }
964  }
965 
966  def_internal_vicon(ICON_KEYTYPE_KEYFRAME_VEC, vicon_keytype_keyframe_draw);
967  def_internal_vicon(ICON_KEYTYPE_BREAKDOWN_VEC, vicon_keytype_breakdown_draw);
968  def_internal_vicon(ICON_KEYTYPE_EXTREME_VEC, vicon_keytype_extreme_draw);
969  def_internal_vicon(ICON_KEYTYPE_JITTER_VEC, vicon_keytype_jitter_draw);
970  def_internal_vicon(ICON_KEYTYPE_MOVING_HOLD_VEC, vicon_keytype_moving_hold_draw);
971 
972  def_internal_vicon(ICON_HANDLETYPE_FREE_VEC, vicon_handletype_free_draw);
973  def_internal_vicon(ICON_HANDLETYPE_ALIGNED_VEC, vicon_handletype_aligned_draw);
974  def_internal_vicon(ICON_HANDLETYPE_VECTOR_VEC, vicon_handletype_vector_draw);
975  def_internal_vicon(ICON_HANDLETYPE_AUTO_VEC, vicon_handletype_auto_draw);
976  def_internal_vicon(ICON_HANDLETYPE_AUTO_CLAMP_VEC, vicon_handletype_auto_clamp_draw);
977 
978  def_internal_vicon(ICON_COLORSET_01_VEC, vicon_colorset_draw_01);
979  def_internal_vicon(ICON_COLORSET_02_VEC, vicon_colorset_draw_02);
980  def_internal_vicon(ICON_COLORSET_03_VEC, vicon_colorset_draw_03);
981  def_internal_vicon(ICON_COLORSET_04_VEC, vicon_colorset_draw_04);
982  def_internal_vicon(ICON_COLORSET_05_VEC, vicon_colorset_draw_05);
983  def_internal_vicon(ICON_COLORSET_06_VEC, vicon_colorset_draw_06);
984  def_internal_vicon(ICON_COLORSET_07_VEC, vicon_colorset_draw_07);
985  def_internal_vicon(ICON_COLORSET_08_VEC, vicon_colorset_draw_08);
986  def_internal_vicon(ICON_COLORSET_09_VEC, vicon_colorset_draw_09);
987  def_internal_vicon(ICON_COLORSET_10_VEC, vicon_colorset_draw_10);
988  def_internal_vicon(ICON_COLORSET_11_VEC, vicon_colorset_draw_11);
989  def_internal_vicon(ICON_COLORSET_12_VEC, vicon_colorset_draw_12);
990  def_internal_vicon(ICON_COLORSET_13_VEC, vicon_colorset_draw_13);
991  def_internal_vicon(ICON_COLORSET_14_VEC, vicon_colorset_draw_14);
992  def_internal_vicon(ICON_COLORSET_15_VEC, vicon_colorset_draw_15);
993  def_internal_vicon(ICON_COLORSET_16_VEC, vicon_colorset_draw_16);
994  def_internal_vicon(ICON_COLORSET_17_VEC, vicon_colorset_draw_17);
995  def_internal_vicon(ICON_COLORSET_18_VEC, vicon_colorset_draw_18);
996  def_internal_vicon(ICON_COLORSET_19_VEC, vicon_colorset_draw_19);
997  def_internal_vicon(ICON_COLORSET_20_VEC, vicon_colorset_draw_20);
998 
999  def_internal_vicon(ICON_COLLECTION_COLOR_01, vicon_collection_color_draw_01);
1000  def_internal_vicon(ICON_COLLECTION_COLOR_02, vicon_collection_color_draw_02);
1001  def_internal_vicon(ICON_COLLECTION_COLOR_03, vicon_collection_color_draw_03);
1002  def_internal_vicon(ICON_COLLECTION_COLOR_04, vicon_collection_color_draw_04);
1003  def_internal_vicon(ICON_COLLECTION_COLOR_05, vicon_collection_color_draw_05);
1004  def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06);
1005  def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07);
1006  def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08);
1007 
1008  def_internal_vicon(ICON_SEQUENCE_COLOR_01, vicon_strip_color_draw_01);
1009  def_internal_vicon(ICON_SEQUENCE_COLOR_02, vicon_strip_color_draw_02);
1010  def_internal_vicon(ICON_SEQUENCE_COLOR_03, vicon_strip_color_draw_03);
1011  def_internal_vicon(ICON_SEQUENCE_COLOR_04, vicon_strip_color_draw_04);
1012  def_internal_vicon(ICON_SEQUENCE_COLOR_05, vicon_strip_color_draw_05);
1013  def_internal_vicon(ICON_SEQUENCE_COLOR_06, vicon_strip_color_draw_06);
1014  def_internal_vicon(ICON_SEQUENCE_COLOR_07, vicon_strip_color_draw_07);
1015  def_internal_vicon(ICON_SEQUENCE_COLOR_08, vicon_strip_color_draw_08);
1016  def_internal_vicon(ICON_SEQUENCE_COLOR_09, vicon_strip_color_draw_09);
1017 
1019  def_internal_vicon(ICON_LIBRARY_DATA_OVERRIDE_NONEDITABLE,
1021 }
1022 
1023 static void init_iconfile_list(struct ListBase *list)
1024 {
1025  BLI_listbase_clear(list);
1026  const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
1027 
1028  if (icondir == NULL) {
1029  return;
1030  }
1031 
1032  struct direntry *dir;
1033  const int totfile = BLI_filelist_dir_contents(icondir, &dir);
1034 
1035  int index = 1;
1036  for (int i = 0; i < totfile; i++) {
1037  if (dir[i].type & S_IFREG) {
1038  const char *filename = dir[i].relname;
1039 
1040  if (BLI_path_extension_check(filename, ".png")) {
1041  /* loading all icons on file start is overkill & slows startup
1042  * its possible they change size after blender load anyway. */
1043 # if 0
1044  int ifilex, ifiley;
1045  char iconfilestr[FILE_MAX + 16]; /* allow 256 chars for file+dir */
1046  ImBuf *bbuf = NULL;
1047  /* check to see if the image is the right size, continue if not */
1048  /* copying strings here should go ok, assuming that we never get back
1049  * a complete path to file longer than 256 chars */
1050  BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename);
1051  bbuf = IMB_loadiffname(iconfilestr, IB_rect);
1052 
1053  if (bbuf) {
1054  ifilex = bbuf->x;
1055  ifiley = bbuf->y;
1056  IMB_freeImBuf(bbuf);
1057  }
1058  else {
1059  ifilex = ifiley = 0;
1060  }
1061 
1062  /* bad size or failed to load */
1063  if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H)) {
1064  printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
1065  continue;
1066  }
1067 # endif /* removed */
1068 
1069  /* found a potential icon file, so make an entry for it in the cache list */
1070  IconFile *ifile = MEM_callocN(sizeof(IconFile), "IconFile");
1071 
1072  BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
1073  ifile->index = index;
1074 
1075  BLI_addtail(list, ifile);
1076 
1077  index++;
1078  }
1079  }
1080  }
1081 
1082  BLI_filelist_free(dir, totfile);
1083  dir = NULL;
1084 }
1085 
1086 static void free_iconfile_list(struct ListBase *list)
1087 {
1088  IconFile *ifile = NULL, *next_ifile = NULL;
1089 
1090  for (ifile = list->first; ifile; ifile = next_ifile) {
1091  next_ifile = ifile->next;
1092  BLI_freelinkN(list, ifile);
1093  }
1094 }
1095 
1096 #else
1097 
1099 {
1100 }
1101 
1102 #endif /* WITH_HEADLESS */
1103 
1104 int UI_iconfile_get_index(const char *filename)
1105 {
1106  IconFile *ifile;
1107  ListBase *list = &(iconfilelist);
1108 
1109  for (ifile = list->first; ifile; ifile = ifile->next) {
1110  if (BLI_path_cmp(filename, ifile->filename) == 0) {
1111  return ifile->index;
1112  }
1113  }
1114 
1115  return 0;
1116 }
1117 
1119 {
1120  ListBase *list = &(iconfilelist);
1121 
1122  return list;
1123 }
1124 
1125 void UI_icons_free(void)
1126 {
1127 #ifndef WITH_HEADLESS
1130 #endif
1131  BKE_icons_free();
1132 }
1133 
1134 void UI_icons_free_drawinfo(void *drawinfo)
1135 {
1136  DrawInfo *di = drawinfo;
1137 
1138  if (di == NULL) {
1139  return;
1140  }
1141 
1142  if (di->type == ICON_TYPE_BUFFER) {
1143  if (di->data.buffer.image) {
1144  if (di->data.buffer.image->rect) {
1145  MEM_freeN(di->data.buffer.image->rect);
1146  }
1147  MEM_freeN(di->data.buffer.image);
1148  }
1149  }
1150  else if (di->type == ICON_TYPE_GEOM) {
1151  if (di->data.geom.image_cache) {
1152  IMB_freeImBuf(di->data.geom.image_cache);
1153  }
1154  }
1155 
1156  MEM_freeN(di);
1157 }
1158 
1163 {
1164  const int icon_data_type = icon->obj_type;
1165 
1166  DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "di_icon");
1167 
1168  if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
1169  di->type = ICON_TYPE_PREVIEW;
1170  }
1171  else if (icon_data_type == ICON_DATA_IMBUF) {
1172  di->type = ICON_TYPE_IMBUF;
1173  }
1174  else if (icon_data_type == ICON_DATA_GEOM) {
1175  di->type = ICON_TYPE_GEOM;
1176  }
1177  else if (icon_data_type == ICON_DATA_STUDIOLIGHT) {
1178  di->type = ICON_TYPE_BUFFER;
1179  }
1180  else if (icon_data_type == ICON_DATA_GPLAYER) {
1181  di->type = ICON_TYPE_GPLAYER;
1182  }
1183  else {
1184  BLI_assert(0);
1185  }
1186 
1187  return di;
1188 }
1189 
1191 {
1192  if (icon->drawinfo) {
1193  return icon->drawinfo;
1194  }
1195  DrawInfo *di = icon_create_drawinfo(icon);
1196  icon->drawinfo = di;
1198  return di;
1199 }
1200 
1201 int UI_icon_get_width(int icon_id)
1202 {
1203  Icon *icon = BKE_icon_get(icon_id);
1204 
1205  if (icon == NULL) {
1206  if (G.debug & G_DEBUG) {
1207  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1208  }
1209  return 0;
1210  }
1211 
1212  DrawInfo *di = icon_ensure_drawinfo(icon);
1213  if (di) {
1214  return ICON_DEFAULT_WIDTH;
1215  }
1216 
1217  return 0;
1218 }
1219 
1220 int UI_icon_get_height(int icon_id)
1221 {
1222  Icon *icon = BKE_icon_get(icon_id);
1223  if (icon == NULL) {
1224  if (G.debug & G_DEBUG) {
1225  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1226  }
1227  return 0;
1228  }
1229 
1230  DrawInfo *di = icon_ensure_drawinfo(icon);
1231  if (di) {
1232  return ICON_DEFAULT_HEIGHT;
1233  }
1234 
1235  return 0;
1236 }
1237 
1238 bool UI_icon_get_theme_color(int icon_id, uchar color[4])
1239 {
1240  Icon *icon = BKE_icon_get(icon_id);
1241  if (icon == NULL) {
1242  return false;
1243  }
1244 
1245  DrawInfo *di = icon_ensure_drawinfo(icon);
1246  return UI_GetIconThemeColor4ubv(di->data.texture.theme_color, color);
1247 }
1248 
1250 {
1251 #ifndef WITH_HEADLESS
1255  init_brush_icons();
1256  init_event_icons();
1257 #endif
1258 }
1259 
1261 {
1262  switch (size) {
1263  case ICON_SIZE_ICON:
1265  case ICON_SIZE_PREVIEW:
1267  default:
1268  return 0;
1269  }
1270 }
1271 
1272 /* Create rect for the icon
1273  */
1274 static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
1275 {
1276  const uint render_size = UI_icon_preview_to_render_size(size);
1277 
1278  if (!prv_img) {
1279  if (G.debug & G_DEBUG) {
1280  printf("%s, error: requested preview image does not exist", __func__);
1281  }
1282  }
1283  else if (!prv_img->rect[size]) {
1284  prv_img->w[size] = render_size;
1285  prv_img->h[size] = render_size;
1286  prv_img->flag[size] |= PRV_CHANGED;
1287  prv_img->changed_timestamp[size] = 0;
1288  prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect");
1289  }
1290 }
1291 
1293  const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job);
1294 
1295 static void ui_studiolight_icon_job_exec(void *customdata,
1296  short *UNUSED(stop),
1297  short *UNUSED(do_update),
1298  float *UNUSED(progress))
1299 {
1300  Icon **tmp = (Icon **)customdata;
1301  Icon *icon = *tmp;
1302  DrawInfo *di = icon_ensure_drawinfo(icon);
1303  StudioLight *sl = icon->obj;
1304  BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type);
1305 }
1306 
1308 {
1309  Icon *icon = BKE_icon_get(icon_id);
1311  icon->obj = NULL;
1312 }
1313 
1315 {
1316  wmWindowManager *wm = data;
1317 
1318  /* Happens if job was canceled or already finished. */
1319  if (wm == NULL) {
1320  return;
1321  }
1322 
1323  /* get icons_id, get icons and kill wm jobs */
1324  if (sl->icon_id_radiance) {
1326  }
1327  if (sl->icon_id_irradiance) {
1329  }
1330  if (sl->icon_id_matcap) {
1332  }
1333  if (sl->icon_id_matcap_flipped) {
1335  }
1336 }
1337 
1338 static void ui_studiolight_icon_job_end(void *customdata)
1339 {
1340  Icon **tmp = (Icon **)customdata;
1341  Icon *icon = *tmp;
1342  StudioLight *sl = icon->obj;
1344 }
1345 
1346 void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
1347 {
1348  Icon *icon = BKE_icon_get(icon_id);
1349 
1350  if (icon == NULL) {
1351  return;
1352  }
1353 
1354  DrawInfo *di = icon_ensure_drawinfo(icon);
1355 
1356  if (di == NULL) {
1357  return;
1358  }
1359 
1360  switch (di->type) {
1361  case ICON_TYPE_PREVIEW: {
1362  ID *id = (icon->id_type != 0) ? icon->obj : NULL;
1363  PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
1364  /* Using jobs for screen previews crashes due to off-screen rendering.
1365  * XXX: would be nicer if #PreviewImage could store if it supports jobs. */
1366  const bool use_jobs = !id || (GS(id->name) != ID_SCR);
1367 
1368  if (prv) {
1369  const int size = big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON;
1370 
1371  if (id || (prv->tag & PRV_TAG_DEFFERED) != 0) {
1372  ui_id_preview_image_render_size(C, NULL, id, prv, size, use_jobs);
1373  }
1374  }
1375  break;
1376  }
1377  case ICON_TYPE_BUFFER: {
1378  if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
1379  if (di->data.buffer.image == NULL) {
1381  StudioLight *sl = icon->obj;
1383  IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
1384 
1385  img->w = STUDIOLIGHT_ICON_SIZE;
1386  img->h = STUDIOLIGHT_ICON_SIZE;
1387  const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
1388  img->rect = MEM_mallocN(size, __func__);
1389  memset(img->rect, 0, size);
1390  di->data.buffer.image = img;
1391 
1392  wmJob *wm_job = WM_jobs_get(
1393  wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
1394  Icon **tmp = MEM_callocN(sizeof(Icon *), __func__);
1395  *tmp = icon;
1396  WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
1397  WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW);
1400  WM_jobs_start(CTX_wm_manager(C), wm_job);
1401  }
1402  }
1403  break;
1404  }
1405  }
1406 }
1407 
1414 static void icon_set_image(const bContext *C,
1415  Scene *scene,
1416  ID *id,
1417  PreviewImage *prv_img,
1418  enum eIconSizes size,
1419  const bool use_job)
1420 {
1421  if (!prv_img) {
1422  if (G.debug & G_DEBUG) {
1423  printf("%s: no preview image for this ID: %s\n", __func__, id->name);
1424  }
1425  return;
1426  }
1427 
1428  if (prv_img->flag[size] & PRV_USER_EDITED) {
1429  /* user-edited preview, do not auto-update! */
1430  return;
1431  }
1432 
1433  const bool delay = prv_img->rect[size] != NULL;
1434  icon_create_rect(prv_img, size);
1435 
1436  if (use_job && (!id || BKE_previewimg_id_supports_jobs(id))) {
1437  /* Job (background) version */
1438  ED_preview_icon_job(C, prv_img, id, size, delay);
1439  }
1440  else {
1441  if (!scene) {
1442  scene = CTX_data_scene(C);
1443  }
1444  /* Immediate version */
1445  ED_preview_icon_render(C, scene, prv_img, id, size);
1446  }
1447 }
1448 
1450 {
1451  Icon *icon = BKE_icon_get(icon_id);
1452 
1453  if (icon == NULL) {
1454  return NULL;
1455  }
1456 
1457  DrawInfo *di = (DrawInfo *)icon->drawinfo;
1458 
1459  if (di == NULL) {
1460  return NULL;
1461  }
1462 
1463  if (di->type == ICON_TYPE_PREVIEW) {
1464  PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
1465  icon->obj;
1466 
1467  if (prv) {
1468  return BKE_previewimg_copy(prv);
1469  }
1470  }
1471  else if (di->data.buffer.image) {
1472  ImBuf *bbuf;
1473 
1474  bbuf = IMB_ibImageFromMemory(di->data.buffer.image->datatoc_rect,
1475  di->data.buffer.image->datatoc_size,
1476  IB_rect,
1477  NULL,
1478  __func__);
1479  if (bbuf) {
1481 
1482  prv->rect[0] = bbuf->rect;
1483 
1484  prv->w[0] = bbuf->x;
1485  prv->h[0] = bbuf->y;
1486 
1487  bbuf->rect = NULL;
1488  IMB_freeImBuf(bbuf);
1489 
1490  return prv;
1491  }
1492  }
1493 
1494  return NULL;
1495 }
1496 
1497 static void icon_draw_rect(float x,
1498  float y,
1499  int w,
1500  int h,
1501  float UNUSED(aspect),
1502  int rw,
1503  int rh,
1504  uint *rect,
1505  float alpha,
1506  const float desaturate)
1507 {
1508  int draw_w = w;
1509  int draw_h = h;
1510  int draw_x = x;
1511  /* We need to round y, to avoid the icon jittering in some cases. */
1512  int draw_y = round_fl_to_int(y);
1513 
1514  /* sanity check */
1515  if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
1516  printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
1517  BLI_assert_msg(0, "invalid icon size");
1518  return;
1519  }
1520  /* modulate color */
1521  const float col[4] = {alpha, alpha, alpha, alpha};
1522 
1523  float scale_x = 1.0f;
1524  float scale_y = 1.0f;
1525  /* rect contains image in 'rendersize', we only scale if needed */
1526  if (rw != w || rh != h) {
1527  /* preserve aspect ratio and center */
1528  if (rw > rh) {
1529  draw_w = w;
1530  draw_h = (int)(((float)rh / (float)rw) * (float)w);
1531  draw_y += (h - draw_h) / 2;
1532  }
1533  else if (rw < rh) {
1534  draw_w = (int)(((float)rw / (float)rh) * (float)h);
1535  draw_h = h;
1536  draw_x += (w - draw_w) / 2;
1537  }
1538  scale_x = draw_w / (float)rw;
1539  scale_y = draw_h / (float)rh;
1540  /* If the image is squared, the `draw_*` initialization values are good. */
1541  }
1542 
1543  /* draw */
1544  eGPUBuiltinShader shader;
1545  if (desaturate != 0.0f) {
1547  }
1548  else {
1549  shader = GPU_SHADER_2D_IMAGE_COLOR;
1550  }
1552 
1553  if (shader == GPU_SHADER_2D_IMAGE_DESATURATE_COLOR) {
1554  immUniform1f("factor", desaturate);
1555  }
1556 
1558  &state, draw_x, draw_y, rw, rh, GPU_RGBA8, true, rect, scale_x, scale_y, 1.0f, 1.0f, col);
1559 }
1560 
1561 /* High enough to make a difference, low enough so that
1562  * small draws are still efficient with the use of glUniform.
1563  * NOTE TODO: We could use UBO but we would need some triple
1564  * buffer system + persistent mapping for this to be more
1565  * efficient than simple glUniform calls. */
1566 #define ICON_DRAW_CACHE_SIZE 16
1567 
1568 typedef struct IconDrawCall {
1571  float color[4];
1573 
1574 typedef struct IconTextureDrawCall {
1576  int calls; /* Number of calls batched together */
1578 
1579 static struct {
1582  bool enabled;
1583 } g_icon_draw_cache = {{{{{0}}}}};
1584 
1586 {
1587  BLI_assert(g_icon_draw_cache.enabled == false);
1588  g_icon_draw_cache.enabled = true;
1589 }
1590 
1592  IconTextureDrawCall *texture_draw_calls)
1593 {
1594  if (texture_draw_calls->calls == 0) {
1595  return;
1596  }
1597 
1599  GPU_shader_bind(shader);
1600 
1601  const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data");
1603  sizeof(struct MultiRectCallData), texture_draw_calls->drawcall_cache, __func__);
1604  GPU_uniformbuf_bind(ubo, data_binding);
1605 
1606  const int img_binding = GPU_shader_get_texture_binding(shader, "image");
1607  GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
1608 
1610  GPU_batch_set_shader(quad, shader);
1611  GPU_batch_draw_instanced(quad, texture_draw_calls->calls);
1612 
1613  GPU_texture_unbind(texture);
1614  GPU_uniformbuf_unbind(ubo);
1615  GPU_uniformbuf_free(ubo);
1616 
1617  texture_draw_calls->calls = 0;
1618 }
1619 
1620 static void icon_draw_cache_flush_ex(bool only_full_caches)
1621 {
1622  bool should_draw = false;
1623  if (only_full_caches) {
1624  should_draw = g_icon_draw_cache.normal.calls == ICON_DRAW_CACHE_SIZE ||
1625  g_icon_draw_cache.border.calls == ICON_DRAW_CACHE_SIZE;
1626  }
1627  else {
1628  should_draw = g_icon_draw_cache.normal.calls || g_icon_draw_cache.border.calls;
1629  }
1630 
1631  if (should_draw) {
1632  /* We need to flush widget base first to ensure correct ordering. */
1634 
1636 
1637  if (!only_full_caches || g_icon_draw_cache.normal.calls == ICON_DRAW_CACHE_SIZE) {
1639  }
1640 
1641  if (!only_full_caches || g_icon_draw_cache.border.calls == ICON_DRAW_CACHE_SIZE) {
1643  }
1644 
1646  }
1647 }
1648 
1650 {
1651  BLI_assert(g_icon_draw_cache.enabled == true);
1652  g_icon_draw_cache.enabled = false;
1653 
1654  /* Don't change blend state if it's not needed. */
1655  if (g_icon_draw_cache.border.calls == 0 && g_icon_draw_cache.normal.calls == 0) {
1656  return;
1657  }
1658 
1660  icon_draw_cache_flush_ex(false);
1662 }
1663 
1664 static void icon_draw_texture_cached(float x,
1665  float y,
1666  float w,
1667  float h,
1668  int ix,
1669  int iy,
1670  int UNUSED(iw),
1671  int ih,
1672  float alpha,
1673  const float rgb[3],
1674  bool with_border)
1675 {
1676 
1677  float mvp[4][4];
1679 
1680  IconTextureDrawCall *texture_call = with_border ? &g_icon_draw_cache.border :
1681  &g_icon_draw_cache.normal;
1682 
1683  IconDrawCall *call = &texture_call->drawcall_cache[texture_call->calls];
1684  texture_call->calls++;
1685 
1686  /* Manual mat4*vec2 */
1687  call->pos.xmin = x * mvp[0][0] + y * mvp[1][0] + mvp[3][0];
1688  call->pos.ymin = x * mvp[0][1] + y * mvp[1][1] + mvp[3][1];
1689  call->pos.xmax = call->pos.xmin + w * mvp[0][0] + h * mvp[1][0];
1690  call->pos.ymax = call->pos.ymin + w * mvp[0][1] + h * mvp[1][1];
1691 
1692  call->tex.xmin = ix * icongltex.invw;
1693  call->tex.xmax = (ix + ih) * icongltex.invw;
1694  call->tex.ymin = iy * icongltex.invh;
1695  call->tex.ymax = (iy + ih) * icongltex.invh;
1696 
1697  if (rgb) {
1698  copy_v4_fl4(call->color, rgb[0], rgb[1], rgb[2], alpha);
1699  }
1700  else {
1701  copy_v4_fl(call->color, alpha);
1702  }
1703 
1704  if (texture_call->calls == ICON_DRAW_CACHE_SIZE) {
1706  }
1707 }
1708 
1709 static void icon_draw_texture(float x,
1710  float y,
1711  float w,
1712  float h,
1713  int ix,
1714  int iy,
1715  int iw,
1716  int ih,
1717  float alpha,
1718  const float rgb[3],
1719  bool with_border)
1720 {
1721  if (g_icon_draw_cache.enabled) {
1722  icon_draw_texture_cached(x, y, w, h, ix, iy, iw, ih, alpha, rgb, with_border);
1723  return;
1724  }
1725 
1726  /* We need to flush widget base first to ensure correct ordering. */
1728 
1730 
1731  const float x1 = ix * icongltex.invw;
1732  const float x2 = (ix + ih) * icongltex.invw;
1733  const float y1 = iy * icongltex.invh;
1734  const float y2 = (iy + ih) * icongltex.invh;
1735 
1736  GPUTexture *texture = with_border ? icongltex.tex[1] : icongltex.tex[0];
1737 
1739  GPU_shader_bind(shader);
1740 
1741  const int img_binding = GPU_shader_get_texture_binding(shader, "image");
1742  const int color_loc = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR);
1743  const int rect_tex_loc = GPU_shader_get_uniform(shader, "rect_icon");
1744  const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
1745 
1746  if (rgb) {
1747  GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){UNPACK3(rgb), alpha});
1748  }
1749  else {
1750  GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){alpha, alpha, alpha, alpha});
1751  }
1752 
1753  GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, (float[4]){x1, y1, x2, y2});
1754  GPU_shader_uniform_vector(shader, rect_geom_loc, 4, 1, (float[4]){x, y, x + w, y + h});
1755 
1756  GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
1757 
1759  GPU_batch_set_shader(quad, shader);
1761 
1762  GPU_texture_unbind(texture);
1763 
1765 }
1766 
1767 /* Drawing size for preview images */
1769 {
1770  switch (size) {
1771  case ICON_SIZE_ICON:
1772  return ICON_DEFAULT_HEIGHT;
1773  case ICON_SIZE_PREVIEW:
1774  return PREVIEW_DEFAULT_HEIGHT;
1775  default:
1776  return 0;
1777  }
1778 }
1779 
1780 static void icon_draw_size(float x,
1781  float y,
1782  int icon_id,
1783  float aspect,
1784  float alpha,
1785  enum eIconSizes size,
1786  int draw_size,
1787  const float desaturate,
1788  const uchar mono_rgba[4],
1789  const bool mono_border)
1790 {
1791  bTheme *btheme = UI_GetTheme();
1792  const float fdraw_size = (float)draw_size;
1793 
1794  Icon *icon = BKE_icon_get(icon_id);
1795  alpha *= btheme->tui.icon_alpha;
1796 
1797  if (icon == NULL) {
1798  if (G.debug & G_DEBUG) {
1799  printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
1800  }
1801  return;
1802  }
1803 
1804  /* scale width and height according to aspect */
1805  int w = (int)(fdraw_size / aspect + 0.5f);
1806  int h = (int)(fdraw_size / aspect + 0.5f);
1807 
1808  DrawInfo *di = icon_ensure_drawinfo(icon);
1809 
1810  /* We need to flush widget base first to ensure correct ordering. */
1812 
1813  if (di->type == ICON_TYPE_IMBUF) {
1814  ImBuf *ibuf = icon->obj;
1815 
1817  icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate);
1819  }
1820  else if (di->type == ICON_TYPE_VECTOR) {
1821  /* vector icons use the uiBlock transformation, they are not drawn
1822  * with untransformed coordinates like the other icons */
1823  di->data.vector.func((int)x, (int)y, w, h, 1.0f);
1824  }
1825  else if (di->type == ICON_TYPE_GEOM) {
1826 #ifdef USE_UI_TOOLBAR_HACK
1827  /* TODO(campbell): scale icons up for toolbar,
1828  * we need a way to detect larger buttons and do this automatic. */
1829  {
1830  float scale = (float)ICON_DEFAULT_HEIGHT_TOOLBAR / (float)ICON_DEFAULT_HEIGHT;
1831  y = (y + (h / 2)) - ((h * scale) / 2);
1832  w *= scale;
1833  h *= scale;
1834  }
1835 #endif
1836 
1837  /* If the theme is light, we will adjust the icon colors. */
1838  const bool invert = (rgb_to_grayscale_byte(btheme->tui.wcol_toolbar_item.inner) > 128);
1839  const bool geom_inverted = di->data.geom.inverted;
1840 
1841  /* This could re-generate often if rendered at different sizes in the one interface.
1842  * TODO(campbell): support caching multiple sizes. */
1843  ImBuf *ibuf = di->data.geom.image_cache;
1844  if ((ibuf == NULL) || (ibuf->x != w) || (ibuf->y != h) || (invert != geom_inverted)) {
1845  if (ibuf) {
1846  IMB_freeImBuf(ibuf);
1847  }
1848  if (invert != geom_inverted) {
1850  }
1851  ibuf = BKE_icon_geom_rasterize(icon->obj, w, h);
1852  di->data.geom.image_cache = ibuf;
1853  di->data.geom.inverted = invert;
1854  }
1855 
1857  icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, desaturate);
1859  }
1860  else if (di->type == ICON_TYPE_EVENT) {
1861  const short event_type = di->data.input.event_type;
1862  const short event_value = di->data.input.event_value;
1863  icon_draw_rect_input(x, y, w, h, alpha, event_type, event_value);
1864  }
1865  else if (di->type == ICON_TYPE_COLOR_TEXTURE) {
1866  /* texture image use premul alpha for correct scaling */
1868  y,
1869  (float)w,
1870  (float)h,
1871  di->data.texture.x,
1872  di->data.texture.y,
1873  di->data.texture.w,
1874  di->data.texture.h,
1875  alpha,
1876  NULL,
1877  false);
1878  }
1879  else if (di->type == ICON_TYPE_MONO_TEXTURE) {
1880  /* Monochrome icon that uses text or theme color. */
1881  const bool with_border = mono_border && (btheme->tui.icon_border_intensity > 0.0f);
1882  float color[4];
1883  if (mono_rgba) {
1884  rgba_uchar_to_float(color, (const uchar *)mono_rgba);
1885  }
1886  else {
1888  }
1889 
1890  mul_v4_fl(color, alpha);
1891 
1892  float border_outset = 0.0;
1893  uint border_texel = 0;
1894 #ifndef WITH_HEADLESS
1895  if (with_border) {
1896  const float scale = (float)ICON_GRID_W / (float)ICON_DEFAULT_WIDTH;
1897  border_texel = ICON_MONO_BORDER_OUTSET;
1898  border_outset = ICON_MONO_BORDER_OUTSET / (scale * aspect);
1899  }
1900 #endif
1901  icon_draw_texture(x - border_outset,
1902  y - border_outset,
1903  (float)w + 2 * border_outset,
1904  (float)h + 2 * border_outset,
1905  di->data.texture.x - border_texel,
1906  di->data.texture.y - border_texel,
1907  di->data.texture.w + 2 * border_texel,
1908  di->data.texture.h + 2 * border_texel,
1909  color[3],
1910  color,
1911  with_border);
1912  }
1913 
1914  else if (di->type == ICON_TYPE_BUFFER) {
1915  /* it is a builtin icon */
1916  IconImage *iimg = di->data.buffer.image;
1917 #ifndef WITH_HEADLESS
1918  icon_verify_datatoc(iimg);
1919 #endif
1920  if (!iimg->rect) {
1921  /* something has gone wrong! */
1922  return;
1923  }
1924 
1925  icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, desaturate);
1926  }
1927  else if (di->type == ICON_TYPE_PREVIEW) {
1928  PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
1929  icon->obj;
1930 
1931  if (pi) {
1932  /* no create icon on this level in code */
1933  if (!pi->rect[size]) {
1934  /* Something has gone wrong! */
1935  return;
1936  }
1937 
1938  /* Preview images use premultiplied alpha. */
1941  x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, desaturate);
1943  }
1944  }
1945  else if (di->type == ICON_TYPE_GPLAYER) {
1946  BLI_assert(icon->obj != NULL);
1947 
1948  /* Just draw a colored rect - Like for vicon_colorset_draw() */
1949 #ifndef WITH_HEADLESS
1950  vicon_gplayer_color_draw(icon, (int)x, (int)y, w, h);
1951 #endif
1952  }
1953 }
1954 
1956  const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job)
1957 {
1958  /* changed only ever set by dynamic icons */
1959  if (((pi->flag[size] & PRV_CHANGED) || !pi->rect[size])) {
1960  /* create the rect if necessary */
1961  icon_set_image(C, scene, id, pi, size, use_job);
1962 
1963  pi->flag[size] &= ~PRV_CHANGED;
1964  }
1965 }
1966 
1968  Scene *scene,
1969  ID *id_to_render,
1970  const enum eIconSizes size,
1971  const bool use_job,
1972  PreviewImage *r_preview_image)
1973 {
1974  ui_id_preview_image_render_size(C, scene, id_to_render, r_preview_image, size, use_job);
1975 }
1976 
1978  const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job)
1979 {
1981  if (pi == NULL) {
1982  return;
1983  }
1984 
1985  ID *id_to_render = id;
1986 
1987  /* For objects, first try if a preview can created via the object data. */
1988  if (GS(id->name) == ID_OB) {
1989  Object *ob = (Object *)id;
1990  if (ED_preview_id_is_supported(ob->data)) {
1991  id_to_render = ob->data;
1992  }
1993  }
1994 
1995  if (!ED_preview_id_is_supported(id_to_render)) {
1996  return;
1997  }
1998 
1999  UI_icon_render_id_ex(C, scene, id_to_render, size, use_job, pi);
2000 }
2001 
2002 static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
2003 {
2005 
2006  if (!pi) {
2007  return;
2008  }
2009 
2010  for (enum eIconSizes i = 0; i < NUM_ICON_SIZES; i++) {
2011  ui_id_preview_image_render_size(C, NULL, id, pi, i, use_jobs);
2012  }
2013 }
2014 
2015 static int ui_id_brush_get_icon(const bContext *C, ID *id)
2016 {
2017  Brush *br = (Brush *)id;
2018 
2019  if (br->flag & BRUSH_CUSTOM_ICON) {
2020  BKE_icon_id_ensure(id);
2021  ui_id_icon_render(C, id, true);
2022  }
2023  else {
2025  const EnumPropertyItem *items = NULL;
2026  ePaintMode paint_mode = PAINT_MODE_INVALID;
2027  ScrArea *area = CTX_wm_area(C);
2028  char space_type = area->spacetype;
2029  /* Fallback to 3D view. */
2030  if (space_type == SPACE_PROPERTIES) {
2031  space_type = SPACE_VIEW3D;
2032  }
2033 
2034  /* XXX: this is not nice, should probably make brushes
2035  * be strictly in one paint mode only to avoid
2036  * checking various context stuff here */
2037 
2038  if ((space_type == SPACE_VIEW3D) && ob) {
2039  if (ob->mode & OB_MODE_SCULPT) {
2040  paint_mode = PAINT_MODE_SCULPT;
2041  }
2042  else if (ob->mode & OB_MODE_VERTEX_PAINT) {
2043  paint_mode = PAINT_MODE_VERTEX;
2044  }
2045  else if (ob->mode & OB_MODE_WEIGHT_PAINT) {
2046  paint_mode = PAINT_MODE_WEIGHT;
2047  }
2048  else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
2049  paint_mode = PAINT_MODE_TEXTURE_3D;
2050  }
2051  else if (ob->mode & OB_MODE_SCULPT_CURVES) {
2052  paint_mode = PAINT_MODE_SCULPT_CURVES;
2053  }
2054  }
2055  else if (space_type == SPACE_IMAGE) {
2056  if (area->spacetype == space_type) {
2057  const SpaceImage *sima = area->spacedata.first;
2058  if (sima->mode == SI_MODE_PAINT) {
2059  paint_mode = PAINT_MODE_TEXTURE_2D;
2060  }
2061  }
2062  }
2063 
2064  /* reset the icon */
2065  if ((ob != NULL) &&
2068  (br->gpencil_settings != NULL)) {
2069  switch (br->gpencil_settings->icon_id) {
2070  case GP_BRUSH_ICON_PENCIL:
2071  br->id.icon_id = ICON_GPBRUSH_PENCIL;
2072  break;
2073  case GP_BRUSH_ICON_PEN:
2074  br->id.icon_id = ICON_GPBRUSH_PEN;
2075  break;
2076  case GP_BRUSH_ICON_INK:
2077  br->id.icon_id = ICON_GPBRUSH_INK;
2078  break;
2080  br->id.icon_id = ICON_GPBRUSH_INKNOISE;
2081  break;
2082  case GP_BRUSH_ICON_BLOCK:
2083  br->id.icon_id = ICON_GPBRUSH_BLOCK;
2084  break;
2085  case GP_BRUSH_ICON_MARKER:
2086  br->id.icon_id = ICON_GPBRUSH_MARKER;
2087  break;
2088  case GP_BRUSH_ICON_FILL:
2089  br->id.icon_id = ICON_GPBRUSH_FILL;
2090  break;
2092  br->id.icon_id = ICON_GPBRUSH_AIRBRUSH;
2093  break;
2094  case GP_BRUSH_ICON_CHISEL:
2095  br->id.icon_id = ICON_GPBRUSH_CHISEL;
2096  break;
2098  br->id.icon_id = ICON_GPBRUSH_ERASE_SOFT;
2099  break;
2101  br->id.icon_id = ICON_GPBRUSH_ERASE_HARD;
2102  break;
2104  br->id.icon_id = ICON_GPBRUSH_ERASE_STROKE;
2105  break;
2106  case GP_BRUSH_ICON_TINT:
2107  br->id.icon_id = ICON_BRUSH_TEXDRAW;
2108  break;
2110  br->id.icon_id = ICON_BRUSH_MIX;
2111  break;
2113  br->id.icon_id = ICON_BRUSH_BLUR;
2114  break;
2116  br->id.icon_id = ICON_BRUSH_BLUR;
2117  break;
2119  br->id.icon_id = ICON_BRUSH_BLUR;
2120  break;
2122  br->id.icon_id = ICON_BRUSH_MIX;
2123  break;
2125  br->id.icon_id = ICON_GPBRUSH_SMOOTH;
2126  break;
2128  br->id.icon_id = ICON_GPBRUSH_THICKNESS;
2129  break;
2131  br->id.icon_id = ICON_GPBRUSH_STRENGTH;
2132  break;
2134  br->id.icon_id = ICON_GPBRUSH_RANDOMIZE;
2135  break;
2137  br->id.icon_id = ICON_GPBRUSH_GRAB;
2138  break;
2140  br->id.icon_id = ICON_GPBRUSH_PUSH;
2141  break;
2143  br->id.icon_id = ICON_GPBRUSH_TWIST;
2144  break;
2146  br->id.icon_id = ICON_GPBRUSH_PINCH;
2147  break;
2149  br->id.icon_id = ICON_GPBRUSH_CLONE;
2150  break;
2152  br->id.icon_id = ICON_GPBRUSH_WEIGHT;
2153  break;
2154  default:
2155  br->id.icon_id = ICON_GPBRUSH_PEN;
2156  break;
2157  }
2158  return id->icon_id;
2159  }
2160 
2161  if (paint_mode != PAINT_MODE_INVALID) {
2162  items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
2163  const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paintmode(paint_mode);
2164  const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
2165  if (!items || !RNA_enum_icon_from_value(items, tool_type, &id->icon_id)) {
2166  id->icon_id = 0;
2167  }
2168  }
2169  else {
2170  id->icon_id = 0;
2171  }
2172  }
2173 
2174  return id->icon_id;
2175 }
2176 
2177 static int ui_id_screen_get_icon(const bContext *C, ID *id)
2178 {
2179  BKE_icon_id_ensure(id);
2180  /* Don't use jobs here, off-screen rendering doesn't like this and crashes. */
2181  ui_id_icon_render(C, id, false);
2182 
2183  return id->icon_id;
2184 }
2185 
2186 int ui_id_icon_get(const bContext *C, ID *id, const bool big)
2187 {
2188  int iconid = 0;
2189 
2190  /* icon */
2191  switch (GS(id->name)) {
2192  case ID_BR:
2193  iconid = ui_id_brush_get_icon(C, id);
2194  break;
2195  case ID_MA: /* fall through */
2196  case ID_TE: /* fall through */
2197  case ID_IM: /* fall through */
2198  case ID_WO: /* fall through */
2199  case ID_LA: /* fall through */
2200  iconid = BKE_icon_id_ensure(id);
2201  /* checks if not exists, or changed */
2203  break;
2204  case ID_SCR:
2205  iconid = ui_id_screen_get_icon(C, id);
2206  break;
2207  case ID_GR:
2208  iconid = UI_icon_color_from_collection((Collection *)id);
2209  break;
2210  default:
2211  break;
2212  }
2213 
2214  return iconid;
2215 }
2216 
2217 int UI_icon_from_library(const ID *id)
2218 {
2219  if (ID_IS_LINKED(id)) {
2220  if (id->tag & LIB_TAG_MISSING) {
2221  return ICON_LIBRARY_DATA_BROKEN;
2222  }
2223  if (id->tag & LIB_TAG_INDIRECT) {
2224  return ICON_LIBRARY_DATA_INDIRECT;
2225  }
2226  return ICON_LIBRARY_DATA_DIRECT;
2227  }
2228  if (ID_IS_OVERRIDE_LIBRARY(id)) {
2229  if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) ||
2231  return ICON_LIBRARY_DATA_OVERRIDE_NONEDITABLE;
2232  }
2233  return ICON_LIBRARY_DATA_OVERRIDE;
2234  }
2235  if (ID_IS_ASSET(id)) {
2236  return ICON_ASSET_MANAGER;
2237  }
2238 
2239  return ICON_NONE;
2240 }
2241 
2242 int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
2243 {
2244  ID *id = NULL;
2245 
2246  if (!ptr->data) {
2247  return rnaicon;
2248  }
2249 
2250  /* try ID, material, texture or dynapaint slot */
2251  if (RNA_struct_is_ID(ptr->type)) {
2252  id = ptr->owner_id;
2253  }
2254  else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
2255  id = RNA_pointer_get(ptr, "material").data;
2256  }
2257  else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) {
2258  id = RNA_pointer_get(ptr, "texture").data;
2259  }
2260  else if (RNA_struct_is_a(ptr->type, &RNA_FileBrowserFSMenuEntry)) {
2261  return RNA_int_get(ptr, "icon");
2262  }
2263  else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) {
2265 
2266  if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
2267  return ICON_SHADING_TEXTURE;
2268  }
2269  if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
2270  return ICON_OUTLINER_DATA_MESH;
2271  }
2272  if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
2273  return ICON_FILE_IMAGE;
2274  }
2275  }
2276  else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) {
2277  StudioLight *sl = ptr->data;
2278  switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) {
2280  return sl->icon_id_irradiance;
2282  default:
2283  return sl->icon_id_radiance;
2285  return sl->icon_id_matcap;
2286  }
2287  }
2288 
2289  /* get icon from ID */
2290  if (id) {
2291  const int icon = ui_id_icon_get(C, id, big);
2292 
2293  return icon ? icon : rnaicon;
2294  }
2295 
2296  return rnaicon;
2297 }
2298 
2299 int UI_icon_from_idcode(const int idcode)
2300 {
2301  switch ((ID_Type)idcode) {
2302  case ID_AC:
2303  return ICON_ACTION;
2304  case ID_AR:
2305  return ICON_ARMATURE_DATA;
2306  case ID_BR:
2307  return ICON_BRUSH_DATA;
2308  case ID_CA:
2309  return ICON_CAMERA_DATA;
2310  case ID_CF:
2311  return ICON_FILE;
2312  case ID_CU_LEGACY:
2313  return ICON_CURVE_DATA;
2314  case ID_GD:
2315  return ICON_OUTLINER_DATA_GREASEPENCIL;
2316  case ID_GR:
2317  return ICON_OUTLINER_COLLECTION;
2318  case ID_IM:
2319  return ICON_IMAGE_DATA;
2320  case ID_LA:
2321  return ICON_LIGHT_DATA;
2322  case ID_LS:
2323  return ICON_LINE_DATA;
2324  case ID_LT:
2325  return ICON_LATTICE_DATA;
2326  case ID_MA:
2327  return ICON_MATERIAL_DATA;
2328  case ID_MB:
2329  return ICON_META_DATA;
2330  case ID_MC:
2331  return ICON_TRACKER;
2332  case ID_ME:
2333  return ICON_MESH_DATA;
2334  case ID_MSK:
2335  return ICON_MOD_MASK; /* TODO: this would need its own icon! */
2336  case ID_NT:
2337  return ICON_NODETREE;
2338  case ID_OB:
2339  return ICON_OBJECT_DATA;
2340  case ID_PA:
2341  return ICON_PARTICLE_DATA;
2342  case ID_PAL:
2343  return ICON_COLOR; /* TODO: this would need its own icon! */
2344  case ID_PC:
2345  return ICON_CURVE_BEZCURVE; /* TODO: this would need its own icon! */
2346  case ID_LP:
2347  return ICON_OUTLINER_DATA_LIGHTPROBE;
2348  case ID_SCE:
2349  return ICON_SCENE_DATA;
2350  case ID_SPK:
2351  return ICON_SPEAKER;
2352  case ID_SO:
2353  return ICON_SOUND;
2354  case ID_TE:
2355  return ICON_TEXTURE_DATA;
2356  case ID_TXT:
2357  return ICON_TEXT;
2358  case ID_VF:
2359  return ICON_FONT_DATA;
2360  case ID_CV:
2361  return ICON_CURVES_DATA;
2362  case ID_PT:
2363  return ICON_POINTCLOUD_DATA;
2364  case ID_VO:
2365  return ICON_VOLUME_DATA;
2366  case ID_WO:
2367  return ICON_WORLD_DATA;
2368  case ID_WS:
2369  return ICON_WORKSPACE;
2370  case ID_SIM:
2371  /* TODO: Use correct icon. */
2372  return ICON_PHYSICS;
2373 
2374  /* No icons for these ID-types. */
2375  case ID_LI:
2376  case ID_IP:
2377  case ID_KE:
2378  case ID_SCR:
2379  case ID_WM:
2380  break;
2381  }
2382  return ICON_NONE;
2383 }
2384 
2385 int UI_icon_from_object_mode(const int mode)
2386 {
2387  switch ((eObjectMode)mode) {
2388  case OB_MODE_OBJECT:
2389  return ICON_OBJECT_DATAMODE;
2390  case OB_MODE_EDIT:
2391  case OB_MODE_EDIT_GPENCIL:
2392  return ICON_EDITMODE_HLT;
2393  case OB_MODE_SCULPT:
2395  case OB_MODE_SCULPT_CURVES:
2396  return ICON_SCULPTMODE_HLT;
2397  case OB_MODE_VERTEX_PAINT:
2399  return ICON_VPAINT_HLT;
2400  case OB_MODE_WEIGHT_PAINT:
2402  return ICON_WPAINT_HLT;
2403  case OB_MODE_TEXTURE_PAINT:
2404  return ICON_TPAINT_HLT;
2405  case OB_MODE_PARTICLE_EDIT:
2406  return ICON_PARTICLEMODE;
2407  case OB_MODE_POSE:
2408  return ICON_POSE_HLT;
2409  case OB_MODE_PAINT_GPENCIL:
2410  return ICON_GREASEPENCIL;
2411  }
2412  return ICON_NONE;
2413 }
2414 
2416 {
2417  int icon = ICON_OUTLINER_COLLECTION;
2418 
2419  if (collection->color_tag != COLLECTION_COLOR_NONE) {
2420  icon = ICON_COLLECTION_COLOR_01 + collection->color_tag;
2421  }
2422 
2423  return icon;
2424 }
2425 
2426 void UI_icon_draw(float x, float y, int icon_id)
2427 {
2428  UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, 1.0f, 0.0f, NULL, false);
2429 }
2430 
2431 void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
2432 {
2433  UI_icon_draw_ex(x, y, icon_id, U.inv_dpi_fac, alpha, 0.0f, NULL, false);
2434 }
2435 
2436 void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
2437 {
2438  icon_draw_size(x, y, icon_id, aspect, alpha, ICON_SIZE_PREVIEW, size, false, NULL, false);
2439 }
2440 
2441 void UI_icon_draw_ex(float x,
2442  float y,
2443  int icon_id,
2444  float aspect,
2445  float alpha,
2446  float desaturate,
2447  const uchar mono_color[4],
2448  const bool mono_border)
2449 {
2450  const int draw_size = get_draw_size(ICON_SIZE_ICON);
2451  icon_draw_size(x,
2452  y,
2453  icon_id,
2454  aspect,
2455  alpha,
2457  draw_size,
2458  desaturate,
2459  mono_color,
2460  mono_border);
2461 }
2462 
2463 /* ********** Alert Icons ********** */
2464 
2466 {
2467 #ifdef WITH_HEADLESS
2468  UNUSED_VARS(icon);
2469  return NULL;
2470 #else
2471  const int ALERT_IMG_SIZE = 256;
2472  icon = MIN2(icon, ALERT_ICON_MAX - 1);
2473  const int left = icon * ALERT_IMG_SIZE;
2474  const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1};
2477  IB_rect,
2478  NULL,
2479  "alert_icon");
2480  IMB_rect_crop(ibuf, &crop);
2481  IMB_premultiply_alpha(ibuf);
2482  return ibuf;
2483 #endif
2484 }
typedef float(TangentPoint)[2]
void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float scaleX, float scaleY, float xzoom, float yzoom, const float color[4])
Definition: glutil.c:59
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
Definition: glutil.c:44
const char * BKE_appdir_folder_id(int folder_id, const char *subfolder)
Definition: appdir.c:672
@ BLENDER_DATAFILES
Definition: BKE_appdir.h:154
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
@ G_DEBUG
Definition: BKE_global.h:174
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
Definition: icons.cc:385
bool BKE_previewimg_id_supports_jobs(const struct ID *id)
struct PreviewImage * BKE_previewimg_create(void)
Definition: icons.cc:261
struct ImBuf * BKE_icon_geom_rasterize(const struct Icon_Geom *geom, unsigned int size_x, unsigned int size_y)
#define ICON_RENDER_DEFAULT_HEIGHT
Definition: BKE_icons.h:253
void BKE_icon_set(int icon_id, struct Icon *icon)
Definition: icons.cc:848
struct PreviewImage * BKE_previewimg_copy(const struct PreviewImage *prv)
struct Icon * BKE_icon_get(int icon_id)
Definition: icons.cc:832
void BKE_icons_free(void)
Definition: icons.cc:200
void BKE_icon_geom_invert_lightness(struct Icon_Geom *geom)
@ ICON_DATA_IMBUF
Definition: BKE_icons.h:29
@ ICON_DATA_STUDIOLIGHT
Definition: BKE_icons.h:35
@ ICON_DATA_PREVIEW
Definition: BKE_icons.h:31
@ ICON_DATA_ID
Definition: BKE_icons.h:27
@ ICON_DATA_GPLAYER
Definition: BKE_icons.h:37
@ ICON_DATA_GEOM
Definition: BKE_icons.h:33
int BKE_icon_id_ensure(struct ID *id)
Definition: icons.cc:699
uint BKE_paint_get_brush_tool_offset_from_paintmode(ePaintMode mode)
Definition: paint.c:675
const struct EnumPropertyItem * BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
Definition: paint.c:382
ePaintMode
Definition: BKE_paint.h:67
@ PAINT_MODE_INVALID
Definition: BKE_paint.h:86
@ PAINT_MODE_SCULPT_CURVES
Definition: BKE_paint.h:83
@ PAINT_MODE_TEXTURE_3D
Definition: BKE_paint.h:73
@ PAINT_MODE_SCULPT
Definition: BKE_paint.h:68
@ PAINT_MODE_WEIGHT
Definition: BKE_paint.h:71
@ PAINT_MODE_TEXTURE_2D
Definition: BKE_paint.h:75
@ PAINT_MODE_VERTEX
Definition: BKE_paint.h:70
@ STUDIOLIGHT_TYPE_MATCAP
@ STUDIOLIGHT_TYPE_WORLD
@ STUDIOLIGHT_TYPE_STUDIO
#define STUDIOLIGHT_ICON_SIZE
void BKE_studiolight_set_free_function(StudioLight *sl, StudioLightFreeFunction *free_function, void *data)
Definition: studiolight.c:1610
#define STUDIOLIGHT_FLAG_ORIENTATIONS
void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type)
Definition: studiolight.c:1494
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
unsigned int BLI_filelist_dir_contents(const char *dir, struct direntry **r_filelist)
Definition: BLI_filelist.c:218
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
Definition: BLI_filelist.c:420
Some types for dealing with directories.
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
MINLINE int round_fl_to_int(float a)
MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
unsigned int rgb_to_cpack(float r, float g, float b)
Definition: math_color.c:348
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
Definition: math_color.c:383
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void copy_v4_fl(float r[4], float f)
#define FILE_MAX
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1299
#define BLI_path_cmp
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1531
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED_VARS(...)
#define UNUSED(x)
#define UNPACK3(a)
#define MAX2(a, b)
#define ELEM(...)
#define MIN2(a, b)
#define POINTER_OFFSET(v, ofs)
@ PRV_TAG_DEFFERED
Definition: DNA_ID.h:524
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition: DNA_ID.h:581
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:566
#define ID_IS_ASSET(_id)
Definition: DNA_ID.h:598
@ LIB_TAG_INDIRECT
Definition: DNA_ID.h:677
@ LIB_TAG_MISSING
Definition: DNA_ID.h:690
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:588
@ PRV_CHANGED
Definition: DNA_ID.h:517
@ PRV_USER_EDITED
Definition: DNA_ID.h:518
@ IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED
Definition: DNA_ID.h:327
eIconSizes
Definition: DNA_ID_enums.h:14
@ ICON_SIZE_PREVIEW
Definition: DNA_ID_enums.h:16
@ ICON_SIZE_ICON
Definition: DNA_ID_enums.h:15
@ NUM_ICON_SIZES
Definition: DNA_ID_enums.h:18
ID_Type
Definition: DNA_ID_enums.h:44
@ ID_WM
Definition: DNA_ID_enums.h:72
@ ID_CA
Definition: DNA_ID_enums.h:56
@ ID_AR
Definition: DNA_ID_enums.h:66
@ ID_MC
Definition: DNA_ID_enums.h:73
@ ID_CF
Definition: DNA_ID_enums.h:78
@ ID_LI
Definition: DNA_ID_enums.h:46
@ ID_TE
Definition: DNA_ID_enums.h:52
@ ID_IM
Definition: DNA_ID_enums.h:53
@ ID_VO
Definition: DNA_ID_enums.h:83
@ ID_WS
Definition: DNA_ID_enums.h:79
@ ID_NT
Definition: DNA_ID_enums.h:68
@ ID_LA
Definition: DNA_ID_enums.h:55
@ ID_KE
Definition: DNA_ID_enums.h:58
@ ID_TXT
Definition: DNA_ID_enums.h:62
@ ID_SO
Definition: DNA_ID_enums.h:64
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ID_LS
Definition: DNA_ID_enums.h:75
@ ID_MSK
Definition: DNA_ID_enums.h:74
@ ID_GD
Definition: DNA_ID_enums.h:71
@ ID_CV
Definition: DNA_ID_enums.h:81
@ ID_PAL
Definition: DNA_ID_enums.h:76
@ ID_BR
Definition: DNA_ID_enums.h:69
@ ID_LP
Definition: DNA_ID_enums.h:80
@ ID_WO
Definition: DNA_ID_enums.h:59
@ ID_SIM
Definition: DNA_ID_enums.h:84
@ ID_MA
Definition: DNA_ID_enums.h:51
@ ID_AC
Definition: DNA_ID_enums.h:67
@ ID_SCR
Definition: DNA_ID_enums.h:60
@ ID_CU_LEGACY
Definition: DNA_ID_enums.h:49
@ ID_VF
Definition: DNA_ID_enums.h:61
@ ID_ME
Definition: DNA_ID_enums.h:48
@ ID_IP
Definition: DNA_ID_enums.h:57
@ ID_GR
Definition: DNA_ID_enums.h:65
@ ID_SPK
Definition: DNA_ID_enums.h:63
@ ID_MB
Definition: DNA_ID_enums.h:50
@ ID_LT
Definition: DNA_ID_enums.h:54
@ ID_OB
Definition: DNA_ID_enums.h:47
@ ID_PA
Definition: DNA_ID_enums.h:70
@ ID_PT
Definition: DNA_ID_enums.h:82
@ ID_PC
Definition: DNA_ID_enums.h:77
@ BRUSH_CUSTOM_ICON
@ GP_BRUSH_ICON_ERASE_SOFT
@ GP_BRUSH_ICON_GPBRUSH_RANDOMIZE
@ GP_BRUSH_ICON_VERTEX_BLUR
@ GP_BRUSH_ICON_TINT
@ GP_BRUSH_ICON_FILL
@ GP_BRUSH_ICON_PENCIL
@ GP_BRUSH_ICON_GPBRUSH_GRAB
@ GP_BRUSH_ICON_GPBRUSH_STRENGTH
@ GP_BRUSH_ICON_INKNOISE
@ GP_BRUSH_ICON_GPBRUSH_TWIST
@ GP_BRUSH_ICON_PEN
@ GP_BRUSH_ICON_VERTEX_REPLACE
@ GP_BRUSH_ICON_MARKER
@ GP_BRUSH_ICON_VERTEX_DRAW
@ GP_BRUSH_ICON_BLOCK
@ GP_BRUSH_ICON_GPBRUSH_WEIGHT
@ GP_BRUSH_ICON_INK
@ GP_BRUSH_ICON_GPBRUSH_PINCH
@ GP_BRUSH_ICON_VERTEX_SMEAR
@ GP_BRUSH_ICON_GPBRUSH_THICKNESS
@ GP_BRUSH_ICON_AIRBRUSH
@ GP_BRUSH_ICON_GPBRUSH_CLONE
@ GP_BRUSH_ICON_CHISEL
@ GP_BRUSH_ICON_ERASE_STROKE
@ GP_BRUSH_ICON_ERASE_HARD
@ GP_BRUSH_ICON_GPBRUSH_SMOOTH
@ GP_BRUSH_ICON_GPBRUSH_PUSH
@ GP_BRUSH_ICON_VERTEX_AVERAGE
Object groups, one object can be in many groups at once.
@ COLLECTION_COLOR_NONE
@ COLLECTION_COLOR_02
@ COLLECTION_COLOR_05
@ COLLECTION_COLOR_07
@ COLLECTION_COLOR_06
@ COLLECTION_COLOR_04
@ COLLECTION_COLOR_01
@ COLLECTION_COLOR_08
@ COLLECTION_COLOR_03
@ BEZT_KEYTYPE_EXTREME
@ BEZT_KEYTYPE_JITTER
@ BEZT_KEYTYPE_BREAKDOWN
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_KEYFRAME
@ MOD_DPAINT_SURFACE_F_PTEX
@ MOD_DPAINT_SURFACE_F_VERTEX
@ MOD_DPAINT_SURFACE_F_IMAGESEQ
eObjectMode
@ OB_MODE_VERTEX_GPENCIL
@ OB_MODE_EDIT_GPENCIL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_WEIGHT_GPENCIL
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_SCULPT_GPENCIL
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_VERTEX_PAINT
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ RGN_TYPE_WINDOW
@ SEQUENCE_COLOR_05
@ SEQUENCE_COLOR_02
@ SEQUENCE_COLOR_04
@ SEQUENCE_COLOR_06
@ SEQUENCE_COLOR_01
@ SEQUENCE_COLOR_09
@ SEQUENCE_COLOR_08
@ SEQUENCE_COLOR_03
@ SEQUENCE_COLOR_07
@ SPACE_ACTION
@ SPACE_PROPERTIES
@ SPACE_IMAGE
@ SPACE_VIEW3D
@ SI_MODE_PAINT
const char datatoc_blender_icons32_png[]
int datatoc_blender_icons32_png_size
int datatoc_blender_icons16_png_size
int datatoc_alert_icons_png_size
const char datatoc_alert_icons_png[]
const char datatoc_blender_icons16_png[]
@ KEYFRAME_SHAPE_BOTH
@ KEYFRAME_HANDLE_VECTOR
@ KEYFRAME_HANDLE_FREE
@ KEYFRAME_HANDLE_AUTO_CLAMP
@ KEYFRAME_HANDLE_NONE
@ KEYFRAME_HANDLE_AUTO
@ KEYFRAME_HANDLE_ALIGNED
@ KEYFRAME_EXTREME_NONE
bool ED_preview_id_is_supported(const struct ID *id)
void ED_preview_icon_render(const struct bContext *C, struct Scene *scene, struct PreviewImage *prv_img, struct ID *id, enum eIconSizes icon_size)
void ED_preview_icon_job(const struct bContext *C, struct PreviewImage *prv_img, struct ID *id, enum eIconSizes icon_size, bool delay)
GPUBatch
Definition: GPU_batch.h:78
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
Definition: gpu_batch.cc:235
void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
Definition: gpu_batch.cc:211
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:223
struct GPUBatch * GPU_batch_preset_quad(void)
void immUniform2f(const char *name, float x, float y)
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniformColor3ubv(const unsigned char rgb[3])
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void immUniformColor3fv(const float rgb[3])
void immRecti(uint pos, int x1, int y1, int x2, int y2)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define GPU_matrix_model_view_projection_get(x)
Definition: GPU_matrix.h:229
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:19
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:559
struct GPUShader GPUShader
Definition: GPU_shader.h:20
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:630
int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:592
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
void GPU_shader_bind(GPUShader *shader)
Definition: gpu_shader.cc:491
@ GPU_UNIFORM_COLOR
Definition: GPU_shader.h:129
eGPUBuiltinShader
Definition: GPU_shader.h:189
@ GPU_SHADER_KEYFRAME_SHAPE
Definition: GPU_shader.h:192
@ GPU_SHADER_2D_IMAGE_DESATURATE_COLOR
Definition: GPU_shader.h:218
@ GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR
Definition: GPU_shader.h:220
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ GPU_SHADER_2D_IMAGE_RECT_COLOR
Definition: GPU_shader.h:219
@ GPU_SHADER_2D_IMAGE_COLOR
Definition: GPU_shader.h:217
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:599
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:566
void GPU_program_point_size(bool enable)
Definition: gpu_state.cc:172
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:63
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
@ GPU_SAMPLER_ICON
Definition: GPU_texture.h:35
void GPU_texture_bind_ex(GPUTexture *tex, eGPUSamplerState state, int unit, bool set_number)
void GPU_texture_update_mipmap(GPUTexture *tex, int miplvl, eGPUDataFormat gpu_data_format, const void *pixels)
Definition: gpu_texture.cc:406
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:472
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
@ GPU_RGBA8
Definition: GPU_texture.h:87
struct GPUUniformBuf GPUUniformBuf
void GPU_uniformbuf_unbind(GPUUniformBuf *ubo)
GPUUniformBuf * GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT
@ GPU_FETCH_INT_TO_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U32
@ GPU_COMP_U8
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1644
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_crop(struct ImBuf *ibuf, const struct rcti *crop)
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: readimage.c:209
void IMB_premultiply_alpha(struct ImBuf *ibuf)
Definition: filter.c:662
struct ImBuf * IMB_ibImageFromMemory(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
Definition: readimage.c:84
Contains defines and structs used throughout the imbuf module.
@ IB_rect
#define PREVIEW_RENDER_DEFAULT_HEIGHT
Definition: IMB_thumbs.h:40
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define C
Definition: RandGen.cpp:25
void UI_widgetbase_draw_cache_flush(void)
#define ICON_DEFAULT_HEIGHT
#define ICON_DEFAULT_HEIGHT_TOOLBAR
#define PREVIEW_DEFAULT_HEIGHT
eAlertIcon
@ ALERT_ICON_MAX
#define ICON_DEFAULT_WIDTH
@ TH_TEXT
Definition: UI_resources.h:42
#define BIFICONID_FIRST
Definition: UI_resources.h:24
void UI_Theme_Restore(struct bThemeState *theme_state)
Definition: resources.c:1076
struct bTheme * UI_GetTheme(void)
Definition: resources.c:1067
void UI_GetThemeColor4fv(int colorid, float col[4])
Definition: resources.c:1173
bool UI_GetIconThemeColor4ubv(int colorid, unsigned char col[4])
Definition: resources.c:1386
void UI_SetTheme(int spacetype, int regionid)
Definition: resources.c:1045
void UI_Theme_Store(struct bThemeState *theme_state)
Definition: resources.c:1072
@ WM_JOB_TYPE_STUDIOLIGHT
Definition: WM_api.h:1368
@ KM_NOTHING
Definition: WM_types.h:266
@ KM_ANY
Definition: WM_types.h:265
@ KM_PRESS
Definition: WM_types.h:267
@ KM_CLICK
Definition: WM_types.h:269
#define NC_WINDOW
Definition: WM_types.h:325
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Scene scene
SyclQueue void void size_t num_bytes void
struct @211::@212 surface
uint pos
uint col
GPUBatch * quad
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
#define mix(a, b, c)
Definition: hash.h:17
void UI_icons_free_drawinfo(void *drawinfo)
static struct ListBase iconfilelist
static void vicon_collection_color_draw(short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
int UI_icon_from_object_mode(const int mode)
struct IconType IconType
void UI_icon_draw_cache_end(void)
static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, short key_type, short handle_type)
#define ICON_TYPE_MONO_TEXTURE
static void ui_studiolight_icon_job_exec(void *customdata, short *UNUSED(stop), short *UNUSED(do_update), float *UNUSED(progress))
static void icon_draw_cache_flush_ex(bool only_full_caches)
void UI_icons_free(void)
#define ICON_TYPE_COLOR_TEXTURE
static void ui_id_preview_image_render_size(const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job)
#define DEF_ICON_VECTOR_COLORSET_DRAW_NTH(prefix, index)
static void vicon_handletype_aligned_draw(int x, int y, int w, int h, float alpha)
#define DEF_ICON_COLLECTION_COLOR_DRAW(index, color)
struct IconImage IconImage
int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, const bool big)
static DrawInfo * icon_ensure_drawinfo(Icon *icon)
static IconTexture icongltex
void(* VectorDrawFunc)(int x, int y, int w, int h, float alpha)
#define ICON_GRID_MARGIN
static void init_iconfile_list(struct ListBase *list)
static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy, int iw, int ih, float alpha, const float rgb[3], bool with_border)
static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float alpha)
static void vicon_keytype_keyframe_draw(int x, int y, int w, int h, float alpha)
void UI_icons_reload_internal_textures(void)
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
static const IconType icontypes[]
#define ICON_INDIRECT_DATA_ALPHA
int UI_icon_from_idcode(const int idcode)
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
static void vicon_keytype_jitter_draw(int x, int y, int w, int h, float alpha)
void UI_icon_draw(float x, float y, int icon_id)
static void vicon_handletype_vector_draw(int x, int y, int w, int h, float alpha)
static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha))
static void vicon_strip_color_draw_library_data_override_noneditable(int x, int y, int w, int UNUSED(h), float alpha)
#define INIT_BRUSH_ICON(icon_id, name)
static void free_icons_textures(void)
#define ICON_GRID_W
void UI_icon_draw_cache_begin(void)
static void free_iconfile_list(struct ListBase *list)
static void icon_verify_datatoc(IconImage *iimg)
IconTextureDrawCall normal
static void vicon_handletype_free_draw(int x, int y, int w, int h, float alpha)
static void ui_studiolight_icon_job_end(void *customdata)
struct IconTextureDrawCall IconTextureDrawCall
void UI_icon_render_id(const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job)
bool enabled
struct IconTexture IconTexture
PreviewImage * UI_icon_to_preview(int icon_id)
int ui_id_icon_get(const bContext *C, ID *id, const bool big)
static int ui_id_screen_get_icon(const bContext *C, ID *id)
static void vicon_strip_color_draw_library_data_indirect(int x, int y, int w, int UNUSED(h), float alpha)
#define ICON_TYPE_GEOM
#define ICON_TYPE_EVENT
static void init_brush_icons(void)
int UI_icon_from_keymap_item(const wmKeyMapItem *kmi, int r_icon_mod[4])
int UI_icon_get_height(int icon_id)
bool UI_icon_get_theme_color(int icon_id, uchar color[4])
static void vicon_keytype_moving_hold_draw(int x, int y, int w, int h, float alpha)
void UI_icon_render_id_ex(const bContext *C, Scene *scene, ID *id_to_render, const enum eIconSizes size, const bool use_job, PreviewImage *r_preview_image)
static DrawInfo * icon_create_drawinfo(Icon *icon)
ImBuf * UI_icon_alert_imbuf_get(eAlertIcon icon)
static void vicon_handletype_auto_draw(int x, int y, int w, int h, float alpha)
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
#define ICON_TYPE_BUFFER
int UI_icon_from_library(const ID *id)
static void ui_studiolight_free_function(StudioLight *sl, void *data)
static ImBuf * create_mono_icon_with_border(ImBuf *buf, int resolution_divider, float border_intensity)
int UI_iconfile_get_index(const char *filename)
#define ICON_MONO_BORDER_OUTSET
void UI_icons_init()
#define ICON_DRAW_CACHE_SIZE
#define ICON_GRID_ROWS
int UI_icon_from_event_type(short event_type, short event_value)
int UI_icon_color_from_collection(const Collection *collection)
static DrawInfo * def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
ListBase * UI_iconfile_list(void)
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, uint *rect, float alpha, const float desaturate)
void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size)
#define ICON_TYPE_GPLAYER
static void vicon_keytype_extreme_draw(int x, int y, int w, int h, float alpha)
static int ui_id_brush_get_icon(const bContext *C, ID *id)
static void init_internal_icons(void)
#define DEF_ICON_STRIP_COLOR_DRAW(index, color)
#define ICON_TYPE_PREVIEW
struct IconDrawCall IconDrawCall
#define ICON_TYPE_IMBUF
#define ICON_TYPE_VECTOR
static int get_draw_size(enum eIconSizes size)
int UI_icon_preview_to_render_size(enum eIconSizes size)
static DrawInfo * g_di_event_list
int UI_icon_get_width(int icon_id)
static void icon_draw_texture_cached(float x, float y, float w, float h, int ix, int iy, int UNUSED(iw), int ih, float alpha, const float rgb[3], bool with_border)
static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_id)
static void vicon_keytype_breakdown_draw(int x, int y, int w, int h, float alpha)
#define INIT_EVENT_ICON(icon_id, type, value)
static void init_event_icons(void)
#define ICON_GRID_H
void UI_icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], const bool mono_border)
static void vicon_strip_color_draw(short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
static void icon_draw_cache_texture_flush_ex(GPUTexture *texture, IconTextureDrawCall *texture_draw_calls)
struct DrawInfo DrawInfo
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int draw_size, const float desaturate, const uchar mono_rgba[4], const bool mono_border)
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
static struct @417 g_icon_draw_cache
IconTextureDrawCall border
#define ICON_GRID_COLS
static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
static void icon_set_image(const bContext *C, Scene *scene, ID *id, PreviewImage *prv_img, enum eIconSizes size, const bool use_job)
void icon_draw_rect_input(float x, float y, int w, int h, float UNUSED(alpha), short event_type, short UNUSED(event_value))
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: invert.h:8
#define GS(x)
Definition: iris.c:225
ccl_gpu_kernel_postfix ccl_global float int int sy
const int state
ccl_gpu_kernel_postfix ccl_global float int sx
void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha, const KeyframeShaderBindings *sh_bindings, short handle_type, short extreme_type)
format
Definition: logImageCore.h:38
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int left
#define G(x, y, z)
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static void area(int d1, int d2, int e1, int e2, float weights[2])
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)
smooth(Type::FLOAT, "mask_weight")
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:695
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5167
bool RNA_struct_is_ID(const StructRNA *type)
Definition: rna_access.c:655
bool RNA_enum_icon_from_value(const EnumPropertyItem *item, int value, int *r_icon)
Definition: rna_access.c:5096
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
struct BrushGpencilSettings * gpencil_settings
IconImage * image
struct DrawInfo::@418::@420 geom
struct DrawInfo::@418::@421 buffer
short event_type
struct DrawInfo::@418::@422 texture
struct DrawInfo * next
VectorDrawFunc func
ImBuf * image_cache
short event_value
struct DrawInfo::@418::@419 vector
union DrawInfo::@418 data
struct DrawInfo::@418::@423 input
unsigned int flag
Definition: DNA_ID.h:312
Definition: DNA_ID.h:368
int tag
Definition: DNA_ID.h:387
int icon_id
Definition: DNA_ID.h:389
IDOverrideLibrary * override_library
Definition: DNA_ID.h:412
char name[66]
Definition: DNA_ID.h:378
char filename[256]
struct IconFile * next
const uchar * datatoc_rect
IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE]
struct GPUTexture * tex[2]
Definition: BKE_icons.h:43
void * obj
Definition: BKE_icons.h:50
char obj_type
Definition: BKE_icons.h:51
void * drawinfo
Definition: BKE_icons.h:44
short id_type
Definition: BKE_icons.h:55
DrawInfoFreeFP drawinfo_free
Definition: BKE_icons.h:56
unsigned int * rect
void * first
Definition: DNA_listBase.h:31
void * data
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
unsigned int h[2]
Definition: DNA_ID.h:532
short changed_timestamp[2]
Definition: DNA_ID.h:534
short flag[2]
Definition: DNA_ID.h:533
unsigned int * rect[2]
Definition: DNA_ID.h:535
unsigned int w[2]
Definition: DNA_ID.h:531
int icon_id_matcap_flipped
unsigned char color[4]
unsigned char color[4]
float icon_border_intensity
float icon_alpha
uiWidgetColors wcol_toolbar_item
unsigned char select[4]
unsigned char solid[4]
unsigned char active[4]
float color[4]
ThemeStripColor strip_color[9]
ThemeUI tui
ThemeWireColor tarm[20]
ThemeCollectionColor collection_color[8]
const char * relname
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
unsigned char inner[4]
Definition: wm_jobs.c:57
@ RIGHTMOUSE
@ EVT_OKEY
@ EVT_EKEY
@ EVT_JKEY
@ EVT_F7KEY
@ EVT_YKEY
@ EVT_RIGHTCTRLKEY
@ EVT_SKEY
@ EVT_VKEY
@ EVT_IKEY
@ EVT_F1KEY
@ EVT_XKEY
@ EVT_F10KEY
@ EVT_FKEY
@ EVT_CKEY
@ EVT_F2KEY
@ EVT_GKEY
@ EVT_KKEY
@ EVT_TABKEY
@ EVT_UKEY
@ EVT_AKEY
@ EVT_PAGEUPKEY
@ EVT_OSKEY
@ EVT_F4KEY
@ EVT_PAGEDOWNKEY
@ EVT_F8KEY
@ EVT_LEFTCTRLKEY
@ EVT_F6KEY
@ EVT_F5KEY
@ EVT_SPACEKEY
@ EVT_WKEY
@ EVT_RIGHTALTKEY
@ EVT_MKEY
@ EVT_TKEY
@ EVT_HKEY
@ LEFTMOUSE
@ EVT_F11KEY
@ EVT_NKEY
@ EVT_QKEY
@ MIDDLEMOUSE
@ EVT_LEFTALTKEY
@ EVT_ZKEY
@ EVT_ESCKEY
@ EVT_F12KEY
@ EVT_DKEY
@ EVT_LKEY
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
@ EVT_F3KEY
@ EVT_F9KEY
@ EVT_RKEY
@ EVT_BKEY
@ EVT_PKEY
@ EVT_RETKEY
PointerRNA * ptr
Definition: wm_files.c:3480
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:437
void WM_jobs_kill_type(struct wmWindowManager *wm, const void *owner, int job_type)
Definition: wm_jobs.c:572
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:351
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:323
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:339
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:184