All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clipCache.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_USD_CLIP_CACHE_H
25 #define PXR_USD_USD_CLIP_CACHE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/clip.h"
29 #include "pxr/usd/sdf/pathTable.h"
30 
31 #include <tbb/mutex.h>
32 #include <vector>
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 
37 class PcpPrimIndex;
38 
44 class Usd_ClipCache
45 {
46  Usd_ClipCache(Usd_ClipCache const &) = delete;
47  Usd_ClipCache &operator=(Usd_ClipCache const &) = delete;
48 public:
49  Usd_ClipCache();
50  ~Usd_ClipCache();
51 
58  struct ConcurrentPopulationContext
59  {
60  explicit ConcurrentPopulationContext(Usd_ClipCache &cache);
61  ~ConcurrentPopulationContext();
62  Usd_ClipCache &_cache;
63  tbb::mutex _mutex;
64  };
65 
72  bool PopulateClipsForPrim(
73  const SdfPath& path, const PcpPrimIndex& primIndex);
74 
78  struct Clips
79  {
80  Clips() : sourceLayerIndex(0) {}
81 
82  void Swap(Clips& rhs)
83  {
84  std::swap(sourceLayerStack, rhs.sourceLayerStack);
85  std::swap(sourcePrimPath, rhs.sourcePrimPath);
86  std::swap(sourceLayerIndex, rhs.sourceLayerIndex);
87  std::swap(manifestClip, rhs.manifestClip);
88  std::swap(valueClips, rhs.valueClips);
89  }
90 
91  PcpLayerStackPtr sourceLayerStack;
92  SdfPath sourcePrimPath;
93  size_t sourceLayerIndex;
94  Usd_ClipRefPtr manifestClip;
95  Usd_ClipRefPtrVector valueClips;
96  };
97 
103  SdfLayerHandleSet GetUsedLayers() const;
104 
111  const std::vector<Clips>&
112  GetClipsForPrim(const SdfPath& path) const;
113 
119  struct Lifeboat
120  {
121  std::vector<Clips> _clips;
122  };
123 
132  void InvalidateClipsForPrim(const SdfPath& path, Lifeboat* lifeboat);
133 
134 private:
135  inline const std::vector<Clips>&
136  _GetClipsForPrim_NoLock(const SdfPath& path) const;
137 
138  // Map from prim path to all clips that apply to that prim, including
139  // ancestral clips. This map is sparse; only prims where clips are
140  // authored will have entries.
141  typedef SdfPathTable<std::vector<Clips> >_ClipTable;
142  _ClipTable _table;
143  ConcurrentPopulationContext *_concurrentPopulationContext;
144 };
145 
146 
147 PXR_NAMESPACE_CLOSE_SCOPE
148 
149 #endif // PXR_USD_USD_CLIP_CACHE_H
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:77
void swap(UsdStageLoadRules &l, UsdStageLoadRules &r)
Swap the contents of rules l and r.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
A mapping from SdfPath to MappedType, somewhat similar to map&lt;SdfPath, MappedType&gt; and TfHashMap&lt;SdfP...
Definition: pathTable.h:84