Blender V4.3
deg_eval_runtime_backup.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2017 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
12
13#include "BLI_utildefines.h"
14
15#include "DRW_engine.hh"
16
17namespace blender::deg {
18
20 : have_backup(false),
21 id_data({nullptr}),
22 animation_backup(depsgraph),
23 scene_backup(depsgraph),
24 sound_backup(depsgraph),
25 object_backup(depsgraph),
26 drawdata_ptr(nullptr),
27 movieclip_backup(depsgraph),
28 volume_backup(depsgraph)
29{
30 drawdata_backup.first = drawdata_backup.last = nullptr;
31}
32
34{
36 return;
37 }
38 have_backup = true;
39
40 /* Clear, so freeing the expanded data doesn't touch this Python reference. */
41 id_data.py_instance = id->py_instance;
42 id->py_instance = nullptr;
43
45
46 const ID_Type id_type = GS(id->name);
47 switch (id_type) {
48 case ID_OB:
49 object_backup.init_from_object(reinterpret_cast<Object *>(id));
50 break;
51 case ID_SCE:
52 scene_backup.init_from_scene(reinterpret_cast<Scene *>(id));
53 break;
54 case ID_SO:
55 sound_backup.init_from_sound(reinterpret_cast<bSound *>(id));
56 break;
57 case ID_MC:
58 movieclip_backup.init_from_movieclip(reinterpret_cast<MovieClip *>(id));
59 break;
60 case ID_VO:
61 volume_backup.init_from_volume(reinterpret_cast<Volume *>(id));
62 break;
63 default:
64 break;
65 }
66
67 /* Note that we never free GPU draw data from here since that's not
68 * safe for threading and draw data is likely to be re-used. */
70 if (drawdata_ptr != nullptr) {
72 drawdata_ptr->first = drawdata_ptr->last = nullptr;
73 }
74}
75
77{
78 if (!have_backup) {
79 return;
80 }
81
82 id->py_instance = id_data.py_instance;
83
85
86 const ID_Type id_type = GS(id->name);
87 switch (id_type) {
88 case ID_OB:
89 object_backup.restore_to_object(reinterpret_cast<Object *>(id));
90 break;
91 case ID_SCE:
92 scene_backup.restore_to_scene(reinterpret_cast<Scene *>(id));
93 break;
94 case ID_SO:
95 sound_backup.restore_to_sound(reinterpret_cast<bSound *>(id));
96 break;
97 case ID_MC:
98 movieclip_backup.restore_to_movieclip(reinterpret_cast<MovieClip *>(id));
99 break;
100 case ID_VO:
101 volume_backup.restore_to_volume(reinterpret_cast<Volume *>(id));
102 break;
103 default:
104 break;
105 }
106 if (drawdata_ptr != nullptr) {
108 }
109}
110
111} // namespace blender::deg
ID_Type
@ ID_MC
@ ID_VO
@ ID_SO
@ ID_SCE
@ ID_OB
DrawDataList * DRW_drawdatalist_from_id(ID *id)
struct blender::deg::RuntimeBackup::@186 id_data
RuntimeBackup(const Depsgraph *depsgraph)
const Depsgraph * depsgraph
#define GS(x)
Definition iris.cc:202
bool deg_eval_copy_is_expanded(const ID *id_cow)
struct DrawData * first
Definition DNA_ID.h:54
struct DrawData * last
Definition DNA_ID.h:54
Definition DNA_ID.h:413