All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
subtextureIdentifier.h
1 //
2 // Copyright 2020 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_ST_SUBTEXTURE_IDENTIFIER_H
25 #define PXR_IMAGING_HD_ST_SUBTEXTURE_IDENTIFIER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
30 #include "pxr/base/tf/token.h"
31 
32 #include <memory>
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
37 
46 {
47 public:
48  using ID = size_t;
49 
50  HDST_API
51  virtual std::unique_ptr<HdStSubtextureIdentifier> Clone() const = 0;
52 
53  HDST_API
54  virtual ~HdStSubtextureIdentifier();
55 
56 protected:
57  HDST_API
58  friend size_t hash_value(const HdStSubtextureIdentifier &subId);
59 
60  virtual ID _Hash() const = 0;
61 };
62 
63 HDST_API
64 size_t hash_value(const HdStSubtextureIdentifier &subId);
65 
73 {
74 public:
77  HDST_API
78  TfToken const &GetFieldName() const { return _fieldName; }
79 
82  HDST_API
83  int GetFieldIndex() const { return _fieldIndex; }
84 
85  HDST_API
86  ~HdStFieldBaseSubtextureIdentifier() override = 0;
87 
88 protected:
89  HDST_API
90  HdStFieldBaseSubtextureIdentifier(TfToken const &fieldName, int fieldIndex);
91 
92  HDST_API
93  ID _Hash() const override;
94 
95 private:
96  TfToken _fieldName;
97  int _fieldIndex;
98 };
99 
113  : public HdStSubtextureIdentifier
114 {
115 public:
118  HDST_API
119  explicit HdStAssetUvSubtextureIdentifier(bool flipVertically,
120  bool premultiplyAlpha,
121  const TfToken& sourceColorSpace);
122 
123  HDST_API
124  std::unique_ptr<HdStSubtextureIdentifier> Clone() const override;
125 
126  HDST_API
127  bool GetFlipVertically() const { return _flipVertically; }
128 
129  HDST_API
130  bool GetPremultiplyAlpha() const { return _premultiplyAlpha; }
131 
132  HDST_API
133  TfToken GetSourceColorSpace() const { return _sourceColorSpace; }
134 
135  HDST_API
136  ~HdStAssetUvSubtextureIdentifier() override;
137 
138 protected:
139  HDST_API
140  ID _Hash() const override;
141 
142 private:
143  bool _flipVertically;
144  bool _premultiplyAlpha;
145  TfToken _sourceColorSpace;
146 };
147 
172 {
173 public:
174  HDST_API
176 
177  HDST_API
178  ~HdStDynamicUvSubtextureIdentifier() override;
179 
180  HDST_API
181  std::unique_ptr<HdStSubtextureIdentifier> Clone() const override;
182 
185  HDST_API
187 
188 protected:
189  HDST_API
190  ID _Hash() const override;
191 };
192 
200  : public HdStSubtextureIdentifier
201 {
202 public:
204  HDST_API
205  explicit HdStPtexSubtextureIdentifier(bool premultiplyAlpha);
206 
207  HDST_API
208  std::unique_ptr<HdStSubtextureIdentifier> Clone() const override;
209 
210  HDST_API
211  bool GetPremultiplyAlpha() const { return _premultiplyAlpha; }
212 
213  HDST_API
214  ~HdStPtexSubtextureIdentifier() override;
215 
216 protected:
217  HDST_API
218  ID _Hash() const override;
219 
220 private:
221  bool _premultiplyAlpha;
222 };
223 
231  : public HdStSubtextureIdentifier
232 {
233 public:
236  HDST_API
237  explicit HdStUdimSubtextureIdentifier(bool premultiplyAlpha,
238  const TfToken& sourceColorSpace);
239 
240  HDST_API
241  std::unique_ptr<HdStSubtextureIdentifier> Clone() const override;
242 
243  HDST_API
244  bool GetPremultiplyAlpha() const { return _premultiplyAlpha; }
245 
246  HDST_API
247  TfToken GetSourceColorSpace() const { return _sourceColorSpace; }
248 
249  HDST_API
250  ~HdStUdimSubtextureIdentifier() override;
251 
252 protected:
253  HDST_API
254  ID _Hash() const override;
255 
256 private:
257  bool _premultiplyAlpha;
258  TfToken _sourceColorSpace;
259 };
260 
261 PXR_NAMESPACE_CLOSE_SCOPE
262 
263 #endif
virtual HDST_API HdStDynamicUvTextureImplementation * GetTextureImplementation() const
Textures can return their own HdStDynamicUvTextureImplementation to customize the load and commit beh...
Base class for additional information to identify a texture in a file that can contain several textur...
HDST_API HdStPtexSubtextureIdentifier(bool premultiplyAlpha)
C&#39;tor takes bool whether to pre-multiply by alpha.
Used as a tag that the Storm texture system returns a HdStDynamicUvTextureObject that is populated by...
Specifies whether a UV texture should be loaded flipped vertically, whether it should be loaded with ...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Allows external clients to specify how a UV texture is loaded from, e.g., a file and how it is commit...
HDST_API int GetFieldIndex() const
Get field index.
HDST_API TfToken const & GetFieldName() const
Get field name.
HDST_API HdStAssetUvSubtextureIdentifier(bool flipVertically, bool premultiplyAlpha, const TfToken &sourceColorSpace)
C&#39;tor takes bool whether flipping vertically, whether to pre-multiply by alpha, and the texture&#39;s sou...
Specifies whether a Ptex texture should be loaded with pre-multiplied alpha values.
Specifies whether a Udim texture should be loaded with pre-multiplied alpha values and the color spac...
Base class for information identifying a grid in a volume field file.
HDST_API HdStUdimSubtextureIdentifier(bool premultiplyAlpha, const TfToken &sourceColorSpace)
C&#39;tor takes bool whether to pre-multiply by alpha and the texture&#39;s source color space.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...