HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colorChannelTask.h
Go to the documentation of this file.
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_COLORCHANNEL_TASK_H
25 #define HDX_COLORCHANNEL_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/path.h"
29 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hdx/task.h"
31 #include "pxr/imaging/hdx/tokens.h"
33 
35 
36 /// \class HdxColorChannelTask
37 ///
38 /// A task for choosing a color channel for display.
39 ///
41 {
42 public:
43  HDX_API
44  HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
45 
46  HDX_API
47  ~HdxColorChannelTask() override;
48 
49  /// Prepare the tasks resources
50  HDX_API
51  void Prepare(HdTaskContext* ctx,
52  HdRenderIndex* renderIndex) override;
53 
54  /// Execute the color channel task
55  HDX_API
56  void Execute(HdTaskContext* ctx) override;
57 
58 protected:
59  /// Sync the render pass resources
60  HDX_API
61  void _Sync(HdSceneDelegate* delegate,
62  HdTaskContext* ctx,
63  HdDirtyBits* dirtyBits) override;
64 
65 private:
66  HdxColorChannelTask() = delete;
67  HdxColorChannelTask(const HdxColorChannelTask &) = delete;
68  HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
69 
70  // Utility function to update the shader uniform parameters.
71  // Returns true if the values were updated. False if unchanged.
72  bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY);
73 
74  /// Apply the color channel filtering.
75  void _ApplyColorChannel();
76 
77  // This struct must match ParameterBuffer in colorChannel.glslfx.
78  // Be careful to remember the std430 rules.
79  struct _ParameterBuffer
80  {
81  float screenSize[2];
82  int channel;
83  bool operator==(const _ParameterBuffer& other) const {
84  return channel == other.channel &&
85  screenSize[0] == other.screenSize[0] &&
86  screenSize[1] == other.screenSize[1];
87  }
88  };
89 
90  std::unique_ptr<class HdxFullscreenShader> _compositor;
91  _ParameterBuffer _parameterData;
92 
93  // The color channel to be rendered (see HdxColorChannelTokens for the
94  // possible values).
95  TfToken _channel;
96 };
97 
98 
99 /// \class HdxColorChannelTaskParams
100 ///
101 /// ColorChannelTask parameters.
102 ///
104 {
106 
107  // Specifies which output color channel should be drawn. Defaults to 'color'
108  // (untouched RGBA).
109  TfToken channel = HdxColorChannelTokens->color;
110 };
111 
112 // VtValue requirements
113 HDX_API
114 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
115 HDX_API
116 bool operator==(const HdxColorChannelTaskParams& lhs,
117  const HdxColorChannelTaskParams& rhs);
118 HDX_API
119 bool operator!=(const HdxColorChannelTaskParams& lhs,
120  const HdxColorChannelTaskParams& rhs);
121 
122 
124 
125 #endif
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
uint32_t HdDirtyBits
Definition: types.h:158
HDX_API ~HdxColorChannelTask() override
#define HDX_API
Definition: api.h:40
Definition: token.h:87
HDX_API std::ostream & operator<<(std::ostream &out, const HdxColorChannelTaskParams &pv)
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Definition: path.h:291
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
Definition: task.h:44
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HDX_API bool operator==(const HdxColorChannelTaskParams &lhs, const HdxColorChannelTaskParams &rhs)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDX_API void Execute(HdTaskContext *ctx) override
Execute the color channel task.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.