HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sprim.h
Go to the documentation of this file.
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_IMAGING_HD_SPRIM_H
25 #define PXR_IMAGING_HD_SPRIM_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/types.h"
31 
32 #include "pxr/usd/sdf/path.h"
33 #include "pxr/base/vt/value.h"
34 
36 
37 class HdSceneDelegate;
38 class HdRenderParam;
39 
40 /// \class HdSprim
41 ///
42 /// Sprim (state prim) is a base class of managing state for non-drawable
43 /// scene entity (e.g. camera, light). Similar to Rprim, Sprim communicates
44 /// scene delegate and tracks the changes through change tracker, then updates
45 /// data cached in Hd (either on CPU or GPU).
46 ///
47 /// Unlike Rprim, Sprim doesn't produce draw items. The data cached in HdSprim
48 /// may be used by HdTask or by HdShader.
49 ///
50 /// The lifetime of HdSprim is owned by HdRenderIndex.
51 ///
52 class HdSprim {
53 public:
54  HD_API
55  HdSprim(SdfPath const & id);
56  HD_API
57  virtual ~HdSprim();
58 
59  /// Returns the identifier by which this state is known. This
60  /// identifier is a common associative key used by the SceneDelegate,
61  /// RenderIndex, and for binding to the state (e.g. camera, light)
62  SdfPath const& GetId() const { return _id; }
63 
64  /// Synchronizes state from the delegate to this object.
65  /// @param[in, out] dirtyBits: On input specifies which state is
66  /// is dirty and can be pulled from the scene
67  /// delegate.
68  /// On output specifies which bits are still
69  /// dirty and were not cleaned by the sync.
70  ///
71  virtual void Sync(HdSceneDelegate *sceneDelegate,
72  HdRenderParam *renderParam,
73  HdDirtyBits *dirtyBits) = 0;
74 
75  /// Finalizes object resources. This function might not delete resources,
76  /// but it should deal with resource ownership so that the sprim is
77  /// deletable.
78  HD_API
79  virtual void Finalize(HdRenderParam *renderParam);
80 
81  /// Returns the minimal set of dirty bits to place in the
82  /// change tracker for use in the first sync of this prim.
83  /// Typically this would be all dirty bits.
84  virtual HdDirtyBits GetInitialDirtyBitsMask() const = 0;
85 
86 private:
87  SdfPath _id;
88 };
89 
90 
92 
93 #endif // PXR_IMAGING_HD_SPRIM_H
SdfPath const & GetId() const
Definition: sprim.h:62
uint32_t HdDirtyBits
Definition: types.h:127
#define HD_API
Definition: api.h:40
HD_API HdSprim(SdfPath const &id)
virtual HD_API ~HdSprim()
Definition: path.h:288
virtual HdDirtyBits GetInitialDirtyBitsMask() const =0
Definition: sprim.h:52
virtual HD_API void Finalize(HdRenderParam *renderParam)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits)=0