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 USD_CLIP_CACHE_H
25 #define 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  bool PopulateClipsForPrim(
59  const SdfPath& path, const PcpPrimIndex& primIndex);
60 
64  struct Clips
65  {
66  Clips() : sourceLayerIndex(0) {}
67 
68  void Swap(Clips& rhs)
69  {
70  std::swap(sourceLayerStack, rhs.sourceLayerStack);
71  std::swap(sourcePrimPath, rhs.sourcePrimPath);
72  std::swap(sourceLayerIndex, rhs.sourceLayerIndex);
73  std::swap(manifestClip, rhs.manifestClip);
74  std::swap(valueClips, rhs.valueClips);
75  }
76 
77  PcpLayerStackPtr sourceLayerStack;
78  SdfPath sourcePrimPath;
79  size_t sourceLayerIndex;
80  Usd_ClipRefPtr manifestClip;
81  Usd_ClipRefPtrVector valueClips;
82  };
83 
89  SdfLayerHandleSet GetUsedLayers() const;
90 
97  const std::vector<Clips>&
98  GetClipsForPrim(const SdfPath& path) const;
99 
105  struct Lifeboat
106  {
107  std::vector<Clips> _clips;
108  };
109 
115  void InvalidateClipsForPrim(const SdfPath& path, Lifeboat* lifeboat);
116 
117 private:
118  const std::vector<Clips>&
119  _GetClipsForPrim_NoLock(const SdfPath& path) const;
120 
121  // Map from prim path to all clips that apply to that prim, including
122  // ancestral clips. This map is sparse; only prims where clips are
123  // authored will have entries.
124  typedef SdfPathTable<std::vector<Clips> >_ClipTable;
125  _ClipTable _table;
126  mutable tbb::mutex _mutex;
127 };
128 
129 
130 PXR_NAMESPACE_CLOSE_SCOPE
131 
132 #endif // 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