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