Blender V4.3
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
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
14
15#include "RNA_access.hh"
16
17struct ID;
18struct PointerRNA;
19struct PropertyRNA;
20
21namespace blender::deg {
22
23class DepsgraphBuilderCache;
24
25/* Identifier for animated property. */
27 public:
29 AnimatedPropertyID(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
30 AnimatedPropertyID(const PointerRNA &pointer_rna, const PropertyRNA *property_rna);
31 AnimatedPropertyID(const ID *id, StructRNA *type, const char *property_name);
32 AnimatedPropertyID(const ID *id, StructRNA *type, void *data, const char *property_name);
33
34 uint64_t hash() const;
35 friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b);
36
37 /* Corresponds to PointerRNA.data. */
38 const void *data;
40
41 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID");
42};
43
45 public:
47
48 void initializeFromID(DepsgraphBuilderCache *builder_cache, const ID *id);
49
50 void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
51 void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
52
53 bool isPropertyAnimated(const AnimatedPropertyID &property_id);
54 bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
55
56 bool isAnyPropertyAnimated(const PointerRNA *pointer_rna);
57
58 /* The storage is fully initialized from all F-Curves from corresponding ID. */
60
61 /* indexed by PointerRNA.data. */
64
65 MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage");
66};
67
68/* Cached data which can be re-used by multiple builders. */
70 public:
72
73 /* Makes sure storage for animated properties exists and initialized for the given ID. */
76
77 /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
78 * isPropertyAnimated.
79 *
80 * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
81 * the storage.
82 *
83 * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
84 * the better name? */
85 template<typename... Args> bool isPropertyAnimated(const ID *id, Args... args)
86 {
88 id);
89 return animated_property_storage->isPropertyAnimated(args...);
90 }
91
93 {
95 ptr->owner_id);
96 return animated_property_storage->isAnyPropertyAnimated(ptr);
97 }
98
100
101 MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache");
102};
103
104} // namespace blender::deg
Read Guarded memory(de)allocation.
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)
local_group_size(16, 16) .push_constant(Type b
unsigned __int64 uint64_t
Definition stdint.h:90
Definition DNA_ID.h:413
ID * owner_id
Definition RNA_types.hh:40
PointerRNA * ptr
Definition wm_files.cc:4126