Blender  V2.93
deg_builder_cache.h
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) 2018 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "intern/depsgraph_type.h"
29 
30 #include "RNA_access.h"
31 
32 struct ID;
33 struct PointerRNA;
34 struct PropertyRNA;
35 
36 namespace blender {
37 namespace deg {
38 
39 class DepsgraphBuilderCache;
40 
41 /* Identifier for animated property. */
43  public:
47  AnimatedPropertyID(ID *id, StructRNA *type, const char *property_name);
48  AnimatedPropertyID(ID *id, StructRNA *type, void *data, const char *property_name);
49 
50  uint64_t hash() const;
51  friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b);
52 
53  /* Corresponds to PointerRNA.data. */
54  void *data;
56 
57  MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyID");
58 };
59 
61  public:
63 
65 
66  void tagPropertyAsAnimated(const AnimatedPropertyID &property_id);
67  void tagPropertyAsAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
68 
69  bool isPropertyAnimated(const AnimatedPropertyID &property_id);
70  bool isPropertyAnimated(const PointerRNA *pointer_rna, const PropertyRNA *property_rna);
71 
72  /* The storage is fully initialized from all F-Curves from corresponding ID. */
74 
75  /* indexed by PointerRNA.data. */
77 
78  MEM_CXX_CLASS_ALLOC_FUNCS("AnimatedPropertyStorage");
79 };
80 
81 /* Cached data which can be re-used by multiple builders. */
83  public:
85 
86  /* Makes sure storage for animated properties exists and initialized for the given ID. */
89 
90  /* Shortcuts to go through ensureInitializedAnimatedPropertyStorage and its
91  * isPropertyAnimated.
92  *
93  * NOTE: Avoid using for multiple subsequent lookups, query for the storage once, and then query
94  * the storage.
95  *
96  * TODO(sergey): Technically, this makes this class something else than just a cache, but what is
97  * the better name? */
98  template<typename... Args> bool isPropertyAnimated(ID *id, Args... args)
99  {
101  id);
102  return animated_property_storage->isPropertyAnimated(args...);
103  }
104 
106 
107  MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache");
108 };
109 
110 } // namespace deg
111 } // namespace blender
_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 type
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")
bool isPropertyAnimated(const AnimatedPropertyID &property_id)
void initializeFromID(DepsgraphBuilderCache *builder_cache, ID *id)
void tagPropertyAsAnimated(const AnimatedPropertyID &property_id)
AnimatedPropertyStorage * ensureAnimatedPropertyStorage(ID *id)
bool isPropertyAnimated(ID *id, Args... args)
Map< ID *, AnimatedPropertyStorage * > animated_property_storage_map_
AnimatedPropertyStorage * ensureInitializedAnimatedPropertyStorage(ID *id)
MEM_CXX_CLASS_ALLOC_FUNCS("DepsgraphBuilderCache")
AnimatedPropertyStorage * animated_property_storage
DepsgraphBuilderCache * builder_cache
PointerRNA pointer_rna
static unsigned a[3]
Definition: RandGen.cpp:92
unsigned __int64 uint64_t
Definition: stdint.h:93
Definition: DNA_ID.h:273