HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flattenedDataSourceProvider.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 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_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
25 #define PXR_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
26 
27 #include "pxr/imaging/hd/api.h"
28 
31 #include "pxr/usd/sdf/path.h"
32 
34 
35 class HdSceneIndexBase;
37  std::shared_ptr<class HdFlattenedDataSourceProvider>;
38 
39 /// \class HdFlattenedDataSourceProvider.
40 ///
41 /// Given to HdFlatteningSceneIndex to determine how to compute the
42 /// flattened data source which is in the prim container data
43 /// source.
44 ///
46 {
47 public:
48  class Context
49  {
50  public:
52  const HdSceneIndexBase &flatteningSceneIndex,
53  const SdfPath &primPath,
54  const TfToken &name,
55  const HdContainerDataSourceHandle &inputPrimDataSource)
56  : _flatteningSceneIndex(flatteningSceneIndex)
57  , _primPath(primPath)
58  , _name(name)
59  , _inputPrimDataSource(inputPrimDataSource)
60  {
61  }
62 
63  // Returns data source of input scene index which is in
64  // the prim container data source.
65  HD_API
66  HdContainerDataSourceHandle GetInputDataSource() const;
67  // Returns flattened data source which is in the flattened
68  // container data source of the parent prim.
69  HD_API
70  HdContainerDataSourceHandle GetFlattenedDataSourceFromParentPrim() const;
71 
72  private:
73  const HdSceneIndexBase &_flatteningSceneIndex;
74  const SdfPath &_primPath;
75  const TfToken &_name;
76  const HdContainerDataSourceHandle &_inputPrimDataSource;
77  };
78 
79  /// Returns flattened data source.
80  virtual HdContainerDataSourceHandle GetFlattenedDataSource(
81  const Context &ctx) const = 0;
82 
83  /// If data source locators are dirtied in the input scene index, the
84  /// locators relevant for the input data source serving this provider
85  /// are extracted and made relative to the input data source.
86  ///
87  /// They are later used to invalidate the flattened data source of the
88  /// dirtied prim and its descendants and send prim dirtied messages to
89  /// the descendants.
90  ///
91  /// Example: If a prim dirtied for locator xform:matrix was received, the
92  /// flattening scene index will call the flattened data source provider
93  /// for xform. The locators given to ComputeDirtyLocatorsForDescendants
94  /// will be { matrix }. If ComputeDirtyLocatorsForDescendants sets it to
95  /// the universal set, the flatening scene index will emit a prim dirtied
96  /// locator xform for the descendants.
97  ///
98  /// The implementation of ComputeDirtyLocatorsForDescendants gives a chance
99  /// to drop locators or expand the locator set in between.
100  ///
101  /// Note that ComputeDirtyLocatorsForDescendants will never be called with
102  /// the empty or universal set as these cases are already handled by the
103  /// callee.
104  ///
106  HdDataSourceLocatorSet * locators) const = 0;
107 };
108 
109 namespace HdMakeDataSourceContainingFlattenedDataSourceProvider
110 {
111 
112 template<typename T>
115 {
116  using DataSource =
118  return DataSource::New(std::make_shared<T>());
119 }
120 
121 }
122 
124 
125 #endif
virtual HdContainerDataSourceHandle GetFlattenedDataSource(const Context &ctx) const =0
Returns flattened data source.
HdTypedSampledDataSource< HdFlattenedDataSourceProviderSharedPtr >::Handle Make()
HD_API HdContainerDataSourceHandle GetFlattenedDataSourceFromParentPrim() const
#define HD_API
Definition: api.h:40
HD_API HdContainerDataSourceHandle GetInputDataSource() const
std::shared_ptr< class HdFlattenedDataSourceProvider > HdFlattenedDataSourceProviderSharedPtr
Definition: token.h:87
class OCIOEXPORT Context
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:290
Context(const HdSceneIndexBase &flatteningSceneIndex, const SdfPath &primPath, const TfToken &name, const HdContainerDataSourceHandle &inputPrimDataSource)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual void ComputeDirtyLocatorsForDescendants(HdDataSourceLocatorSet *locators) const =0