HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OcioColorManagementSystem.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_OCIO_COLOR_MANAGEMENT_SYSTEM_H
7 #define MATERIALX_OCIO_COLOR_MANAGEMENT_SYSTEM_H
8 
9 #ifdef MATERIALX_BUILD_OCIO
10 
11 /// @file
12 /// OCIO color management system implementation
13 
15 
17 
18 #include <map>
19 
21 
22 // Opaque class to insulate from the full OCIO API
23 class OcioColorManagementSystemImpl;
24 
25 /// A shared pointer to a OcioColorManagementSystem
26 using OcioColorManagementSystemPtr = std::shared_ptr<class OcioColorManagementSystem>;
27 
28 /// @class OcioColorManagementSystem
29 /// Class for a default color management system.
30 class MX_GENSHADER_API OcioColorManagementSystem : public DefaultColorManagementSystem
31 {
32  public:
33  virtual ~OcioColorManagementSystem();
34 
35  /// Create a new OcioColorManagementSystem using using the OCIO environment variable.
36  static OcioColorManagementSystemPtr createFromEnv(string target);
37 
38  /// Create a new OcioColorManagementSystem using a specific OCIO config file.
39  static OcioColorManagementSystemPtr createFromFile(const string& filename, string target);
40 
41  /// Create a new OcioColorManagementSystem using an OCIO built-in config.
42  static OcioColorManagementSystemPtr createFromBuiltinConfig(const string& configName, string target);
43 
44  /// Return the OcioColorManagementSystem name
45  const string& getName() const override;
46 
47  /// Can the CMS create a shader node implementation for one of its registered CMS transforms
48  bool hasImplementation(const string& implName) const override;
49 
50  /// Create an OCIO node
51  ShaderNodeImplPtr createImplementation(const string& implName) const override;
52 
53  /// Returns shader text for an implementation
54  string getGpuProcessorCode(const string& implName, const string& functionName) const;
55 
56  /// Prefix common to all implementation names
57  static const string IMPL_PREFIX;
58 
59  /// SourceUri common to all OCIO NodeDefs and Implementations:
60  static const string OCIO_SOURCE_URI;
61 
62  protected:
63  /// Returns a nodedef for a given transform
64  NodeDefPtr getNodeDef(const ColorSpaceTransform& transform) const override;
65 
66  /// Looks for a valid color space name, either in the current config, or using built-in
67  /// color spaces to find an equivalent one.
68  const char* getSupportedColorSpaceName(const char* colorSpace) const;
69 
70  /// Protected constructor
71  OcioColorManagementSystem(OcioColorManagementSystemImpl*);
72 
73  private:
74  std::unique_ptr<OcioColorManagementSystemImpl> _impl;
75 };
76 
78 
79 #endif // MATERIALX_BUILD_OCIO
80 
81 #endif
GT_API const UT_StringHolder filename
shared_ptr< ShaderNodeImpl > ShaderNodeImplPtr
Shared pointer to a ShaderNodeImpl.
Definition: Library.h:39
NodeDefPtr getNodeDef(const ColorSpaceTransform &transform) const override
Returns a nodedef for a given transform.
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
const string & getName() const override
Return the DefaultColorManagementSystem name.
virtual bool hasImplementation(const string &) const
Returns true if the CMS can create a shader node implementation for a locally managed CMS transform...
#define MX_GENSHADER_API
Definition: Export.h:18
virtual ShaderNodeImplPtr createImplementation(const string &) const
Create an CMS node implementation for a locally managed transform.
GLenum target
Definition: glcorearb.h:1667
GA_API const UT_StringHolder transform
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
shared_ptr< NodeDef > NodeDefPtr
A shared pointer to a NodeDef.
Definition: Definition.h:32