ocio_capi.cc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. #include "MEM_guardedalloc.h"
  20. #include "ocio_impl.h"
  21. static IOCIOImpl *impl = NULL;
  22. void OCIO_init(void)
  23. {
  24. #ifdef WITH_OCIO
  25. impl = new OCIOImpl();
  26. #else
  27. impl = new FallbackImpl();
  28. #endif
  29. }
  30. void OCIO_exit(void)
  31. {
  32. delete impl;
  33. impl = NULL;
  34. }
  35. OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void)
  36. {
  37. return impl->getCurrentConfig();
  38. }
  39. OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void)
  40. {
  41. delete impl;
  42. impl = new FallbackImpl();
  43. return impl->getCurrentConfig();
  44. }
  45. void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
  46. {
  47. impl->setCurrentConfig(config);
  48. }
  49. OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
  50. {
  51. return impl->configCreateFromEnv();
  52. }
  53. OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
  54. {
  55. return impl->configCreateFromFile(filename);
  56. }
  57. void OCIO_configRelease(OCIO_ConstConfigRcPtr *config)
  58. {
  59. impl->configRelease(config);
  60. }
  61. int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
  62. {
  63. return impl->configGetNumColorSpaces(config);
  64. }
  65. const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
  66. {
  67. return impl->configGetColorSpaceNameByIndex(config, index);
  68. }
  69. OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config,
  70. const char *name)
  71. {
  72. return impl->configGetColorSpace(config, name);
  73. }
  74. int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
  75. {
  76. return impl->configGetIndexForColorSpace(config, name);
  77. }
  78. const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
  79. {
  80. return impl->configGetDefaultDisplay(config);
  81. }
  82. int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr *config)
  83. {
  84. return impl->configGetNumDisplays(config);
  85. }
  86. const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
  87. {
  88. return impl->configGetDisplay(config, index);
  89. }
  90. const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
  91. {
  92. return impl->configGetDefaultView(config, display);
  93. }
  94. int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
  95. {
  96. return impl->configGetNumViews(config, display);
  97. }
  98. const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
  99. {
  100. return impl->configGetView(config, display, index);
  101. }
  102. const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
  103. const char *display,
  104. const char *view)
  105. {
  106. return impl->configGetDisplayColorSpaceName(config, display, view);
  107. }
  108. void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb)
  109. {
  110. impl->configGetDefaultLumaCoefs(config, rgb);
  111. }
  112. void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3])
  113. {
  114. impl->configGetXYZtoRGB(config, xyz_to_rgb);
  115. }
  116. int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config)
  117. {
  118. return impl->configGetNumLooks(config);
  119. }
  120. const char *OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
  121. {
  122. return impl->configGetLookNameByIndex(config, index);
  123. }
  124. OCIO_ConstLookRcPtr *OCIO_configGetLook(OCIO_ConstConfigRcPtr *config, const char *name)
  125. {
  126. return impl->configGetLook(config, name);
  127. }
  128. const char *OCIO_lookGetProcessSpace(OCIO_ConstLookRcPtr *look)
  129. {
  130. return impl->lookGetProcessSpace(look);
  131. }
  132. void OCIO_lookRelease(OCIO_ConstLookRcPtr *look)
  133. {
  134. impl->lookRelease(look);
  135. }
  136. int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
  137. {
  138. return impl->colorSpaceIsInvertible(cs);
  139. }
  140. int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
  141. {
  142. return impl->colorSpaceIsData(cs);
  143. }
  144. void OCIO_colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
  145. OCIO_ConstColorSpaceRcPtr *cs,
  146. bool *is_scene_linear,
  147. bool *is_srgb)
  148. {
  149. impl->colorSpaceIsBuiltin(config, cs, *is_scene_linear, *is_srgb);
  150. }
  151. void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
  152. {
  153. impl->colorSpaceRelease(cs);
  154. }
  155. OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  156. const char *srcName,
  157. const char *dstName)
  158. {
  159. return impl->configGetProcessorWithNames(config, srcName, dstName);
  160. }
  161. OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config,
  162. OCIO_ConstTransformRcPtr *transform)
  163. {
  164. return impl->configGetProcessor(config, transform);
  165. }
  166. void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
  167. {
  168. impl->processorApply(processor, img);
  169. }
  170. void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
  171. {
  172. impl->processorApply_predivide(processor, img);
  173. }
  174. void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  175. {
  176. impl->processorApplyRGB(processor, pixel);
  177. }
  178. void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  179. {
  180. impl->processorApplyRGBA(processor, pixel);
  181. }
  182. void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  183. {
  184. impl->processorApplyRGBA_predivide(processor, pixel);
  185. }
  186. void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p)
  187. {
  188. impl->processorRelease(p);
  189. }
  190. const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
  191. {
  192. return impl->colorSpaceGetName(cs);
  193. }
  194. const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
  195. {
  196. return impl->colorSpaceGetDescription(cs);
  197. }
  198. const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
  199. {
  200. return impl->colorSpaceGetFamily(cs);
  201. }
  202. OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
  203. {
  204. return impl->createDisplayTransform();
  205. }
  206. void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
  207. {
  208. impl->displayTransformSetInputColorSpaceName(dt, name);
  209. }
  210. void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
  211. {
  212. impl->displayTransformSetDisplay(dt, name);
  213. }
  214. void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
  215. {
  216. impl->displayTransformSetView(dt, name);
  217. }
  218. void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
  219. {
  220. impl->displayTransformSetDisplayCC(dt, t);
  221. }
  222. void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
  223. {
  224. impl->displayTransformSetLinearCC(dt, t);
  225. }
  226. void OCIO_displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks)
  227. {
  228. impl->displayTransformSetLooksOverride(dt, looks);
  229. }
  230. void OCIO_displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled)
  231. {
  232. impl->displayTransformSetLooksOverrideEnabled(dt, enabled);
  233. }
  234. void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
  235. {
  236. impl->displayTransformRelease(dt);
  237. }
  238. OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data,
  239. long width,
  240. long height,
  241. long numChannels,
  242. long chanStrideBytes,
  243. long xStrideBytes,
  244. long yStrideBytes)
  245. {
  246. return impl->createOCIO_PackedImageDesc(
  247. data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
  248. }
  249. void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *id)
  250. {
  251. impl->OCIO_PackedImageDescRelease(id);
  252. }
  253. OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void)
  254. {
  255. return impl->createExponentTransform();
  256. }
  257. void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
  258. {
  259. impl->exponentTransformSetValue(et, exponent);
  260. }
  261. void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
  262. {
  263. impl->exponentTransformRelease(et);
  264. }
  265. OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
  266. {
  267. return impl->createMatrixTransform();
  268. }
  269. void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  270. const float *m44,
  271. const float *offset4)
  272. {
  273. impl->matrixTransformSetValue(mt, m44, offset4);
  274. }
  275. void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
  276. {
  277. impl->matrixTransformRelease(mt);
  278. }
  279. void OCIO_matrixTransformScale(float *m44, float *offset4, const float *scale4f)
  280. {
  281. impl->matrixTransformScale(m44, offset4, scale4f);
  282. }
  283. int OCIO_supportGLSLDraw(void)
  284. {
  285. return (int)impl->supportGLSLDraw();
  286. }
  287. int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
  288. OCIO_ConstProcessorRcPtr *processor,
  289. OCIO_CurveMappingSettings *curve_mapping_settings,
  290. float dither,
  291. bool predivide)
  292. {
  293. return (int)impl->setupGLSLDraw(state_r, processor, curve_mapping_settings, dither, predivide);
  294. }
  295. void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state)
  296. {
  297. impl->finishGLSLDraw(state);
  298. }
  299. void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state)
  300. {
  301. impl->freeGLState(state);
  302. }
  303. const char *OCIO_getVersionString(void)
  304. {
  305. return impl->getVersionString();
  306. }
  307. int OCIO_getVersionHex(void)
  308. {
  309. return impl->getVersionHex();
  310. }