Blender  V3.3
screen.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 /* Allow using deprecated functionality for .blend file I/O. */
9 #define DNA_DEPRECATED_ALLOW
10 
11 #ifdef WIN32
12 # include "BLI_winstuff.h"
13 #endif
14 
15 #include <math.h>
16 #include <stdio.h>
17 #include <string.h>
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "DNA_collection_types.h"
22 #include "DNA_defaults.h"
23 #include "DNA_gpencil_types.h"
24 #include "DNA_mask_types.h"
25 #include "DNA_scene_types.h"
26 #include "DNA_screen_types.h"
27 #include "DNA_space_types.h"
28 #include "DNA_text_types.h"
29 #include "DNA_view3d_types.h"
30 #include "DNA_workspace_types.h"
31 
32 #include "BLI_ghash.h"
33 #include "BLI_listbase.h"
34 #include "BLI_math_vector.h"
35 #include "BLI_mempool.h"
36 #include "BLI_rect.h"
37 #include "BLI_utildefines.h"
38 
39 #include "BLT_translation.h"
40 
41 #include "BKE_gpencil.h"
42 #include "BKE_icons.h"
43 #include "BKE_idprop.h"
44 #include "BKE_idtype.h"
45 #include "BKE_lib_id.h"
46 #include "BKE_lib_query.h"
47 #include "BKE_node.h"
48 #include "BKE_screen.h"
49 #include "BKE_workspace.h"
50 
51 #include "BLO_read_write.h"
52 
53 #ifdef WITH_PYTHON
54 # include "BPY_extern.h"
55 #endif
56 
57 static void screen_free_data(ID *id)
58 {
59  bScreen *screen = (bScreen *)id;
60 
61  /* No animation-data here. */
62 
63  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
64  BKE_area_region_free(NULL, region);
65  }
66 
67  BLI_freelistN(&screen->regionbase);
68 
70 
71  BKE_previewimg_free(&screen->preview);
72 
73  /* Region and timer are freed by the window manager. */
74  MEM_SAFE_FREE(screen->tool_tip);
75 }
76 
78 {
79  if (ads != NULL) {
82  }
83 }
84 
86 {
88 
89  /* TODO: this should be moved to a callback in `SpaceType`, defined in each editor's own code.
90  * Will be for a later round of cleanup though... */
91  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
92  switch (sl->spacetype) {
93  case SPACE_VIEW3D: {
94  View3D *v3d = (View3D *)sl;
97  if (v3d->localvd) {
99  }
100  break;
101  }
102  case SPACE_GRAPH: {
103  SpaceGraph *sipo = (SpaceGraph *)sl;
106  break;
107  }
108  case SPACE_PROPERTIES: {
109  SpaceProperties *sbuts = (SpaceProperties *)sl;
111  break;
112  }
113  case SPACE_FILE:
114  break;
115  case SPACE_ACTION: {
116  SpaceAction *saction = (SpaceAction *)sl;
119  break;
120  }
121  case SPACE_IMAGE: {
122  SpaceImage *sima = (SpaceImage *)sl;
126  break;
127  }
128  case SPACE_SEQ: {
129  SpaceSeq *sseq = (SpaceSeq *)sl;
131  break;
132  }
133  case SPACE_NLA: {
134  SpaceNla *snla = (SpaceNla *)sl;
137  break;
138  }
139  case SPACE_TEXT: {
140  SpaceText *st = (SpaceText *)sl;
142  break;
143  }
144  case SPACE_SCRIPT: {
145  SpaceScript *scpt = (SpaceScript *)sl;
147  break;
148  }
149  case SPACE_OUTLINER: {
150  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
152  if (space_outliner->treestore != NULL) {
153  TreeStoreElem *tselem;
154  BLI_mempool_iter iter;
155 
156  BLI_mempool_iternew(space_outliner->treestore, &iter);
157  while ((tselem = BLI_mempool_iterstep(&iter))) {
159  }
160  }
161  break;
162  }
163  case SPACE_NODE: {
164  SpaceNode *snode = (SpaceNode *)sl;
165  const bool is_private_nodetree = snode->id != NULL &&
166  ntreeFromID(snode->id) == snode->nodetree;
167 
171  data, snode->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_USER_ONE);
172 
173  LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
174  if (path == snode->treepath.first) {
175  /* first nodetree in path is same as snode->nodetree */
177  path->nodetree,
178  is_private_nodetree ? IDWALK_CB_EMBEDDED :
180  }
181  else {
183  }
184 
185  if (path->nodetree == NULL) {
186  break;
187  }
188  }
189 
191  break;
192  }
193  case SPACE_CLIP: {
194  SpaceClip *sclip = (SpaceClip *)sl;
197  break;
198  }
199  case SPACE_SPREADSHEET: {
200  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
202  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
205  }
206  }
207  break;
208  }
209  default:
210  break;
211  }
212  }
213 }
214 
216 {
218  return;
219  }
220  bScreen *screen = (bScreen *)id;
221 
222  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
224  }
225 }
226 
227 static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
228 {
229  bScreen *screen = (bScreen *)id;
230 
231  /* write LibData */
232  /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
233  BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
234  BKE_id_blend_write(writer, &screen->id);
235 
236  BKE_previewimg_blend_write(writer, screen->preview);
237 
238  /* direct data */
240 }
241 
243 {
244  bool success = true;
245 
246  screen->regionbase.first = screen->regionbase.last = NULL;
247  screen->context = NULL;
248  screen->active_region = NULL;
249 
250  BLO_read_data_address(reader, &screen->preview);
251  BKE_previewimg_blend_read(reader, screen->preview);
252 
254  printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
255  success = false;
256  }
257 
258  return success;
259 }
260 
261 /* NOTE: file read without screens option G_FILE_NO_UI;
262  * check lib pointers in call below */
263 static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
264 {
265  bScreen *screen = (bScreen *)id;
266  /* deprecated, but needed for versioning (will be NULL'ed then) */
267  BLO_read_id_address(reader, screen->id.lib, &screen->scene);
268 
269  screen->animtimer = NULL; /* saved in rare cases */
270  screen->tool_tip = NULL;
271  screen->scrubbing = false;
272 
273  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
274  BKE_screen_area_blend_read_lib(reader, &screen->id, area);
275  }
276 }
277 
279  .id_code = ID_SCR,
280  .id_filter = FILTER_ID_SCR,
281  .main_listbase_index = INDEX_ID_SCR,
282  .struct_size = sizeof(bScreen),
283  .name = "Screen",
284  .name_plural = "screens",
285  .translation_context = BLT_I18NCONTEXT_ID_SCREEN,
287  .asset_type_info = NULL,
288 
289  .init_data = NULL,
290  .copy_data = NULL,
291  .free_data = screen_free_data,
292  .make_local = NULL,
293  .foreach_id = screen_foreach_id,
294  .foreach_cache = NULL,
295  .foreach_path = NULL,
296  .owner_get = NULL,
297 
298  .blend_write = screen_blend_write,
299  /* Cannot be used yet, because #direct_link_screen has a return value. */
300  .blend_read_data = NULL,
301  .blend_read_lib = screen_blend_read_lib,
302  .blend_read_expand = NULL,
303 
304  .blend_read_undo_preserve = NULL,
305 
306  .lib_override_apply_post = NULL,
307 };
308 
309 /* ************ Spacetype/regiontype handling ************** */
310 
311 /* keep global; this has to be accessible outside of windowmanager */
313 
314 /* not SpaceType itself */
316 {
317  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
318 #ifdef WITH_PYTHON
320 #endif
321  BLI_freelistN(&art->drawcalls);
322 
323  LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) {
324  if (pt->rna_ext.free) {
325  pt->rna_ext.free(pt->rna_ext.data);
326  }
327 
328  BLI_freelistN(&pt->children);
329  }
330 
331  LISTBASE_FOREACH (HeaderType *, ht, &art->headertypes) {
332  if (ht->rna_ext.free) {
333  ht->rna_ext.free(ht->rna_ext.data);
334  }
335  }
336 
337  BLI_freelistN(&art->paneltypes);
338  BLI_freelistN(&art->headertypes);
339  }
340 
341  BLI_freelistN(&st->regiontypes);
342 }
343 
345 {
348  }
349 
351 }
352 
354 {
356  if (st->spaceid == spaceid) {
357  return st;
358  }
359  }
360  return NULL;
361 }
362 
364 {
365  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
366  if (art->regionid == regionid) {
367  return art;
368  }
369  }
370 
371  printf(
372  "Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid);
373  return st->regiontypes.first;
374 }
375 
377 {
378  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
379  if (art->regionid == regionid) {
380  return art;
381  }
382  }
383  return NULL;
384 }
385 
387 {
388  return &spacetypes;
389 }
390 
392 {
393  /* sanity check */
394  SpaceType *stype = BKE_spacetype_from_id(st->spaceid);
395  if (stype) {
396  printf("error: redefinition of spacetype %s\n", stype->name);
397  spacetype_free(stype);
398  MEM_freeN(stype);
399  }
400 
402 }
403 
404 bool BKE_spacetype_exists(int spaceid)
405 {
406  return BKE_spacetype_from_id(spaceid) != NULL;
407 }
408 
409 /* ***************** Space handling ********************** */
410 
412 {
413  LISTBASE_FOREACH (SpaceLink *, sl, lb) {
414  SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
415 
416  /* free regions for pushed spaces */
417  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
418  BKE_area_region_free(st, region);
419  }
420 
421  BLI_freelistN(&sl->regionbase);
422 
423  if (st && st->free) {
424  st->free(sl);
425  }
426  }
427 
428  BLI_freelistN(lb);
429 }
430 
431 static void panel_list_copy(ListBase *newlb, const ListBase *lb)
432 {
433  BLI_listbase_clear(newlb);
434  BLI_duplicatelist(newlb, lb);
435 
436  /* copy panel pointers */
437  Panel *new_panel = newlb->first;
438  Panel *panel = lb->first;
439  for (; new_panel; new_panel = new_panel->next, panel = panel->next) {
440  new_panel->activedata = NULL;
441  memset(&new_panel->runtime, 0x0, sizeof(new_panel->runtime));
442  panel_list_copy(&new_panel->children, &panel->children);
443  }
444 }
445 
447 {
448  ARegion *newar = MEM_dupallocN(region);
449 
450  memset(&newar->runtime, 0x0, sizeof(newar->runtime));
451 
452  newar->prev = newar->next = NULL;
453  BLI_listbase_clear(&newar->handlers);
454  BLI_listbase_clear(&newar->uiblocks);
457  BLI_listbase_clear(&newar->ui_lists);
458  newar->visible = 0;
459  newar->gizmo_map = NULL;
460  newar->regiontimer = NULL;
461  newar->headerstr = NULL;
462  newar->draw_buffer = NULL;
463 
464  /* use optional regiondata callback */
465  if (region->regiondata) {
467 
468  if (art && art->duplicate) {
469  newar->regiondata = art->duplicate(region->regiondata);
470  }
471  else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
472  newar->regiondata = NULL;
473  }
474  else {
475  newar->regiondata = MEM_dupallocN(region->regiondata);
476  }
477  }
478 
479  panel_list_copy(&newar->panels, &region->panels);
480 
482  BLI_duplicatelist(&newar->ui_previews, &region->ui_previews);
483 
484  return newar;
485 }
486 
487 /* from lb_src to lb_dst, lb_dst is supposed to be freed */
488 static void region_copylist(SpaceType *st, ListBase *lb_dst, ListBase *lb_src)
489 {
490  /* to be sure */
491  BLI_listbase_clear(lb_dst);
492 
493  LISTBASE_FOREACH (ARegion *, region, lb_src) {
494  ARegion *region_new = BKE_area_region_copy(st, region);
495  BLI_addtail(lb_dst, region_new);
496  }
497 }
498 
500 {
501  BLI_listbase_clear(lb_dst); /* to be sure */
502 
503  LISTBASE_FOREACH (SpaceLink *, sl, lb_src) {
504  SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
505 
506  if (st && st->duplicate) {
507  SpaceLink *slnew = st->duplicate(sl);
508 
509  BLI_addtail(lb_dst, slnew);
510 
511  region_copylist(st, &slnew->regionbase, &sl->regionbase);
512  }
513  }
514 }
515 
517 {
519  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
520  if (set) {
521  art->do_lock = art->lock;
522  }
523  else {
524  art->do_lock = false;
525  }
526  }
527  }
528 }
529 
531  const ScrArea *area,
532  int region_type)
533 {
534  const bool is_slink_active = slink == area->spacedata.first;
535  const ListBase *regionbase = (is_slink_active) ? &area->regionbase : &slink->regionbase;
536  ARegion *region = NULL;
537 
538  BLI_assert(BLI_findindex(&area->spacedata, slink) != -1);
539 
540  LISTBASE_FOREACH (ARegion *, region_iter, regionbase) {
541  if (region_iter->regiontype == region_type) {
542  region = region_iter;
543  break;
544  }
545  }
546 
547  /* Should really unit test this instead. */
548  BLI_assert(!is_slink_active || region == BKE_area_find_region_type(area, region_type));
549 
550  return region;
551 }
552 
554  struct SpaceLink *sl,
555  ID *old_id,
556  ID *new_id) = NULL;
557 
559 {
560  spacedata_id_remap_cb = func;
561 }
562 
563 void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id)
564 {
565  if (spacedata_id_remap_cb) {
566  spacedata_id_remap_cb(area, sl, id, NULL);
567  }
568 }
569 
574 
576 {
578 }
579 
581 {
583  return;
584  }
585 
586  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
587  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
588  if (region->gizmo_map != NULL) {
589  region_refresh_tag_gizmomap_callback(region->gizmo_map);
590  }
591  }
592  }
593 }
594 
599 
601 {
603 }
604 
606 {
607  MEM_SAFE_FREE(panel->activedata);
608 
609  LISTBASE_FOREACH_MUTABLE (Panel *, child_panel, &panel->children) {
611  }
612 
613  MEM_freeN(panel);
614 }
615 
617 {
618  LISTBASE_FOREACH_MUTABLE (Panel *, panel, panels) {
619  /* Free custom data just for parent panels to avoid a double free. */
620  MEM_SAFE_FREE(panel->runtime.custom_data_ptr);
622  }
623  BLI_listbase_clear(panels);
624 }
625 
627 {
628  if (st) {
630 
631  if (art && art->free) {
632  art->free(region);
633  }
634 
635  if (region->regiondata) {
636  printf("regiondata free error\n");
637  }
638  }
639  else if (region->type && region->type->free) {
640  region->type->free(region);
641  }
642 
644 
645  LISTBASE_FOREACH (uiList *, uilst, &region->ui_lists) {
646  if (uilst->dyn_data && uilst->dyn_data->free_runtime_data_fn) {
647  uilst->dyn_data->free_runtime_data_fn(uilst);
648  }
649  if (uilst->properties) {
650  IDP_FreeProperty(uilst->properties);
651  }
652  MEM_SAFE_FREE(uilst->dyn_data);
653  }
654 
655  if (region->gizmo_map != NULL) {
657  }
658 
659  if (region->runtime.block_name_map != NULL) {
661  region->runtime.block_name_map = NULL;
662  }
663 
664  BLI_freelistN(&region->ui_lists);
665  BLI_freelistN(&region->ui_previews);
666  BLI_freelistN(&region->panels_category);
668 }
669 
671 {
672  SpaceType *st = BKE_spacetype_from_id(area->spacetype);
673 
674  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
675  BKE_area_region_free(st, region);
676  }
677 
678  MEM_SAFE_FREE(area->global);
679  BLI_freelistN(&area->regionbase);
680 
681  BKE_spacedata_freelist(&area->spacedata);
682 
683  BLI_freelistN(&area->actionzones);
684 }
685 
687 {
688  LISTBASE_FOREACH_MUTABLE (ScrArea *, area, &area_map->areabase) {
690  }
691 
692  BLI_freelistN(&area_map->vertbase);
693  BLI_freelistN(&area_map->edgebase);
694  BLI_freelistN(&area_map->areabase);
695 }
696 
698 {
699  screen_free_data(&screen->id);
700 }
701 
702 /* ***************** Screen edges & verts ***************** */
703 
705 {
707  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
708  if (se->v1 == v1 && se->v2 == v2) {
709  return se;
710  }
711  }
712 
713  return NULL;
714 }
715 
717 {
718  if (*v1 > *v2) {
719  ScrVert *tmp = *v1;
720  *v1 = *v2;
721  *v2 = tmp;
722  }
723 }
724 
726 {
727  LISTBASE_FOREACH (ScrVert *, verg, &screen->vertbase) {
728  if (verg->newv == NULL) { /* !!! */
729  ScrVert *v1 = verg->next;
730  while (v1) {
731  if (v1->newv == NULL) { /* !?! */
732  if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) {
733  // printf("doublevert\n");
734  v1->newv = verg;
735  }
736  }
737  v1 = v1->next;
738  }
739  }
740  }
741 
742  /* replace pointers in edges and faces */
743  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
744  if (se->v1->newv) {
745  se->v1 = se->v1->newv;
746  }
747  if (se->v2->newv) {
748  se->v2 = se->v2->newv;
749  }
750  /* edges changed: so.... */
751  BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
752  }
753  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
754  if (area->v1->newv) {
755  area->v1 = area->v1->newv;
756  }
757  if (area->v2->newv) {
758  area->v2 = area->v2->newv;
759  }
760  if (area->v3->newv) {
761  area->v3 = area->v3->newv;
762  }
763  if (area->v4->newv) {
764  area->v4 = area->v4->newv;
765  }
766  }
767 
768  /* remove */
769  LISTBASE_FOREACH_MUTABLE (ScrVert *, verg, &screen->vertbase) {
770  if (verg->newv) {
771  BLI_remlink(&screen->vertbase, verg);
772  MEM_freeN(verg);
773  }
774  }
775 }
776 
778 {
779  /* compare */
780  LISTBASE_FOREACH (ScrEdge *, verg, &screen->edgebase) {
781  ScrEdge *se = verg->next;
782  while (se) {
783  ScrEdge *sn = se->next;
784  if (verg->v1 == se->v1 && verg->v2 == se->v2) {
785  BLI_remlink(&screen->edgebase, se);
786  MEM_freeN(se);
787  }
788  se = sn;
789  }
790  }
791 }
792 
794 {
795  /* sets flags when edge is used in area */
796  int a = 0;
797  LISTBASE_FOREACH_INDEX (ScrArea *, area, &screen->areabase, a) {
798  ScrEdge *se = BKE_screen_find_edge(screen, area->v1, area->v2);
799  if (se == NULL) {
800  printf("error: area %d edge 1 doesn't exist\n", a);
801  }
802  else {
803  se->flag = 1;
804  }
805  se = BKE_screen_find_edge(screen, area->v2, area->v3);
806  if (se == NULL) {
807  printf("error: area %d edge 2 doesn't exist\n", a);
808  }
809  else {
810  se->flag = 1;
811  }
812  se = BKE_screen_find_edge(screen, area->v3, area->v4);
813  if (se == NULL) {
814  printf("error: area %d edge 3 doesn't exist\n", a);
815  }
816  else {
817  se->flag = 1;
818  }
819  se = BKE_screen_find_edge(screen, area->v4, area->v1);
820  if (se == NULL) {
821  printf("error: area %d edge 4 doesn't exist\n", a);
822  }
823  else {
824  se->flag = 1;
825  }
826  }
827  LISTBASE_FOREACH_MUTABLE (ScrEdge *, se, &screen->edgebase) {
828  if (se->flag == 0) {
829  BLI_remlink(&screen->edgebase, se);
830  MEM_freeN(se);
831  }
832  else {
833  se->flag = 0;
834  }
835  }
836 }
837 
839 {
840  /* we assume edges are ok */
841  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
842  se->v1->flag = 1;
843  se->v2->flag = 1;
844  }
845 
846  LISTBASE_FOREACH_MUTABLE (ScrVert *, sv, &screen->vertbase) {
847  if (sv->flag == 0) {
848  BLI_remlink(&screen->vertbase, sv);
849  MEM_freeN(sv);
850  }
851  else {
852  sv->flag = 0;
853  }
854  }
855 }
856 
857 /* ***************** Utilities ********************** */
858 
859 ARegion *BKE_region_find_in_listbase_by_type(const ListBase *regionbase, const int region_type)
860 {
861  LISTBASE_FOREACH (ARegion *, region, regionbase) {
862  if (region->regiontype == region_type) {
863  return region;
864  }
865  }
866 
867  return NULL;
868 }
869 
871 {
872  if (area) {
873  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
874  if (region->regiontype == region_type) {
875  return region;
876  }
877  }
878  }
879 
880  return NULL;
881 }
882 
884 {
885  if (area == NULL) {
886  return NULL;
887  }
888 
889  ARegion *region = BLI_findlink(&area->regionbase, area->region_active_win);
890  if (region && (region->regiontype == RGN_TYPE_WINDOW)) {
891  return region;
892  }
893 
894  /* fallback to any */
896 }
897 
898 ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, const int xy[2])
899 {
900  if (area == NULL) {
901  return NULL;
902  }
903 
904  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
905  if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
906  if (BLI_rcti_isect_pt_v(&region->winrct, xy)) {
907  return region;
908  }
909  }
910  }
911  return NULL;
912 }
913 
914 ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, const int xy[2])
915 {
916  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
917  if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
918  if (BLI_rcti_isect_pt_v(&region->winrct, xy)) {
919  return region;
920  }
921  }
922  }
923  return NULL;
924 }
925 
927 {
928  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
929  if (BLI_findindex(&area->spacedata, sl) != -1) {
930  return area;
931  }
932  }
933 
934  return NULL;
935 }
936 
937 ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min)
938 {
939  ScrArea *big = NULL;
940  int maxsize = 0;
941 
942  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
943  if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
944  if (min <= area->winx && min <= area->winy) {
945  int size = area->winx * area->winy;
946  if (size > maxsize) {
947  maxsize = size;
948  big = area;
949  }
950  }
951  }
952  }
953 
954  return big;
955 }
956 
958  const int spacetype,
959  const int xy[2])
960 {
961  LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) {
962  if (BLI_rcti_isect_pt_v(&area->totrct, xy)) {
963  if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
964  return area;
965  }
966  break;
967  }
968  }
969  return NULL;
970 }
971 ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, const int xy[2])
972 {
973  return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, xy);
974 }
975 
977 {
978  if (v3d->scenelock && v3d->localvd == NULL) {
979  v3d->camera = scene->camera;
980 
981  if (v3d->camera == NULL) {
982  LISTBASE_FOREACH (ARegion *, region, &v3d->regionbase) {
983  if (region->regiontype == RGN_TYPE_WINDOW) {
984  RegionView3D *rv3d = region->regiondata;
985  if (rv3d->persp == RV3D_CAMOB) {
986  rv3d->persp = RV3D_PERSP;
987  }
988  }
989  }
990  }
991  }
992 }
993 
995 {
996  /* are there cameras in the views that are not in the scene? */
997  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
998  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
999  if (sl->spacetype == SPACE_VIEW3D) {
1000  View3D *v3d = (View3D *)sl;
1002  }
1003  }
1004  }
1005 }
1006 
1008 {
1009  const View3DShading *shading_default = DNA_struct_default_get(View3DShading);
1010  memcpy(shading, shading_default, sizeof(*shading));
1011 }
1012 
1013 ARegion *BKE_screen_find_main_region_at_xy(bScreen *screen, const int space_type, const int xy[2])
1014 {
1015  ScrArea *area = BKE_screen_find_area_xy(screen, space_type, xy);
1016  if (!area) {
1017  return NULL;
1018  }
1020 }
1021 
1022 /* Magic zoom calculation, no idea what it signifies, if you find out, tell me! -zr
1023  *
1024  * Simple, its magic dude! Well, to be honest,
1025  * this gives a natural feeling zooming with multiple keypad presses (ton). */
1026 
1027 float BKE_screen_view3d_zoom_to_fac(float camzoom)
1028 {
1029  return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f;
1030 }
1031 
1033 {
1034  return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
1035 }
1036 
1038 {
1039  return ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL);
1040 }
1041 
1042 bool BKE_screen_is_used(const bScreen *screen)
1043 {
1044  return (screen->winid != 0);
1045 }
1046 
1048 {
1049  int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
1050  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1051  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1052  if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
1054  region->alignment = RGN_ALIGN_TOP;
1055  continue;
1056  }
1057  region->alignment = alignment;
1058  }
1059  if (region->regiontype == RGN_TYPE_FOOTER) {
1061  region->alignment = RGN_ALIGN_BOTTOM;
1062  continue;
1063  }
1064  region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
1065  }
1066  }
1067  }
1068  screen->do_refresh = true;
1069 }
1070 
1072 {
1073  if (shading->prop) {
1074  IDP_BlendWrite(writer, shading->prop);
1075  }
1076 }
1077 
1079 {
1080  if (shading->prop) {
1081  BLO_read_data_address(reader, &shading->prop);
1082  IDP_BlendDataRead(reader, &shading->prop);
1083  }
1084 }
1085 
1086 static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
1087 {
1088  BLO_write_struct(writer, ARegion, region);
1089 
1090  if (region->regiondata) {
1091  if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
1092  return;
1093  }
1094 
1095  switch (spacetype) {
1096  case SPACE_VIEW3D:
1097  if (region->regiontype == RGN_TYPE_WINDOW) {
1098  RegionView3D *rv3d = region->regiondata;
1099  BLO_write_struct(writer, RegionView3D, rv3d);
1100 
1101  if (rv3d->localvd) {
1102  BLO_write_struct(writer, RegionView3D, rv3d->localvd);
1103  }
1104  if (rv3d->clipbb) {
1105  BLO_write_struct(writer, BoundBox, rv3d->clipbb);
1106  }
1107  }
1108  else {
1109  printf("regiondata write missing!\n");
1110  }
1111  break;
1112  default:
1113  printf("regiondata write missing!\n");
1114  }
1115  }
1116 }
1117 
1118 static void write_uilist(BlendWriter *writer, uiList *ui_list)
1119 {
1120  BLO_write_struct(writer, uiList, ui_list);
1121 
1122  if (ui_list->properties) {
1123  IDP_BlendWrite(writer, ui_list->properties);
1124  }
1125 }
1126 
1127 static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
1128 {
1129  BLI_mempool *ts = space_outliner->treestore;
1130 
1131  if (ts) {
1132  SpaceOutliner space_outliner_flat = *space_outliner;
1133 
1134  int elems = BLI_mempool_len(ts);
1135  /* linearize mempool to array */
1136  TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
1137 
1138  if (data) {
1139  /* In this block we use the memory location of the treestore
1140  * but _not_ its data, the addresses in this case are UUID's,
1141  * since we can't rely on malloc giving us different values each time.
1142  */
1143  TreeStore ts_flat = {0};
1144 
1145  /* we know the treestore is at least as big as a pointer,
1146  * so offsetting works to give us a UUID. */
1147  void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
1148 
1149  ts_flat.usedelem = elems;
1150  ts_flat.totelem = elems;
1151  ts_flat.data = data_addr;
1152 
1153  BLO_write_struct(writer, SpaceOutliner, space_outliner);
1154 
1155  BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
1156  BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
1157 
1158  MEM_freeN(data);
1159  }
1160  else {
1161  space_outliner_flat.treestore = NULL;
1162  BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
1163  }
1164  }
1165  else {
1166  BLO_write_struct(writer, SpaceOutliner, space_outliner);
1167  }
1168 }
1169 
1170 static void write_panel_list(BlendWriter *writer, ListBase *lb)
1171 {
1172  LISTBASE_FOREACH (Panel *, panel, lb) {
1173  BLO_write_struct(writer, Panel, panel);
1174  write_panel_list(writer, &panel->children);
1175  }
1176 }
1177 
1178 static void write_area(BlendWriter *writer, ScrArea *area)
1179 {
1180  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1181  write_region(writer, region, area->spacetype);
1182  write_panel_list(writer, &region->panels);
1183 
1184  LISTBASE_FOREACH (PanelCategoryStack *, pc_act, &region->panels_category_active) {
1185  BLO_write_struct(writer, PanelCategoryStack, pc_act);
1186  }
1187 
1188  LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
1189  write_uilist(writer, ui_list);
1190  }
1191 
1192  LISTBASE_FOREACH (uiPreview *, ui_preview, &region->ui_previews) {
1193  BLO_write_struct(writer, uiPreview, ui_preview);
1194  }
1195  }
1196 
1197  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1198  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
1199  write_region(writer, region, sl->spacetype);
1200  }
1201 
1202  if (sl->spacetype == SPACE_VIEW3D) {
1203  View3D *v3d = (View3D *)sl;
1204  BLO_write_struct(writer, View3D, v3d);
1205 
1206  if (v3d->localvd) {
1207  BLO_write_struct(writer, View3D, v3d->localvd);
1208  }
1209 
1211  }
1212  else if (sl->spacetype == SPACE_GRAPH) {
1213  SpaceGraph *sipo = (SpaceGraph *)sl;
1214  ListBase tmpGhosts = sipo->runtime.ghost_curves;
1215 
1216  /* temporarily disable ghost curves when saving */
1218 
1219  BLO_write_struct(writer, SpaceGraph, sl);
1220  if (sipo->ads) {
1221  BLO_write_struct(writer, bDopeSheet, sipo->ads);
1222  }
1223 
1224  /* reenable ghost curves */
1225  sipo->runtime.ghost_curves = tmpGhosts;
1226  }
1227  else if (sl->spacetype == SPACE_PROPERTIES) {
1228  BLO_write_struct(writer, SpaceProperties, sl);
1229  }
1230  else if (sl->spacetype == SPACE_FILE) {
1231  SpaceFile *sfile = (SpaceFile *)sl;
1232 
1233  BLO_write_struct(writer, SpaceFile, sl);
1234  if (sfile->params) {
1235  BLO_write_struct(writer, FileSelectParams, sfile->params);
1236  }
1237  if (sfile->asset_params) {
1239  }
1240  }
1241  else if (sl->spacetype == SPACE_SEQ) {
1242  BLO_write_struct(writer, SpaceSeq, sl);
1243  }
1244  else if (sl->spacetype == SPACE_OUTLINER) {
1245  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1246  write_space_outliner(writer, space_outliner);
1247  }
1248  else if (sl->spacetype == SPACE_IMAGE) {
1249  BLO_write_struct(writer, SpaceImage, sl);
1250  }
1251  else if (sl->spacetype == SPACE_TEXT) {
1252  BLO_write_struct(writer, SpaceText, sl);
1253  }
1254  else if (sl->spacetype == SPACE_SCRIPT) {
1255  SpaceScript *scr = (SpaceScript *)sl;
1256  scr->but_refs = NULL;
1257  BLO_write_struct(writer, SpaceScript, sl);
1258  }
1259  else if (sl->spacetype == SPACE_ACTION) {
1260  BLO_write_struct(writer, SpaceAction, sl);
1261  }
1262  else if (sl->spacetype == SPACE_NLA) {
1263  SpaceNla *snla = (SpaceNla *)sl;
1264 
1265  BLO_write_struct(writer, SpaceNla, snla);
1266  if (snla->ads) {
1267  BLO_write_struct(writer, bDopeSheet, snla->ads);
1268  }
1269  }
1270  else if (sl->spacetype == SPACE_NODE) {
1271  SpaceNode *snode = (SpaceNode *)sl;
1272  BLO_write_struct(writer, SpaceNode, snode);
1273 
1274  LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
1275  BLO_write_struct(writer, bNodeTreePath, path);
1276  }
1277  }
1278  else if (sl->spacetype == SPACE_CONSOLE) {
1279  SpaceConsole *con = (SpaceConsole *)sl;
1280 
1281  LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
1282  /* 'len_alloc' is invalid on write, set from 'len' on read */
1283  BLO_write_struct(writer, ConsoleLine, cl);
1284  BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
1285  }
1286  BLO_write_struct(writer, SpaceConsole, sl);
1287  }
1288  else if (sl->spacetype == SPACE_TOPBAR) {
1289  BLO_write_struct(writer, SpaceTopBar, sl);
1290  }
1291  else if (sl->spacetype == SPACE_STATUSBAR) {
1292  BLO_write_struct(writer, SpaceStatusBar, sl);
1293  }
1294  else if (sl->spacetype == SPACE_USERPREF) {
1295  BLO_write_struct(writer, SpaceUserPref, sl);
1296  }
1297  else if (sl->spacetype == SPACE_CLIP) {
1298  BLO_write_struct(writer, SpaceClip, sl);
1299  }
1300  else if (sl->spacetype == SPACE_INFO) {
1301  BLO_write_struct(writer, SpaceInfo, sl);
1302  }
1303  else if (sl->spacetype == SPACE_SPREADSHEET) {
1304  BLO_write_struct(writer, SpaceSpreadsheet, sl);
1305  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1306 
1307  LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
1308  BLO_write_struct(writer, SpreadsheetRowFilter, row_filter);
1309  BLO_write_string(writer, row_filter->value_string);
1310  }
1311 
1312  LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
1313  BLO_write_struct(writer, SpreadsheetColumn, column);
1314  BLO_write_struct(writer, SpreadsheetColumnID, column->id);
1315  BLO_write_string(writer, column->id->name);
1316  /* While the display name is technically runtime data, we write it here, otherwise the row
1317  * filters might not now their type if their region draws before the main region.
1318  * This would ideally be cleared here. */
1319  BLO_write_string(writer, column->display_name);
1320  }
1322  switch (context->type) {
1325  BLO_write_struct(writer, SpreadsheetContextObject, object_context);
1326  break;
1327  }
1330  BLO_write_struct(writer, SpreadsheetContextModifier, modifier_context);
1331  BLO_write_string(writer, modifier_context->modifier_name);
1332  break;
1333  }
1334  case SPREADSHEET_CONTEXT_NODE: {
1337  BLO_write_string(writer, node_context->node_name);
1338  break;
1339  }
1340  }
1341  }
1342  }
1343  }
1344 }
1345 
1347 {
1348  BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
1349  BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
1350  LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
1351  area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
1352 
1353  BLO_write_struct(writer, ScrArea, area);
1354 
1355  BLO_write_struct(writer, ScrGlobalAreaData, area->global);
1356 
1357  write_area(writer, area);
1358 
1359  area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
1360  }
1361 }
1362 
1364 {
1365  BLO_read_list(reader, lb);
1366 
1367  LISTBASE_FOREACH (Panel *, panel, lb) {
1368  panel->runtime_flag = 0;
1369  panel->activedata = NULL;
1370  panel->type = NULL;
1371  panel->runtime.custom_data_ptr = NULL;
1372  direct_link_panel_list(reader, &panel->children);
1373  }
1374 }
1375 
1376 static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
1377 {
1378  memset(&region->runtime, 0x0, sizeof(region->runtime));
1379 
1380  direct_link_panel_list(reader, &region->panels);
1381 
1382  BLO_read_list(reader, &region->panels_category_active);
1383 
1384  BLO_read_list(reader, &region->ui_lists);
1385 
1386  /* The area's search filter is runtime only, so we need to clear the active flag on read. */
1387  region->flag &= ~RGN_FLAG_SEARCH_FILTER_ACTIVE;
1388 
1389  LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
1390  ui_list->type = NULL;
1391  ui_list->dyn_data = NULL;
1392  BLO_read_data_address(reader, &ui_list->properties);
1393  IDP_BlendDataRead(reader, &ui_list->properties);
1394  }
1395 
1396  BLO_read_list(reader, &region->ui_previews);
1397 
1398  if (spacetype == SPACE_EMPTY) {
1399  /* unknown space type, don't leak regiondata */
1400  region->regiondata = NULL;
1401  }
1402  else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
1403  /* Runtime data, don't use. */
1404  region->regiondata = NULL;
1405  }
1406  else {
1407  BLO_read_data_address(reader, &region->regiondata);
1408  if (region->regiondata) {
1409  if (spacetype == SPACE_VIEW3D) {
1410  RegionView3D *rv3d = region->regiondata;
1411 
1412  BLO_read_data_address(reader, &rv3d->localvd);
1413  BLO_read_data_address(reader, &rv3d->clipbb);
1414 
1415  rv3d->render_engine = NULL;
1416  rv3d->sms = NULL;
1417  rv3d->smooth_timer = NULL;
1418 
1419  rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
1420  rv3d->runtime_viewlock = 0;
1421  }
1422  }
1423  }
1424 
1425  region->v2d.sms = NULL;
1426  region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
1428  BLI_listbase_clear(&region->handlers);
1429  BLI_listbase_clear(&region->uiblocks);
1430  region->headerstr = NULL;
1431  region->visible = 0;
1432  region->type = NULL;
1433  region->do_draw = 0;
1434  region->gizmo_map = NULL;
1435  region->regiontimer = NULL;
1436  region->draw_buffer = NULL;
1437  memset(&region->drawrct, 0, sizeof(region->drawrct));
1438 }
1439 
1440 /* for the saved 2.50 files without regiondata */
1442 {
1443  LISTBASE_FOREACH (ARegion *, region, regions) {
1444  if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
1445  RegionView3D *rv3d;
1446 
1447  rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
1448  rv3d->persp = (char)v3d->persp;
1449  rv3d->view = (char)v3d->view;
1450  rv3d->dist = v3d->dist;
1451  copy_v3_v3(rv3d->ofs, v3d->ofs);
1452  copy_qt_qt(rv3d->viewquat, v3d->viewquat);
1453  }
1454  }
1455 
1456  /* this was not initialized correct always */
1457  if (v3d->gridsubdiv == 0) {
1458  v3d->gridsubdiv = 10;
1459  }
1460 }
1461 
1463 {
1464  BLO_read_list(reader, &(area->spacedata));
1465  BLO_read_list(reader, &(area->regionbase));
1466 
1467  BLI_listbase_clear(&area->handlers);
1468  area->type = NULL; /* spacetype callbacks */
1469 
1470  /* Should always be unset so that rna_Area_type_get works correctly. */
1471  area->butspacetype = SPACE_EMPTY;
1472 
1473  area->region_active_win = -1;
1474 
1476 
1477  BLO_read_data_address(reader, &area->global);
1478 
1479  /* if we do not have the spacetype registered we cannot
1480  * free it, so don't allocate any new memory for such spacetypes. */
1481  if (!BKE_spacetype_exists(area->spacetype)) {
1482  /* Hint for versioning code to replace deprecated space types. */
1483  area->butspacetype = area->spacetype;
1484 
1485  area->spacetype = SPACE_EMPTY;
1486  }
1487 
1488  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1489  direct_link_region(reader, region, area->spacetype);
1490  }
1491 
1492  /* accident can happen when read/save new file with older version */
1493  /* 2.50: we now always add spacedata for info */
1494  if (area->spacedata.first == NULL) {
1495  SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
1496  area->spacetype = sinfo->spacetype = SPACE_INFO;
1497  BLI_addtail(&area->spacedata, sinfo);
1498  }
1499  /* add local view3d too */
1500  else if (area->spacetype == SPACE_VIEW3D) {
1501  BKE_screen_view3d_do_versions_250(area->spacedata.first, &area->regionbase);
1502  }
1503 
1504  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1505  BLO_read_list(reader, &(sl->regionbase));
1506 
1507  /* if we do not have the spacetype registered we cannot
1508  * free it, so don't allocate any new memory for such spacetypes. */
1509  if (!BKE_spacetype_exists(sl->spacetype)) {
1510  sl->spacetype = SPACE_EMPTY;
1511  }
1512 
1513  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
1514  direct_link_region(reader, region, sl->spacetype);
1515  }
1516 
1517  if (sl->spacetype == SPACE_VIEW3D) {
1518  View3D *v3d = (View3D *)sl;
1519 
1520  memset(&v3d->runtime, 0x0, sizeof(v3d->runtime));
1521 
1522  if (v3d->gpd) {
1523  BLO_read_data_address(reader, &v3d->gpd);
1524  BKE_gpencil_blend_read_data(reader, v3d->gpd);
1525  }
1526  BLO_read_data_address(reader, &v3d->localvd);
1527 
1528  /* render can be quite heavy, set to solid on load */
1529  if (v3d->shading.type == OB_RENDER) {
1530  v3d->shading.type = OB_SOLID;
1531  }
1532  v3d->shading.prev_type = OB_SOLID;
1533 
1535 
1537  }
1538  else if (sl->spacetype == SPACE_GRAPH) {
1539  SpaceGraph *sipo = (SpaceGraph *)sl;
1540 
1541  BLO_read_data_address(reader, &sipo->ads);
1542  memset(&sipo->runtime, 0x0, sizeof(sipo->runtime));
1543  }
1544  else if (sl->spacetype == SPACE_NLA) {
1545  SpaceNla *snla = (SpaceNla *)sl;
1546 
1547  BLO_read_data_address(reader, &snla->ads);
1548  }
1549  else if (sl->spacetype == SPACE_OUTLINER) {
1550  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1551 
1552  /* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
1553  * frees and use of freed memory. this could happen because of a
1554  * bug fixed in revision 58959 where the treestore memory address
1555  * was not unique */
1556  TreeStore *ts = BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore);
1557  space_outliner->treestore = NULL;
1558  if (ts) {
1560 
1561  space_outliner->treestore = BLI_mempool_create(
1562  sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
1563  if (ts->usedelem && elems) {
1564  for (int i = 0; i < ts->usedelem; i++) {
1565  TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
1566  *new_elem = elems[i];
1567  }
1568  }
1569  /* we only saved what was used */
1570  space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
1571  }
1572  space_outliner->tree.first = space_outliner->tree.last = NULL;
1573  space_outliner->runtime = NULL;
1574  }
1575  else if (sl->spacetype == SPACE_IMAGE) {
1576  SpaceImage *sima = (SpaceImage *)sl;
1577 
1578  sima->iuser.scene = NULL;
1579  sima->scopes.waveform_1 = NULL;
1580  sima->scopes.waveform_2 = NULL;
1581  sima->scopes.waveform_3 = NULL;
1582  sima->scopes.vecscope = NULL;
1583  sima->scopes.ok = 0;
1584 
1585  /* WARNING: gpencil data is no longer stored directly in sima after 2.5
1586  * so sacrifice a few old files for now to avoid crashes with new files!
1587  * committed: r28002 */
1588 #if 0
1589  sima->gpd = newdataadr(fd, sima->gpd);
1590  if (sima->gpd) {
1591  BKE_gpencil_blend_read_data(fd, sima->gpd);
1592  }
1593 #endif
1594  }
1595  else if (sl->spacetype == SPACE_NODE) {
1596  SpaceNode *snode = (SpaceNode *)sl;
1597 
1598  if (snode->gpd) {
1599  BLO_read_data_address(reader, &snode->gpd);
1600  BKE_gpencil_blend_read_data(reader, snode->gpd);
1601  }
1602 
1603  BLO_read_list(reader, &snode->treepath);
1604  snode->edittree = NULL;
1605  snode->runtime = NULL;
1606  }
1607  else if (sl->spacetype == SPACE_TEXT) {
1608  SpaceText *st = (SpaceText *)sl;
1609  memset(&st->runtime, 0x0, sizeof(st->runtime));
1610  }
1611  else if (sl->spacetype == SPACE_SEQ) {
1612  SpaceSeq *sseq = (SpaceSeq *)sl;
1613 
1614  /* grease pencil data is not a direct data and can't be linked from direct_link*
1615  * functions, it should be linked from lib_link* functions instead
1616  *
1617  * otherwise it'll lead to lost grease data on open because it'll likely be
1618  * read from file after all other users of grease pencil and newdataadr would
1619  * simple return NULL here (sergey)
1620  */
1621 #if 0
1622  if (sseq->gpd) {
1623  sseq->gpd = newdataadr(fd, sseq->gpd);
1624  BKE_gpencil_blend_read_data(fd, sseq->gpd);
1625  }
1626 #endif
1627  sseq->scopes.reference_ibuf = NULL;
1628  sseq->scopes.zebra_ibuf = NULL;
1629  sseq->scopes.waveform_ibuf = NULL;
1630  sseq->scopes.sep_waveform_ibuf = NULL;
1631  sseq->scopes.vector_ibuf = NULL;
1632  sseq->scopes.histogram_ibuf = NULL;
1633  memset(&sseq->runtime, 0x0, sizeof(sseq->runtime));
1634  }
1635  else if (sl->spacetype == SPACE_PROPERTIES) {
1636  SpaceProperties *sbuts = (SpaceProperties *)sl;
1637 
1638  sbuts->path = NULL;
1639  sbuts->texuser = NULL;
1640  sbuts->mainbo = sbuts->mainb;
1641  sbuts->mainbuser = sbuts->mainb;
1642  sbuts->runtime = NULL;
1643  }
1644  else if (sl->spacetype == SPACE_CONSOLE) {
1645  SpaceConsole *sconsole = (SpaceConsole *)sl;
1646 
1647  BLO_read_list(reader, &sconsole->scrollback);
1648  BLO_read_list(reader, &sconsole->history);
1649 
1650  /* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
1651  * from left to right. the right-most expression sets the result of the comma
1652  * expression as a whole. */
1653  LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
1654  BLO_read_data_address(reader, &cl->line);
1655  if (cl->line) {
1656  /* the allocted length is not written, so reset here */
1657  cl->len_alloc = cl->len + 1;
1658  }
1659  else {
1660  BLI_remlink(&sconsole->history, cl);
1661  MEM_freeN(cl);
1662  }
1663  }
1664  }
1665  else if (sl->spacetype == SPACE_FILE) {
1666  SpaceFile *sfile = (SpaceFile *)sl;
1667 
1668  /* this sort of info is probably irrelevant for reloading...
1669  * plus, it isn't saved to files yet!
1670  */
1671  sfile->folders_prev = sfile->folders_next = NULL;
1673  sfile->files = NULL;
1674  sfile->layout = NULL;
1675  sfile->op = NULL;
1676  sfile->previews_timer = NULL;
1677  sfile->tags = 0;
1678  sfile->runtime = NULL;
1679  BLO_read_data_address(reader, &sfile->params);
1680  BLO_read_data_address(reader, &sfile->asset_params);
1681  if (sfile->params) {
1682  sfile->params->rename_id = NULL;
1683  }
1684  if (sfile->asset_params) {
1686  }
1687  }
1688  else if (sl->spacetype == SPACE_ACTION) {
1689  SpaceAction *saction = (SpaceAction *)sl;
1690 
1691  memset(&saction->runtime, 0x0, sizeof(saction->runtime));
1692  }
1693  else if (sl->spacetype == SPACE_CLIP) {
1694  SpaceClip *sclip = (SpaceClip *)sl;
1695 
1696  sclip->scopes.track_search = NULL;
1697  sclip->scopes.track_preview = NULL;
1698  sclip->scopes.ok = 0;
1699  }
1700  else if (sl->spacetype == SPACE_SPREADSHEET) {
1701  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1702 
1703  sspreadsheet->runtime = NULL;
1704  BLO_read_list(reader, &sspreadsheet->row_filters);
1705  LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
1706  BLO_read_data_address(reader, &row_filter->value_string);
1707  }
1708  BLO_read_list(reader, &sspreadsheet->columns);
1709  LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
1710  BLO_read_data_address(reader, &column->id);
1711  BLO_read_data_address(reader, &column->id->name);
1712  /* While the display name is technically runtime data, it is loaded here, otherwise the row
1713  * filters might not now their type if their region draws before the main region.
1714  * This would ideally be cleared here. */
1715  BLO_read_data_address(reader, &column->display_name);
1716  }
1717 
1718  BLO_read_list(reader, &sspreadsheet->context_path);
1720  switch (context->type) {
1721  case SPREADSHEET_CONTEXT_NODE: {
1723  BLO_read_data_address(reader, &node_context->node_name);
1724  break;
1725  }
1728  BLO_read_data_address(reader, &modifier_context->modifier_name);
1729  break;
1730  }
1732  break;
1733  }
1734  }
1735  }
1736  }
1737  }
1738 
1739  BLI_listbase_clear(&area->actionzones);
1740 
1741  BLO_read_data_address(reader, &area->v1);
1742  BLO_read_data_address(reader, &area->v2);
1743  BLO_read_data_address(reader, &area->v3);
1744  BLO_read_data_address(reader, &area->v4);
1745 }
1746 
1748 {
1749  BLO_read_list(reader, &area_map->vertbase);
1750  BLO_read_list(reader, &area_map->edgebase);
1751  BLO_read_list(reader, &area_map->areabase);
1752  LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
1753  direct_link_area(reader, area);
1754  }
1755 
1756  /* edges */
1757  LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
1758  BLO_read_data_address(reader, &se->v1);
1759  BLO_read_data_address(reader, &se->v2);
1760  BKE_screen_sort_scrvert(&se->v1, &se->v2);
1761 
1762  if (se->v1 == NULL) {
1763  BLI_remlink(&area_map->edgebase, se);
1764 
1765  return false;
1766  }
1767  }
1768 
1769  return true;
1770 }
1771 
1773 {
1774  BLO_read_id_address(reader, parent_id->lib, &area->full);
1775 
1776  memset(&area->runtime, 0x0, sizeof(area->runtime));
1777 
1778  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1779  switch (sl->spacetype) {
1780  case SPACE_VIEW3D: {
1781  View3D *v3d = (View3D *)sl;
1782 
1783  BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
1784  BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
1785 
1786  if (v3d->localvd) {
1787  BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
1788  }
1789  break;
1790  }
1791  case SPACE_GRAPH: {
1792  SpaceGraph *sipo = (SpaceGraph *)sl;
1793  bDopeSheet *ads = sipo->ads;
1794 
1795  if (ads) {
1796  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1797  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1798  }
1799  break;
1800  }
1801  case SPACE_PROPERTIES: {
1802  SpaceProperties *sbuts = (SpaceProperties *)sl;
1803  BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
1804  if (sbuts->pinid == NULL) {
1805  sbuts->flag &= ~SB_PIN_CONTEXT;
1806  }
1807  break;
1808  }
1809  case SPACE_FILE: {
1810  SpaceFile *sfile = (SpaceFile *)sl;
1812  break;
1813  }
1814  case SPACE_ACTION: {
1815  SpaceAction *saction = (SpaceAction *)sl;
1816  bDopeSheet *ads = &saction->ads;
1817 
1818  if (ads) {
1819  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1820  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1821  }
1822 
1823  BLO_read_id_address(reader, parent_id->lib, &saction->action);
1824  break;
1825  }
1826  case SPACE_IMAGE: {
1827  SpaceImage *sima = (SpaceImage *)sl;
1828 
1829  BLO_read_id_address(reader, parent_id->lib, &sima->image);
1830  BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
1831 
1832  /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
1833  * so fingers crossed this works fine!
1834  */
1835  BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
1836  break;
1837  }
1838  case SPACE_SEQ: {
1839  SpaceSeq *sseq = (SpaceSeq *)sl;
1840 
1841  /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
1842  * so fingers crossed this works fine!
1843  */
1844  BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
1845  break;
1846  }
1847  case SPACE_NLA: {
1848  SpaceNla *snla = (SpaceNla *)sl;
1849  bDopeSheet *ads = snla->ads;
1850 
1851  if (ads) {
1852  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1853  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1854  }
1855  break;
1856  }
1857  case SPACE_TEXT: {
1858  SpaceText *st = (SpaceText *)sl;
1859 
1860  BLO_read_id_address(reader, parent_id->lib, &st->text);
1861  break;
1862  }
1863  case SPACE_SCRIPT: {
1864  SpaceScript *scpt = (SpaceScript *)sl;
1865  /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
1866  if (scpt->script) {
1867  BLO_read_id_address(reader, parent_id->lib, &scpt->script);
1868  if (scpt->script) {
1869  SCRIPT_SET_NULL(scpt->script);
1870  }
1871  }
1872  break;
1873  }
1874  case SPACE_OUTLINER: {
1875  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1876  BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
1877 
1878  if (space_outliner->treestore) {
1879  TreeStoreElem *tselem;
1880  BLI_mempool_iter iter;
1881 
1882  BLI_mempool_iternew(space_outliner->treestore, &iter);
1883  while ((tselem = BLI_mempool_iterstep(&iter))) {
1884  BLO_read_id_address(reader, NULL, &tselem->id);
1885  }
1886  /* rebuild hash table, because it depends on ids too */
1887  space_outliner->storeflag |= SO_TREESTORE_REBUILD;
1888  }
1889  break;
1890  }
1891  case SPACE_NODE: {
1892  SpaceNode *snode = (SpaceNode *)sl;
1893 
1894  /* node tree can be stored locally in id too, link this first */
1895  BLO_read_id_address(reader, parent_id->lib, &snode->id);
1896  BLO_read_id_address(reader, parent_id->lib, &snode->from);
1897 
1898  bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
1899  if (ntree) {
1900  snode->nodetree = ntree;
1901  }
1902  else {
1903  BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
1904  }
1905 
1906  bNodeTreePath *path;
1907  for (path = snode->treepath.first; path; path = path->next) {
1908  if (path == snode->treepath.first) {
1909  /* first nodetree in path is same as snode->nodetree */
1910  path->nodetree = snode->nodetree;
1911  }
1912  else {
1913  BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
1914  }
1915 
1916  if (!path->nodetree) {
1917  break;
1918  }
1919  }
1920 
1921  /* remaining path entries are invalid, remove */
1922  bNodeTreePath *path_next;
1923  for (; path; path = path_next) {
1924  path_next = path->next;
1925 
1926  BLI_remlink(&snode->treepath, path);
1927  MEM_freeN(path);
1928  }
1929 
1930  /* edittree is just the last in the path,
1931  * set this directly since the path may have been shortened above */
1932  if (snode->treepath.last) {
1933  path = snode->treepath.last;
1934  snode->edittree = path->nodetree;
1935  }
1936  else {
1937  snode->edittree = NULL;
1938  }
1939  break;
1940  }
1941  case SPACE_CLIP: {
1942  SpaceClip *sclip = (SpaceClip *)sl;
1943  BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
1944  BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
1945  break;
1946  }
1947  case SPACE_SPREADSHEET: {
1948  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1950  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
1952  reader, parent_id->lib, &((SpreadsheetContextObject *)context)->object);
1953  }
1954  }
1955  break;
1956  }
1957  default:
1958  break;
1959  }
1960  }
1961 }
void BKE_gpencil_blend_read_data(struct BlendDataReader *reader, struct bGPdata *gpd)
Definition: gpencil.c:183
void BKE_previewimg_free(struct PreviewImage **prv)
Definition: icons.cc:283
void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv)
Definition: icons.cc:615
void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv)
void IDP_BlendWrite(struct BlendWriter *writer, const struct IDProperty *prop)
#define IDP_BlendDataRead(reader, prop)
Definition: BKE_idprop.h:321
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1093
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition: BKE_idtype.h:41
@ IDTYPE_FLAGS_ONLY_APPEND
Definition: BKE_idtype.h:36
@ IDTYPE_FLAGS_NO_COPY
Definition: BKE_idtype.h:30
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2008
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag)
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(_data, _func_call)
@ IDWALK_INCLUDE_UI
int BKE_lib_query_foreachid_process_flags_get(struct LibraryForeachIDData *data)
Definition: lib_query.c:109
@ IDWALK_CB_USER_ONE
Definition: BKE_lib_query.h:79
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:73
@ IDWALK_CB_EMBEDDED
Definition: BKE_lib_query.h:48
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:33
#define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag)
struct bNodeTree * ntreeFromID(struct ID *id)
Definition: node.cc:3231
#define BLI_assert(a)
Definition: BLI_assert.h:46
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
Definition: BLI_listbase.h:344
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define M_SQRT2
Definition: BLI_math_base.h:29
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
Definition: BLI_mempool.c:498
@ BLI_MEMPOOL_ALLOW_ITER
Definition: BLI_mempool.h:107
void * BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_mempool.c:577
int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1)
Definition: BLI_mempool.c:434
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition: BLI_mempool.c:253
void void void void * BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
Definition: BLI_mempool.c:319
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
#define ELEM(...)
#define POINTER_OFFSET(v, ofs)
Compatibility-like things for windows.
#define BLO_read_data_address(reader, ptr_p)
void * BLO_read_get_new_data_address_no_us(BlendDataReader *reader, const void *old_address)
Definition: readfile.c:5128
#define BLO_write_struct_array_at_address(writer, struct_name, array_size, address, data_ptr)
#define BLO_write_struct_at_address_with_filecode(writer, filecode, struct_name, address, data_ptr)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5172
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
Definition: writefile.c:1601
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_write_struct_list(writer, struct_name, list_ptr)
void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
Definition: writefile.c:1489
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
#define BLT_I18NCONTEXT_ID_SCREEN
void BPY_callback_screen_free(struct ARegionType *art)
#define FILTER_ID_SCR
Definition: DNA_ID.h:935
@ INDEX_ID_SCR
Definition: DNA_ID.h:1052
@ ID_SCR
Definition: DNA_ID_enums.h:60
#define ID_SCRN
Definition: DNA_ID_enums.h:91
Object groups, one object can be in many groups at once.
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:29
@ OB_SOLID
@ OB_RENDER
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
@ RGN_FLAG_TEMP_REGIONDATA
@ RGN_FLAG_SEARCH_FILTER_ACTIVE
@ SCREENFULL
@ SCREENMAXIMIZED
#define AREAMAP_FROM_SCREEN(screen)
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_WINDOW
@ RGN_TYPE_FOOTER
@ RGN_TYPE_HEADER
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_TOP
struct bScreen bScreen
#define RGN_TYPE_ANY
@ SPREADSHEET_CONTEXT_OBJECT
@ SPREADSHEET_CONTEXT_MODIFIER
@ SPREADSHEET_CONTEXT_NODE
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_CONSOLE
@ SPACE_OUTLINER
@ SPACE_STATUSBAR
@ SPACE_TOPBAR
@ SPACE_NODE
@ SPACE_SPREADSHEET
@ SPACE_USERPREF
@ SPACE_FILE
@ SPACE_PROPERTIES
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_SCRIPT
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SPACE_INFO
#define SCRIPT_SET_NULL(_script)
@ FILE_TAG_REBUILD_MAIN_FILES
@ SB_PIN_CONTEXT
@ SO_TREESTORE_CLEANUP
@ SO_TREESTORE_REBUILD
#define SPACE_TYPE_ANY
@ USER_HEADER_BOTTOM
#define RV3D_CAMOB
#define RV3D_PAINTING
#define RV3D_PERSP
#define RV3D_NAVIGATING
_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 v1
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static void init_data(ModifierData *md)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
#define powf(x, y)
Definition: cuda/compat.h:103
Scene scene
DEGForeachIDComponentCallback callback
SyclQueue void void size_t num_bytes void
bNodeTree * ntree
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned a[3]
Definition: RandGen.cpp:78
static void area(int d1, int d2, int e1, int e2, float weights[2])
static int node_context(const bContext *C, const char *member, bContextDataResult *result)
Definition: space_node.cc:834
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
static void * newdataadr(FileData *fd, const void *adr)
Definition: readfile.c:1600
void BKE_spacetype_register(SpaceType *st)
Definition: screen.c:391
ARegion * BKE_screen_find_region_xy(bScreen *screen, const int regiontype, const int xy[2])
Definition: screen.c:914
ScrArea * BKE_screen_find_area_from_space(struct bScreen *screen, SpaceLink *sl)
Definition: screen.c:926
ARegion * BKE_area_find_region_xy(ScrArea *area, const int regiontype, const int xy[2])
Definition: screen.c:898
static void area_region_panels_free_recursive(Panel *panel)
Definition: screen.c:605
void BKE_screen_remove_unused_scrverts(bScreen *screen)
Definition: screen.c:838
void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading)
Definition: screen.c:1078
void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id)
Definition: screen.c:563
static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
Definition: screen.c:1127
bool BKE_screen_is_used(const bScreen *screen)
Definition: screen.c:1042
void BKE_region_callback_refresh_tag_gizmomap_set(void(*callback)(struct wmGizmoMap *))
Definition: screen.c:575
void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
Definition: screen.c:976
void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map)
Definition: screen.c:1346
ARegionType * BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid)
Definition: screen.c:363
void BKE_spacedata_draw_locks(bool set)
Definition: screen.c:516
ScrArea * BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, const int spacetype, const int xy[2])
Definition: screen.c:957
void BKE_screen_remove_unused_scredges(bScreen *screen)
Definition: screen.c:793
static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: screen.c:227
void BKE_spacedata_copylist(ListBase *lb_dst, ListBase *lb_src)
Definition: screen.c:499
ScrEdge * BKE_screen_find_edge(const bScreen *screen, ScrVert *v1, ScrVert *v2)
Definition: screen.c:704
static void screen_foreach_id_dopesheet(LibraryForeachIDData *data, bDopeSheet *ads)
Definition: screen.c:77
static void spacetype_free(SpaceType *st)
Definition: screen.c:315
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
Definition: screen.c:1032
void BKE_spacedata_callback_id_remap_set(void(*func)(ScrArea *area, SpaceLink *sl, ID *, ID *))
Definition: screen.c:558
static ListBase spacetypes
Definition: screen.c:312
void BKE_screen_remove_double_scrverts(bScreen *screen)
Definition: screen.c:725
bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
Definition: screen.c:242
void BKE_spacetypes_free(void)
Definition: screen.c:344
ARegion * BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *area, int region_type)
Definition: screen.c:530
void BKE_spacedata_freelist(ListBase *lb)
Definition: screen.c:411
ARegionType * BKE_regiontype_from_id(const SpaceType *st, int regionid)
Definition: screen.c:376
static void write_area(BlendWriter *writer, ScrArea *area)
Definition: screen.c:1178
static void region_copylist(SpaceType *st, ListBase *lb_dst, ListBase *lb_src)
Definition: screen.c:488
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition: screen.c:353
void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading)
Definition: screen.c:1071
static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: screen.c:263
void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2)
Definition: screen.c:716
static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
Definition: screen.c:1363
void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrArea *area)
Definition: screen.c:1772
static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
Definition: screen.c:1086
ARegion * BKE_screen_find_main_region_at_xy(bScreen *screen, const int space_type, const int xy[2])
Definition: screen.c:1013
void BKE_screen_area_free(ScrArea *area)
Definition: screen.c:670
bool BKE_spacetype_exists(int spaceid)
Definition: screen.c:404
void BKE_screen_gizmo_tag_refresh(struct bScreen *screen)
Definition: screen.c:580
static void write_panel_list(BlendWriter *writer, ListBase *lb)
Definition: screen.c:1170
void BKE_screen_header_alignment_reset(bScreen *screen)
Definition: screen.c:1047
const ListBase * BKE_spacetypes_list(void)
Definition: screen.c:386
void BKE_screen_area_map_free(ScrAreaMap *area_map)
Definition: screen.c:686
void BKE_area_region_free(SpaceType *st, ARegion *region)
Definition: screen.c:626
void BKE_region_callback_free_gizmomap_set(void(*callback)(struct wmGizmoMap *))
Definition: screen.c:600
ARegion * BKE_area_find_region_active_win(ScrArea *area)
Definition: screen.c:883
ScrArea * BKE_screen_find_area_xy(bScreen *screen, const int spacetype, const int xy[2])
Definition: screen.c:971
bool BKE_screen_is_fullscreen_area(const bScreen *screen)
Definition: screen.c:1037
bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *area_map)
Definition: screen.c:1747
static void(* region_free_gizmomap_callback)(struct wmGizmoMap *)
Definition: screen.c:598
void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene)
Definition: screen.c:994
static void(* region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *)
Definition: screen.c:573
void BKE_screen_remove_double_scredges(bScreen *screen)
Definition: screen.c:777
float BKE_screen_view3d_zoom_to_fac(float camzoom)
Definition: screen.c:1027
ScrArea * BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min)
Definition: screen.c:937
IDTypeInfo IDType_ID_SCR
Definition: screen.c:278
void BKE_screen_view3d_shading_init(View3DShading *shading)
Definition: screen.c:1007
static void(* spacedata_id_remap_cb)(struct ScrArea *area, struct SpaceLink *sl, ID *old_id, ID *new_id)
Definition: screen.c:553
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition: screen.c:870
static void direct_link_area(BlendDataReader *reader, ScrArea *area)
Definition: screen.c:1462
static void write_uilist(BlendWriter *writer, uiList *ui_list)
Definition: screen.c:1118
ARegion * BKE_region_find_in_listbase_by_type(const ListBase *regionbase, const int region_type)
Definition: screen.c:859
void BKE_area_region_panels_free(ListBase *panels)
Definition: screen.c:616
static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: screen.c:215
void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
Definition: screen.c:1441
void BKE_screen_free_data(bScreen *screen)
Definition: screen.c:697
static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
Definition: screen.c:1376
ARegion * BKE_area_region_copy(const SpaceType *st, const ARegion *region)
Definition: screen.c:446
void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area)
Definition: screen.c:85
static void panel_list_copy(ListBase *newlb, const ListBase *lb)
Definition: screen.c:431
static void screen_free_data(ID *id)
Definition: screen.c:57
#define min(a, b)
Definition: sort.c:35
void(* free)(struct ARegion *)
Definition: BKE_screen.h:169
void *(* duplicate)(void *poin)
Definition: BKE_screen.h:172
struct GHash * block_name_map
struct wmTimer * regiontimer
ARegion_Runtime runtime
void * regiondata
struct ARegion * prev
ListBase panels_category_active
ListBase ui_previews
char * headerstr
struct ARegion * next
ListBase panels_category
ListBase panels
ListBase ui_lists
ListBase handlers
struct wmDrawBuffer * draw_buffer
short regiontype
struct wmGizmoMap * gizmo_map
struct ARegionType * type
ListBase uiblocks
FileSelectParams base_params
const ID * rename_id
short id_code
Definition: BKE_idtype.h:114
Definition: DNA_ID.h:368
struct Library * lib
Definition: DNA_ID.h:372
char name[66]
Definition: DNA_ID.h:378
struct Scene * scene
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
struct Mask * mask
struct ImBuf * track_preview
struct ImBuf * track_search
Panel_Runtime runtime
void * activedata
struct Panel * next
ListBase children
struct RenderEngine * render_engine
struct SmoothView3DStore * sms
float viewquat[4]
struct RegionView3D * localvd
struct wmTimer * smooth_timer
struct BoundBox * clipbb
struct Object * camera
float * waveform_3
float * waveform_2
float * waveform_1
float * vecscope
ListBase vertbase
ListBase edgebase
ListBase areabase
ScrVert * v1
struct ScrEdge * next
ScrVert * v2
struct ImBuf * reference_ibuf
struct ImBuf * waveform_ibuf
struct ImBuf * sep_waveform_ibuf
struct ImBuf * zebra_ibuf
struct ImBuf * histogram_ibuf
struct ImBuf * vector_ibuf
bAction * action
bDopeSheet ads
SpaceAction_Runtime runtime
struct MovieClipScopes scopes
struct MovieClip * clip
MaskSpaceInfo mask_info
ListBase scrollback
struct FileLayout * layout
struct wmOperator * op
ListBase * folders_prev
struct FileList * files
FileSelectParams * params
struct wmTimer * previews_timer
FileAssetSelectParams * asset_params
ListBase * folders_next
ListBase folder_histories
SpaceFile_Runtime * runtime
struct bDopeSheet * ads
SpaceGraph_Runtime runtime
struct Scopes scopes
MaskSpaceInfo mask_info
struct ImageUser iuser
struct bGPdata * gpd
struct Image * image
struct bDopeSheet * ads
SpaceNode_Runtime * runtime
struct ID * from
struct bGPdata * gpd
ListBase treepath
struct bNodeTree * edittree
struct ID * id
struct bNodeTree * nodetree
struct TreeStoreElem search_tse
SpaceOutliner_Runtime * runtime
struct BLI_mempool * treestore
struct SpaceProperties_Runtime * runtime
struct Script * script
SpaceSeqRuntime runtime
struct SequencerScopes scopes
struct bGPdata * gpd
SpaceSpreadsheet_Runtime * runtime
char name[BKE_ST_MAXNAME]
Definition: BKE_screen.h:65
TreeStoreElem * data
char alpha_vert
struct SmoothView2DStore * sms
char alpha_hor
struct IDProperty * prop
View3D_Runtime runtime
struct Object * camera
short gridsubdiv
struct View3D * localvd
short scenelock
struct Object * ob_center
ListBase regionbase
View3DShading shading
struct Collection * filter_grp
struct bNodeTree * nodetree
struct bNodeTreePath * next
char do_refresh
ListBase edgebase
void * context
PreviewImage * preview
ListBase regionbase
struct wmTooltipState * tool_tip
ListBase vertbase
struct wmTimer * animtimer
char scrubbing
ListBase areabase
struct ARegion * active_region
IDProperty * properties
int xy[2]
Definition: wm_draw.c:135