HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ColorManagementSystem.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_COLOR_MANAGEMENT_SYSTEM_H
7 #define MATERIALX_COLOR_MANAGEMENT_SYSTEM_H
8 
9 /// @file
10 /// Color management system classes
11 
13 
17 
18 #include <MaterialXCore/Document.h>
19 
21 
22 class ShaderGenerator;
23 
24 /// A shared pointer to a ColorManagementSystem
25 using ColorManagementSystemPtr = shared_ptr<class ColorManagementSystem>;
26 
27 /// @struct ColorSpaceTransform
28 /// Structure that represents color space transform information
30 {
31  ColorSpaceTransform(const string& ss, const string& ts, const TypeDesc* t);
32 
33  string sourceSpace;
34  string targetSpace;
35  const TypeDesc* type;
36 
37  /// Comparison operator
38  bool operator==(const ColorSpaceTransform& other) const
39  {
40  return sourceSpace == other.sourceSpace &&
41  targetSpace == other.targetSpace &&
42  type == other.type;
43  }
44 };
45 
46 /// @class ColorManagementSystem
47 /// Abstract base class for color management systems
49 {
50  public:
51  virtual ~ColorManagementSystem() { }
52 
53  /// Return the ColorManagementSystem name
54  virtual const string& getName() const = 0;
55 
56  /// Load a library of implementations from the provided document,
57  /// replacing any previously loaded content.
58  virtual void loadLibrary(DocumentPtr document);
59 
60  /// Returns whether this color management system supports a provided transform
61  bool supportsTransform(const ColorSpaceTransform& transform) const;
62 
63  /// Create a node to use to perform the given color space transformation.
64  ShaderNodePtr createNode(const ShaderGraph* parent, const ColorSpaceTransform& transform, const string& name,
65  GenContext& context) const;
66 
67  protected:
68  /// Protected constructor
70 
71  /// Returns a nodedef for a given transform
72  virtual NodeDefPtr getNodeDef(const ColorSpaceTransform& transform) const = 0;
73 
74  protected:
76 };
77 
79 
80 #endif
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
MX_FORMAT_API void loadLibrary(const FilePath &file, DocumentPtr doc, const FileSearchPath &searchPath=FileSearchPath(), const XmlReadOptions *readOptions=nullptr)
Load a given MaterialX library into a document.
#define MX_GENSHADER_API
Definition: Export.h:18
bool operator==(const ColorSpaceTransform &other) const
Comparison operator.
shared_ptr< class ColorManagementSystem > ColorManagementSystemPtr
A shared pointer to a ColorManagementSystem.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:35
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
GLuint const GLchar * name
Definition: glcorearb.h:786
GA_API const UT_StringHolder transform
GLdouble t
Definition: glad.h:2397
class OCIOEXPORT ColorSpaceTransform
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
type
Definition: core.h:1059
shared_ptr< NodeDef > NodeDefPtr
A shared pointer to a NodeDef.
Definition: Definition.h:32