All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colorizeSelectionTask.h
1 //
2 // Copyright 2019 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 HDX_COLORIZE_SELECTION_TASK_H
25 #define HDX_COLORIZE_SELECTION_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/compositor.h"
30 #include "pxr/imaging/hdx/progressiveTask.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
39 {
41  : enableSelection(false)
42  , selectionColor(0)
43  , locateColor(0)
44  , primIdBufferPath()
45  , instanceIdBufferPath()
46  , elementIdBufferPath()
47  {}
48 
49  bool enableSelection;
50  GfVec4f selectionColor;
51  GfVec4f locateColor;
52 
53  SdfPath primIdBufferPath;
54  SdfPath instanceIdBufferPath;
55  SdfPath elementIdBufferPath;
56 };
57 
64 {
65 public:
66  HDX_API
67  HdxColorizeSelectionTask(HdSceneDelegate* delegate, SdfPath const& id);
68 
69  HDX_API
70  virtual ~HdxColorizeSelectionTask();
71 
73  virtual bool IsConverged() const override;
74 
76  HDX_API
77  virtual void Sync(HdSceneDelegate* delegate,
78  HdTaskContext* ctx,
79  HdDirtyBits* dirtyBits) override;
80 
82  HDX_API
83  virtual void Prepare(HdTaskContext* ctx,
84  HdRenderIndex* renderIndex) override;
85 
87  HDX_API
88  virtual void Execute(HdTaskContext* ctx) override;
89 
90 private:
91  // The core colorizing logic of this task: given the ID buffers and the
92  // selection buffer, produce a color output at each pixel.
93  void _ColorizeSelection();
94 
95  GfVec4f _GetColorForMode(int mode) const;
96 
97  // Incoming data
99 
100  int _lastVersion;
101  bool _hasSelection;
102  VtIntArray _selectionOffsets;
103 
104  HdRenderBuffer *_primId;
105  HdRenderBuffer *_instanceId;
106  HdRenderBuffer *_elementId;
107 
108  uint8_t *_outputBuffer;
109  size_t _outputBufferSize;
110  bool _converged;
111 
112  HdxCompositor _compositor;
113 };
114 
115 // VtValue requirements
116 HDX_API
117 std::ostream& operator<<(std::ostream& out,
119 HDX_API
121  const HdxColorizeSelectionTaskParams& rhs);
122 HDX_API
124  const HdxColorizeSelectionTaskParams& rhs);
125 
126 PXR_NAMESPACE_CLOSE_SCOPE
127 
128 #endif // HDX_COLORIZE_SELECTION_TASK_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
A task for taking ID buffer data and turning it into a &quot;selection overlay&quot; that can be composited o...
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute the task.
This is an interface class that declares that derived tasks implement some form of progressive render...
virtual bool IsConverged() const override
Hooks for progressive rendering.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
virtual HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
This class is a utility for rendering deep raytracer or aov output (color/depth) to the GL framebuffe...
Definition: compositor.h:47
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the render pass resources.
Input parameters for HdxColorizeSelectionTask.
A render buffer is a handle to a data resource that can be rendered into, such as a 2d image for a dr...
Definition: renderBuffer.h:48