HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PXL_OCIO.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PXL_OCIO.h (UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __PXL_OCIO__
12 #define __PXL_OCIO__
13 
14 #include "PXL_API.h"
15 #include <UT/UT_Functor.h>
16 #include <SYS/SYS_Types.h>
17 
18 class UT_StringHolder;
19 class UT_StringRef;
20 class UT_StringArray;
21 class UT_Options;
22 
23 /// Abstract interface to OpenColorIO
25 {
26 public:
27  /// Private class
28  class ColorSpace;
29 
30  /// The path and filename of the config file being used.
31  static const UT_StringRef &configFilePath();
32 
33  /// Returns whether the user has set $OCIO, $OCIO_ACTIVE_DISPLAYS or
34  /// $OCIO_ACTIVE_VIEWS is set. If there's an error loading the
35  /// configuration, this method will return @c false.
36  static bool isOCIOEnvSet(bool check_for_active_vars=true);
37 
38  /// Returns the current color space name
39  static const char *getDefaultDisplay();
40 
41  /// Returns the current color space name
42  static const char *getDefaultView(const char *display = NULL);
43 
44  /// Return the list of views for a given display.
45  static bool getViewsForDisplay(const char *display,
46  UT_StringArray &view_names);
47 
48  /// Returns the list of active displays
49  static void getActiveDisplays(UT_StringArray &names);
50 
51  /// Returns the list of active views
52  static void getActiveViews(UT_StringArray &names);
53 
54  /// Returns a list of the supported color spaces
55  static void getColorSpaces(UT_StringArray &names);
56 
57  /// Returns a list of looks (color transforms)
58  static void getLooks(UT_StringArray &looks);
59 
60  /// Returns a list of the supported roles
61  static void getRoles(UT_StringArray &names);
62 
63  /// Reload the configuration.
64  static void reload();
65 
66  static const char *getDefaultRole();
67  static const char *getReferenceRole();
68  static const char *getDataRole();
69  static const char *getSceneLinearRole();
70  static const char *getCompLogRole();
71  static const char *getColorPickingRole();
72 
73  // find an sRGB color space in the given config file
74  static const char *getsRGBColorSpace(const char *display = nullptr);
75 
76  /// Return the colorspace defined by the view for a given display.
77  static const char *getColorSpaceForDisplayView(const char *display_name,
78  const char *view_name);
79 
80  /// Return the looks attached to the view for a given display.
81  static const char *getLooksForDisplayView(const char *display_name,
82  const char *view_name);
83 
84 
85  /// Guess at the colorspace using the rightmost colorspace found, or NULL
86  /// if none are found.
87  static const char *parseColorSpaceFromString(const char *string);
88 
89  /// Return a color space handle given a name. The name may be a color
90  /// space name or prefixed with "role:" to specify a color space role.
91  static const ColorSpace *lookupSpace(const UT_StringHolder &name);
92 
93  /// Return the name of the color space
94  static const char *getName(const ColorSpace *space);
95  /// Return the description of the color space
96  static const char *getDescription(const ColorSpace *space);
97  /// Return the allocation variable meta data about the color space
98  static bool getAllocationVars(const ColorSpace* space,
99  bool &uniform,
100  fpreal &min,
101  fpreal &max,
102  fpreal &offset);
103  /// Set 'fp' to true if the color space is defined for FP, false for uint
104  static bool isFloatPointSpace(const ColorSpace* space,
105  bool &fp);
106 
107  /// Fill out metadata for color space in a UT_Options
108  /// Keys are the tokens in the config.ocio file:
109  /// - @c name
110  /// - @c family
111  /// - @c equalitygroup
112  /// - @c bitdepth
113  /// - @c description
114  /// - @c isdata
115  /// - @c allocation
116  /// - @c allocationvars
117  static bool getInfo(const ColorSpace *space, UT_Options &info);
118 
119  /// Is there a transform from src->dest with the applied looks.
120  static bool isValidTransform(const UT_StringHolder &src,
121  const UT_StringHolder &dest,
122  const UT_StringHolder &looks);
123 
124  /// Does the transform from src->dest with applied looks require a 3D LUT.
125  static bool is3DTransform(const UT_StringHolder &src,
126  const UT_StringHolder &dest,
127  const UT_StringHolder &looks);
128 
129  /// @{
130  /// Transform color data from one color space to another color space.
131  /// The color space names may either refer to a color space name, or it can
132  /// also be prefixed with "role:" and refer to a color space role. The
133  /// 'looks' is a comma separated list of color gradings (aka looks)
134  static bool transform(const UT_StringHolder &src,
135  const UT_StringHolder &dest,
136  const UT_StringHolder &looks,
137  fpreal32 *data, int npixels, int nchannels);
138  static bool transform(const ColorSpace *src,
139  const ColorSpace *dest,
140  const UT_StringHolder &looks,
141  fpreal32 *data, int npixels, int nchannels);
142  /// @}
143 
144  /// Transform from a colorspace to a display/view, including looks.
145  static bool transformToView(const UT_StringHolder &src,
146  const UT_StringHolder &display,
147  const UT_StringHolder &view,
148  fpreal32 *data, int npixels, int nchannels);
149 
150 
151  static int addConfigChangeCB(UT_Functor<void> callback);
152  static void removeConfigChangeCB(int id);
153 
154 private:
155 };
156 
157 #endif
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
GLenum src
Definition: glew.h:2410
GLuint const GLchar * name
Definition: glew.h:1814
GLuint GLenum GLenum transform
Definition: glew.h:14742
#define PXL_API
Definition: PXL_API.h:10
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
GLuint const GLuint * names
Definition: glew.h:2690
double fpreal
Definition: SYS_Types.h:276
A map of string to various well defined value types.
Definition: UT_Options.h:42
cl_int getInfo(Func f, cl_uint name, T *param)
Definition: cl.hpp:1028
Abstract interface to OpenColorIO.
Definition: PXL_OCIO.h:24
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
float fpreal32
Definition: SYS_Types.h:195
GLintptr offset
Definition: glew.h:1682