Blender V5.0
deg_builder_cache.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
13#include "RNA_types.hh"
14
15#include "BLI_map.hh"
16#include "BLI_set.hh"
17
18struct ID;
19struct PointerRNA;
20struct PropertyRNA;
21struct StructRNA;
22
23namespace blender::deg {
24
26
27/* Identifier for animated property. */
29 public:
31 AnimatedPropertyID(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
32 AnimatedPropertyID(const PointerRNA &pointer_rna, const PropertyRNA *property_rna);
33 AnimatedPropertyID(const ID *id, StructRNA *type, const char *property_name);
34 AnimatedPropertyID(const ID *id, StructRNA *type, void *data, const char *property_name);
35
36 uint64_t hash() const;
37 friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b);
38
39 /* Corresponds to PointerRNA.data. */
40 const void *data;
42
43 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID");
44};
45
47 public:
49
50 void initializeFromID(DepsgraphBuilderCache *builder_cache, const ID *id);
51
52 void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
53 void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
54
55 bool isPropertyAnimated(const AnimatedPropertyID &property_id);
56 bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
57
58 bool isAnyPropertyAnimated(const PointerRNA *pointer_rna);
59
60 /* The storage is fully initialized from all F-Curves from corresponding ID. */
62
63 /* indexed by PointerRNA.data. */
66
67 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage");
68};
69
70/* Cached data which can be re-used by multiple builders. */
72 public:
74
75 /* Makes sure storage for animated properties exists and initialized for the given ID. */
78
79 /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
80 * isPropertyAnimated.
81 *
82 * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
83 * the storage.
84 *
85 * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
86 * the better name? */
87 template<typename... Args> bool isPropertyAnimated(const ID *id, Args... args)
88 {
90 id);
91 return animated_property_storage->isPropertyAnimated(args...);
92 }
93
95 {
97 ptr->owner_id);
98 return animated_property_storage->isAnyPropertyAnimated(ptr);
99 }
100
102
103 MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache");
104};
105
106} // namespace blender::deg
Read Guarded memory(de)allocation.
unsigned long long int uint64_t
MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID")
friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b)
Set< AnimatedPropertyID > animated_properties_set
MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage")
void initializeFromID(DepsgraphBuilderCache *builder_cache, const ID *id)
bool isAnyPropertyAnimated(const PointerRNA *pointer_rna)
bool isPropertyAnimated(const AnimatedPropertyID &property_id)
void tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
Map< const ID *, AnimatedPropertyStorage * > animated_property_storage_map_
bool isPropertyAnimated(const ID *id, Args... args)
bool isAnyPropertyAnimated(const PointerRNA *ptr)
AnimatedPropertyStorage * ensureInitializedAnimatedPropertyStorage(const ID *id)
MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache")
AnimatedPropertyStorage * ensureAnimatedPropertyStorage(const ID *id)
Definition DNA_ID.h:414
PointerRNA * ptr
Definition wm_files.cc:4238