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