Blender  V2.93
deg_eval_runtime_backup.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2017 Blender Foundation.
17  * All rights reserved.
18  */
19 
25 
27 
28 #include "BLI_utildefines.h"
29 
30 #include "DRW_engine.h"
31 
32 namespace blender::deg {
33 
35  : have_backup(false),
36  id_data({nullptr}),
37  animation_backup(depsgraph),
38  scene_backup(depsgraph),
39  sound_backup(depsgraph),
40  object_backup(depsgraph),
41  drawdata_ptr(nullptr),
42  movieclip_backup(depsgraph),
43  volume_backup(depsgraph)
44 {
45  drawdata_backup.first = drawdata_backup.last = nullptr;
46 }
47 
49 {
51  return;
52  }
53  have_backup = true;
54 
55  id_data.py_instance = id->py_instance;
56 
58 
59  const ID_Type id_type = GS(id->name);
60  switch (id_type) {
61  case ID_OB:
62  object_backup.init_from_object(reinterpret_cast<Object *>(id));
63  break;
64  case ID_SCE:
65  scene_backup.init_from_scene(reinterpret_cast<Scene *>(id));
66  break;
67  case ID_SO:
68  sound_backup.init_from_sound(reinterpret_cast<bSound *>(id));
69  break;
70  case ID_MC:
71  movieclip_backup.init_from_movieclip(reinterpret_cast<MovieClip *>(id));
72  break;
73  case ID_VO:
74  volume_backup.init_from_volume(reinterpret_cast<Volume *>(id));
75  break;
76  default:
77  break;
78  }
79 
80  /* Note that we never free GPU draw data from here since that's not
81  * safe for threading and draw data is likely to be re-used. */
83  if (drawdata_ptr != nullptr) {
85  drawdata_ptr->first = drawdata_ptr->last = nullptr;
86  }
87 }
88 
90 {
91  if (!have_backup) {
92  return;
93  }
94 
95  id->py_instance = id_data.py_instance;
96 
98 
99  const ID_Type id_type = GS(id->name);
100  switch (id_type) {
101  case ID_OB:
102  object_backup.restore_to_object(reinterpret_cast<Object *>(id));
103  break;
104  case ID_SCE:
105  scene_backup.restore_to_scene(reinterpret_cast<Scene *>(id));
106  break;
107  case ID_SO:
108  sound_backup.restore_to_sound(reinterpret_cast<bSound *>(id));
109  break;
110  case ID_MC:
111  movieclip_backup.restore_to_movieclip(reinterpret_cast<MovieClip *>(id));
112  break;
113  case ID_VO:
114  volume_backup.restore_to_volume(reinterpret_cast<Volume *>(id));
115  break;
116  default:
117  break;
118  }
119  if (drawdata_ptr != nullptr) {
121  }
122 }
123 
124 } // namespace blender::deg
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_MC
Definition: DNA_ID_enums.h:85
@ ID_VO
Definition: DNA_ID_enums.h:95
@ ID_SO
Definition: DNA_ID_enums.h:76
@ ID_SCE
Definition: DNA_ID_enums.h:57
@ ID_OB
Definition: DNA_ID_enums.h:59
struct DrawDataList * DRW_drawdatalist_from_id(struct ID *id)
Definition: draw_manager.c:869
struct blender::deg::RuntimeBackup::@184 id_data
RuntimeBackup(const Depsgraph *depsgraph)
const Depsgraph * depsgraph
#define GS(x)
Definition: iris.c:241
bool deg_copy_on_write_is_expanded(const ID *id_cow)
struct DrawData * first
Definition: DNA_ID.h:59
struct DrawData * last
Definition: DNA_ID.h:59
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283