Loading...
Searching...
No Matches
flattenedDataSourceProvider.h
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
29#include "pxr/imaging/hd/dataSource.h"
30#include "pxr/imaging/hd/retainedDataSource.h"
31#include "pxr/usd/sdf/path.h"
32
33PXR_NAMESPACE_OPEN_SCOPE
34
36using HdFlattenedDataSourceProviderSharedPtr =
37 std::shared_ptr<class HdFlattenedDataSourceProvider>;
38
45class HdFlattenedDataSourceProvider
46{
47public:
48 class Context
49 {
50 public:
51 Context(
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
80 virtual HdContainerDataSourceHandle GetFlattenedDataSource(
81 const Context &ctx) const = 0;
82
105 virtual void ComputeDirtyLocatorsForDescendants(
106 HdDataSourceLocatorSet * locators) const = 0;
107};
108
109namespace HdMakeDataSourceContainingFlattenedDataSourceProvider
110{
111
112template<typename T>
114Make()
115{
116 using DataSource =
118 return DataSource::New(std::make_shared<T>());
119}
120
121}
122
123PXR_NAMESPACE_CLOSE_SCOPE
124
125#endif
Represents a set of data source locators closed under descendancy.
Similar to HdRetainedSampledDataSource but provides strongly typed semantics.
Abstract interface to scene data.
Definition: sceneIndex.h:65
A datasource representing a concretely-typed sampled value.
Definition: dataSource.h:210
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88