HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpenColorIO.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 // Copyright Contributors to the OpenColorIO Project.
3 
4 
5 #ifndef INCLUDED_OCIO_OPENCOLORIO_H
6 #define INCLUDED_OCIO_OPENCOLORIO_H
7 
8 #include <cstddef>
9 #include <iosfwd>
10 #include <limits>
11 #include <stdexcept>
12 #include <string>
13 #include <fstream>
14 #include <vector>
15 
16 #include "OpenColorABI.h"
17 #include "OpenColorTypes.h"
18 #include "OpenColorTransforms.h"
19 #include "OpenColorAppHelpers.h"
20 
21 /*
22 
23 C++ API
24 =======
25 
26 **Usage Example:** *Compositing plugin that converts from "log" to "lin"*
27 
28 .. code-block:: cpp
29 
30  #include <OpenColorIO/OpenColorIO.h>
31  namespace OCIO = OCIO_NAMESPACE;
32 
33  try
34  {
35  // Get the global OpenColorIO config
36  // This will auto-initialize (using $OCIO) on first use
37  OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
38 
39  // Get the processor corresponding to this transform.
40  OCIO::ConstProcessorRcPtr processor = config->getProcessor(OCIO::ROLE_COMPOSITING_LOG,
41  OCIO::ROLE_SCENE_LINEAR);
42 
43  // Get the corresponding CPU processor for 32-bit float image processing.
44  OCIO::ConstCPUProcessorRcPtr cpuProcessor = processor->getDefaultCPUProcessor();
45 
46  // Wrap the image in a light-weight ImageDescription
47  OCIO::PackedImageDesc img(imageData, w, h, 4);
48 
49  // Apply the color transformation (in place)
50  cpuProcessor->apply(img);
51  }
52  catch(OCIO::Exception & exception)
53  {
54  std::cerr << "OpenColorIO Error: " << exception.what() << std::endl;
55  }
56 
57 */
58 
59 namespace OCIO_NAMESPACE
60 {
61 ///////////////////////////////////////////////////////////////////////////
62 // Exceptions
63 
64 // Silence warning C4275 under Visual Studio:
65 // Exceptions derive from std::runtime_error but STL classes are not exportable.
66 #ifdef _MSC_VER
67 #pragma warning( push )
68 #pragma warning( disable : 4275 )
69 #endif
70 
71 /**
72  * \brief An exception class to throw for errors detected at runtime.
73  *
74  * \warning
75  * All functions in the Config class can potentially throw this exception.
76  */
77 class OCIOEXPORT Exception : public std::runtime_error
78 {
79 public:
80  Exception() = delete;
81  /// Constructor that takes a string as the exception message.
82  explicit Exception(const char *);
83  /// Constructor that takes an existing exception.
84  Exception(const Exception &);
85  Exception & operator= (const Exception &) = delete;
86 
87  ~Exception();
88 };
89 
90 /**
91  * \brief An exception class for errors detected at runtime.
92  *
93  * Thrown when OCIO cannot find a file that is expected to exist. This is provided as a custom
94  * type to distinguish cases where one wants to continue looking for missing files, but wants
95  * to properly fail for other error conditions.
96  */
98 {
99 public:
100  ExceptionMissingFile() = delete;
101  /// Constructor that takes a string as the exception message.
102  explicit ExceptionMissingFile(const char *);
103  /// Constructor that takes an existing exception.
105  ExceptionMissingFile & operator= (const ExceptionMissingFile &) = delete;
106 
108 };
109 
110 // Restore default warning behaviour for Visual Studio.
111 #ifdef _MSC_VER
112 #pragma warning( pop )
113 #endif
114 
115 ///////////////////////////////////////////////////////////////////////////
116 // Global
117 // ******
118 
119 /**
120  * During normal usage, OpenColorIO tends to cache certain global information (such
121  * as the contents of LUTs on disk, intermediate results, etc.). Calling this function will flush
122  * all such information. The global information are related to LUT file identifications, loaded LUT
123  * file content and CDL transforms from loaded CDL files.
124  *
125  * Under normal usage, this is not necessary, but it can be helpful in particular instances,
126  * such as designing OCIO profiles, and wanting to re-read luts without restarting.
127  *
128  * \note The method does not apply to instance specific caches such as the processor cache in a
129  * config instance or the GPU and CPU processor caches in a processor instance. Here deleting the
130  * instance flushes the cache.
131  */
132 extern OCIOEXPORT void ClearAllCaches();
133 
134 /**
135  * \brief Get the version number for the library, as a dot-delimited string
136  * (e.g., "1.0.0").
137  *
138  * This is also available at compile time as OCIO_VERSION_FULL_STR.
139  */
140 extern OCIOEXPORT const char * GetVersion();
141 
142 /**
143  * \brief Get the version number for the library, as a
144  * single 4-byte hex number (e.g., 0x01050200 for "1.5.2"), to be used
145  * for numeric comparisons.
146  *
147  * This is also at compile time as OCIO_VERSION_HEX.
148  */
149 extern OCIOEXPORT int GetVersionHex();
150 
151 /**
152  * \brief Get the global logging level.
153  *
154  * You can override this at runtime using the \ref OCIO_LOGGING_LEVEL
155  * environment variable. The client application that sets this should use
156  * \ref SetLoggingLevel, and not the environment variable. The default value is INFO.
157  */
159 
160 /// Set the global logging level.
162 
163 /**
164  * \brief Set the logging function to use; otherwise, use the default
165  * (i.e. std::cerr).
166  *
167  * \note
168  * The logging mechanism is thread-safe.
169  */
170 extern OCIOEXPORT void SetLoggingFunction(LoggingFunction logFunction);
172 /// Log a message using the library logging function.
173 extern OCIOEXPORT void LogMessage(LoggingLevel level, const char * message);
174 
175 /**
176  * \brief Set the Compute Hash Function to use; otherwise, use the default.
177  *
178  * This is not used when using CreateFromFile with an OCIOZ archive or CreateFromConfigIOProxy.
179  *
180  * \param ComputeHashFunction
181  */
182 extern OCIOEXPORT void SetComputeHashFunction(ComputeHashFunction hashFunction);
184 
185 //
186 // Note that the following environment variable access methods are not thread safe.
187 //
188 
189 /**
190  * Another call modifies the string obtained from a previous call as the method always uses the
191  * same memory buffer.
192  */
193 extern OCIOEXPORT const char * GetEnvVariable(const char * name);
194 /// \warning This method is not thread safe.
195 extern OCIOEXPORT void SetEnvVariable(const char * name, const char * value);
196 /// \warning This method is not thread safe.
197 extern OCIOEXPORT void UnsetEnvVariable(const char * name);
198 //!cpp:function::
199 extern OCIOEXPORT bool IsEnvVariablePresent(const char * name);
200 
201 /// Get the current configuration.
203 
204 /// Set the current configuration. This will then store a copy of the specified config.
205 extern OCIOEXPORT void SetCurrentConfig(const ConstConfigRcPtr & config);
206 
207 /**
208  * \brief Extract an OCIO Config archive.
209  *
210  * Converts an archived config file (.ocioz file) back to its original form as a config file
211  * and associated LUT files. This creates destinationDir and then creates a config.ocio file
212  * at the root of that working directory and then unpacks the LUT files into their relative
213  * locations relative to that working directory, creating any necessary sub-directories in the
214  * process. Note that configs which contain LUT files outside the working directory are not
215  * archivable, and so this function will not create directories outside the working directory.
216  *
217  * \param archivePath Absolute path to the .ocioz file.
218  * \param destinationDir Absolute path of the directory you want to be created to contain the
219  * contents of the unarchived config.
220  * \throw Exception If the archive is not found or there is a problem extracting it.
221  */
222 extern OCIOEXPORT void ExtractOCIOZArchive(
223  const char * archivePath,
224  const char * destinationDir
225 );
226 
227 /**
228  * \brief
229  * A config defines all the color spaces to be available at runtime.
230  *
231  * The color configuration (Config) is the main object for interacting with this library. It
232  * encapsulates all of the information necessary to use customized ColorSpaceTransform and
233  * DisplayViewTransform operations.
234  *
235  * See the \ref user-guide for more information on selecting, creating, and working with custom
236  * color configurations.
237  *
238  * For applications interested in using only one color config at a time (this is the vast majority
239  * of apps), their API would traditionally get the global configuration and use that, as opposed
240  * to creating a new one. This simplifies the use case for plugins and bindings, as it alleviates
241  * the need to pass around configuration handles.
242  *
243  * An example of an application where this would not be sufficient would be a multi-threaded image
244  * proxy server (daemon), which wished to handle multiple show configurations in a single process
245  * concurrently. This app would need to keep multiple configurations alive, and to manage them
246  * appropriately.
247  *
248  * Roughly speaking, a novice user should select a default configuration that most closely
249  * approximates the use case (animation, visual effects, etc.), and set the :envvar:`OCIO`
250  * environment variable to point at the root of that configuration.
251  *
252  * \note
253  * Initialization using environment variables is typically preferable in
254  * a multi-app ecosystem, as it allows all applications to be
255  * consistently configured.
256  *
257  * See \ref developers-usageexamples
258  */
260 {
261 public:
262 
263  //
264  // Initialization
265  //
266 
267  /**
268  * \brief Create an empty config of the current version.
269  *
270  * Note that an empty config will not pass validation since required elements will be missing.
271  * \return The Config object.
272  */
273  static ConfigRcPtr Create();
274 
275  /**
276  * \brief Create a fall-back config.
277  *
278  * This may be useful to allow client apps to launch in cases when the
279  * supplied config path is not loadable.
280  * \return The Config object.
281  */
282  static ConstConfigRcPtr CreateRaw();
283 
284  /**
285  * \brief Create a configuration using the OCIO environment variable.
286  *
287  * Also supports the OCIO URI format for Built-in configs and supports archived configs.
288  * See \ref Config::CreateFromFile.
289  *
290  * If the variable is missing or empty, returns the same result as
291  * \ref Config::CreateRaw.
292  * \return The Config object.
293  */
294  static ConstConfigRcPtr CreateFromEnv();
295 
296  /**
297  * \brief Create a configuration using a specific config file.
298  *
299  * Also supports the following OCIO URI format for Built-in configs:
300  * "ocio://default" - Default Built-in config.
301  * "ocio://<CONFIG NAME>" - A specific Built-in config. For the list of available
302  * <CONFIG NAME> strings, see \ref Config::CreateFromBuiltinConfig.
303  *
304  * Also supports archived configs (.ocioz files).
305  *
306  * \throw Exception If the file may not be read or does not parse.
307  * \return The Config object.
308  */
309  static ConstConfigRcPtr CreateFromFile(const char * filename);
310 
311  /**
312  * \brief Create a configuration using a stream.
313  *
314  * Note that CreateFromStream does not set the working directory so the caller would need to
315  * set that separately in order to resolve FileTransforms. This function is typically only
316  * used for self-contained configs (no LUTs).
317  *
318  * Configs created from CreateFromStream can not be archived unless the working directory is
319  * set and contains any necessary LUT files.
320  *
321  * \param istream Stream to the config.
322  * \throw Exception If the stream does not parse.
323  * \return The Config object.
324  */
325  static ConstConfigRcPtr CreateFromStream(std::istream & istream);
326 
327  /**
328  * \brief Create a config from the supplied ConfigIOProxy object. This allows the calling
329  * program to directly provide the config and associated LUTs rather than reading them from
330  * the standard file system.
331  *
332  * See the \ref ConfigIOProxy class documentation for more info.
333  *
334  * \param ciop ConfigIOProxy object providing access to the config's files.
335  * \throw Exception If the config may not be read from the proxy, or does not parse.
336  * \return The Config object.
337  */
338  static ConstConfigRcPtr CreateFromConfigIOProxy(ConfigIOProxyRcPtr ciop);
339 
340  /**
341  * \brief Create a configuration using an OCIO built-in config.
342  *
343  * \param configName Built-in config name.
344  *
345  * The available configNames are:
346  *
347  * ACES Studio config, contains a more complete collection of color spaces and displays:
348  * "studio-config-v1.0.0_aces-v1.3_ocio-v2.1"
349  *
350  * ACES CG config, basic color spaces for computer graphics apps:
351  * "cg-config-v1.0.0_aces-v1.3_ocio-v2.1"
352  *
353  * More information is available at:
354  * %https://github.com/AcademySoftwareFoundation/OpenColorIO-Config-ACES
355  *
356  * Information about the available configs is available from the \ref BuiltinConfigRegistry.
357  *
358  * \throw Exception If the configName is not recognized.
359  * \return One of the configs built into the OCIO library.
360  */
361  static ConstConfigRcPtr CreateFromBuiltinConfig(const char * configName);
362 
363  ConfigRcPtr createEditableCopy() const;
364 
365  /// Get the configuration major version.
366  unsigned int getMajorVersion() const;
367 
368  /**
369  * Set the configuration major version.
370  *
371  * Throws if it is not supported. Resets minor to the most recent minor for the given major.
372  */
373  void setMajorVersion(unsigned int major);
374 
375  /// Get the configuration minor version.
376  unsigned int getMinorVersion() const;
377 
378  /// Set the configuration minor version. Throws if it is not supported for the current major.
379  void setMinorVersion(unsigned int minor);
380 
381  /// Set the configuration major and minor versions. Throws if version is not supported.
382  void setVersion(unsigned int major, unsigned int minor);
383 
384  /// Allows an older config to be serialized as the current version.
385  void upgradeToLatestVersion() noexcept;
386 
387  /**
388  * \brief Performs a thorough validation for the most common user errors.
389  *
390  * This will throw an exception if the config is malformed. The most
391  * common error occurs when references are made to colorspaces that do not
392  * exist.
393  */
394  void validate() const;
395 
396  /**
397  * \brief Get/set a name string for the config.
398  *
399  * The name string may be used to communicate config update details or similar information
400  * to workflows external to OCIO in cases where the config path/filename itself does not
401  * provide adequate information.
402  */
403  const char * getName() const noexcept;
404  void setName(const char * name) noexcept;
405 
406  /**
407  * \brief Get the family separator
408  *
409  * A single character used to separate the family string into tokens for use in hierarchical
410  * menus. Defaults to '/'.
411  */
412  char getFamilySeparator() const;
413  /// Get the default family separator i.e. '/' .
414  static char GetDefaultFamilySeparator() noexcept;
415  /**
416  * \brief Set the family separator
417  *
418  * Succeeds if the characters is null or a valid character from the ASCII table i.e. from
419  * value 32 (i.e. space) to 126 (i.e. '~'); otherwise, it throws an exception.
420  */
421  void setFamilySeparator(char separator);
422 
423  const char * getDescription() const;
424  void setDescription(const char * description);
425 
426  /**
427  * \brief Returns the string representation of the Config in YAML text form.
428  *
429  * This is typically stored on disk in a file with the extension .ocio.
430  * NB: This does not validate the config. Applications should validate before serializing.
431  */
432  void serialize(std::ostream & os) const;
433 
434  /**
435  * This will produce a hash of the all colorspace definitions, etc. All external references,
436  * such as files used in FileTransforms, etc., will be incorporated into the cacheID. While
437  * the contents of the files are not read, the file system is queried for relevant information
438  * (mtime, inode) so that the config's cacheID will change when the underlying luts are updated.
439  *
440  * If a context is not provided, the current Context will be used.
441  *
442  * If a null context is provided, file references will not be taken into
443  * account (this is essentially a hash of Config::serialize).
444  */
445  const char * getCacheID() const;
446  const char * getCacheID(const ConstContextRcPtr & context) const;
447 
448  //
449  // Resources
450  //
451 
452  ConstContextRcPtr getCurrentContext() const;
453 
454  /// Add (or update) an environment variable with a default value.
455  /// But it removes it if the default value is null.
456  void addEnvironmentVar(const char * name, const char * defaultValue);
457  int getNumEnvironmentVars() const;
458  const char * getEnvironmentVarNameByIndex(int index) const;
459  const char * getEnvironmentVarDefault(const char * name) const;
460  void clearEnvironmentVars();
461 
462  /**
463  * \brief The EnvironmentMode controls the behavior of loadEnvironment.
464  * * ENV_ENVIRONMENT_LOAD_PREDEFINED - Only update vars already added to the Context.
465  * * ENV_ENVIRONMENT_LOAD_ALL - Load all env. vars into the Context.
466  *
467  * \note Loading ALL the env. vars may reduce performance and reduce cache efficiency.
468  *
469  * Client programs generally will not use these methods because the EnvironmentMode is
470  * set automatically when a Config is loaded. If the Config has an "environment"
471  * section, the mode is set to LOAD_PREDEFINED, and otherwise set to LOAD_ALL.
472  */
473  void setEnvironmentMode(EnvironmentMode mode) noexcept;
474  EnvironmentMode getEnvironmentMode() const noexcept;
475  /// Initialize the environment/context variables in the Config's Context.
476  void loadEnvironment() noexcept;
477 
478  const char * getSearchPath() const;
479  /**
480  * \brief Set all search paths as a concatenated string, use ':' to separate the paths.
481  *
482  * See \ref addSearchPath for a more robust and platform-agnostic method of
483  * setting the search paths.
484  */
485  void setSearchPath(const char * path);
486 
487  int getNumSearchPaths() const;
488  /**
489  * Get a search path from the list.
490  *
491  * The paths are in the order they will be searched (that is, highest to
492  * lowest priority).
493  */
494  const char * getSearchPath(int index) const;
495  void clearSearchPaths();
496  /**
497  * \brief Add a single search path to the end of the list.
498  *
499  * Paths may be either absolute or relative. Relative paths are
500  * relative to the working directory. Forward slashes will be
501  * normalized to reverse for Windows. Environment (context) variables
502  * may be used in paths.
503  */
504  void addSearchPath(const char * path);
505 
506  const char * getWorkingDir() const;
507  /**
508  * \brief
509  *
510  * The working directory defaults to the location of the
511  * config file. It is used to convert any relative paths to absolute.
512  * If no search paths have been set, the working directory will be used
513  * as the fallback search path. No environment (context) variables may
514  * be used in the working directory.
515  */
516  void setWorkingDir(const char * dirname);
517 
518  //
519  // ColorSpaces
520  //
521 
522  /**
523  * \brief Get all active color spaces having a specific category
524  * in the order they appear in the config file.
525  *
526  * \note
527  * If the category is null or empty, the method returns
528  * all the active color spaces like \ref Config::getNumColorSpaces
529  * and \ref Config::getColorSpaceNameByIndex do.
530  *
531  * \note
532  * It's worth noticing that the method returns a copy of the
533  * selected color spaces decoupling the result from the config.
534  * Hence, any changes on the config do not affect the existing
535  * color space sets, and vice-versa.
536  */
537  ColorSpaceSetRcPtr getColorSpaces(const char * category) const;
538 
539  /**
540  * \brief Work on the color spaces selected by the reference color space type
541  * and visibility.
542  */
543  int getNumColorSpaces(SearchReferenceSpaceType searchReferenceType,
544  ColorSpaceVisibility visibility) const;
545 
546  /**
547  * \brief Work on the color spaces selected by the reference color space
548  * type and visibility (active or inactive).
549  *
550  * Return empty for invalid index.
551  */
552  const char * getColorSpaceNameByIndex(SearchReferenceSpaceType searchReferenceType,
553  ColorSpaceVisibility visibility, int index) const;
554 
555  /**
556  * \brief Work on the active color spaces only.
557  *
558  * \note
559  * Only works from the list of active color spaces.
560  */
561  int getNumColorSpaces() const;
562 
563  /**
564  * Work on the active color spaces only and return null for invalid index.
565  *
566  * \note
567  * Only works from the list of active color spaces.
568  */
569  const char * getColorSpaceNameByIndex(int index) const;
570 
571  /**
572  * \brief Get an index from the active color spaces only
573  * and return -1 if the name is not found.
574  *
575  * \note
576  * The fcn accepts either a color space name, role name, or alias.
577  * (Color space names take precedence over roles.)
578  */
579  int getIndexForColorSpace(const char * name) const;
580 
581  /**
582  * \brief Get the color space from all the color spaces
583  * (i.e. active and inactive) and return null if the name is not found.
584  *
585  * \note
586  * The fcn accepts either a color space name, role name, or alias.
587  * (Color space names take precedence over roles.)
588  */
589  ConstColorSpaceRcPtr getColorSpace(const char * name) const;
590 
591  /**
592  * Accepts an alias, role name, named transform name, or color space name and returns the
593  * color space name or the named transform name.
594  */
595  const char * getCanonicalName(const char * name) const;
596 
597  /**
598  * \brief Add a color space to the configuration.
599  *
600  * \note
601  * If another color space is already present with the same name,
602  * this will overwrite it. This stores a copy of the specified
603  * color space.
604  * \note
605  * Adding a color space to a \ref Config does not affect any
606  * \ref ColorSpaceSet sets that have already been created.
607  */
608  void addColorSpace(const ConstColorSpaceRcPtr & cs);
609 
610  /**
611  * \brief Remove a color space from the configuration.
612  *
613  * \note
614  * It does not throw an exception. Name must be the canonical name. If a role name or
615  * alias is provided or if the name is not in the config, nothing is done.
616  * \note
617  * Removing a color space from a \ref Config does not affect any
618  * \ref ColorSpaceSet sets that have already been created.
619  */
620  void removeColorSpace(const char * name);
621 
622  /**
623  * Return true if the color space is used by a transform, a role, or a look.
624  *
625  * \note
626  * Name must be the canonical name.
627  */
628  bool isColorSpaceUsed(const char * name) const noexcept;
629 
630  /**
631  * \brief Remove all the color spaces from the configuration.
632  *
633  * \note
634  * Removing color spaces from a \ref Config does not affect
635  * any \ref ColorSpaceSet sets that have already been created.
636  */
637  void clearColorSpaces();
638 
639  /**
640  * \brief Set/get a list of inactive color space or named transform names.
641  *
642  * Notes:
643  * * List can contain color space and/or named transform names.
644  * * The inactive spaces are color spaces that should not appear in application menus.
645  * * These color spaces will still work in Config::getProcessor calls.
646  * * The argument is a comma-delimited string. A null or empty string empties the list.
647  * * The environment variable OCIO_INACTIVE_COLORSPACES may also be used to set the
648  * inactive color space list.
649  * * The env. var. takes precedence over the inactive_colorspaces list in the config file.
650  * * Setting the list via the API takes precedence over either the env. var. or the
651  * config file list.
652  */
653  void setInactiveColorSpaces(const char * inactiveColorSpaces);
654  const char * getInactiveColorSpaces() const;
655 
656  /**
657  * \brief Return true if the specified color space is linear.
658  *
659  * The determination of linearity is made with respect to one of the two reference spaces
660  * (i.e., either the scene-referred one or the display-referred one). If the reference space
661  * type of the color space is the opposite of the requested reference space type, false is
662  * returned immediately rather than trying to invoke the default view transform to convert
663  * between the reference spaces.
664  *
665  * Note: This function relies on heuristics that may sometimes give an incorrect result.
666  * For example, if the encoding attribute is not set appropriately or the sampled values fail
667  * to detect non-linearity.
668  *
669  * The algorithm proceeds as follows:
670  * -- If the color space isdata attribute is true, return false.
671  * -- If the reference space type of the color space differs from the requested reference
672  * space type, return false.
673  * -- If the color space's encoding attribute is present, return true if it matches the
674  * expected reference space type (i.e., "scene-linear" for REFERENCE_SPACE_SCENE or
675  * "display-linear" for REFERENCE_SPACE_DISPLAY) and false otherwise.
676  * -- If the color space has no to_reference or from_reference transform, return true.
677  * -- Evaluate several points through the color space's transform and check if the output only
678  * differs by a scale factor (which may be different per channel, e.g. allowing an arbitrary
679  * matrix transform, with no offset).
680  *
681  * Note that the encoding test happens before the sampled value test to give config authors
682  * ultimate control over the linearity determination. For example, they could set the encoding
683  * attribute to indicate linearity if they want to ignore some areas of non-linearity
684  * (e.g., at extreme values). Or they could set it to indicate that a color space should not
685  * be considered linear, even if it is, in a mathematical sense.
686  *
687  * \param colorSpace Color space to evaluate.
688  * \param referenceSpaceType Evaluate linearity with respect to the specified reference space
689  * (either scene-referred or display-referred).
690  */
691  bool isColorSpaceLinear(const char * colorSpace, ReferenceSpaceType referenceSpaceType) const;
692 
693  //
694  // Roles
695  //
696 
697  // A role is like an alias for a colorspace. You can query the colorspace
698  // corresponding to a role using the normal getColorSpace fcn.
699 
700  /**
701  * \brief
702  *
703  * \note
704  * Setting the ``colorSpaceName`` name to a null string unsets it.
705  */
706  void setRole(const char * role, const char * colorSpaceName);
707  int getNumRoles() const;
708  /// Return true if the role has been defined.
709  bool hasRole(const char * role) const;
710  /**
711  * \brief Get the role name at index, this will return values
712  * like 'scene_linear', 'compositing_log'.
713  *
714  * Return empty string if index is out of range.
715  */
716  const char * getRoleName(int index) const;
717  /**
718  * \brief Get the role color space at index.
719  *
720  * Return empty string if index is out of range.
721  */
722  const char * getRoleColorSpace(int index) const;
723 
724  /**
725  * \defgroup Methods related to displays and views.
726  * @{
727  */
728 
729  /**
730  * The following methods only manipulate active displays and views. Active
731  * displays and views are defined from an env. variable or from the config file.
732  *
733  * Looks is a potentially comma (or colon) delimited list of lookNames,
734  * Where +/- prefixes are optionally allowed to denote forward/inverse
735  * look specification. (And forward is assumed in the absence of either)
736 
737  * Add shared view (or replace existing one with same name).
738  * Shared views are defined at config level and can be referenced by several
739  * displays. Either provide a view transform and a display color space or
740  * just a color space (and a null view transform). Looks, rule and description
741  * are optional, they can be null or empty.
742  *
743  * Shared views using a view transform may use the token <USE_DISPLAY_NAME>
744  * for the color space (see :c:var:`OCIO_VIEW_USE_DISPLAY_NAME`). In that
745  * case, when the view is referenced in a display, the display color space
746  * that is used will be the one matching the display name. In other words,
747  * the view will be customized based on the display it is used in.
748  * \ref Config::validate will throw if the config does not contain
749  * the matching display color space.
750  */
751  /// Will throw if view or colorSpaceName are null or empty.
752  void addSharedView(const char * view, const char * viewTransformName,
753  const char * colorSpaceName, const char * looks,
754  const char * ruleName, const char * description);
755  /// Remove a shared view. Will throw if the view does not exist.
756  void removeSharedView(const char * view);
757 
758  const char * getDefaultDisplay() const;
759  int getNumDisplays() const;
760  /// Will return "" if the index is invalid.
761  const char * getDisplay(int index) const;
762 
763  const char * getDefaultView(const char * display) const;
764  // Get the default view for a given color space using the viewing rules.
765  // This is the preferred call to use if the color space being viewed is known.
766  const char * getDefaultView(const char * display, const char * colorspaceName) const;
767 
768  /**
769  * Return the number of views attached to the display including the number of
770  * shared views if any. Return 0 if display does not exist.
771  */
772  int getNumViews(const char * display) const;
773  const char * getView(const char * display, int index) const;
774 
775  /**
776  * If the config has ViewingRules, get the number of active Views for this
777  * colorspace. (If there are no rules, it returns all of them.)
778  */
779  int getNumViews(const char * display, const char * colorspaceName) const;
780  const char * getView(const char * display, const char * colorspaceName, int index) const;
781 
782  /**
783  * Returns the view_transform attribute of the (display, view) pair. View can
784  * be a shared view of the display. If display is null or empty, config shared views are used.
785  */
786  const char * getDisplayViewTransformName(const char * display, const char * view) const;
787  /**
788  * Returns the colorspace attribute of the (display, view) pair.
789  * (Note that this may be either a color space or a display color space.)
790  */
791  const char * getDisplayViewColorSpaceName(const char * display, const char * view) const;
792  /// Returns the looks attribute of a (display, view) pair.
793  const char * getDisplayViewLooks(const char * display, const char * view) const;
794  /// Returns the rule attribute of a (display, view) pair.
795  const char * getDisplayViewRule(const char * display, const char * view) const noexcept;
796  /// Returns the description attribute of a (display, view) pair.
797  const char * getDisplayViewDescription(const char * display, const char * view) const noexcept;
798 
799  /**
800  * For the (display, view) pair, specify which color space and look to use.
801  * If a look is not desired, then just pass a null or empty string.
802  */
803  void addDisplayView(const char * display, const char * view,
804  const char * colorSpaceName, const char * looks);
805 
806  /**
807  * \brief
808  *
809  * For the (display, view) pair, specify the color space or alternatively
810  * specify the view transform and display color space. The looks, viewing rule, and
811  * description are optional. Pass a null or empty string for any optional arguments.
812  * If the view already exists, it is replaced.
813  *
814  * Will throw if:
815  * * Display, view or colorSpace are null or empty.
816  * * Display already has a shared view with the same name.
817  */
818  void addDisplayView(const char * display, const char * view, const char * viewTransformName,
819  const char * colorSpaceName, const char * looks,
820  const char * ruleName, const char * description);
821 
822  /**
823  * \brief Add a (reference to a) shared view to a display.
824  *
825  * The shared view must be part of the config. See \ref Config::addSharedView
826  *
827  * This will throw if:
828  * * Display or view are null or empty.
829  * * Display already has a view (shared or not) with the same name.
830  */
831  void addDisplaySharedView(const char * display, const char * sharedView);
832 
833  /**
834  * \brief Remove the view and the display if no more views.
835  *
836  * It does not remove the associated color space. If the view name is a
837  * shared view, it only removes the reference to the view from the display
838  * but the shared view, remains in the config.
839  *
840  * Will throw if the view does not exist.
841  */
842  void removeDisplayView(const char * display, const char * view);
843  /// Clear all the displays.
844  void clearDisplays();
845 
846  /** @} */
847 
848  /**
849  * \defgroup Methods related to the Virtual Display.
850  * @{
851  *
852  * ... (See descriptions for the non-virtual methods above.)
853  *
854  * The virtual display is the way to incorporate the ICC monitor profile for a user's display
855  * into OCIO. The views that are defined for the virtual display are the views that are used to
856  * create a new display for an ICC profile. They serve as a kind of template that lets OCIO
857  * know how to build the new display.
858  *
859  * Typically the views will define a View Transform and set the colorSpaceName to
860  * "<USE_DISPLAY_NAME>" so that it will use the display color space with the same name as the
861  * display, in this case corresponding to the ICC profile.
862  *
863  */
864 
865  void addVirtualDisplayView(const char * view,
866  const char * viewTransformName,
867  const char * colorSpaceName,
868  const char * looks,
869  const char * ruleName,
870  const char * description);
871 
872  void addVirtualDisplaySharedView(const char * sharedView);
873 
874  /// Get the number of views associated to the virtual display.
875  int getVirtualDisplayNumViews(ViewType type) const noexcept;
876  /// Get the view name at a specific index.
877  const char * getVirtualDisplayView(ViewType type, int index) const noexcept;
878 
879  const char * getVirtualDisplayViewTransformName(const char * view) const noexcept;
880  const char * getVirtualDisplayViewColorSpaceName(const char * view) const noexcept;
881  const char * getVirtualDisplayViewLooks(const char * view) const noexcept;
882  const char * getVirtualDisplayViewRule(const char * view) const noexcept;
883  const char * getVirtualDisplayViewDescription(const char * view) const noexcept;
884 
885  /// Remove the view from the virtual display.
886  void removeVirtualDisplayView(const char * view) noexcept;
887 
888  /// Clear the virtual display.
889  void clearVirtualDisplay() noexcept;
890 
891  /**
892  * \brief Instantiate a new display from a virtual display, using the monitor name.
893  *
894  * This method uses the virtual display to create an actual display for the given monitorName.
895  * The new display will receive the views from the virtual display.
896  *
897  * After the ICC profile is read, a display name will be created by combining the description
898  * text from the profile with the monitorName obtained from the OS. Use the SystemMonitors class
899  * to obtain the list of monitorName strings for the displays connected to the computer.
900  *
901  * A new display color space will also be created using the display name. It will have a
902  * from_display_reference transform that is a FileTransform pointing to the ICC profile.
903  *
904  * Any instantiated display color spaces for a virtual display are intended to be temporary
905  * (i.e. last as long as the current session). By default, they are not saved when writing a
906  * config file. If there is a need to make it a permanent color space, it may be desirable to
907  * copy the ICC profile somewhere under the config search_path.
908  *
909  * Will throw if the config does not have a virtual display or if the monitorName does not exist.
910  *
911  * If there is already a display or a display color space with the name monitorName, it will be
912  * replaced/updated.
913  *
914  * Returns the index of the display.
915  */
916  int instantiateDisplayFromMonitorName(const char * monitorName);
917 
918  /**
919  * \brief Instantiate a new display from a virtual display, using an ICC profile.
920  *
921  * On platforms such as Linux, where the SystemMonitors class is not able to obtain a list of
922  * ICC profiles from the OS, this method may be used to manually specify a path to an ICC profile.
923  *
924  * Will throw if the virtual display definition is missing from the config.
925  *
926  * Returns the index of the display.
927  */
928  int instantiateDisplayFromICCProfile(const char * ICCProfileFilepath);
929 
930  /** @} */
931 
932  /**
933  * \brief
934  *
935  * $OCIO_ACTIVE_DISPLAYS envvar can, at runtime, optionally override the
936  * allowed displays. It is a comma or colon delimited list. Active displays
937  * that are not in the specified profile will be ignored, and the
938  * left-most defined display will be the default.
939  *
940  * Comma-delimited list of names to filter and order the active displays.
941  *
942  * \note
943  * The setter does not override the envvar. The getter does not take into
944  * account the envvar value and thus may not represent what the user is seeing.
945  */
946  void setActiveDisplays(const char * displays);
947  const char * getActiveDisplays() const;
948 
949  /**
950  * \brief
951  *
952  * $OCIO_ACTIVE_VIEWS envvar can, at runtime, optionally override the allowed views.
953  * It is a comma or colon delimited list.
954  * Active views that are not in the specified profile will be ignored, and the
955  * left-most defined view will be the default.
956  *
957  * Comma-delimited list of names to filter and order the active views.
958  *
959  * \note
960  * The setter does not override the envvar. The getter does not take
961  * into account the envvar value and thus may not represent what the
962  * user is seeing.
963  */
964  void setActiveViews(const char * views);
965  const char * getActiveViews() const;
966 
967  /// Get all displays in the config, ignoring the active_displays list.
968  int getNumDisplaysAll() const noexcept;
969  const char * getDisplayAll(int index) const noexcept;
970  int getDisplayAllByName(const char *) const noexcept;
971  /**
972  * Will be true for a display that was instantiated from a virtual display. These displays are
973  * intended to be temporary (i.e. for the current session) and are not saved to a config file.
974  */
975  bool isDisplayTemporary(int index) const noexcept;
976 
977  /**
978  * Get either the shared or display-defined views for a display. The
979  * active_views list is ignored. Passing a null or empty display (with type=VIEW_SHARED)
980  * returns the contents of the shared_views section of the config. Return 0 if display
981  * does not exist.
982  */
983  int getNumViews(ViewType type, const char * display) const;
984  const char * getView(ViewType type, const char * display, int index) const;
985 
986  //
987  // Viewing Rules
988  //
989 
990  /// Get read-only version of the viewing rules.
991  ConstViewingRulesRcPtr getViewingRules() const noexcept;
992 
993  /**
994  * \brief Set viewing rules.
995  *
996  * \note
997  * The argument is cloned.
998  */
999  void setViewingRules(ConstViewingRulesRcPtr viewingRules);
1000 
1001  //
1002  // Luma
1003  // ^^^^
1004 
1005  /**
1006  * \brief Get the default coefficients for computing luma.
1007  *
1008  * \note
1009  * There is no "1 size fits all" set of luma coefficients. (The
1010  * values are typically different for each colorspace, and the
1011  * application of them may be nonsensical depending on the
1012  * intensity coding anyways). Thus, the 'right' answer is to make
1013  * these functions on the ColorSpace class. However, it's
1014  * often useful to have a config-wide default so here it is. We will
1015  * add the colorspace specific luma call if/when another client is
1016  * interesting in using it.
1017  */
1018  void getDefaultLumaCoefs(double * rgb) const;
1019  /// These should be normalized (sum to 1.0 exactly).
1020  void setDefaultLumaCoefs(const double * rgb);
1021 
1022 
1023  //
1024  // Look
1025  //
1026 
1027  // Manager per-shot look settings.
1028 
1029  ConstLookRcPtr getLook(const char * name) const;
1030 
1031  int getNumLooks() const;
1032 
1033  const char * getLookNameByIndex(int index) const;
1034 
1035  void addLook(const ConstLookRcPtr & look);
1036 
1037  void clearLooks();
1038 
1039 
1040  //
1041  // View Transforms
1042  //
1043 
1044  // ViewTransform objects are used with the display reference space.
1045 
1046  int getNumViewTransforms() const noexcept;
1047 
1048  ConstViewTransformRcPtr getViewTransform(const char * name) const noexcept;
1049 
1050  const char * getViewTransformNameByIndex(int i) const noexcept;
1051 
1052  void addViewTransform(const ConstViewTransformRcPtr & viewTransform);
1053 
1054  /**
1055  * \brief
1056  *
1057  * This view transform is the one that will be used by default if a ColorSpaceTransform is
1058  * needed between a scene-referred and display-referred color space. The config author may
1059  * specify a transform to use via the default_view_transform entry in the config. If that is
1060  * not present, or does not return a valid view transform from the scene-referred connection
1061  * space, the fall-back is to use the first valid view transform in the config. Returns a
1062  * null ConstTransformRcPtr if there isn't one.
1063  */
1064  ConstViewTransformRcPtr getDefaultSceneToDisplayViewTransform() const;
1065 
1066  /**
1067  * Get or set the default_view_transform string from the config.
1068  *
1069  * Note that if this is not the name of a valid view transform from the scene-referred
1070  * connection space, it will be ignored.
1071  */
1072  const char * getDefaultViewTransformName() const noexcept;
1073  void setDefaultViewTransformName(const char * defaultName) noexcept;
1074 
1075 
1076  void clearViewTransforms();
1077 
1078  /**
1079  * \defgroup Methods related to named transforms.
1080  * @{
1081  */
1082 
1083  /**
1084  * \brief Work on the named transforms selected by visibility.
1085  */
1086  int getNumNamedTransforms(NamedTransformVisibility visibility) const noexcept;
1087 
1088  /**
1089  * \brief Work on the named transforms selected by visibility (active or inactive).
1090  *
1091  * Return an empty string for invalid index.
1092  */
1093  const char * getNamedTransformNameByIndex(NamedTransformVisibility visibility,
1094  int index) const noexcept;
1095 
1096  /// Work on the active named transforms only.
1097  int getNumNamedTransforms() const noexcept;
1098 
1099  /// Work on the active named transforms only and return an empty string for invalid index.
1100  const char * getNamedTransformNameByIndex(int index) const noexcept;
1101 
1102  /// Get an index from the active named transforms only and return -1 if the name is not found.
1103  int getIndexForNamedTransform(const char * name) const noexcept;
1104 
1105  /**
1106  * \brief Get the named transform from all the named transforms (i.e. active and inactive) and
1107  * return null if the name is not found.
1108  */
1109  ConstNamedTransformRcPtr getNamedTransform(const char * name) const noexcept;
1110 
1111  /**
1112  * \brief Add or replace named transform.
1113  *
1114  * \note
1115  * Throws if namedTransform is null, name is missing, or no transform is set. Also throws
1116  * if the name or the aliases conflict with names or aliases already in the config.
1117  */
1118  void addNamedTransform(const ConstNamedTransformRcPtr & namedTransform);
1119 
1120  /// Clear all named transforms.
1121  void clearNamedTransforms();
1122 
1123  /** @} */
1124 
1125  //
1126  // File Rules
1127  //
1128 
1129  /// Get read-only version of the file rules.
1130  ConstFileRulesRcPtr getFileRules() const noexcept;
1131 
1132  /**
1133  * \brief Set file rules.
1134  *
1135  * \note
1136  * The argument is cloned.
1137  */
1138  void setFileRules(ConstFileRulesRcPtr fileRules);
1139 
1140  /// Get the color space of the first rule that matched filePath. (For v1 configs, this is
1141  /// equivalent to calling parseColorSpaceFromString with strictparsing set to false.)
1142  const char * getColorSpaceFromFilepath(const char * filePath) const;
1143 
1144  /**
1145  * Most applications will use the preceding method, but this method may be
1146  * used for applications that want to know which was the highest priority rule to match
1147  * filePath. \ref FileRules::getNumCustomKeys and custom keys methods
1148  * may then be used to get additional information about the matching rule.
1149  */
1150  const char * getColorSpaceFromFilepath(const char * filePath, size_t & ruleIndex) const;
1151 
1152  /**
1153  * \brief
1154  *
1155  * Returns true if the only rule matched by filePath is the default rule.
1156  * This is a convenience method for applications that want to require the user to manually
1157  * choose a color space when strictParsing is true and no other rules match.
1158  */
1159  bool filepathOnlyMatchesDefaultRule(const char * filePath) const;
1160 
1161  /**
1162  * Given the specified string, get the longest, right-most, colorspace substring that
1163  * appears.
1164  *
1165  * * If strict parsing is enabled, and no color space is found, return
1166  * an empty string.
1167  * * If strict parsing is disabled, return ROLE_DEFAULT (if defined).
1168  * * If the default role is not defined, return an empty string.
1169  */
1170  OCIO_DEPRECATED("This was marked as deprecated starting in v2.0, please use Config::getColorSpaceFromFilepath().")
1171  const char * parseColorSpaceFromString(const char * str) const;
1172 
1173  bool isStrictParsingEnabled() const;
1174  void setStrictParsingEnabled(bool enabled);
1175 
1176  //
1177  // Processors
1178  //
1179 
1180  // Create a Processor to assemble a transformation between two
1181  // color spaces. It may then be used to create a CPUProcessor
1182  // or GPUProcessor to process/convert pixels.
1183 
1184  /// Get the processor to apply a ColorSpaceTransform from a source to a destination
1185  /// color space.
1186  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1187  const ConstColorSpaceRcPtr & srcColorSpace,
1188  const ConstColorSpaceRcPtr & dstColorSpace) const;
1189  ConstProcessorRcPtr getProcessor(const ConstColorSpaceRcPtr & srcColorSpace,
1190  const ConstColorSpaceRcPtr & dstColorSpace) const;
1191 
1192  /**
1193  * \brief
1194  *
1195  * \note
1196  * Names can be colorspace name, role name, or a combination of both.
1197  */
1198  ConstProcessorRcPtr getProcessor(const char * srcColorSpaceName,
1199  const char * dstColorSpaceName) const;
1200  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1201  const char * srcColorSpaceName,
1202  const char * dstColorSpaceName) const;
1203 
1204  /// Get the processor to apply a DisplayViewTransform for a display and view. Refer to the
1205  /// Display/View Registration section above for more info on the display and view arguments.
1206  ConstProcessorRcPtr getProcessor(const char * srcColorSpaceName,
1207  const char * display,
1208  const char * view,
1210 
1211  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1212  const char * srcColorSpaceName,
1213  const char * display,
1214  const char * view,
1215  TransformDirection direction) const;
1216 
1217  /// Get the processor to apply a NamedTransform in the specified direction.
1218  ConstProcessorRcPtr getProcessor(const ConstNamedTransformRcPtr & namedTransform,
1219  TransformDirection direction) const;
1220  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1221  const ConstNamedTransformRcPtr & namedTransform,
1222  TransformDirection direction) const;
1223 
1224  ConstProcessorRcPtr getProcessor(const char * namedTransformName,
1225  TransformDirection direction) const;
1226  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1227  const char * namedTransformName,
1228  TransformDirection direction) const;
1229 
1230  /**
1231  * \brief Get the processor for the specified transform.
1232  *
1233  * Not often needed, but will allow for the re-use of atomic OCIO
1234  * functionality (such as to apply an individual LUT file).
1235  */
1236  ConstProcessorRcPtr getProcessor(const ConstTransformRcPtr & transform) const;
1237  ConstProcessorRcPtr getProcessor(const ConstTransformRcPtr & transform,
1238  TransformDirection direction) const;
1239  ConstProcessorRcPtr getProcessor(const ConstContextRcPtr & context,
1240  const ConstTransformRcPtr & transform,
1241  TransformDirection direction) const;
1242 
1243  /**
1244  * \brief Get a Processor to or from a known external color space.
1245  *
1246  * These methods provide a way to interface color spaces in a config with known standard
1247  * external color spaces. The set of external color space are those contained in the current
1248  * default Built-in config. This includes common spaces such as "Linear Rec.709 (sRGB)",
1249  * "sRGB - Texture", "ACEScg", and "ACES2065-1".
1250  *
1251  * If the source config defines the necessary Interchange Role (typically "aces_interchange"),
1252  * then the conversion will be well-defined and equivalent to calling GetProcessorFromConfigs
1253  * with the source config and the Built-in config
1254  *
1255  * However, if the Interchange Roles are not present, heuristics will be used to try and
1256  * identify a common color space in the source config that may be used to allow the conversion
1257  * to proceed. If the heuristics fail to find a suitable space, an exception is thrown.
1258  * The heuristics may evolve, so the results returned by this function for a given source config
1259  * and color space may change in future releases of the library. However, the Interchange Roles
1260  * are required in config versions 2.2 and higher, so it is hoped that the need for the heuristics
1261  * will decrease over time.
1262  *
1263  * \param srcConfig The user's source config.
1264  * \param srcColorSpaceName The name of the color space in the source config.
1265  * \param builtinColorSpaceName The name of the color space in the current default Built-in config.
1266  */
1267  static ConstProcessorRcPtr GetProcessorToBuiltinColorSpace(
1268  ConstConfigRcPtr srcConfig,
1269  const char * srcColorSpaceName,
1270  const char * builtinColorSpaceName);
1271  /**
1272  * \brief See description of GetProcessorToBuiltinColorSpace.
1273  *
1274  * \param builtinColorSpaceName The name of the color space in the current default Built-in config.
1275  * \param srcConfig The user's source config.
1276  * \param srcColorSpaceName The name of the color space in the source config.
1277  */
1278  static ConstProcessorRcPtr GetProcessorFromBuiltinColorSpace(
1279  const char * builtinColorSpaceName,
1280  ConstConfigRcPtr srcConfig,
1281  const char * srcColorSpaceName);
1282 
1283  /**
1284  * \brief Get a processor to convert between color spaces in two separate
1285  * configs.
1286  *
1287  * This relies on both configs having the aces_interchange role (when srcName
1288  * is scene-referred) or the role cie_xyz_d65_interchange (when srcName is
1289  * display-referred) defined. An exception is thrown if that is not the case.
1290  */
1291  static ConstProcessorRcPtr GetProcessorFromConfigs(const ConstConfigRcPtr & srcConfig,
1292  const char * srcColorSpaceName,
1293  const ConstConfigRcPtr & dstConfig,
1294  const char * dstColorSpaceName);
1295  static ConstProcessorRcPtr GetProcessorFromConfigs(const ConstContextRcPtr & srcContext,
1296  const ConstConfigRcPtr & srcConfig,
1297  const char * srcColorSpaceName,
1298  const ConstContextRcPtr & dstContext,
1299  const ConstConfigRcPtr & dstConfig,
1300  const char * dstColorSpaceName);
1301 
1302  /**
1303  * The srcInterchangeName and dstInterchangeName must refer to a pair of
1304  * color spaces in the two configs that are the same. A role name may also be used.
1305  */
1306  static ConstProcessorRcPtr GetProcessorFromConfigs(const ConstConfigRcPtr & srcConfig,
1307  const char * srcColorSpaceName,
1308  const char * srcInterchangeName,
1309  const ConstConfigRcPtr & dstConfig,
1310  const char * dstColorSpaceName,
1311  const char * dstInterchangeName);
1312 
1313  static ConstProcessorRcPtr GetProcessorFromConfigs(const ConstContextRcPtr & srcContext,
1314  const ConstConfigRcPtr & srcConfig,
1315  const char * srcColorSpaceName,
1316  const char * srcInterchangeName,
1317  const ConstContextRcPtr & dstContext,
1318  const ConstConfigRcPtr & dstConfig,
1319  const char * dstColorSpaceName,
1320  const char * dstInterchangeName);
1321 
1322  /// Set the ConfigIOProxy object used to provision the config and LUTs from somewhere other
1323  /// than the file system. (This is set on the config's embedded Context object.)
1324  void setConfigIOProxy(ConfigIOProxyRcPtr ciop);
1325  ConfigIOProxyRcPtr getConfigIOProxy() const;
1326 
1327  /**
1328  * \brief Verify if the config is archivable.
1329  *
1330  * A config is not archivable if any of the following are true:
1331  * -- The working directory is not set
1332  * -- It contains FileTransforms with a src outside the working directory
1333  * -- The search path contains paths outside the working directory
1334  * -- The search path contains paths that start with a context variable
1335  *
1336  * Context variables are allowed but the intent is that they may only resolve to paths that
1337  * are within or below the working directory. This is because the archiving function will
1338  * only archive files that are within the working directory in order to ensure that if it is
1339  * later expanded, that it will not create any files outside this directory.
1340  *
1341  * For example, a context variable on the search path intended to contain the name of a
1342  * sub-directory under the working directory must have the form "./$DIR_NAME" rather than just
1343  * "$DIR_NAME" to be considered archivable. This is imperfect since there is no way to
1344  * prevent the context variable from creating a path outside the working dir, but it should
1345  * at least draw attention to the fact that the archive would fail if used with context vars
1346  * that try to abuse the intended functionality.
1347  *
1348  * \return bool Archivable if true.
1349  */
1350  bool isArchivable() const;
1351 
1352  /**
1353  * \brief Archive the config and its LUTs into the specified output stream.
1354  *
1355  * The config is archived by serializing the Config object into a file named "config.ocio" and
1356  * then walking through the current working directory and any sub-directories. Any files that
1357  * have an extension matching a supported LUT file format are added to the archive. Any files
1358  * that do not have an extension (or have some unsupported LUT extension, including .ocio),
1359  * will not be added to the archive. To reiterate, it is the in-memory Config object that is
1360  * archived, and not any .ocio file in the current working directory. The directory structure
1361  * relative to the working directory is preserved. No files outside the working directory are
1362  * archived so that if it is later expanded, no files will be created outside the working dir.
1363  *
1364  * The reason the archive is created using all supported LUT file extensions rather than by
1365  * trying to resolve all the FileTransforms in the Config to specific files is because of the
1366  * goal to allow context variables to continue to work.
1367  *
1368  * If a Config is created with CreateFromStream, CreateFromFile with an OCIOZ archive, or
1369  * CreateFromConfigIOProxy, it cannot be archived unless the working directory is manually set
1370  * to a directory that contains any necessary LUT files.
1371  *
1372  * The provided output stream must be closed by the caller, if necessary (e.g., an ofstream).
1373  *
1374  * \param ostream The output stream to write to.
1375  */
1376  void archive(std::ostream & ostream) const;
1377 
1378  Config(const Config &) = delete;
1379  Config& operator= (const Config &) = delete;
1380 
1381  /// Do not use (needed only for pybind11).
1382  ~Config();
1383 
1384  /// Control the caching of processors in the config instance. By default, caching is on.
1385  /// The flags allow turning caching off entirely or only turning it off if dynamic
1386  /// properties are being used by the processor.
1387  void setProcessorCacheFlags(ProcessorCacheFlags flags) noexcept;
1388 
1389 private:
1390  Config();
1391 
1392  static void deleter(Config* c);
1393 
1394  class Impl;
1395  Impl * m_impl;
1396  Impl * getImpl() { return m_impl; }
1397  const Impl * getImpl() const { return m_impl; }
1398 };
1399 
1400 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Config&);
1401 
1402 
1403 /**
1404  * \brief
1405  * The File Rules are a set of filepath to color space mappings that are evaluated
1406  * from first to last. The first rule to match is what determines which color space is
1407  * returned. There are four types of rules available. Each rule type has a name key that may
1408  * be used by applications to refer to that rule. Name values must be unique i.e. using a
1409  * case insensitive comparison. The other keys depend on the rule type:
1410  *
1411  * * *Basic Rule*: This is the basic rule type that uses Unix glob style pattern matching and
1412  * is thus very easy to use. It contains the keys:
1413  * * name: Name of the rule
1414  * * colorspace: Color space name to be returned.
1415  * * pattern: Glob pattern to be used for the main part of the name/path.
1416  * * extension: Glob pattern to be used for the file extension. Note that if glob tokens
1417  * are not used, the extension will be used in a non-case-sensitive way by default.
1418  *
1419  * * *Regex Rule*: This is similar to the basic rule but allows additional capabilities for
1420  * power-users. It contains the keys:
1421  * * name: Name of the rule
1422  * * colorspace: Color space name to be returned.
1423  * * regex: Regular expression to be evaluated.
1424  *
1425  * * *OCIO v1 style Rule*: This rule allows the use of the OCIO v1 style, where the string
1426  * is searched for color space names from the config. This rule may occur 0 or 1 times
1427  * in the list. The position in the list prioritizes it with respect to the other rules.
1428  * StrictParsing is not used. If no color space is found in the path, the rule will not
1429  * match and the next rule will be considered.
1430  * see \ref insertPathSearchRule.
1431  * It has the key:
1432  * * name: Must be "ColorSpaceNamePathSearch".
1433  *
1434  * * *Default Rule*: The file_rules must always end with this rule. If no prior rules match,
1435  * this rule specifies the color space applications will use.
1436  * see \ref setDefaultRuleColorSpace.
1437  * It has the keys:
1438  * * name: must be "Default".
1439  * * colorspace : Color space name to be returned.
1440  *
1441  * Custom string keys and associated string values may be used to convey app or
1442  * workflow-specific information, e.g. whether the color space should be left as is
1443  * or converted into a working space.
1444  *
1445  * Getters and setters are using the rule position, they will throw if the position is not
1446  * valid. If the rule at the specified position does not implement the requested property
1447  * getter will return NULL and setter will throw.
1448  *
1449  * When loading a v1 config, a set of FileRules are created with ColorSpaceNamePathSearch followed
1450  * by the Default rule pointing to the default role. This allows getColorSpaceFromFilepath to emulate
1451  * OCIO v1 code that used parseColorSpaceFromString with strictparsing set to false.
1452  */
1453 
1455 {
1456 public:
1457 
1458  /// Reserved rule name for the default rule.
1459  static const char * DefaultRuleName;
1460  /// Reserved rule name for the file path search rule \see FileRules::insertPathSearchRule.
1461  static const char * FilePathSearchRuleName;
1462 
1463  /**
1464  * Creates FileRules for a Config. File rules will contain the default rule
1465  * using the default role. The default rule cannot be removed.
1466  */
1467  static FileRulesRcPtr Create();
1468 
1469  /// The method clones the content decoupling the two instances.
1470  FileRulesRcPtr createEditableCopy() const;
1471 
1472  /// Does include default rule. Result will be at least 1.
1473  size_t getNumEntries() const noexcept;
1474 
1475  /// Get the index from the rule name.
1476  size_t getIndexForRule(const char * ruleName) const;
1477 
1478  /// Get name of the rule.
1479  const char * getName(size_t ruleIndex) const;
1480 
1481  /// Setting pattern will erase regex.
1482  const char * getPattern(size_t ruleIndex) const;
1483  void setPattern(size_t ruleIndex, const char * pattern);
1484 
1485  /// Setting extension will erase regex.
1486  const char * getExtension(size_t ruleIndex) const;
1487  void setExtension(size_t ruleIndex, const char * extension);
1488 
1489  /// Setting a regex will erase pattern & extension.
1490  const char * getRegex(size_t ruleIndex) const;
1491  void setRegex(size_t ruleIndex, const char * regex);
1492 
1493  /// Set the rule's color space (may also be a role).
1494  const char * getColorSpace(size_t ruleIndex) const;
1495  void setColorSpace(size_t ruleIndex, const char * colorSpace);
1496 
1497  /// Get number of key/value pairs.
1498  size_t getNumCustomKeys(size_t ruleIndex) const;
1499  /// Get name of key.
1500  const char * getCustomKeyName(size_t ruleIndex, size_t key) const;
1501  /// Get value for the key.
1502  const char * getCustomKeyValue(size_t ruleIndex, size_t key) const;
1503  /**
1504  * Adds a key/value or replace value if key exists. Setting a NULL or an
1505  * empty value will erase the key.
1506  */
1507  void setCustomKey(size_t ruleIndex, const char * key, const char * value);
1508 
1509  /**
1510  * \brief Insert a rule at a given ruleIndex.
1511  *
1512  * Rule currently at ruleIndex will be pushed to index: ruleIndex + 1.
1513  * Name must be unique.
1514  * - "Default" is a reserved name for the default rule. The default rule is automatically
1515  * added and can't be removed. (see \ref FileRules::setDefaultRuleColorSpace ).
1516  * - "ColorSpaceNamePathSearch" is also a reserved name
1517  * (see \ref FileRules::insertPathSearchRule ).
1518  *
1519  * Will throw if pattern, extension or regex is a null or empty string.
1520  *
1521  * Will throw if ruleIndex is not less than \ref FileRules::getNumEntries .
1522  */
1523  void insertRule(size_t ruleIndex, const char * name, const char * colorSpace,
1524  const char * pattern, const char * extension);
1525  void insertRule(size_t ruleIndex, const char * name, const char * colorSpace,
1526  const char * regex);
1527  /**
1528  * \brief Helper function to insert a rule.
1529  *
1530  * Uses \ref Config:parseColorSpaceFromString to search the path for any of
1531  * the color spaces named in the config (as per OCIO v1).
1532  */
1533  void insertPathSearchRule(size_t ruleIndex);
1534  /// Helper function to set the color space for the default rule.
1535  void setDefaultRuleColorSpace(const char * colorSpace);
1536 
1537  /**
1538  * \brief
1539  *
1540  * \note
1541  * Default rule can't be removed.
1542  * Will throw if ruleIndex + 1 is not less than \ref FileRules::getNumEntries .
1543  */
1544  void removeRule(size_t ruleIndex);
1545 
1546  /// Move a rule closer to the start of the list by one position.
1547  void increaseRulePriority(size_t ruleIndex);
1548 
1549  /// Move a rule closer to the end of the list by one position.
1550  void decreaseRulePriority(size_t ruleIndex);
1551 
1552  /**
1553  * Check if there is only the default rule using default role and no custom key. This is the
1554  * default FileRules state when creating a new config.
1555  */
1556  bool isDefault() const noexcept;
1557 
1558  FileRules(const FileRules &) = delete;
1559  FileRules & operator= (const FileRules &) = delete;
1560 
1561  /// Do not use (needed only for pybind11).
1562  virtual ~FileRules();
1563 
1564 private:
1565  FileRules();
1566 
1567  static void deleter(FileRules* c);
1568 
1569  friend class Config;
1570 
1571  class Impl;
1572  Impl * m_impl;
1573  Impl * getImpl() { return m_impl; }
1574  const Impl * getImpl() const { return m_impl; }
1575 };
1576 
1577 extern OCIOEXPORT std::ostream & operator<< (std::ostream &, const FileRules &);
1578 
1579 
1580 
1581 /**
1582  * ViewingRules
1583  *
1584  * Viewing Rules allow config authors to filter the list of views an application should offer
1585  * based on the color space of an image. For example, a config may define a large number of
1586  * views but not all of them may be appropriate for use with all color spaces. E.g., some views
1587  * may be intended for use with scene-linear color space encodings and others with video color
1588  * space encodings.
1589  *
1590  * Each rule has a name key for applications to refer to the rule. Name values must be unique
1591  * (using case insensitive comparison). Viewing Rules may also have the following keys:
1592  *
1593  * * colorspaces: Either a single colorspace name or a list of names.
1594  *
1595  * * encodings: One or more strings to be found in the colorspace's encoding attribute.
1596  * Either this attribute or colorspaces must be present, but not both.
1597  *
1598  * * custom : Allows arbitrary key / value string pairs, similar to FileRules.
1599  *
1600  * Getters and setters are using the rule position, they will throw if the position is not
1601  * valid.
1602 */
1604 {
1605 public:
1606  /// Creates ViewingRules for a Config.
1607  static ViewingRulesRcPtr Create();
1608 
1609  /// The method clones the content decoupling the two instances.
1610  ViewingRulesRcPtr createEditableCopy() const;
1611 
1612  size_t getNumEntries() const noexcept;
1613 
1614  /**
1615  * Get the index from the rule name. Will throw if there is no rule named
1616  * ruleName.
1617  */
1618  size_t getIndexForRule(const char * ruleName) const;
1619 
1620  /// Get name of the rule. Will throw if ruleIndex is invalid.
1621  const char * getName(size_t ruleIndex) const;
1622 
1623  /// Get number of colorspaces. Will throw if ruleIndex is invalid.
1624  size_t getNumColorSpaces(size_t ruleIndex) const;
1625  /// Get colorspace name. Will throw if ruleIndex or colorSpaceIndex is invalid.
1626  const char * getColorSpace(size_t ruleIndex, size_t colorSpaceIndex) const;
1627  /**
1628  * \brief
1629  *
1630  * Add colorspace name. Will throw if:
1631  * * RuleIndex is invalid.
1632  * * \ref ViewingRules::getNumEncodings is not 0.
1633  */
1634  void addColorSpace(size_t ruleIndex, const char * colorSpace);
1635  /// Remove colorspace. Will throw if ruleIndex or colorSpaceIndex is invalid.
1636  void removeColorSpace(size_t ruleIndex, size_t colorSpaceIndex);
1637 
1638  /// Get number of encodings. Will throw if ruleIndex is invalid.
1639  size_t getNumEncodings(size_t ruleIndex) const;
1640  /// Get encoding name. Will throw if ruleIndex or encodingIndex is invalid.
1641  const char * getEncoding(size_t ruleIndex, size_t encodingIndex) const;
1642 
1643  /**
1644  * \brief
1645  * Add encoding name. Will throw if:
1646  * * RuleIndex is invalid.
1647  * * \ref ViewingRules::getNumColorSpaces is not 0.
1648  */
1649  void addEncoding(size_t ruleIndex, const char * encoding);
1650  /// Remove encoding. Will throw if ruleIndex or encodingIndex is invalid.
1651  void removeEncoding(size_t ruleIndex, size_t encodingIndex);
1652 
1653  /// Get number of key/value pairs. Will throw if ruleIndex is invalid.
1654  size_t getNumCustomKeys(size_t ruleIndex) const;
1655  /// Get name of key. Will throw if ruleIndex or keyIndex is invalid.
1656  const char * getCustomKeyName(size_t ruleIndex, size_t keyIndex) const;
1657  /// Get value for the key. Will throw if ruleIndex or keyIndex is invalid.
1658  const char * getCustomKeyValue(size_t ruleIndex, size_t keyIndex) const;
1659  /**
1660  * Adds a key/value or replace value if key exists. Setting a NULL or an
1661  * empty value will erase the key. Will throw if ruleIndex is invalid.
1662  */
1663  void setCustomKey(size_t ruleIndex, const char * key, const char * value);
1664 
1665  /**
1666  * \brief Insert a rule at a given ruleIndex.
1667  *
1668  * Rule currently at ruleIndex will be pushed to index: ruleIndex + 1. If ruleIndex is
1669  * \ref ViewingRules::getNumEntries, a new rule will be added at the end. Will throw if:
1670  * * RuleIndex is invalid (must be less than or equal to
1671  * \ref ViewingRules::getNumEntries).
1672  * * RuleName already exists.
1673  */
1674  void insertRule(size_t ruleIndex, const char * ruleName);
1675 
1676  /// Remove a rule. Throws if ruleIndex is not valid.
1677  void removeRule(size_t ruleIndex);
1678 
1679  ViewingRules(const ViewingRules &) = delete;
1680  ViewingRules & operator= (const ViewingRules &) = delete;
1681  /// Do not use (needed only for pybind11).
1682  virtual ~ViewingRules();
1683 
1684 private:
1685  ViewingRules();
1686 
1687  static void deleter(ViewingRules* c);
1688 
1689  friend class Config;
1690 
1691  class Impl;
1692  Impl * m_impl;
1693  Impl * getImpl() { return m_impl; }
1694  const Impl * getImpl() const { return m_impl; }
1695 };
1696 
1697 extern OCIOEXPORT std::ostream & operator<< (std::ostream &, const ViewingRules &);
1698 
1699 //
1700 // ColorSpace
1701 //
1702 /**
1703  * The *ColorSpace* is the state of an image with respect to colorimetry
1704  * and color encoding. Transforming images between different
1705  * *ColorSpaces* is the primary motivation for this library.
1706  *
1707  * While a complete discussion of color spaces is beyond the scope of
1708  * header documentation, traditional uses would be to have *ColorSpaces*
1709  * corresponding to: physical capture devices (known cameras, scanners),
1710  * and internal 'convenience' spaces (such as scene linear, logarithmic).
1711  */
1713 {
1714 public:
1715  static ColorSpaceRcPtr Create();
1716 
1717  static ColorSpaceRcPtr Create(ReferenceSpaceType referenceSpace);
1718 
1719  ColorSpaceRcPtr createEditableCopy() const;
1720 
1721  const char * getName() const noexcept;
1722  /// If the name is already an alias, that alias is removed.
1723  void setName(const char * name) noexcept;
1724 
1725  size_t getNumAliases() const noexcept;
1726  /// Return empty string if idx is out of range.
1727  const char * getAlias(size_t idx) const noexcept;
1728  /**
1729  * Add an alias for the color space name (the aliases may be used as a synonym for the
1730  * name). Nothing will be added if the alias is already the color space name, one of its
1731  * aliases, or the argument is null. The aliases must not conflict with existing roles,
1732  * color space names, named transform names, or other aliases. This is verified when
1733  * adding the color space to the config.
1734  */
1735  void addAlias(const char * alias) noexcept;
1736  /// Does nothing if alias is not present.
1737  void removeAlias(const char * alias) noexcept;
1738  void clearAliases() noexcept;
1739 
1740  /**
1741  * Get the family, for use in user interfaces (optional)
1742  * The family string could use a '/' separator to indicate levels to be used
1743  * by hierarchical menus.
1744  */
1745  const char * getFamily() const noexcept;
1746  /// Set the family, for use in user interfaces (optional)
1747  void setFamily(const char * family);
1748 
1749  /**
1750  * Get the ColorSpace group name (used for equality comparisons)
1751  * This allows no-op transforms between different colorspaces.
1752  * If an equalityGroup is not defined (an empty string), it will be considered
1753  * unique (i.e., it will not compare as equal to other ColorSpaces with an
1754  * empty equality group).
1755  */
1756  const char * getEqualityGroup() const noexcept;
1757  void setEqualityGroup(const char * equalityGroup);
1758 
1759  const char * getDescription() const noexcept;
1760  void setDescription(const char * description);
1761 
1762  BitDepth getBitDepth() const noexcept;
1763  void setBitDepth(BitDepth bitDepth);
1764 
1765  /// A display color space will use the display-referred reference space.
1766  ReferenceSpaceType getReferenceSpaceType() const noexcept;
1767 
1768  //
1769  // Categories
1770  //
1771 
1772  /**
1773  * A category is used to allow applications to filter the list of color spaces
1774  * they display in menus based on what that color space is used for.
1775  *
1776  * Here is an example config entry that could appear under a ColorSpace:
1777  *
1778  * \code{.yaml}
1779  * categories: [ file-io, working-space, basic-3d ]
1780  * \endcode
1781  *
1782  * The example contains three categories: 'file-io', 'working-space' and 'basic-3d'.
1783  *
1784  * \note
1785  * Category strings are not case-sensitive and the order is not significant.
1786  *
1787  * There is no limit imposed on length or number. Although users may add their own categories,
1788  * the strings will typically come from a fixed set listed in the documentation (similar to
1789  * roles).
1790  */
1791  /// Return true if the category is present.
1792  bool hasCategory(const char * category) const;
1793  /**
1794  * \brief Add a single category.
1795  *
1796  * \note
1797  * Will do nothing if the category already exists.
1798  */
1799  void addCategory(const char * category);
1800  /**
1801  * \brief Remove a category.
1802  *
1803  * \note
1804  * Will do nothing if the category is missing.
1805  */
1806  void removeCategory(const char * category);
1807  /// Get the number of categories.
1808  int getNumCategories() const;
1809  /**
1810  * \brief Return the category name using its index
1811  *
1812  * \note
1813  * Will be null if the index is invalid.
1814  */
1815  const char * getCategory(int index) const;
1816  /// Clear all the categories.
1817  void clearCategories();
1818 
1819  /**
1820  * *Encodings*
1821  *
1822  * It is sometimes useful for applications to group color spaces based on how the color values
1823  * are digitally encoded. For example, images in scene-linear, logarithmic, video, and data
1824  * color spaces could have different default views. Unlike the Family and EqualityGroup
1825  * attributes of a color space, the list of Encodings is predefined in the OCIO documentation
1826  * (rather than being config-specific) to make it easier for applications to utilize.
1827  *
1828  * Here is an example config entry that could appear under a ColorSpace:
1829  *
1830  * \code{.yaml}
1831  * encoding: scene-linear
1832  * \endcode
1833  *
1834  * Encoding strings are not case-sensitive. Although users may add their own encodings, the
1835  * strings will typically come from a fixed set listed in the documentation (similar to roles).
1836  */
1837  const char * getEncoding() const noexcept;
1838  void setEncoding(const char * encoding);
1839 
1840  /**
1841  * *Data*
1842  *
1843  * ColorSpaces that are data are treated a bit special. Basically, any colorspace transforms
1844  * you try to apply to them are ignored. (Think of applying a gamut mapping transform to an
1845  * ID pass). However, the setDataBypass method on ColorSpaceTransform and DisplayViewTransform
1846  * allow applications to process data when necessary. (Think of sending mattes to an HDR
1847  * monitor.)
1848  *
1849  * This is traditionally used for pixel data that represents non-color
1850  * pixel data, such as normals, point positions, ID information, etc.
1851  */
1852  bool isData() const noexcept;
1853  void setIsData(bool isData) noexcept;
1854 
1855  /**
1856  * *Allocation*
1857  *
1858  * If this colorspace needs to be transferred to a limited dynamic
1859  * range coding space (such as during display with a GPU path), use this
1860  * allocation to maximize bit efficiency.
1861  */
1862  Allocation getAllocation() const noexcept;
1863  void setAllocation(Allocation allocation) noexcept;
1864 
1865  /**
1866  * Specify the optional variable values to configure the allocation.
1867  * If no variables are specified, the defaults are used.
1868  *
1869  * ALLOCATION_UNIFORM::
1870  *
1871  * 2 vars: [min, max]
1872  *
1873  * ALLOCATION_LG2::
1874  *
1875  * 2 vars: [lg2min, lg2max]
1876  * 3 vars: [lg2min, lg2max, linear_offset]
1877  */
1878  int getAllocationNumVars() const;
1879  void getAllocationVars(float * vars) const;
1880  void setAllocationVars(int numvars, const float * vars);
1881 
1882  /**
1883  * *Transform*
1884  *
1885  * If a transform in the specified direction has been specified,
1886  * return it. Otherwise return a null ConstTransformRcPtr
1887  */
1888  ConstTransformRcPtr getTransform(ColorSpaceDirection dir) const noexcept;
1889  /**
1890  * Specify the transform for the appropriate direction.
1891  * Setting the transform to null will clear it.
1892  */
1893  void setTransform(const ConstTransformRcPtr & transform, ColorSpaceDirection dir);
1894 
1895  ColorSpace(const ColorSpace &) = delete;
1896  ColorSpace& operator= (const ColorSpace &) = delete;
1897  /// Do not use (needed only for pybind11).
1898  ~ColorSpace();
1899 
1900 private:
1901  explicit ColorSpace(ReferenceSpaceType referenceSpace);
1902  ColorSpace();
1903 
1904  static void deleter(ColorSpace* c);
1905 
1906  class Impl;
1907  Impl * m_impl;
1908  Impl * getImpl() { return m_impl; }
1909  const Impl * getImpl() const { return m_impl; }
1910 };
1911 
1912 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const ColorSpace&);
1913 
1914 
1915 
1916 
1917 //
1918 // ColorSpaceSet
1919 //
1920 
1921 
1922 /**
1923  * The *ColorSpaceSet* is a set of color spaces (i.e. no color space duplication)
1924  * which could be the result of \ref Config::getColorSpaces
1925  * or built from scratch.
1926  *
1927  * \note
1928  * The color spaces are decoupled from the config ones, i.e., any
1929  * changes to the set itself or to its color spaces do not affect the
1930  * original color spaces from the configuration. If needed,
1931  * use \ref Config::addColorSpace to update the configuration.
1932  */
1934 {
1935 public:
1936  /// Create an empty set of color spaces.
1937  static ColorSpaceSetRcPtr Create();
1938 
1939  /// Create a set containing a copy of all the color spaces.
1940  ColorSpaceSetRcPtr createEditableCopy() const;
1941 
1942  /**
1943  * \brief Return true if the two sets are equal.
1944  *
1945  * \note
1946  * The comparison is done on the color space names (not a deep comparison).
1947  */
1948  bool operator==(const ColorSpaceSet & css) const;
1949  /// Return true if the two sets are different.
1950  bool operator!=(const ColorSpaceSet & css) const;
1951 
1952  /// Return the number of color spaces.
1953  int getNumColorSpaces() const;
1954  /**
1955  * Return the color space name using its index.
1956  * This will be null if an invalid index is specified.
1957  */
1958  const char * getColorSpaceNameByIndex(int index) const;
1959  /**
1960  * Return the color space using its index.
1961  * This will be empty if an invalid index is specified.
1962  */
1963  ConstColorSpaceRcPtr getColorSpaceByIndex(int index) const;
1964 
1965  /**
1966  * \brief
1967  *
1968  * \note
1969  * Only accepts color space names (i.e. no role name).
1970  *
1971  * Will return null if the name is not found.
1972  */
1973  ConstColorSpaceRcPtr getColorSpace(const char * name) const;
1974  /**
1975  * Will return -1 if the name is not found.
1976  *
1977  * \note
1978  * Only accepts color space names (i.e. no role name).
1979  */
1980  int getColorSpaceIndex(const char * name) const;
1981  /**
1982  * \brief
1983  *
1984  * \note
1985  * Only accepts color space names (i.e. no role name)
1986  *
1987  * \param name
1988  * \return true
1989  * \return false
1990  */
1991  bool hasColorSpace(const char * name) const;
1992 
1993  /**
1994  * \brief Add color space(s).
1995  *
1996  * \note
1997  * If another color space is already registered with the same name,
1998  * this will overwrite it. This stores a copy of the specified
1999  * color space(s). Throws if one of the aliases is already assigned as
2000  * a name or alias to an existing color space.
2001  */
2002  void addColorSpace(const ConstColorSpaceRcPtr & cs);
2003  void addColorSpaces(const ConstColorSpaceSetRcPtr & cs);
2004 
2005  /**
2006  * \brief Remove color space(s) using color space names (i.e. no role name).
2007  *
2008  * \note
2009  * The removal of a missing color space does nothing.
2010  */
2011  void removeColorSpace(const char * name);
2012  void removeColorSpaces(const ConstColorSpaceSetRcPtr & cs);
2013 
2014  /// Clear all color spaces.
2015  void clearColorSpaces();
2016 
2017  /// Do not use (needed only for pybind11).
2018  ~ColorSpaceSet();
2019 
2020 private:
2021  ColorSpaceSet();
2022 
2023  ColorSpaceSet(const ColorSpaceSet &);
2024  ColorSpaceSet & operator= (const ColorSpaceSet &);
2025 
2026  static void deleter(ColorSpaceSet * c);
2027 
2028  class Impl;
2029  Impl * m_impl;
2030  Impl * getImpl() { return m_impl; }
2031  const Impl * getImpl() const { return m_impl; }
2032 };
2033 
2034 /** \defgroup ColorSpaceSetOperators
2035  * @{
2036  */
2037 
2038 /**
2039  * \brief Perform the union of two sets.
2040  *
2041  * \note
2042  * This function provides operations on two color space sets
2043  * where the result contains copied color spaces and no duplicates.
2044  *
2045  * \param lcss
2046  * \param rcss
2047  */
2049  const ConstColorSpaceSetRcPtr & rcss);
2050  /**
2051  * \brief Perform the intersection of two sets.
2052  *
2053  * \note
2054  * This function provides operations on two color space sets
2055  * where the result contains copied color spaces and no duplicates.
2056  *
2057  * \param lcss
2058  * \param rcss
2059  */
2061  const ConstColorSpaceSetRcPtr & rcss);
2062 /**
2063  * \brief Perform the difference of two sets.
2064  *
2065  * \note
2066  * This function provides operations on two color space sets
2067  * where the result contains copied color spaces and no duplicates.
2068  *
2069  * \param lcss
2070  * \param rcss
2071  */
2073  const ConstColorSpaceSetRcPtr & rcss);
2074 
2075 /** @}*/
2076 
2077 
2078 //
2079 // Look
2080 //
2081 
2082 /**
2083  * The *Look* is an 'artistic' image modification, in a specified image
2084  * state.
2085  * The processSpace defines the ColorSpace the image is required to be
2086  * in, for the math to apply correctly.
2087  */
2089 {
2090 public:
2091  static LookRcPtr Create();
2092 
2093  LookRcPtr createEditableCopy() const;
2094 
2095  const char * getName() const;
2096  void setName(const char * name);
2097 
2098  const char * getProcessSpace() const;
2099  void setProcessSpace(const char * processSpace);
2100 
2101  ConstTransformRcPtr getTransform() const;
2102  /// Setting a transform to a non-null call makes it allowed.
2103  void setTransform(const ConstTransformRcPtr & transform);
2104 
2105  ConstTransformRcPtr getInverseTransform() const;
2106  /// Setting a transform to a non-null call makes it allowed.
2107  void setInverseTransform(const ConstTransformRcPtr & transform);
2108 
2109  const char * getDescription() const;
2110  void setDescription(const char * description);
2111 
2112  Look(const Look &) = delete;
2113  Look& operator= (const Look &) = delete;
2114  /// Do not use (needed only for pybind11).
2115  ~Look();
2116 
2117 private:
2118  Look();
2119 
2120  static void deleter(Look* c);
2121 
2122  class Impl;
2123  Impl * m_impl;
2124  Impl * getImpl() { return m_impl; }
2125  const Impl * getImpl() const { return m_impl; }
2126 };
2127 
2128 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Look&);
2129 
2130 
2131 /**
2132  * \brief NamedTransform.
2133  *
2134  * A NamedTransform provides a way for config authors to include a set of color
2135  * transforms that are independent of the color space being processed. For example a "utility
2136  * curve" transform where there is no need to convert to or from a reference space.
2137  */
2138 
2140 {
2141 public:
2142  static NamedTransformRcPtr Create();
2143 
2144  virtual NamedTransformRcPtr createEditableCopy() const = 0;
2145 
2146  virtual const char * getName() const noexcept = 0;
2147  virtual void setName(const char * name) noexcept = 0;
2148 
2149  /// Aliases can be used instead of the name. They must be unique within the config.
2150  virtual size_t getNumAliases() const noexcept = 0;
2151  /// Return empty string if idx is out of range.
2152  virtual const char * getAlias(size_t idx) const noexcept = 0;
2153  /**
2154  * Nothing is done if alias is NULL or empty, if it is already there, or if it is already
2155  * the named transform name.
2156  */
2157  virtual void addAlias(const char * alias) noexcept = 0;
2158  /// Does nothing if alias is not present.
2159  virtual void removeAlias(const char * alias) noexcept = 0;
2160  virtual void clearAliases() noexcept = 0;
2161 
2162  /// \see ColorSpace::getFamily
2163  virtual const char * getFamily() const noexcept = 0;
2164  /// \see ColorSpace::setFamily
2165  virtual void setFamily(const char * family) noexcept = 0;
2166 
2167  virtual const char * getDescription() const noexcept = 0;
2168  virtual void setDescription(const char * description) noexcept = 0;
2169 
2170  /// \see ColorSpace::hasCategory
2171  virtual bool hasCategory(const char * category) const noexcept = 0;
2172  /// \see ColorSpace::addCategory
2173  virtual void addCategory(const char * category) noexcept = 0;
2174  /// \see ColorSpace::removeCategory
2175  virtual void removeCategory(const char * category) noexcept = 0;
2176  /// \see ColorSpace::getNumCategories
2177  virtual int getNumCategories() const noexcept = 0;
2178  /// \see ColorSpace::getCategory
2179  virtual const char * getCategory(int index) const noexcept = 0;
2180  /// \see ColorSpace::clearCategories
2181  virtual void clearCategories() noexcept = 0;
2182 
2183  /**
2184  * A NamedTransform is not a color space and does not have an encoding in the same sense.
2185  * However, it may be useful to associate a color space encoding that the transform is intended
2186  * to be used with, for organizational purposes.
2187  */
2188  virtual const char * getEncoding() const noexcept = 0;
2189  virtual void setEncoding(const char * encoding) noexcept = 0;
2190 
2191  virtual ConstTransformRcPtr getTransform(TransformDirection dir) const = 0;
2192  virtual void setTransform(const ConstTransformRcPtr & transform, TransformDirection dir) = 0;
2193 
2194  /**
2195  * Will create the transform from the inverse direction if the transform for requested
2196  * direction is missing.
2197  */
2198  static ConstTransformRcPtr GetTransform(const ConstNamedTransformRcPtr & nt,
2199  TransformDirection dir);
2200 
2201  NamedTransform(const NamedTransform &) = delete;
2202  NamedTransform & operator= (const NamedTransform &) = delete;
2203  // Do not use (needed only for pybind11).
2204  virtual ~NamedTransform() = default;
2205 
2206 protected:
2207  NamedTransform() = default;
2208 };
2209 
2210 extern OCIOEXPORT std::ostream & operator<< (std::ostream &, const NamedTransform &);
2211 
2212 
2213 /**
2214  * A *ViewTransform* provides a conversion from the main (usually scene-referred) reference space
2215  * to the display-referred reference space. This allows splitting the conversion from the main
2216  * reference space to a display into two parts: the ViewTransform plus a display color space.
2217  *
2218  * It is also possible to provide a ViewTransform that converts from the display-referred
2219  * reference space back to that space. This is useful in cases when a ViewTransform is needed
2220  * when converting between displays (such as HDR to SDR).
2221  *
2222  * The ReferenceSpaceType indicates whether the ViewTransform converts from scene-to-display
2223  * reference or display-to-display reference.
2224  *
2225  * The from_reference transform direction is the one that is used when going out towards a display.
2226  */
2228 {
2229 public:
2230  static ViewTransformRcPtr Create(ReferenceSpaceType referenceSpace);
2231 
2232  ViewTransformRcPtr createEditableCopy() const;
2233 
2234  const char * getName() const noexcept;
2235  void setName(const char * name) noexcept;
2236 
2237  /// \see ColorSpace::getFamily
2238  const char * getFamily() const noexcept;
2239  /// \see ColorSpace::setFamily
2240  void setFamily(const char * family);
2241 
2242  const char * getDescription() const noexcept;
2243  void setDescription(const char * description);
2244 
2245  /// \see ColorSpace::hasCategory
2246  bool hasCategory(const char * category) const;
2247  /// \see ColorSpace::addCategory
2248  void addCategory(const char * category);
2249  /// \see ColorSpace::removeCategory
2250  void removeCategory(const char * category);
2251  /// \see ColorSpace::getNumCategories
2252  int getNumCategories() const;
2253  /// \see ColorSpace::getCategory
2254  const char * getCategory(int index) const;
2255  /// \see ColorSpace::clearCategories
2256  void clearCategories();
2257 
2258  ReferenceSpaceType getReferenceSpaceType() const noexcept;
2259 
2260  /**
2261  * If a transform in the specified direction has been specified, return it.
2262  * Otherwise return a null ConstTransformRcPtr
2263  */
2264  ConstTransformRcPtr getTransform(ViewTransformDirection dir) const noexcept;
2265 
2266  /**
2267  * Specify the transform for the appropriate direction. Setting the transform
2268  * to null will clear it.
2269  */
2270  void setTransform(const ConstTransformRcPtr & transform, ViewTransformDirection dir);
2271 
2272  ViewTransform(const ViewTransform &) = delete;
2273  ViewTransform & operator= (const ViewTransform &) = delete;
2274  /// Do not use (needed only for pybind11).
2275  ~ViewTransform();
2276 
2277 private:
2278  ViewTransform();
2279  explicit ViewTransform(ReferenceSpaceType referenceSpace);
2280 
2281  static void deleter(ViewTransform * c);
2282 
2283  class Impl;
2284  Impl * m_impl;
2285  Impl * getImpl() { return m_impl; }
2286  const Impl * getImpl() const { return m_impl; }
2287 };
2288 
2289 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const ViewTransform&);
2290 
2291 //
2292 // Processor
2293 //
2294 
2295 
2296 /**
2297  * The *Processor* represents a specific color transformation which is
2298  * the result of \ref Config::getProcessor.
2299  */
2301 {
2302 public:
2303  bool isNoOp() const;
2304 
2305  /**
2306  * True if the image transformation is non-separable.
2307  * For example, if a change in red may also cause a change in green or blue.
2308  */
2309  bool hasChannelCrosstalk() const;
2310 
2311  const char * getCacheID() const;
2312 
2313  /**
2314  * The ProcessorMetadata contains technical information
2315  * such as the number of files and looks used in the processor.
2316  */
2317  ConstProcessorMetadataRcPtr getProcessorMetadata() const;
2318 
2319  /**
2320  * Get a FormatMetadata containing the top level metadata
2321  * for the processor. For a processor from a CLF file, this corresponds to
2322  * the ProcessList metadata.
2323  */
2324  const FormatMetadata & getFormatMetadata() const;
2325 
2326  /**
2327  * Get the number of transforms that comprise the processor.
2328  * Each transform has a (potentially empty) FormatMetadata.
2329  */
2330  int getNumTransforms() const;
2331  /**
2332  * Get a FormatMetadata containing the metadata for a
2333  * transform within the processor. For a processor from a CLF file, this
2334  * corresponds to the metadata associated with an individual process node.
2335  */
2336  const FormatMetadata & getTransformFormatMetadata(int index) const;
2337 
2338  /**
2339  * Return a \ref GroupTransform that contains a copy of the transforms that comprise the
2340  * processor. (Changes to it will not modify the original processor.) Note that the
2341  * GroupTransform::write method may be used to serialize a Processor. Serializing to
2342  * CTF format is a useful technique for debugging Processor contents.
2343  */
2344  GroupTransformRcPtr createGroupTransform() const;
2345 
2346  /**
2347  * The returned pointer may be used to set the default value of any dynamic
2348  * properties of the requested type. Throws if the requested property is not found. Note
2349  * that if the processor contains several ops that support the requested property, only one
2350  * can be dynamic and only this one will be controlled.
2351  *
2352  * \note The dynamic properties are a convenient way to change on-the-fly values without
2353  * generating again and again a CPU or GPU processor instance. Color transformations can
2354  * contain dynamic properties from a ExposureContrastTransform for example.
2355  * So, Processor, CPUProcessor and GpuShaderCreator all have ways to manage dynamic
2356  * properties. However, the transform dynamic properties are decoupled between the types
2357  * of processor instances so that the same Processor can generate several independent CPU
2358  * and/or GPU processor instances i.e. changing the value of the exposure dynamic property
2359  * from a CPU processor instance does not affect the corresponding GPU processor instance.
2360  * Processor creation will log a warning if there are more than one property of a given type.
2361  * There may be more than one property of a given type, but only one will respond to parameter
2362  * updates, the others will use their original parameter values.
2363  */
2364  DynamicPropertyRcPtr getDynamicProperty(DynamicPropertyType type) const;
2365  /// True if at least one dynamic property of that type exists.
2366  bool hasDynamicProperty(DynamicPropertyType type) const noexcept;
2367  /// True if at least one dynamic property of any type exists and is dynamic.
2368  bool isDynamic() const noexcept;
2369 
2370  /**
2371  * Run the optimizer on a Processor to create a new Processor.
2372  * It is usually not necessary to call this since getting a CPUProcessor or GPUProcessor
2373  * will also optimize. However if you need both, calling this method first makes getting
2374  * a CPU and GPU Processor faster since the optimization is effectively only done once.
2375  */
2376  ConstProcessorRcPtr getOptimizedProcessor(OptimizationFlags oFlags) const;
2377 
2378  /**
2379  * Create a Processor that is optimized for a specific in and out bit-depth (as CPUProcessor
2380  * would do). This method is provided primarily for diagnostic purposes.
2381  */
2382  ConstProcessorRcPtr getOptimizedProcessor(BitDepth inBD, BitDepth outBD,
2383  OptimizationFlags oFlags) const;
2384 
2385  //
2386  // GPU Renderer
2387  //
2388 
2389  /// Get an optimized GPUProcessor instance.
2390  ConstGPUProcessorRcPtr getDefaultGPUProcessor() const;
2391  ConstGPUProcessorRcPtr getOptimizedGPUProcessor(OptimizationFlags oFlags) const;
2392 
2393  /**
2394  * Get an optimized GPUProcessor instance that will emulate the OCIO v1 GPU path. This approach
2395  * bakes some of the ops into a single Lut3D and so is less accurate than the current GPU
2396  * processing methods.
2397  */
2398  ConstGPUProcessorRcPtr getOptimizedLegacyGPUProcessor(OptimizationFlags oFlags,
2399  unsigned edgelen) const;
2400 
2401  //
2402  // CPU Renderer
2403  //
2404 
2405  /**
2406  * Get an optimized CPUProcessor instance.
2407  *
2408  * \note
2409  * This may provide higher fidelity than anticipated due to internal
2410  * optimizations. For example, if the inputColorSpace and the
2411  * outputColorSpace are members of the same equalitygroup, no conversion
2412  * will be applied, even though strictly speaking quantization
2413  * should be added.
2414  *
2415  * \note
2416  * The typical use case to apply color processing to an image is:
2417  *
2418  * \code{.cpp}
2419  *
2420  * OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
2421  *
2422  * OCIO::ConstProcessorRcPtr processor
2423  * = config->getProcessor(colorSpace1, colorSpace2);
2424  *
2425  * OCIO::ConstCPUProcessorRcPtr cpuProcessor
2426  * = processor->getDefaultCPUProcessor();
2427  *
2428  * OCIO::PackedImageDesc img(imgDataPtr, imgWidth, imgHeight, imgChannels);
2429  * cpuProcessor->apply(img);
2430  *
2431  * \endcode
2432  */
2433  ConstCPUProcessorRcPtr getDefaultCPUProcessor() const;
2434  ConstCPUProcessorRcPtr getOptimizedCPUProcessor(OptimizationFlags oFlags) const;
2435  ConstCPUProcessorRcPtr getOptimizedCPUProcessor(BitDepth inBitDepth,
2436  BitDepth outBitDepth,
2437  OptimizationFlags oFlags) const;
2438 
2439  Processor(const Processor &) = delete;
2440  Processor & operator= (const Processor &) = delete;
2441  /// Do not use (needed only for pybind11).
2442  ~Processor();
2443 
2444 private:
2445  Processor();
2446 
2447  static ProcessorRcPtr Create();
2448 
2449  static void deleter(Processor* c);
2450 
2451  friend class Config;
2452 
2453  class Impl;
2454  Impl * m_impl;
2455  Impl * getImpl() { return m_impl; }
2456  const Impl * getImpl() const { return m_impl; }
2457 };
2458 
2459 
2460 ///////////////////////////////////////////////////////////////////////////
2461 // CPUProcessor
2462 
2464 {
2465 public:
2466  /// The in and out bit-depths must be equal for isNoOp to be true.
2467  bool isNoOp() const;
2468 
2469  /**
2470  * Equivalent to isNoOp from the underlying Processor, i.e., it ignores
2471  * in/out bit-depth differences.
2472  */
2473  bool isIdentity() const;
2474 
2475  bool hasChannelCrosstalk() const;
2476 
2477  const char * getCacheID() const;
2478 
2479  /// Bit-depth of the input pixel buffer.
2480  BitDepth getInputBitDepth() const;
2481  /// Bit-depth of the output pixel buffer.
2482  BitDepth getOutputBitDepth() const;
2483 
2484  /**
2485  * The returned pointer may be used to set the value of any dynamic properties
2486  * of the requested type. Throws if the requested property is not found. Note that if the
2487  * processor contains several ops that support the requested property, only one can be dynamic.
2488  *
2489  * \note The dynamic properties in this object are decoupled from the ones in the
2490  * \ref Processor it was generated from. For each dynamic property in the Processor,
2491  * there is one in the CPU processor.
2492  */
2493  DynamicPropertyRcPtr getDynamicProperty(DynamicPropertyType type) const;
2494 
2495  /**
2496  * \brief Apply to an image with any kind of channel ordering while
2497  * respecting the input and output bit-depths.
2498  */
2499  void apply(const ImageDesc & imgDesc) const;
2500  void apply(const ImageDesc & srcImgDesc, ImageDesc & dstImgDesc) const;
2501 
2502  /**
2503  * Apply to a single pixel respecting that the input and output bit-depths
2504  * be 32-bit float and the image buffer be packed RGB/RGBA.
2505  *
2506  * \note
2507  * This is not as efficient as applying to an entire image at once.
2508  * If you are processing multiple pixels, and have the flexibility,
2509  * use the above function instead.
2510  */
2511  void applyRGB(float * pixel) const;
2512  void applyRGBA(float * pixel) const;
2513 
2514  CPUProcessor(const CPUProcessor &) = delete;
2515  CPUProcessor& operator= (const CPUProcessor &) = delete;
2516  /// Do not use (needed only for pybind11).
2517  ~CPUProcessor();
2518 
2519 private:
2520  CPUProcessor();
2521 
2522  static void deleter(CPUProcessor * c);
2523 
2524  friend class Processor;
2525 
2526  class Impl;
2527  Impl * m_impl;
2528  Impl * getImpl() { return m_impl; }
2529  const Impl * getImpl() const { return m_impl; }
2530 };
2531 
2532 
2533 ///////////////////////////////////////////////////////////////////////////
2534 // GPUProcessor
2535 
2537 {
2538 public:
2539  bool isNoOp() const;
2540 
2541  bool hasChannelCrosstalk() const;
2542 
2543  const char * getCacheID() const;
2544 
2545  /// Extract & Store the shader information to implement the color processing.
2546  void extractGpuShaderInfo(GpuShaderDescRcPtr & shaderDesc) const;
2547 
2548  /// Extract the shader information using a custom GpuShaderCreator class.
2549  void extractGpuShaderInfo(GpuShaderCreatorRcPtr & shaderCreator) const;
2550 
2551  GPUProcessor(const GPUProcessor &) = delete;
2552  GPUProcessor& operator= (const GPUProcessor &) = delete;
2553  /// Do not use (needed only for pybind11).
2554  ~GPUProcessor();
2555 
2556 private:
2557  GPUProcessor();
2558 
2559  static void deleter(GPUProcessor * c);
2560 
2561  friend class Processor;
2562 
2563  class Impl;
2564  Impl * m_impl;
2565  Impl * getImpl() { return m_impl; }
2566  const Impl * getImpl() const { return m_impl; }
2567 };
2568 
2569 
2570 /**
2571  * \brief
2572  *
2573  * This class contains meta information about the process that generated
2574  * this processor. The results of these functions do not
2575  * impact the pixel processing.
2576  */
2578 {
2579 public:
2580  static ProcessorMetadataRcPtr Create();
2581 
2582  int getNumFiles() const;
2583  const char * getFile(int index) const;
2584 
2585  int getNumLooks() const;
2586  const char * getLook(int index) const;
2587 
2588  void addFile(const char * fname);
2589  void addLook(const char * look);
2590 
2591  ProcessorMetadata(const ProcessorMetadata &) = delete;
2592  ProcessorMetadata& operator= (const ProcessorMetadata &) = delete;
2593  /// Do not use (needed only for pybind11).
2594  ~ProcessorMetadata();
2595 
2596 private:
2598 
2599  static void deleter(ProcessorMetadata* c);
2600 
2601  class Impl;
2602  Impl * m_impl;
2603  Impl * getImpl() { return m_impl; }
2604  const Impl * getImpl() const { return m_impl; }
2605 };
2606 
2607 
2608 
2609 /**
2610  * In certain situations it is necessary to serialize transforms into a variety
2611  * of application specific LUT formats. Note that not all file formats that may
2612  * be read also support baking.
2613  *
2614  * **Usage Example:** *Bake a CSP sRGB viewer LUT*
2615  *
2616  * \code{.cpp}
2617  *
2618  * OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromEnv();
2619  * OCIO::BakerRcPtr baker = OCIO::Baker::Create();
2620  * baker->setConfig(config);
2621  * baker->setFormat("csp");
2622  * baker->setInputSpace("lnf");
2623  * baker->setShaperSpace("log");
2624  * baker->setTargetSpace("sRGB");
2625  * auto & metadata = baker->getFormatMetadata();
2626  * metadata.addChildElement(OCIO::METADATA_DESCRIPTION, "A first comment");
2627  * metadata.addChildElement(OCIO::METADATA_DESCRIPTION, "A second comment");
2628  * std::ostringstream out;
2629  * baker->bake(out); // fresh bread anyone!
2630  * std::cout << out.str();
2631  *
2632  * \endcode
2633  */
2635 {
2636 public:
2637  /// Create a new Baker.
2638  static BakerRcPtr Create();
2639 
2640  /// Create a copy of this Baker.
2641  BakerRcPtr createEditableCopy() const;
2642 
2643  ConstConfigRcPtr getConfig() const;
2644  /// Set the config to use.
2645  void setConfig(const ConstConfigRcPtr & config);
2646 
2647  const char * getFormat() const;
2648  /// Set the LUT output format.
2649  void setFormat(const char * formatName);
2650 
2651  const FormatMetadata & getFormatMetadata() const;
2652  /**
2653  * Get editable *optional* format metadata. The metadata that will be used
2654  * varies based on the capability of the given file format. Formats such as CSP,
2655  * IridasCube, and ResolveCube will create comments in the file header using the value of
2656  * any first-level children elements of the formatMetadata. The CLF/CTF formats will make
2657  * use of the top-level "id" and "name" attributes and children elements "Description",
2658  * "InputDescriptor", "OutputDescriptor", and "Info".
2659  */
2660  FormatMetadata & getFormatMetadata();
2661 
2662  const char * getInputSpace() const;
2663  /// Set the input ColorSpace that the LUT will be applied to.
2664  void setInputSpace(const char * inputSpace);
2665 
2666  const char * getShaperSpace() const;
2667  /**
2668  * Set an *optional* ColorSpace or NamedTransform to shape the incoming
2669  * values of the LUT. When baking 3DLUT, this will correspond to the 1D
2670  * shaper used to normalise incoming values to the unit range. When baking
2671  * 1D LUT, this will be used to determine the input range of the LUT.
2672  */
2673  void setShaperSpace(const char * shaperSpace);
2674 
2675  const char * getLooks() const;
2676  /**
2677  * Set the looks to be applied during baking. Looks is a potentially comma
2678  * (or colon) delimited list of lookNames, where +/- prefixes are optionally allowed to
2679  * denote forward/inverse look specification. (And forward is assumed in the absence of
2680  * either).
2681  */
2682  void setLooks(const char * looks);
2683 
2684  const char * getTargetSpace() const;
2685  /// Set the target (i.e., output) color space for the LUT. Must not be used if setDisplayView is used.
2686  void setTargetSpace(const char * targetSpace);
2687 
2688  const char * getDisplay() const;
2689  const char * getView() const;
2690  /// Set the display and view to apply during the baking. Must not be used if setTargetSpace is used.
2691  void setDisplayView(const char * display, const char * view);
2692 
2693  int getShaperSize() const;
2694  /**
2695  * Override the default shaper LUT size. Default value is -1, which allows
2696  * each format to use its own most appropriate size. For the CLF format, the default uses
2697  * a half-domain LUT1D (which is ideal for scene-linear inputs).
2698  */
2699  void setShaperSize(int shapersize);
2700 
2701  int getCubeSize() const;
2702  /**
2703  * Override the main LUT (3d or 1d) sample size. Default value is -1, which allows
2704  * each format to use its own most appropriate size.
2705  */
2706  void setCubeSize(int cubesize);
2707 
2708  /// Bake the LUT into the output stream.
2709  void bake(std::ostream & os) const;
2710 
2711  /// Get the number of LUT bakers.
2712  static int getNumFormats();
2713 
2714  /**
2715  * Get the LUT baker format name at index, return empty string if an invalid
2716  * index is specified.
2717  */
2718  static const char * getFormatNameByIndex(int index);
2719  /**
2720  * Get the LUT baker format extension at index, return empty string if an
2721  * invalid index is specified.
2722  */
2723  static const char * getFormatExtensionByIndex(int index);
2724 
2725  Baker(const Baker &) = delete;
2726  Baker& operator= (const Baker &) = delete;
2727  /// Do not use (needed only for pybind11).
2728  ~Baker();
2729 
2730 private:
2731  Baker();
2732 
2733  static void deleter(Baker* o);
2734 
2735  class Impl;
2736  Impl * m_impl;
2737  Impl * getImpl() { return m_impl; }
2738  const Impl * getImpl() const { return m_impl; }
2739 };
2740 
2741 
2742 ///////////////////////////////////////////////////////////////////////////
2743 // ImageDesc
2744 
2746 
2747 /**
2748  * \brief
2749  * This is a light-weight wrapper around an image, that provides a context
2750  * for pixel access. This does NOT claim ownership of the pixels or copy
2751  * image data.
2752  */
2754 {
2755 public:
2756  ImageDesc();
2757  virtual ~ImageDesc();
2758 
2759  /// Get a pointer to the red channel of the first pixel.
2760  virtual void * getRData() const = 0;
2761  /// Get a pointer to the green channel of the first pixel.
2762  virtual void * getGData() const = 0;
2763  /// Get a pointer to the blue channel of the first pixel.
2764  virtual void * getBData() const = 0;
2765  /**
2766  * Get a pointer to the alpha channel of the first pixel
2767  * or null as alpha channel is optional.
2768  */
2769  virtual void * getAData() const = 0;
2770 
2771  /// Get the bit-depth.
2772  virtual BitDepth getBitDepth() const = 0;
2773 
2774  /// Get the width to process (where x position starts at 0 and ends at width-1).
2775  virtual long getWidth() const = 0;
2776  /// Get the height to process (where y position starts at 0 and ends at height-1).
2777  virtual long getHeight() const = 0;
2778 
2779  /// Get the step in bytes to find the same color channel of the next pixel.
2780  virtual ptrdiff_t getXStrideBytes() const = 0;
2781  /**
2782  * Get the step in bytes to find the same color channel
2783  * of the pixel at the same position in the next line.
2784  */
2785  virtual ptrdiff_t getYStrideBytes() const = 0;
2786 
2787  /**
2788  * Is the image buffer in packed mode with the 4 color channels?
2789  * ("Packed" here means that XStrideBytes is 4x the bytes per channel, so it is more specific
2790  * than simply any PackedImageDesc.)
2791  */
2792  virtual bool isRGBAPacked() const = 0;
2793  /// Is the image buffer 32-bit float?
2794  virtual bool isFloat() const = 0;
2795 
2796 private:
2797  ImageDesc(const ImageDesc &);
2798  ImageDesc & operator= (const ImageDesc &);
2799 };
2800 
2801 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const ImageDesc&);
2802 
2803 
2804 ///////////////////////////////////////////////////////////////////////////
2805 // PackedImageDesc
2806 
2807 /**
2808  * All the constructors expect a pointer to packed image data (such as
2809  * rgbrgbrgb or rgbargbargba) starting at the first color channel of
2810  * the first pixel to process (which does not need to be the first pixel
2811  * of the image). The number of channels must be greater than or equal to 3.
2812  * If a 4th channel is specified, it is assumed to be alpha
2813  * information. Channels > 4 will be ignored.
2814  *
2815  * \note
2816  * The methods assume the CPUProcessor bit-depth type for the data pointer.
2817  */
2819 {
2820 public:
2821 
2822  /**
2823  * \note
2824  * numChannels must be 3 (RGB) or 4 (RGBA).
2825  */
2826  PackedImageDesc(void * data,
2827  long width, long height,
2828  long numChannels);
2829 
2830  /**
2831  * \note
2832  * numChannels must be 3 (RGB) or 4 (RGBA).
2833  */
2834  PackedImageDesc(void * data,
2835  long width, long height,
2836  long numChannels,
2837  BitDepth bitDepth,
2838  ptrdiff_t chanStrideBytes,
2839  ptrdiff_t xStrideBytes,
2840  ptrdiff_t yStrideBytes);
2841 
2842  PackedImageDesc(void * data,
2843  long width, long height,
2844  ChannelOrdering chanOrder);
2845 
2846  PackedImageDesc(void * data,
2847  long width, long height,
2848  ChannelOrdering chanOrder,
2849  BitDepth bitDepth,
2850  ptrdiff_t chanStrideBytes,
2851  ptrdiff_t xStrideBytes,
2852  ptrdiff_t yStrideBytes);
2853 
2854  virtual ~PackedImageDesc();
2855 
2856  /// Get the channel ordering of all the pixels.
2857  ChannelOrdering getChannelOrder() const;
2858 
2859  /// Get the bit-depth.
2860  BitDepth getBitDepth() const override;
2861 
2862  /// Get a pointer to the first color channel of the first pixel.
2863  void * getData() const;
2864 
2865  void * getRData() const override;
2866  void * getGData() const override;
2867  void * getBData() const override;
2868  void * getAData() const override;
2869 
2870  long getWidth() const override;
2871  long getHeight() const override;
2872  long getNumChannels() const;
2873 
2874  ptrdiff_t getChanStrideBytes() const;
2875  ptrdiff_t getXStrideBytes() const override;
2876  ptrdiff_t getYStrideBytes() const override;
2877 
2878  bool isRGBAPacked() const override;
2879  bool isFloat() const override;
2880 
2881 private:
2882  struct Impl;
2883  Impl * m_impl;
2884  Impl * getImpl() { return m_impl; }
2885  const Impl * getImpl() const { return m_impl; }
2886 
2887  PackedImageDesc();
2889  PackedImageDesc& operator= (const PackedImageDesc &);
2890 };
2891 
2892 
2893 ///////////////////////////////////////////////////////////////////////////
2894 // PlanarImageDesc
2895 
2896 /**
2897  * All the constructors expect pointers to the specified image planes
2898  * (i.e. rrrr gggg bbbb) starting at the first color channel of the
2899  * first pixel to process (which need not be the first pixel of the image).
2900  * Pass NULL for aData if no alpha exists (r/g/bData must not be NULL).
2901  *
2902  * \note
2903  * The methods assume the CPUProcessor bit-depth type for the R/G/B/A data pointers.
2904  */
2906 {
2907 public:
2908 
2909  PlanarImageDesc(void * rData, void * gData, void * bData, void * aData,
2910  long width, long height);
2911 
2912  /**
2913  *
2914  * Note that although PlanarImageDesc is powerful enough to also describe
2915  * all PackedImageDesc scenarios, it is recommended to use
2916  * a PackedImageDesc where possible since that allows for additional
2917  * optimizations.
2918  */
2919  PlanarImageDesc(void * rData, void * gData, void * bData, void * aData,
2920  long width, long height,
2921  BitDepth bitDepth,
2922  ptrdiff_t xStrideBytes,
2923  ptrdiff_t yStrideBytes);
2924 
2925  virtual ~PlanarImageDesc();
2926 
2927  void * getRData() const override;
2928  void * getGData() const override;
2929  void * getBData() const override;
2930  void * getAData() const override;
2931 
2932  /// Get the bit-depth.
2933  BitDepth getBitDepth() const override;
2934 
2935  long getWidth() const override;
2936  long getHeight() const override;
2937 
2938  ptrdiff_t getXStrideBytes() const override;
2939  ptrdiff_t getYStrideBytes() const override;
2940 
2941  bool isRGBAPacked() const override;
2942  bool isFloat() const override;
2943 
2944 private:
2945  struct Impl;
2946  Impl * m_impl;
2947  Impl * getImpl() { return m_impl; }
2948  const Impl * getImpl() const { return m_impl; }
2949 
2950  PlanarImageDesc();
2952  PlanarImageDesc& operator= (const PlanarImageDesc &);
2953 };
2954 
2955 
2956 ///////////////////////////////////////////////////////////////////////////
2957 // GpuShaderCreator
2958 /**
2959  * Inherit from the class to fully customize the implementation of a GPU shader program
2960  * from a color transformation.
2961  *
2962  * When no customizations are needed and the intermediate in-memory step is acceptable then the
2963  * \ref GpuShaderDesc is a better choice.
2964  *
2965  * \note
2966  * To better decouple the \ref DynamicProperties from their GPU implementation, the code provides
2967  * several addUniform() methods i.e. one per access function types. For example, an
2968  * \ref ExposureContrastTransform instance owns three \ref DynamicProperties and they are all
2969  * implemented by a double. When creating the GPU fragment shader program, the addUniform() with
2970  * GpuShaderCreator::DoubleGetter is called when property is dynamic, up to three times.
2971  *
2972  * **An OCIO shader program could contain:**
2973  *
2974  * * A declaration part e.g., uniform sampled3D tex3;
2975  *
2976  * * Some helper methods
2977  *
2978  * * The OCIO shader function may be broken down as:
2979  *
2980  * * The function header e.g., void OCIODisplay(in vec4 inColor) {
2981  * * The function body e.g., vec4 outColor.rgb = texture3D(tex3, inColor.rgb).rgb;
2982  * * The function footer e.g., return outColor; }
2983  *
2984  *
2985  * **Usage Example:**
2986  *
2987  * Below is a code snippet to highlight the different parts of the OCIO shader program.
2988  *
2989  * \code{.cpp}
2990  *
2991  * // All global declarations
2992  * uniform sampled3D tex3;
2993  *
2994  * // All helper methods
2995  * vec3 computePosition(vec3 color)
2996  * {
2997  * vec3 coords = color;
2998  * // Some processing...
2999  * return coords;
3000  * }
3001  *
3002  * // The shader function
3003  * vec4 OCIODisplay(in vec4 inColor) //
3004  * { // Function Header
3005  * vec4 outColor = inColor; //
3006  *
3007  * outColor.rgb = texture3D(tex3, computePosition(inColor.rgb)).rgb;
3008  *
3009  * return outColor; // Function Footer
3010  * } //
3011  *
3012  * \endcode
3013  */
3015 {
3016 public:
3017 
3018  virtual GpuShaderCreatorRcPtr clone() const = 0;
3019 
3020  const char * getUniqueID() const noexcept;
3021  void setUniqueID(const char * uid) noexcept;
3022 
3023  GpuLanguage getLanguage() const noexcept;
3024  /// Set the shader program language.
3025  void setLanguage(GpuLanguage lang) noexcept;
3026 
3027  const char * getFunctionName() const noexcept;
3028  // Set the function name of the shader program.
3029  void setFunctionName(const char * name) noexcept;
3030 
3031  const char * getPixelName() const noexcept;
3032  /// Set the pixel name variable holding the color values.
3033  void setPixelName(const char * name) noexcept;
3034 
3035  /**
3036  *
3037  * \note
3038  * Some applications require that textures, uniforms,
3039  * and helper methods be uniquely named because several
3040  * processor instances could coexist.
3041  */
3042  const char * getResourcePrefix() const noexcept;
3043  /// Set a prefix to the resource name
3044  void setResourcePrefix(const char * prefix) noexcept;
3045 
3046  virtual const char * getCacheID() const noexcept;
3047 
3048  /// Start to collect the shader data.
3049  virtual void begin(const char * uid);
3050  /// End to collect the shader data.
3051  virtual void end();
3052 
3053  /// Some graphic cards could have 1D & 2D textures with size limitations.
3054  virtual void setTextureMaxWidth(unsigned maxWidth) = 0;
3055  virtual unsigned getTextureMaxWidth() const noexcept = 0;
3056 
3057  /**
3058  * To avoid global texture sampler and uniform name clashes always append an increasing index
3059  * to the resource name.
3060  */
3061  unsigned getNextResourceIndex() noexcept;
3062 
3063  /// Function returning a double, used by uniforms. GPU converts double to float.
3064  typedef std::function<double()> DoubleGetter;
3065  /// Function returning a bool, used by uniforms.
3066  typedef std::function<bool()> BoolGetter;
3067  /// Functions returning a Float3, used by uniforms.
3068  typedef std::function<const Float3 &()> Float3Getter;
3069  /// Function returning an int, used by uniforms.
3070  typedef std::function<int()> SizeGetter;
3071  /// Function returning a float *, used by uniforms.
3072  typedef std::function<const float *()> VectorFloatGetter;
3073  /// Function returning an int *, used by uniforms.
3074  typedef std::function<const int *()> VectorIntGetter;
3075 
3076  virtual bool addUniform(const char * name,
3077  const DoubleGetter & getDouble) = 0;
3078 
3079  virtual bool addUniform(const char * name,
3080  const BoolGetter & getBool) = 0;
3081 
3082  virtual bool addUniform(const char * name,
3083  const Float3Getter & getFloat3) = 0;
3084 
3085  virtual bool addUniform(const char * name,
3086  const SizeGetter & getSize,
3087  const VectorFloatGetter & getVectorFloat) = 0;
3088 
3089  virtual bool addUniform(const char * name,
3090  const SizeGetter & getSize,
3091  const VectorIntGetter & getVectorInt) = 0;
3092 
3093  /// Adds the property (used internally).
3094  void addDynamicProperty(DynamicPropertyRcPtr & prop);
3095 
3096  /// Dynamic Property related methods.
3097  unsigned getNumDynamicProperties() const noexcept;
3098  DynamicPropertyRcPtr getDynamicProperty(unsigned index) const;
3099 
3100  bool hasDynamicProperty(DynamicPropertyType type) const;
3101  /**
3102  * Dynamic properties allow changes once the fragment shader program has been created. The
3103  * steps are to get the appropriate DynamicProperty instance, and then change its value.
3104  */
3105  DynamicPropertyRcPtr getDynamicProperty(DynamicPropertyType type) const;
3106 
3108  {
3109  TEXTURE_RED_CHANNEL, ///< Only need a red channel texture
3110  TEXTURE_RGB_CHANNEL ///< Need a RGB texture
3111  };
3112 
3113  /**
3114  * Add a 2D texture (1D texture if height equals 1).
3115  *
3116  * \note
3117  * The 'values' parameter contains the LUT data which must be used as-is as the dimensions and
3118  * origin are hard-coded in the fragment shader program. So, it means one GPU texture per entry.
3119  **/
3120  virtual void addTexture(const char * textureName,
3121  const char * samplerName,
3122  unsigned width, unsigned height,
3123  TextureType channel,
3124  Interpolation interpolation,
3125  const float * values) = 0;
3126 
3127  /**
3128  * Add a 3D texture with RGB channel type.
3129  *
3130  * \note
3131  * The 'values' parameter contains the 3D LUT data which must be used as-is as the dimension
3132  * and origin are hard-coded in the fragment shader program. So, it means one GPU 3D texture
3133  * per entry.
3134  **/
3135  virtual void add3DTexture(const char * textureName,
3136  const char * samplerName,
3137  unsigned edgelen,
3138  Interpolation interpolation,
3139  const float * values) = 0;
3140 
3141  // Methods to specialize parts of a OCIO shader program
3142  virtual void addToDeclareShaderCode(const char * shaderCode);
3143  virtual void addToHelperShaderCode(const char * shaderCode);
3144  virtual void addToFunctionHeaderShaderCode(const char * shaderCode);
3145  virtual void addToFunctionShaderCode(const char * shaderCode);
3146  virtual void addToFunctionFooterShaderCode(const char * shaderCode);
3147 
3148  /**
3149  * \brief Create the OCIO shader program
3150  *
3151  * \note
3152  * The OCIO shader program is decomposed to allow a specific implementation
3153  * to change some parts. Some product integrations add the color processing
3154  * within a client shader program, imposing constraints requiring this flexibility.
3155  */
3156  virtual void createShaderText(const char * shaderDeclarations,
3157  const char * shaderHelperMethods,
3158  const char * shaderFunctionHeader,
3159  const char * shaderFunctionBody,
3160  const char * shaderFunctionFooter);
3161 
3162  virtual void finalize();
3163 
3164  GpuShaderCreator(const GpuShaderCreator &) = delete;
3165  GpuShaderCreator & operator= (const GpuShaderCreator &) = delete;
3166  /// Do not use (needed only for pybind11).
3167  virtual ~GpuShaderCreator();
3168 
3169 protected:
3170  GpuShaderCreator();
3171 
3172  class Impl;
3173  Impl * m_impl;
3174  Impl * getImpl() { return m_impl; }
3175  const Impl * getImpl() const { return m_impl; }
3176 };
3177 
3178 // GpuShaderDesc
3179 /**
3180  * \brief This class holds the GPU-related information needed to build a shader program
3181  * from a specific processor.
3182  *
3183  * This class defines the interface and there are two implementations provided.
3184  * The "legacy" mode implements the OCIO v1 approach of baking certain ops
3185  * in order to have at most one 3D-LUT. The "generic" mode is the v2 default and
3186  * allows all the ops to be processed as-is, without baking, like the CPU renderer.
3187  * Custom implementations could be written to accommodate the GPU needs of a
3188  * specific client app.
3189  *
3190  *
3191  * The complete fragment shader program is decomposed in two main parts:
3192  * the OCIO shader program for the color processing and the client shader
3193  * program which consumes the pixel color processing.
3194  *
3195  * The OCIO shader program is fully described by the GpuShaderDesc
3196  * independently from the client shader program. The only critical
3197  * point is the agreement on the OCIO function shader name.
3198  *
3199  * To summarize, the complete shader program is:
3200  *
3201  * \code{.cpp}
3202  *
3203  * ////////////////////////////////////////////////////////////////////////
3204  * // //
3205  * // The complete fragment shader program //
3206  * // //
3207  * ////////////////////////////////////////////////////////////////////////
3208  * // //
3209  * // ////////////////////////////////////////////////////////////// //
3210  * // // // //
3211  * // // The OCIO shader program // //
3212  * // // // //
3213  * // ////////////////////////////////////////////////////////////// //
3214  * // // // //
3215  * // // // All global declarations // //
3216  * // // uniform sampled3D tex3; // //
3217  * // // // //
3218  * // // // All helper methods // //
3219  * // // vec3 computePos(vec3 color) // //
3220  * // // { // //
3221  * // // vec3 coords = color; // //
3222  * // // ... // //
3223  * // // return coords; // //
3224  * // // } // //
3225  * // // // //
3226  * // // // The OCIO shader function // //
3227  * // // vec4 OCIODisplay(in vec4 inColor) // //
3228  * // // { // //
3229  * // // vec4 outColor = inColor; // //
3230  * // // ... // //
3231  * // // outColor.rbg // //
3232  * // // = texture3D(tex3, computePos(inColor.rgb)).rgb; // //
3233  * // // ... // //
3234  * // // return outColor; // //
3235  * // // } // //
3236  * // // // //
3237  * // ////////////////////////////////////////////////////////////// //
3238  * // //
3239  * // ////////////////////////////////////////////////////////////// //
3240  * // // // //
3241  * // // The client shader program // //
3242  * // // // //
3243  * // ////////////////////////////////////////////////////////////// //
3244  * // // // //
3245  * // // uniform sampler2D image; // //
3246  * // // // //
3247  * // // void main() // //
3248  * // // { // //
3249  * // // vec4 inColor = texture2D(image, gl_TexCoord[0].st); // //
3250  * // // ... // //
3251  * // // vec4 outColor = OCIODisplay(inColor); // //
3252  * // // ... // //
3253  * // // gl_FragColor = outColor; // //
3254  * // // } // //
3255  * // // // //
3256  * // ////////////////////////////////////////////////////////////// //
3257  * // //
3258  * ////////////////////////////////////////////////////////////////////////
3259  * \endcode
3260  *
3261  * **Usage Example:** *Building a GPU shader*
3262  *
3263  * This example is based on the code in: src/apps/ociodisplay/main.cpp
3264  *
3265  * \code{.cpp}
3266  *
3267  * // Get the processor
3268  * //
3269  * OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromEnv();
3270  * OCIO::ConstProcessorRcPtr processor
3271  * = config->getProcessor("ACES - ACEScg", "Output - sRGB");
3272  *
3273  * // Step 1: Create a GPU shader description
3274  * //
3275  * // The two potential scenarios are:
3276  * //
3277  * // 1. Instantiate the generic shader description. The color processor
3278  * // is used as-is (i.e. without any baking step) and could contain
3279  * // any number of 1D & 3D luts.
3280  * //
3281  * // This is the default OCIO v2 behavior and allows a much better
3282  * // match between the CPU and GPU renderers.
3283  * //
3284  * OCIO::GpuShaderDescRcPtr shaderDesc = OCIO::GpuShaderDesc::Create();
3285  * //
3286  * // 2. Instantiate a custom shader description.
3287  * //
3288  * // Writing a custom shader description is a way to tailor the shaders
3289  * // to the needs of a given client program. This involves writing a
3290  * // new class inheriting from the pure virtual class GpuShaderDesc.
3291  * //
3292  * // Please refer to the GenericGpuShaderDesc class for an example.
3293  * //
3294  * OCIO::GpuShaderDescRcPtr shaderDesc = MyCustomGpuShader::Create();
3295  *
3296  * shaderDesc->setLanguage(OCIO::GPU_LANGUAGE_GLSL_1_2);
3297  * shaderDesc->setFunctionName("OCIODisplay");
3298  *
3299  * // Step 2: Collect the shader program information for a specific processor
3300  * //
3301  * processor->extractGpuShaderInfo(shaderDesc);
3302  *
3303  * // Step 3: Create a helper to build the shader. Here we use a helper for
3304  * // OpenGL but there will also be helpers for other languages.
3305  * //
3306  * OpenGLBuilderRcPtr oglBuilder = OpenGLBuilder::Create(shaderDesc);
3307  *
3308  * // Step 4: Allocate & upload all the LUTs
3309  * //
3310  * oglBuilder->allocateAllTextures();
3311  *
3312  * // Step 5: Build the complete fragment shader program using
3313  * // g_fragShaderText which is the client shader program.
3314  * //
3315  * g_programId = oglBuilder->buildProgram(g_fragShaderText);
3316  *
3317  * // Step 6: Enable the fragment shader program, and all needed textures
3318  * //
3319  * glUseProgram(g_programId);
3320  * glUniform1i(glGetUniformLocation(g_programId, "tex1"), 1); // image texture
3321  * oglBuilder->useAllTextures(g_programId); // LUT textures
3322  *
3323  * // Step 7: Update uniforms from dynamic property instances.
3324  * m_oglBuilder->useAllUniforms();
3325  * \endcode
3326  *
3327  */
3329 {
3330 public:
3331 
3332  /// Create the default shader description.
3333  static GpuShaderDescRcPtr CreateShaderDesc();
3334 
3335  GpuShaderCreatorRcPtr clone() const override;
3336 
3337  /**
3338  * Used to retrieve uniform information. UniformData m_type indicates the type of uniform
3339  * and what member of the structure should be used:
3340  * * UNIFORM_DOUBLE: m_getDouble.
3341  * * UNIFORM_BOOL: m_getBool.
3342  * * UNIFORM_FLOAT3: m_getFloat3.
3343  * * UNIFORM_VECTOR_FLOAT: m_vectorFloat.
3344  * * UNIFORM_VECTOR_INT: m_vectorInt.
3345  */
3347  {
3349  DoubleGetter m_getDouble{};
3350  BoolGetter m_getBool{};
3351  Float3Getter m_getFloat3{};
3353  {
3354  SizeGetter m_getSize{};
3355  VectorFloatGetter m_getVector{};
3356  } m_vectorFloat{};
3357  struct VectorInt
3358  {
3359  SizeGetter m_getSize{};
3360  VectorIntGetter m_getVector{};
3361  } m_vectorInt{};
3362  };
3363  virtual unsigned getNumUniforms() const noexcept = 0;
3364  /// Returns name of uniform and data as parameter.
3365  virtual const char * getUniform(unsigned index, UniformData & data) const = 0;
3366 
3367  // 1D lut related methods
3368  virtual unsigned getNumTextures() const noexcept = 0;
3369  virtual void getTexture(unsigned index,
3370  const char *& textureName,
3371  const char *& samplerName,
3372  unsigned & width,
3373  unsigned & height,
3374  TextureType & channel,
3375  Interpolation & interpolation) const = 0;
3376  virtual void getTextureValues(unsigned index, const float *& values) const = 0;
3377 
3378  // 3D lut related methods
3379  virtual unsigned getNum3DTextures() const noexcept = 0;
3380  virtual void get3DTexture(unsigned index,
3381  const char *& textureName,
3382  const char *& samplerName,
3383  unsigned & edgelen,
3384  Interpolation & interpolation) const = 0;
3385  virtual void get3DTextureValues(unsigned index, const float *& values) const = 0;
3386 
3387  /// Get the complete OCIO shader program.
3388  const char * getShaderText() const noexcept;
3389 
3390  GpuShaderDesc(const GpuShaderDesc &) = delete;
3391  GpuShaderDesc& operator= (const GpuShaderDesc &) = delete;
3392  /// Do not use (needed only for pybind11).
3393  virtual ~GpuShaderDesc();
3394 
3395 protected:
3396  GpuShaderDesc();
3397 };
3398 
3399 
3400 /**
3401  * Context
3402  *
3403  * A context defines some overrides to a Config. For example, it can override the
3404  * search path or change the value of a context variable.
3405  *
3406  * \note
3407  * Only some \ref Config::getProcessor methods accept a custom context; otherwise,
3408  * the default context instance is used (see \ref Config::getCurrentContext).
3409  *
3410  * Context Variables
3411  *
3412  * The context variables allow changes at runtime using environment variables. For example,
3413  * a color space name (such as src & dst for the ColorSpaceTransform) or a file
3414  * name (such as LUT file name for the FileTransform) could be defined by context
3415  * variables. The color transformation is then customized based on some environment variables.
3416  *
3417  * In a config the context variables support three syntaxes (i.e. ${VAR}, $VAR and %VAR%) and
3418  * the parsing starts from longest to shortest. So, the resolve works like '$TEST_$TESTING_$TE'
3419  * expands in this order '2 1 3'.
3420  *
3421  * Config authors are recommended to include the "environment" section in their configs. This
3422  * improves performance as well as making the config more readable. When present, this section
3423  * must declare all context variables used in the config. It may also provide a default value,
3424  * in case the variable is not present in the user's environment.
3425  *
3426  * A context variable may only be used in the following places:
3427  * * the \ref `ColorSpaceTransform` to define the source and the destination color space names,
3428  * * the \ref `FileTransform` to define the source file name (e.g. a LUT file name),
3429  * * the search_path,
3430  * * the cccid of the \ref `FileTransform` to only extract one specific transform from
3431  * the CDL & CCC files.
3432  *
3433  * Some specific restrictions are worth calling out:
3434  * * they cannot be used as either the name or value of a role,
3435  * * the context variable characters $ and % are prohibited in a color space name.
3436  */
3438 {
3439 public:
3440  static ContextRcPtr Create();
3441 
3442  ContextRcPtr createEditableCopy() const;
3443 
3444  const char * getCacheID() const;
3445 
3446  void setSearchPath(const char * path);
3447  const char * getSearchPath() const;
3448 
3449  int getNumSearchPaths() const;
3450  const char * getSearchPath(int index) const;
3451  void clearSearchPaths();
3452  void addSearchPath(const char * path);
3453  void setWorkingDir(const char * dirname);
3454  const char * getWorkingDir() const;
3455 
3456  /// Add (or update) a context variable. But it removes it if the value argument is null.
3457  /// Note that a Context StringVar is the same thing as a Config EnvironmentVar and these
3458  /// are both often referred to as a "context var".
3459  void setStringVar(const char * name, const char * value) noexcept;
3460  /// Get the context variable value. It returns an empty string if the context
3461  /// variable is null or does not exist.
3462  const char * getStringVar(const char * name) const noexcept;
3463 
3464  int getNumStringVars() const;
3465  const char * getStringVarNameByIndex(int index) const;
3466 
3467  const char * getStringVarByIndex(int index) const;
3468 
3469  void clearStringVars();
3470 
3471  /// Add to the instance all the context variables from ctx.
3472  void addStringVars(const ConstContextRcPtr & ctx) noexcept;
3473 
3474  /// See \ref Config::setEnvironmentMode.
3475  void setEnvironmentMode(EnvironmentMode mode) noexcept;
3476  EnvironmentMode getEnvironmentMode() const noexcept;
3477 
3478  /// Seed string vars with the current environment, based on the EnvironmentMode setting.
3479  void loadEnvironment() noexcept;
3480 
3481  /// Resolve all the context variables from the string. It could be color space
3482  /// names or file names. Note that it recursively applies the context variable resolution.
3483  /// Returns the string unchanged if it does not contain any context variable.
3484  const char * resolveStringVar(const char * string) const noexcept;
3485  /// Resolve all the context variables from the string and return all the context
3486  /// variables used to resolve the string (empty if no context variables were used).
3487  const char * resolveStringVar(const char * string, ContextRcPtr & usedContextVars) const noexcept;
3488 
3489  /**
3490  * Build the resolved and expanded filepath using the search_path when needed,
3491  * and check if the filepath exists. If it cannot be resolved or found, an exception will be
3492  * thrown. The method argument is directly from the config file so it can be an absolute or
3493  * relative file path or a file name.
3494  *
3495  * \note The filepath existence check could add a performance hit.
3496  *
3497  * \note The context variable resolution is performed using :cpp:func:`resolveStringVar`.
3498  */
3499  const char * resolveFileLocation(const char * filename) const;
3500  /// Build the resolved and expanded filepath and return all the context variables
3501  /// used to resolve the filename (empty if no context variables were used).
3502  const char * resolveFileLocation(const char * filename, ContextRcPtr & usedContextVars) const;
3503 
3504  /// Set the ConfigIOProxy object used to provision the config and LUTs from somewhere other
3505  /// than the file system.
3506  void setConfigIOProxy(ConfigIOProxyRcPtr ciop);
3507  ConfigIOProxyRcPtr getConfigIOProxy() const;
3508 
3509  Context(const Context &) = delete;
3510  Context& operator= (const Context &) = delete;
3511  /// Do not use (needed only for pybind11).
3512  ~Context();
3513 
3514 private:
3515  Context();
3516 
3517  static void deleter(Context* c);
3518 
3519  class Impl;
3520  Impl * m_impl;
3521  Impl * getImpl() { return m_impl; }
3522  const Impl * getImpl() const { return m_impl; }
3523 };
3524 
3525 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Context&);
3526 
3527 
3528 ///////////////////////////////////////////////////////////////////////////
3529 // BuiltinTransformRegistry
3530 
3531 /**
3532  * The built-in transform registry contains all the existing built-in transforms which can
3533  * be used by a configuration (version 2 or higher only).
3534  */
3536 {
3537 public:
3539  BuiltinTransformRegistry & operator= (const BuiltinTransformRegistry &) = delete;
3540 
3541  /// Get the current built-in transform registry.
3542  static ConstBuiltinTransformRegistryRcPtr Get() noexcept;
3543 
3544  /// Get the number of built-in transforms available.
3545  virtual size_t getNumBuiltins() const noexcept = 0;
3546  /**
3547  * Get the style string for the i-th built-in transform.
3548  * The style is the ID string that identifies a given transform.
3549  */
3550  virtual const char * getBuiltinStyle(size_t index) const = 0;
3551  /// Get the description string for the i-th built-in transform.
3552  virtual const char * getBuiltinDescription(size_t index) const = 0;
3553 
3554 protected:
3555  BuiltinTransformRegistry() = default;
3556  virtual ~BuiltinTransformRegistry() = default;
3557 };
3558 
3559 ///////////////////////////////////////////////////////////////////////////
3560 // BuiltinConfigRegistry
3561 
3562 /**
3563  * The built-in configs registry contains information about all the existing built-in configs.
3564  */
3566 {
3567 public:
3568  BuiltinConfigRegistry(const BuiltinConfigRegistry &) = delete;
3569  BuiltinConfigRegistry & operator= (const BuiltinConfigRegistry &) = delete;
3570 
3571  /// Get the current built-in configs registry.
3572  static const BuiltinConfigRegistry & Get() noexcept;
3573 
3574  /// Get the number of built-in configs available.
3575  virtual size_t getNumBuiltinConfigs() const noexcept = 0;
3576 
3577  /// Get the name of the config at the specified (zero-based) index.
3578  /// Throws for illegal index.
3579  virtual const char * getBuiltinConfigName(size_t configIndex) const = 0;
3580 
3581  // Get a user-friendly name for a built-in config, appropriate for displaying in a user interface.
3582  /// Throws for illegal index.
3583  virtual const char * getBuiltinConfigUIName(size_t configIndex) const = 0;
3584 
3585  /// Get Yaml text of the built-in config at the specified index.
3586  /// Throws for illegal index.
3587  virtual const char * getBuiltinConfig(size_t configIndex) const = 0;
3588 
3589  /// Get the Yaml text of the built-in config with the specified name.
3590  /// Throws if the name is not found.
3591  virtual const char * getBuiltinConfigByName(const char * configName) const = 0;
3592 
3593  /**
3594  * @brief Check if a specific built-in config is recommended.
3595  *
3596  * For backwards compatibility reasons, configs will remain in the registry even if they have
3597  * been superseded. If an app is presenting a list of configs to users, it should not include
3598  * configs that are no longer recommended.
3599  *
3600  * Throws if the name is not found.
3601  *
3602  * @param configIndex Index of built-in config.
3603  * @return true if the config is recommended.
3604  */
3605  virtual bool isBuiltinConfigRecommended(size_t configIndex) const = 0;
3606 
3607  /**
3608  * @brief Get the default recommended built-in config.
3609  *
3610  * Get the name of the built-in config that is currently recommended as the default config
3611  * to use for applications looking for basic color management.
3612  *
3613  * As the built-in config collection evolves, the default config name will change in future
3614  * releases.
3615  *
3616  * For backwards compatibility, the name provided here will always work as an argument
3617  * to other methods so that any previous default config may be recovered.
3618  *
3619  * Throws if the name is not found.
3620  *
3621  * @return Default's built-in config name.
3622  */
3623  virtual const char * getDefaultBuiltinConfigName() const = 0;
3624 protected:
3625  BuiltinConfigRegistry() = default;
3626  virtual ~BuiltinConfigRegistry() = default;
3627 };
3628 
3629 
3630 ///////////////////////////////////////////////////////////////////////////
3631 // SystemMonitors
3632 
3633 /**
3634  * Provides access to the ICC monitor profile provided by the operating system for each active display.
3635  */
3637 {
3638 public:
3639  SystemMonitors(const SystemMonitors &) = delete;
3640  SystemMonitors & operator= (const SystemMonitors &) = delete;
3641 
3642  /// Get the existing instance.
3643  static ConstSystemMonitorsRcPtr Get() noexcept;
3644 
3645  /**
3646  * True if the OS is able to provide ICC profiles for the attached monitors (macOS, Windows)
3647  * and false otherwise.
3648  */
3649  virtual bool isSupported() const noexcept = 0;
3650 
3651  /**
3652  * \defgroup Methods to access some information of the attached and active monitors.
3653  * @{
3654  */
3655 
3656  /// Get the number of active monitors reported by the operating system.
3657  virtual size_t getNumMonitors() const noexcept = 0;
3658 
3659  /**
3660  * \brief Get the monitor profile name.
3661  *
3662  * Get the string describing the monitor. It is used as an argument to instantiateDisplay. It
3663  * may also be used in a UI to ask a user which of several monitors they want to instantiate a
3664  * display for.
3665  */
3666  virtual const char * getMonitorName(size_t idx) const = 0;
3667  /// Get the ICC profile path associated to the monitor.
3668  virtual const char * getProfileFilepath(size_t idx) const = 0;
3669 
3670  /** @} */
3671 
3672 protected:
3673  SystemMonitors() = default;
3674  virtual ~SystemMonitors() = default;
3675 };
3676 
3677 
3678 ///////////////////////////////////////////////////////////////////////////
3679 // ConfigIOProxy
3680 
3681 /**
3682  * ConfigIOProxy is a proxy class to allow the calling program to supply the config and any
3683  * associated LUT files directly, without relying on the standard file system.
3684  *
3685  * The OCIOZ archive feature is implemented using this mechanism.
3686  */
3688 {
3689 public:
3690  ConfigIOProxy() = default;
3691  virtual ~ConfigIOProxy() = default;
3692 
3693  /**
3694  * \brief Provide the contents of a LUT file as a buffer of uint8_t data.
3695  *
3696  * \param filepath Fully resolved path to the "file."
3697  *
3698  * The file path is based on the Config's current working directory and is the same absolute
3699  * path that would have been provided to the file system.
3700  *
3701  * \return Vector of uint8 with the content of the LUT.
3702  */
3703  virtual std::vector<uint8_t> getLutData(const char * filepath) const = 0;
3704 
3705  /**
3706  * \brief Provide the config file Yaml to be parsed.
3707  *
3708  * \return String with the config Yaml.
3709  */
3710  virtual std::string getConfigData() const = 0;
3711 
3712  /**
3713  * \brief Provide a fast unique ID for a LUT file.
3714  *
3715  * This is intended to supply the string that will be used in OCIO's FileCacheMap.
3716  * This should be highly performant and typically should not require extensive
3717  * computation such as calculating the md5 hash of the file, unless it is pre-computed.
3718  *
3719  * If the "file" does not exist, in other words, if the proxy is unable to supply the requested
3720  * file contents, the function must return an empty string.
3721  *
3722  * \param filepath Fully resolve the path to the "file."
3723  *
3724  * The file path is based on the Config's current working directory and is the same absolute
3725  * path that would have been provided to the file system.
3726  *
3727  * \return The file hash string.
3728  */
3729  virtual std::string getFastLutFileHash(const char * filepath) const = 0;
3730 };
3731 
3732 } // namespace OCIO_NAMESPACE
3733 
3734 #endif // INCLUDED_OCIO_OPENCOLORIO_H
OCIOEXPORT ConstColorSpaceSetRcPtr operator-(const ConstColorSpaceSetRcPtr &lcss, const ConstColorSpaceSetRcPtr &rcss)
Perform the difference of two sets.
OCIOEXPORT ConstConfigRcPtr GetCurrentConfig()
Get the current configuration.
EnvironmentMode
Controls which environment variables are loaded into a Context object.
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
OCIO_SHARED_PTR< const ViewTransform > ConstViewTransformRcPtr
GLbitfield flags
Definition: glcorearb.h:1596
static const char * DefaultRuleName
Reserved rule name for the default rule.
Definition: OpenColorIO.h:1459
class OCIOEXPORT GpuShaderDesc
PXL_API const char * getDescription(const ColorSpace *space)
Return the description of the color space.
GT_API const UT_StringHolder filename
PXL_API void getColorSpaces(UT_StringArray &names)
Returns a list of the supported color spaces.
This class holds the GPU-related information needed to build a shader program from a specific process...
Definition: OpenColorIO.h:3328
std::function< const float *()> VectorFloatGetter
Function returning a float *, used by uniforms.
Definition: OpenColorIO.h:3072
class OCIOEXPORT ColorSpaceSet
OCIOEXPORT void SetLoggingLevel(LoggingLevel level)
Set the global logging level.
OCIO_SHARED_PTR< ViewingRules > ViewingRulesRcPtr
OCIOEXPORT void SetComputeHashFunction(ComputeHashFunction hashFunction)
Set the Compute Hash Function to use; otherwise, use the default.
OCIO_SHARED_PTR< GpuShaderCreator > GpuShaderCreatorRcPtr
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
PXL_API void getActiveViews(UT_StringArray &names)
Returns the list of active views.
ChannelOrdering
Used by PackedImageDesc to indicate the channel ordering of the image to process. ...
This is a light-weight wrapper around an image, that provides a context for pixel access...
Definition: OpenColorIO.h:2753
OCIO_SHARED_PTR< Processor > ProcessorRcPtr
IMF_EXPORT IMATH_NAMESPACE::V3f direction(const IMATH_NAMESPACE::Box2i &dataWindow, const IMATH_NAMESPACE::V2f &pixelPosition)
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
class OCIOEXPORT BuiltinTransformRegistry
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
OptimizationFlags
Provides control over how the ops in a Processor are combined in order to improve performance...
const Impl * getImpl() const
Definition: OpenColorIO.h:3175
class OCIOEXPORT ViewingRules
OCIO_SHARED_PTR< const Transform > ConstTransformRcPtr
GLint level
Definition: glcorearb.h:108
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:860
OCIO_SHARED_PTR< FileRules > FileRulesRcPtr
std::function< int()> SizeGetter
Function returning an int, used by uniforms.
Definition: OpenColorIO.h:3070
An exception class to throw for errors detected at runtime.
Definition: OpenColorIO.h:77
OCIO_SHARED_PTR< const BuiltinTransformRegistry > ConstBuiltinTransformRegistryRcPtr
std::function< const Float3 &()> Float3Getter
Functions returning a Float3, used by uniforms.
Definition: OpenColorIO.h:3068
OCIO_SHARED_PTR< ConfigIOProxy > ConfigIOProxyRcPtr
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
class OCIOEXPORT Config
PXL_API const char * getDefaultView(const char *display=NULL)
Returns the current color space name.
#define OCIO_NAMESPACE
Definition: OpenColorABI.h:8
DynamicPropertyType
Types for dynamic properties.
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
OCIOEXPORT void LogMessage(LoggingLevel level, const char *message)
Log a message using the library logging function.
class OCIOEXPORT Exception
class OCIOEXPORT Look
OCIOEXPORT int GetVersionHex()
Get the version number for the library, as a single 4-byte hex number (e.g., 0x01050200 for "1...
OCIO_SHARED_PTR< const NamedTransform > ConstNamedTransformRcPtr
static const char * FilePathSearchRuleName
Reserved rule name for the file path search rule.
Definition: OpenColorIO.h:1461
std::function< const int *()> VectorIntGetter
Function returning an int *, used by uniforms.
Definition: OpenColorIO.h:3074
OCIOEXPORT void ClearAllCaches()
GpuLanguage
Used when there is a choice of hardware shader language.
ProcessorCacheFlags
cpp:type:: Enum to control the behavior of the internal caches e.g. the processor cache in ...
OCIO_SHARED_PTR< Look > LookRcPtr
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
OCIO_SHARED_PTR< const ProcessorMetadata > ConstProcessorMetadataRcPtr
class OCIOEXPORT GpuShaderCreator
GLint GLsizei GLsizei height
Definition: glcorearb.h:103
OCIO_SHARED_PTR< const Context > ConstContextRcPtr
class OCIOEXPORT Context
class OCIOEXPORT CPUProcessor
OCIO_SHARED_PTR< ProcessorMetadata > ProcessorMetadataRcPtr
OCIO_SHARED_PTR< const CPUProcessor > ConstCPUProcessorRcPtr
OCIOEXPORT void SetLoggingFunction(LoggingFunction logFunction)
Set the logging function to use; otherwise, use the default (i.e. std::cerr).
OCIOEXPORT void ResetToDefaultLoggingFunction()
class OCIOEXPORT ViewTransform
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
class OCIOEXPORT ConfigIOProxy
OCIO_SHARED_PTR< Baker > BakerRcPtr
OCIOEXPORT const char * GetEnvVariable(const char *name)
class OCIOEXPORT ProcessorMetadata
GLuint GLuint end
Definition: glcorearb.h:475
A config defines all the color spaces to be available at runtime.
Definition: OpenColorIO.h:259
class OCIOEXPORT GPUProcessor
PXL_API bool getAllocationVars(const ColorSpace *space, bool &uniform, fpreal &min, fpreal &max, fpreal &offset)
Return the allocation variable meta data about the color space.
OPENVDB_API void setVersion(std::ios_base &, const VersionId &libraryVersion, uint32_t fileVersion)
Associate specific file format and library version numbers with the given stream. ...
std::function< void(const char *)> LoggingFunction
Define the logging function signature.
std::function< double()> DoubleGetter
Function returning a double, used by uniforms. GPU converts double to float.
Definition: OpenColorIO.h:3064
#define OCIOEXPORT
Definition: OpenColorABI.h:67
OCIOEXPORT void SetEnvVariable(const char *name, const char *value)
OCIO_SHARED_PTR< const Processor > ConstProcessorRcPtr
GLuint const GLchar * name
Definition: glcorearb.h:786
OCIO_SHARED_PTR< const ColorSpaceSet > ConstColorSpaceSetRcPtr
OCIO_SHARED_PTR< const FileRules > ConstFileRulesRcPtr
GLushort pattern
Definition: glad.h:2583
#define OCIO_DEPRECATED(msg)
Definition: OpenColorABI.h:38
PXL_API const char * getDefaultDisplay()
Returns the current color space name.
GA_API const UT_StringHolder transform
class OCIOEXPORT Baker
OCIOEXPORT void ResetComputeHashFunction()
PXL_API const char * parseColorSpaceFromString(const char *string)
OCIOEXPORT const char * GetVersion()
Get the version number for the library, as a dot-delimited string (e.g., "1.0.0").
UniformDataType
Types for uniform data.
GLenum mode
Definition: glcorearb.h:99
std::function< std::string(const std::string &)> ComputeHashFunction
Define Compute Hash function signature.
OCIO_SHARED_PTR< const SystemMonitors > ConstSystemMonitorsRcPtr
std::function< bool()> BoolGetter
Function returning a bool, used by uniforms.
Definition: OpenColorIO.h:3066
OCIO_SHARED_PTR< ColorSpaceSet > ColorSpaceSetRcPtr
OCIO_SHARED_PTR< const Config > ConstConfigRcPtr
OCIO_SHARED_PTR< NamedTransform > NamedTransformRcPtr
OCIOEXPORT ConstColorSpaceSetRcPtr operator&&(const ConstColorSpaceSetRcPtr &lcss, const ConstColorSpaceSetRcPtr &rcss)
Perform the intersection of two sets.
OCIO_SHARED_PTR< const Look > ConstLookRcPtr
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
class OCIOEXPORT Processor
class OCIOEXPORT ImageDesc
OCIO_SHARED_PTR< Config > ConfigRcPtr
GLuint index
Definition: glcorearb.h:786
class OCIOEXPORT NamedTransform
OCIO_SHARED_PTR< Context > ContextRcPtr
OCIOEXPORT void SetCurrentConfig(const ConstConfigRcPtr &config)
Set the current configuration. This will then store a copy of the specified config.
OCIOEXPORT void ExtractOCIOZArchive(const char *archivePath, const char *destinationDir)
Extract an OCIO Config archive.
GLint GLsizei width
Definition: glcorearb.h:103
OCIOEXPORT std::ostream & operator<<(std::ostream &, const ColorSpaceMenuParameters &)
Definition: core.h:982
OCIO_SHARED_PTR< GpuShaderDesc > GpuShaderDescRcPtr
class OCIOEXPORT FileRules
OCIOEXPORT void UnsetEnvVariable(const char *name)
OCIOEXPORT bool IsEnvVariablePresent(const char *name)
cpp:function::
OCIOEXPORT ConstColorSpaceSetRcPtr operator||(const ConstColorSpaceSetRcPtr &lcss, const ConstColorSpaceSetRcPtr &rcss)
Perform the union of two sets.
class OCIOEXPORT SystemMonitors
Definition: core.h:1131
OCIO_SHARED_PTR< GroupTransform > GroupTransformRcPtr
class OCIOEXPORT ColorSpace
PXL_API void getLooks(UT_StringArray &looks)
Returns a list of looks (color transforms)
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
#define const
Definition: zconf.h:214
const ptrdiff_t AutoStride
Definition: OpenColorIO.h:2745
OCIO_SHARED_PTR< const ViewingRules > ConstViewingRulesRcPtr
PXL_API void getActiveDisplays(UT_StringArray &names)
Returns the list of active displays.
OCIO_SHARED_PTR< ColorSpace > ColorSpaceRcPtr
type
Definition: core.h:1059
OCIOEXPORT LoggingLevel GetLoggingLevel()
Get the global logging level.
An exception class for errors detected at runtime.
Definition: OpenColorIO.h:97
This class contains meta information about the process that generated this processor. The results of these functions do not impact the pixel processing.
Definition: OpenColorIO.h:2577
OCIO_SHARED_PTR< const ColorSpace > ConstColorSpaceRcPtr
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
OCIO_SHARED_PTR< const GPUProcessor > ConstGPUProcessorRcPtr
Definition: format.h:895
The File Rules are a set of filepath to color space mappings that are evaluated from first to last...
Definition: OpenColorIO.h:1454
OCIO_SHARED_PTR< ViewTransform > ViewTransformRcPtr
OCIO_SHARED_PTR< DynamicProperty > DynamicPropertyRcPtr
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:483