Loading...
Searching...
No Matches
flattenedDataSourceProvider.h
1//
2// Copyright 2023 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
8#define PXR_IMAGING_HD_FLATTENED_DATA_SOURCE_PROVIDER_H
9
10#include "pxr/imaging/hd/api.h"
11
12#include "pxr/imaging/hd/dataSource.h"
13#include "pxr/imaging/hd/retainedDataSource.h"
14#include "pxr/imaging/hd/sceneIndex.h"
15#include "pxr/usd/sdf/path.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
20using HdFlattenedDataSourceProviderSharedPtr =
21 std::shared_ptr<class HdFlattenedDataSourceProvider>;
22
29class HdFlattenedDataSourceProvider
30{
31public:
32 class Context
33 {
34 public:
35 Context(
36 const HdSceneIndexBase &flatteningSceneIndex,
37 const SdfPath &primPath,
38 const TfToken &name,
39 const HdSceneIndexPrim &inputPrim)
40 : _flatteningSceneIndex(flatteningSceneIndex)
41 , _primPath(primPath)
42 , _name(name)
43 , _inputPrim(inputPrim)
44 {
45 }
46
47 // Returns data source of input scene index which is in
48 // the prim container data source.
49 HD_API
50 HdContainerDataSourceHandle GetInputDataSource() const;
51 // Returns flattened data source which is in the flattened
52 // container data source of the parent prim.
53 HD_API
54 HdContainerDataSourceHandle GetFlattenedDataSourceFromParentPrim() const;
55 // Returns the type of the prim from the input scene index.
56 HD_API
57 const TfToken &GetInputPrimType() const {
58 return _inputPrim.primType;
59 }
60
61 private:
62 const HdSceneIndexBase &_flatteningSceneIndex;
63 const SdfPath &_primPath;
64 const TfToken &_name;
65 const HdSceneIndexPrim _inputPrim;
66 };
67
68 HD_API
69 virtual ~HdFlattenedDataSourceProvider();
70
72 virtual HdContainerDataSourceHandle GetFlattenedDataSource(
73 const Context &ctx) const = 0;
74
97 virtual void ComputeDirtyLocatorsForDescendants(
98 HdDataSourceLocatorSet * locators) const = 0;
99};
100
101namespace HdMakeDataSourceContainingFlattenedDataSourceProvider
102{
103
104template<typename T>
106Make()
107{
108 using DataSource =
110 return DataSource::New(std::make_shared<T>());
111}
112
113}
114
115PXR_NAMESPACE_CLOSE_SCOPE
116
117#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:54
A datasource representing a concretely-typed sampled value.
Definition: dataSource.h:193
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35