ocio_impl.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software Foundation,
  14. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. *
  16. * The Original Code is Copyright (C) 2012 Blender Foundation.
  17. * All rights reserved.
  18. */
  19. #ifndef __OCIO_IMPL_H__
  20. #define __OCIO_IMPL_H__
  21. #include "ocio_capi.h"
  22. class IOCIOImpl {
  23. public:
  24. virtual ~IOCIOImpl()
  25. {
  26. }
  27. virtual OCIO_ConstConfigRcPtr *getCurrentConfig(void) = 0;
  28. virtual void setCurrentConfig(const OCIO_ConstConfigRcPtr *config) = 0;
  29. virtual OCIO_ConstConfigRcPtr *configCreateFromEnv(void) = 0;
  30. virtual OCIO_ConstConfigRcPtr *configCreateFromFile(const char *filename) = 0;
  31. virtual void configRelease(OCIO_ConstConfigRcPtr *config) = 0;
  32. virtual int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config) = 0;
  33. virtual const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0;
  34. virtual OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config,
  35. const char *name) = 0;
  36. virtual int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
  37. virtual int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  38. virtual int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  39. virtual void colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
  40. OCIO_ConstColorSpaceRcPtr *cs,
  41. bool &is_scene_linear,
  42. bool &is_srgb) = 0;
  43. virtual void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  44. virtual const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config) = 0;
  45. virtual int configGetNumDisplays(OCIO_ConstConfigRcPtr *config) = 0;
  46. virtual const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index) = 0;
  47. virtual const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
  48. virtual int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
  49. virtual const char *configGetView(OCIO_ConstConfigRcPtr *config,
  50. const char *display,
  51. int index) = 0;
  52. virtual const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
  53. const char *display,
  54. const char *view) = 0;
  55. virtual void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb) = 0;
  56. virtual void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]) = 0;
  57. virtual int configGetNumLooks(OCIO_ConstConfigRcPtr *config) = 0;
  58. virtual const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0;
  59. virtual OCIO_ConstLookRcPtr *configGetLook(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
  60. virtual const char *lookGetProcessSpace(OCIO_ConstLookRcPtr *look) = 0;
  61. virtual void lookRelease(OCIO_ConstLookRcPtr *look) = 0;
  62. virtual OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  63. const char *srcName,
  64. const char *dstName) = 0;
  65. virtual OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
  66. OCIO_ConstTransformRcPtr *transform) = 0;
  67. virtual void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
  68. virtual void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor,
  69. OCIO_PackedImageDesc *img) = 0;
  70. virtual void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
  71. virtual void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
  72. virtual void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
  73. virtual void processorRelease(OCIO_ConstProcessorRcPtr *p) = 0;
  74. virtual const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  75. virtual const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  76. virtual const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs) = 0;
  77. virtual OCIO_DisplayTransformRcPtr *createDisplayTransform(void) = 0;
  78. virtual void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt,
  79. const char *name) = 0;
  80. virtual void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
  81. virtual void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
  82. virtual void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt,
  83. OCIO_ConstTransformRcPtr *et) = 0;
  84. virtual void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt,
  85. OCIO_ConstTransformRcPtr *et) = 0;
  86. virtual void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt,
  87. const char *looks) = 0;
  88. virtual void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt,
  89. bool enabled) = 0;
  90. virtual void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt) = 0;
  91. virtual OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
  92. long width,
  93. long height,
  94. long numChannels,
  95. long chanStrideBytes,
  96. long xStrideBytes,
  97. long yStrideBytes) = 0;
  98. virtual void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p) = 0;
  99. virtual OCIO_ExponentTransformRcPtr *createExponentTransform(void) = 0;
  100. virtual void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et,
  101. const float *exponent) = 0;
  102. virtual void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et) = 0;
  103. virtual OCIO_MatrixTransformRcPtr *createMatrixTransform(void) = 0;
  104. virtual void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  105. const float *m44,
  106. const float *offset4) = 0;
  107. virtual void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt) = 0;
  108. virtual void matrixTransformScale(float *m44, float *offset4, const float *scale4) = 0;
  109. virtual bool supportGLSLDraw(void) = 0;
  110. virtual bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
  111. OCIO_ConstProcessorRcPtr *processor,
  112. OCIO_CurveMappingSettings *curve_mapping_settings,
  113. float dither,
  114. bool predivide) = 0;
  115. virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
  116. virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
  117. virtual const char *getVersionString(void) = 0;
  118. virtual int getVersionHex(void) = 0;
  119. };
  120. class FallbackImpl : public IOCIOImpl {
  121. public:
  122. FallbackImpl()
  123. {
  124. }
  125. OCIO_ConstConfigRcPtr *getCurrentConfig(void);
  126. void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
  127. OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
  128. OCIO_ConstConfigRcPtr *configCreateFromFile(const char *filename);
  129. void configRelease(OCIO_ConstConfigRcPtr *config);
  130. int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
  131. const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  132. OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
  133. int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
  134. int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
  135. int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
  136. void colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
  137. OCIO_ConstColorSpaceRcPtr *cs,
  138. bool &is_scene_linear,
  139. bool &is_srgb);
  140. void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
  141. const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
  142. int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
  143. const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
  144. const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
  145. int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
  146. const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
  147. const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
  148. const char *display,
  149. const char *view);
  150. void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb);
  151. void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]);
  152. int configGetNumLooks(OCIO_ConstConfigRcPtr *config);
  153. const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  154. OCIO_ConstLookRcPtr *configGetLook(OCIO_ConstConfigRcPtr *config, const char *name);
  155. const char *lookGetProcessSpace(OCIO_ConstLookRcPtr *look);
  156. void lookRelease(OCIO_ConstLookRcPtr *look);
  157. OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  158. const char *srcName,
  159. const char *dstName);
  160. OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
  161. OCIO_ConstTransformRcPtr *transform);
  162. void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  163. void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  164. void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  165. void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  166. void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  167. void processorRelease(OCIO_ConstProcessorRcPtr *p);
  168. const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
  169. const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
  170. const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
  171. OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
  172. void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
  173. void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
  174. void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
  175. void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
  176. void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
  177. void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks);
  178. void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled);
  179. void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
  180. OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
  181. long width,
  182. long height,
  183. long numChannels,
  184. long chanStrideBytes,
  185. long xStrideBytes,
  186. long yStrideBytes);
  187. void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
  188. OCIO_ExponentTransformRcPtr *createExponentTransform(void);
  189. void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
  190. void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
  191. OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
  192. void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  193. const float *m44,
  194. const float *offset4);
  195. void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
  196. void matrixTransformScale(float *m44, float *offset4, const float *scale4);
  197. bool supportGLSLDraw(void);
  198. bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
  199. OCIO_ConstProcessorRcPtr *processor,
  200. OCIO_CurveMappingSettings *curve_mapping_settings,
  201. float dither,
  202. bool predivide);
  203. void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
  204. void freeGLState(struct OCIO_GLSLDrawState *state_r);
  205. const char *getVersionString(void);
  206. int getVersionHex(void);
  207. };
  208. #ifdef WITH_OCIO
  209. class OCIOImpl : public IOCIOImpl {
  210. public:
  211. OCIOImpl(){};
  212. OCIO_ConstConfigRcPtr *getCurrentConfig(void);
  213. void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
  214. OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
  215. OCIO_ConstConfigRcPtr *configCreateFromFile(const char *filename);
  216. void configRelease(OCIO_ConstConfigRcPtr *config);
  217. int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
  218. const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  219. OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
  220. int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
  221. int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
  222. int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
  223. void colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
  224. OCIO_ConstColorSpaceRcPtr *cs,
  225. bool &is_scene_linear,
  226. bool &is_srgb);
  227. void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
  228. const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
  229. int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
  230. const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
  231. const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
  232. int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
  233. const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
  234. const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
  235. const char *display,
  236. const char *view);
  237. void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb);
  238. void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]);
  239. int configGetNumLooks(OCIO_ConstConfigRcPtr *config);
  240. const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  241. OCIO_ConstLookRcPtr *configGetLook(OCIO_ConstConfigRcPtr *config, const char *name);
  242. const char *lookGetProcessSpace(OCIO_ConstLookRcPtr *look);
  243. void lookRelease(OCIO_ConstLookRcPtr *look);
  244. OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  245. const char *srcName,
  246. const char *dstName);
  247. OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config,
  248. OCIO_ConstTransformRcPtr *transform);
  249. void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  250. void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  251. void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  252. void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  253. void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  254. void processorRelease(OCIO_ConstProcessorRcPtr *p);
  255. const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
  256. const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
  257. const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
  258. OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
  259. void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
  260. void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
  261. void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
  262. void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
  263. void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
  264. void displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks);
  265. void displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled);
  266. void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
  267. OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data,
  268. long width,
  269. long height,
  270. long numChannels,
  271. long chanStrideBytes,
  272. long xStrideBytes,
  273. long yStrideBytes);
  274. void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
  275. OCIO_ExponentTransformRcPtr *createExponentTransform(void);
  276. void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
  277. void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
  278. OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
  279. void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  280. const float *m44,
  281. const float *offset4);
  282. void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
  283. void matrixTransformScale(float *m44, float *offset4, const float *scale4);
  284. bool supportGLSLDraw(void);
  285. bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
  286. OCIO_ConstProcessorRcPtr *processor,
  287. OCIO_CurveMappingSettings *curve_mapping_settings,
  288. float dither,
  289. bool predivide);
  290. void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
  291. void freeGLState(struct OCIO_GLSLDrawState *state_r);
  292. const char *getVersionString(void);
  293. int getVersionHex(void);
  294. };
  295. #endif
  296. #endif /* OCIO_IMPL_H */