fallback_impl.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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 <algorithm>
  20. #include <cstring>
  21. #include "MEM_guardedalloc.h"
  22. #include "BLI_math_color.h"
  23. #include "BLI_math_vector.h"
  24. #include "ocio_impl.h"
  25. using std::max;
  26. #define CONFIG_DEFAULT ((OCIO_ConstConfigRcPtr *)1)
  27. enum TransformType {
  28. TRANSFORM_LINEAR_TO_SRGB,
  29. TRANSFORM_SRGB_TO_LINEAR,
  30. TRANSFORM_MATRIX,
  31. TRANSFORM_EXPONENT,
  32. TRANSFORM_UNKNOWN,
  33. };
  34. #define COLORSPACE_LINEAR ((OCIO_ConstColorSpaceRcPtr *)1)
  35. #define COLORSPACE_SRGB ((OCIO_ConstColorSpaceRcPtr *)2)
  36. typedef struct OCIO_PackedImageDescription {
  37. float *data;
  38. long width;
  39. long height;
  40. long numChannels;
  41. long chanStrideBytes;
  42. long xStrideBytes;
  43. long yStrideBytes;
  44. } OCIO_PackedImageDescription;
  45. struct FallbackTransform {
  46. FallbackTransform() : type(TRANSFORM_UNKNOWN), linear_transform(NULL), display_transform(NULL)
  47. {
  48. }
  49. ~FallbackTransform()
  50. {
  51. delete linear_transform;
  52. delete display_transform;
  53. }
  54. void applyRGB(float *pixel)
  55. {
  56. if (type == TRANSFORM_LINEAR_TO_SRGB) {
  57. applyLinearRGB(pixel);
  58. linearrgb_to_srgb_v3_v3(pixel, pixel);
  59. applyDisplayRGB(pixel);
  60. }
  61. else if (type == TRANSFORM_SRGB_TO_LINEAR) {
  62. srgb_to_linearrgb_v3_v3(pixel, pixel);
  63. }
  64. else if (type == TRANSFORM_EXPONENT) {
  65. pixel[0] = powf(max(0.0f, pixel[0]), exponent[0]);
  66. pixel[1] = powf(max(0.0f, pixel[1]), exponent[1]);
  67. pixel[2] = powf(max(0.0f, pixel[2]), exponent[2]);
  68. }
  69. else if (type == TRANSFORM_MATRIX) {
  70. float r = pixel[0];
  71. float g = pixel[1];
  72. float b = pixel[2];
  73. pixel[0] = r * matrix[0] + g * matrix[1] + b * matrix[2];
  74. pixel[1] = r * matrix[4] + g * matrix[5] + b * matrix[6];
  75. pixel[2] = r * matrix[8] + g * matrix[9] + b * matrix[10];
  76. pixel[0] += offset[0];
  77. pixel[1] += offset[1];
  78. pixel[2] += offset[2];
  79. }
  80. }
  81. void applyRGBA(float *pixel)
  82. {
  83. if (type == TRANSFORM_LINEAR_TO_SRGB) {
  84. applyLinearRGBA(pixel);
  85. linearrgb_to_srgb_v4(pixel, pixel);
  86. applyDisplayRGBA(pixel);
  87. }
  88. else if (type == TRANSFORM_SRGB_TO_LINEAR) {
  89. srgb_to_linearrgb_v4(pixel, pixel);
  90. }
  91. else if (type == TRANSFORM_EXPONENT) {
  92. pixel[0] = powf(max(0.0f, pixel[0]), exponent[0]);
  93. pixel[1] = powf(max(0.0f, pixel[1]), exponent[1]);
  94. pixel[2] = powf(max(0.0f, pixel[2]), exponent[2]);
  95. pixel[3] = powf(max(0.0f, pixel[3]), exponent[3]);
  96. }
  97. else if (type == TRANSFORM_MATRIX) {
  98. float r = pixel[0];
  99. float g = pixel[1];
  100. float b = pixel[2];
  101. float a = pixel[3];
  102. pixel[0] = r * matrix[0] + g * matrix[1] + b * matrix[2] + a * matrix[3];
  103. pixel[1] = r * matrix[4] + g * matrix[5] + b * matrix[6] + a * matrix[7];
  104. pixel[2] = r * matrix[8] + g * matrix[9] + b * matrix[10] + a * matrix[11];
  105. pixel[3] = r * matrix[12] + g * matrix[13] + b * matrix[14] + a * matrix[15];
  106. pixel[0] += offset[0];
  107. pixel[1] += offset[1];
  108. pixel[2] += offset[2];
  109. pixel[3] += offset[3];
  110. }
  111. }
  112. void applyLinearRGB(float *pixel)
  113. {
  114. if (linear_transform != NULL) {
  115. linear_transform->applyRGB(pixel);
  116. }
  117. }
  118. void applyLinearRGBA(float *pixel)
  119. {
  120. if (linear_transform != NULL) {
  121. linear_transform->applyRGBA(pixel);
  122. }
  123. }
  124. void applyDisplayRGB(float *pixel)
  125. {
  126. if (display_transform != NULL) {
  127. display_transform->applyRGB(pixel);
  128. }
  129. }
  130. void applyDisplayRGBA(float *pixel)
  131. {
  132. if (display_transform != NULL) {
  133. display_transform->applyRGBA(pixel);
  134. }
  135. }
  136. TransformType type;
  137. FallbackTransform *linear_transform;
  138. FallbackTransform *display_transform;
  139. /* Exponent transform. */
  140. float exponent[4];
  141. /* Matrix transform. */
  142. float matrix[16];
  143. float offset[4];
  144. MEM_CXX_CLASS_ALLOC_FUNCS("FallbackProcessor");
  145. };
  146. struct FallbackProcessor {
  147. FallbackProcessor() : transform(NULL)
  148. {
  149. }
  150. ~FallbackProcessor()
  151. {
  152. delete transform;
  153. }
  154. void applyRGB(float *pixel)
  155. {
  156. transform->applyRGB(pixel);
  157. }
  158. void applyRGBA(float *pixel)
  159. {
  160. transform->applyRGBA(pixel);
  161. }
  162. FallbackTransform *transform;
  163. MEM_CXX_CLASS_ALLOC_FUNCS("FallbackProcessor");
  164. };
  165. OCIO_ConstConfigRcPtr *FallbackImpl::getCurrentConfig(void)
  166. {
  167. return CONFIG_DEFAULT;
  168. }
  169. void FallbackImpl::setCurrentConfig(const OCIO_ConstConfigRcPtr * /*config*/)
  170. {
  171. }
  172. OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromEnv(void)
  173. {
  174. return NULL;
  175. }
  176. OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromFile(const char * /*filename*/)
  177. {
  178. return CONFIG_DEFAULT;
  179. }
  180. void FallbackImpl::configRelease(OCIO_ConstConfigRcPtr * /*config*/)
  181. {
  182. }
  183. int FallbackImpl::configGetNumColorSpaces(OCIO_ConstConfigRcPtr * /*config*/)
  184. {
  185. return 2;
  186. }
  187. const char *FallbackImpl::configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr * /*config*/,
  188. int index)
  189. {
  190. if (index == 0)
  191. return "Linear";
  192. else if (index == 1)
  193. return "sRGB";
  194. return NULL;
  195. }
  196. OCIO_ConstColorSpaceRcPtr *FallbackImpl::configGetColorSpace(OCIO_ConstConfigRcPtr * /*config*/,
  197. const char *name)
  198. {
  199. if (strcmp(name, "scene_linear") == 0)
  200. return COLORSPACE_LINEAR;
  201. else if (strcmp(name, "color_picking") == 0)
  202. return COLORSPACE_SRGB;
  203. else if (strcmp(name, "texture_paint") == 0)
  204. return COLORSPACE_LINEAR;
  205. else if (strcmp(name, "default_byte") == 0)
  206. return COLORSPACE_SRGB;
  207. else if (strcmp(name, "default_float") == 0)
  208. return COLORSPACE_LINEAR;
  209. else if (strcmp(name, "default_sequencer") == 0)
  210. return COLORSPACE_SRGB;
  211. else if (strcmp(name, "Linear") == 0)
  212. return COLORSPACE_LINEAR;
  213. else if (strcmp(name, "sRGB") == 0)
  214. return COLORSPACE_SRGB;
  215. return NULL;
  216. }
  217. int FallbackImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
  218. {
  219. OCIO_ConstColorSpaceRcPtr *cs = configGetColorSpace(config, name);
  220. if (cs == COLORSPACE_LINEAR) {
  221. return 0;
  222. }
  223. else if (cs == COLORSPACE_SRGB) {
  224. return 1;
  225. }
  226. return -1;
  227. }
  228. const char *FallbackImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr * /*config*/)
  229. {
  230. return "sRGB";
  231. }
  232. int FallbackImpl::configGetNumDisplays(OCIO_ConstConfigRcPtr * /*config*/)
  233. {
  234. return 1;
  235. }
  236. const char *FallbackImpl::configGetDisplay(OCIO_ConstConfigRcPtr * /*config*/, int index)
  237. {
  238. if (index == 0) {
  239. return "sRGB";
  240. }
  241. return NULL;
  242. }
  243. const char *FallbackImpl::configGetDefaultView(OCIO_ConstConfigRcPtr * /*config*/,
  244. const char * /*display*/)
  245. {
  246. return "Standard";
  247. }
  248. int FallbackImpl::configGetNumViews(OCIO_ConstConfigRcPtr * /*config*/, const char * /*display*/)
  249. {
  250. return 1;
  251. }
  252. const char *FallbackImpl::configGetView(OCIO_ConstConfigRcPtr * /*config*/,
  253. const char * /*display*/,
  254. int index)
  255. {
  256. if (index == 0) {
  257. return "Standard";
  258. }
  259. return NULL;
  260. }
  261. const char *FallbackImpl::configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr * /*config*/,
  262. const char * /*display*/,
  263. const char * /*view*/)
  264. {
  265. return "sRGB";
  266. }
  267. void FallbackImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr * /*config*/, float *rgb)
  268. {
  269. /* Here we simply use the older Blender assumed primaries of
  270. * ITU-BT.709 / sRGB, or 0.2126729 0.7151522 0.0721750. Brute
  271. * force stupid, but only plausible option given no color management
  272. * system in place.
  273. */
  274. rgb[0] = 0.2126f;
  275. rgb[1] = 0.7152f;
  276. rgb[2] = 0.0722f;
  277. }
  278. void FallbackImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr * /*config*/, float xyz_to_rgb[3][3])
  279. {
  280. /* Default to ITU-BT.709. */
  281. memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB));
  282. }
  283. int FallbackImpl::configGetNumLooks(OCIO_ConstConfigRcPtr * /*config*/)
  284. {
  285. return 0;
  286. }
  287. const char *FallbackImpl::configGetLookNameByIndex(OCIO_ConstConfigRcPtr * /*config*/,
  288. int /*index*/)
  289. {
  290. return "";
  291. }
  292. OCIO_ConstLookRcPtr *FallbackImpl::configGetLook(OCIO_ConstConfigRcPtr * /*config*/,
  293. const char * /*name*/)
  294. {
  295. return NULL;
  296. }
  297. const char *FallbackImpl::lookGetProcessSpace(OCIO_ConstLookRcPtr * /*look*/)
  298. {
  299. return NULL;
  300. }
  301. void FallbackImpl::lookRelease(OCIO_ConstLookRcPtr * /*look*/)
  302. {
  303. }
  304. int FallbackImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr * /*cs*/)
  305. {
  306. return 1;
  307. }
  308. int FallbackImpl::colorSpaceIsData(OCIO_ConstColorSpaceRcPtr * /*cs*/)
  309. {
  310. return 0;
  311. }
  312. void FallbackImpl::colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr * /*config*/,
  313. OCIO_ConstColorSpaceRcPtr *cs,
  314. bool &is_scene_linear,
  315. bool &is_srgb)
  316. {
  317. if (cs == COLORSPACE_LINEAR) {
  318. is_scene_linear = true;
  319. is_srgb = false;
  320. }
  321. else if (cs == COLORSPACE_SRGB) {
  322. is_scene_linear = false;
  323. is_srgb = true;
  324. }
  325. else {
  326. is_scene_linear = false;
  327. is_srgb = false;
  328. }
  329. }
  330. void FallbackImpl::colorSpaceRelease(OCIO_ConstColorSpaceRcPtr * /*cs*/)
  331. {
  332. }
  333. OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  334. const char *srcName,
  335. const char *dstName)
  336. {
  337. OCIO_ConstColorSpaceRcPtr *cs_src = configGetColorSpace(config, srcName);
  338. OCIO_ConstColorSpaceRcPtr *cs_dst = configGetColorSpace(config, dstName);
  339. FallbackTransform *transform = new FallbackTransform();
  340. if (cs_src == COLORSPACE_LINEAR && cs_dst == COLORSPACE_SRGB) {
  341. transform->type = TRANSFORM_LINEAR_TO_SRGB;
  342. }
  343. else if (cs_src == COLORSPACE_SRGB && cs_dst == COLORSPACE_LINEAR) {
  344. transform->type = TRANSFORM_SRGB_TO_LINEAR;
  345. }
  346. else {
  347. transform->type = TRANSFORM_UNKNOWN;
  348. }
  349. FallbackProcessor *processor = new FallbackProcessor();
  350. processor->transform = transform;
  351. return (OCIO_ConstProcessorRcPtr *)processor;
  352. }
  353. OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessor(OCIO_ConstConfigRcPtr * /*config*/,
  354. OCIO_ConstTransformRcPtr *transform)
  355. {
  356. FallbackProcessor *processor = new FallbackProcessor();
  357. processor->transform = (FallbackTransform *)transform;
  358. return (OCIO_ConstProcessorRcPtr *)processor;
  359. }
  360. void FallbackImpl::processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
  361. {
  362. /* OCIO_TODO stride not respected, channels must be 3 or 4 */
  363. OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription *)img;
  364. int channels = desc->numChannels;
  365. float *pixels = desc->data;
  366. int width = desc->width;
  367. int height = desc->height;
  368. int x, y;
  369. for (y = 0; y < height; y++) {
  370. for (x = 0; x < width; x++) {
  371. float *pixel = pixels + channels * (y * width + x);
  372. if (channels == 4)
  373. processorApplyRGBA(processor, pixel);
  374. else if (channels == 3)
  375. processorApplyRGB(processor, pixel);
  376. }
  377. }
  378. }
  379. void FallbackImpl::processorApply_predivide(OCIO_ConstProcessorRcPtr *processor,
  380. OCIO_PackedImageDesc *img)
  381. {
  382. /* OCIO_TODO stride not respected, channels must be 3 or 4 */
  383. OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription *)img;
  384. int channels = desc->numChannels;
  385. float *pixels = desc->data;
  386. int width = desc->width;
  387. int height = desc->height;
  388. int x, y;
  389. for (y = 0; y < height; y++) {
  390. for (x = 0; x < width; x++) {
  391. float *pixel = pixels + channels * (y * width + x);
  392. if (channels == 4)
  393. processorApplyRGBA_predivide(processor, pixel);
  394. else if (channels == 3)
  395. processorApplyRGB(processor, pixel);
  396. }
  397. }
  398. }
  399. void FallbackImpl::processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  400. {
  401. ((FallbackProcessor *)processor)->applyRGB(pixel);
  402. }
  403. void FallbackImpl::processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  404. {
  405. ((FallbackProcessor *)processor)->applyRGBA(pixel);
  406. }
  407. void FallbackImpl::processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
  408. {
  409. if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
  410. processorApplyRGBA(processor, pixel);
  411. }
  412. else {
  413. float alpha, inv_alpha;
  414. alpha = pixel[3];
  415. inv_alpha = 1.0f / alpha;
  416. pixel[0] *= inv_alpha;
  417. pixel[1] *= inv_alpha;
  418. pixel[2] *= inv_alpha;
  419. processorApplyRGBA(processor, pixel);
  420. pixel[0] *= alpha;
  421. pixel[1] *= alpha;
  422. pixel[2] *= alpha;
  423. }
  424. }
  425. void FallbackImpl::processorRelease(OCIO_ConstProcessorRcPtr *processor)
  426. {
  427. delete (FallbackProcessor *)(processor);
  428. }
  429. const char *FallbackImpl::colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
  430. {
  431. if (cs == COLORSPACE_LINEAR) {
  432. return "Linear";
  433. }
  434. else if (cs == COLORSPACE_SRGB) {
  435. return "sRGB";
  436. }
  437. return NULL;
  438. }
  439. const char *FallbackImpl::colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr * /*cs*/)
  440. {
  441. return "";
  442. }
  443. const char *FallbackImpl::colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr * /*cs*/)
  444. {
  445. return "";
  446. }
  447. OCIO_DisplayTransformRcPtr *FallbackImpl::createDisplayTransform(void)
  448. {
  449. FallbackTransform *transform = new FallbackTransform();
  450. transform->type = TRANSFORM_LINEAR_TO_SRGB;
  451. return (OCIO_DisplayTransformRcPtr *)transform;
  452. }
  453. void FallbackImpl::displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr * /*dt*/,
  454. const char * /*name*/)
  455. {
  456. }
  457. void FallbackImpl::displayTransformSetDisplay(OCIO_DisplayTransformRcPtr * /*dt*/,
  458. const char * /*name*/)
  459. {
  460. }
  461. void FallbackImpl::displayTransformSetView(OCIO_DisplayTransformRcPtr * /*dt*/,
  462. const char * /*name*/)
  463. {
  464. }
  465. void FallbackImpl::displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt,
  466. OCIO_ConstTransformRcPtr *et)
  467. {
  468. FallbackTransform *transform = (FallbackTransform *)dt;
  469. transform->display_transform = (FallbackTransform *)et;
  470. }
  471. void FallbackImpl::displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt,
  472. OCIO_ConstTransformRcPtr *et)
  473. {
  474. FallbackTransform *transform = (FallbackTransform *)dt;
  475. transform->linear_transform = (FallbackTransform *)et;
  476. }
  477. void FallbackImpl::displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr * /*dt*/,
  478. const char * /*looks*/)
  479. {
  480. }
  481. void FallbackImpl::displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr * /*dt*/,
  482. bool /*enabled*/)
  483. {
  484. }
  485. void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr * /*dt*/)
  486. {
  487. }
  488. OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data,
  489. long width,
  490. long height,
  491. long numChannels,
  492. long chanStrideBytes,
  493. long xStrideBytes,
  494. long yStrideBytes)
  495. {
  496. OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription *)MEM_callocN(
  497. sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription");
  498. desc->data = data;
  499. desc->width = width;
  500. desc->height = height;
  501. desc->numChannels = numChannels;
  502. desc->chanStrideBytes = chanStrideBytes;
  503. desc->xStrideBytes = xStrideBytes;
  504. desc->yStrideBytes = yStrideBytes;
  505. return (OCIO_PackedImageDesc *)desc;
  506. }
  507. void FallbackImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *id)
  508. {
  509. MEM_freeN(id);
  510. }
  511. OCIO_ExponentTransformRcPtr *FallbackImpl::createExponentTransform(void)
  512. {
  513. FallbackTransform *transform = new FallbackTransform();
  514. transform->type = TRANSFORM_EXPONENT;
  515. return (OCIO_ExponentTransformRcPtr *)transform;
  516. }
  517. void FallbackImpl::exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et,
  518. const float *exponent)
  519. {
  520. FallbackTransform *transform = (FallbackTransform *)et;
  521. copy_v4_v4(transform->exponent, exponent);
  522. }
  523. void FallbackImpl::exponentTransformRelease(OCIO_ExponentTransformRcPtr * /*et*/)
  524. {
  525. }
  526. OCIO_MatrixTransformRcPtr *FallbackImpl::createMatrixTransform(void)
  527. {
  528. FallbackTransform *transform = new FallbackTransform();
  529. transform->type = TRANSFORM_MATRIX;
  530. return (OCIO_MatrixTransformRcPtr *)transform;
  531. }
  532. void FallbackImpl::matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  533. const float *m44,
  534. const float *offset4)
  535. {
  536. FallbackTransform *transform = (FallbackTransform *)mt;
  537. copy_m4_m4((float(*)[4])transform->matrix, (float(*)[4])m44);
  538. copy_v4_v4(transform->offset, offset4);
  539. }
  540. void FallbackImpl::matrixTransformRelease(OCIO_MatrixTransformRcPtr * /*mt*/)
  541. {
  542. }
  543. void FallbackImpl::matrixTransformScale(float *m44, float *offset4, const float *scale4)
  544. {
  545. if (scale4 == NULL) {
  546. return;
  547. }
  548. if (m44 != NULL) {
  549. memset(m44, 0, 16 * sizeof(float));
  550. m44[0] = scale4[0];
  551. m44[5] = scale4[1];
  552. m44[10] = scale4[2];
  553. m44[15] = scale4[3];
  554. }
  555. if (offset4 != NULL) {
  556. offset4[0] = 0.0f;
  557. offset4[1] = 0.0f;
  558. offset4[2] = 0.0f;
  559. offset4[3] = 0.0f;
  560. }
  561. }
  562. bool FallbackImpl::supportGLSLDraw(void)
  563. {
  564. return false;
  565. }
  566. bool FallbackImpl::setupGLSLDraw(struct OCIO_GLSLDrawState ** /*state_r*/,
  567. OCIO_ConstProcessorRcPtr * /*processor*/,
  568. OCIO_CurveMappingSettings * /*curve_mapping_settings*/,
  569. float /*dither*/,
  570. bool /*predivide*/)
  571. {
  572. return false;
  573. }
  574. void FallbackImpl::finishGLSLDraw(OCIO_GLSLDrawState * /*state*/)
  575. {
  576. }
  577. void FallbackImpl::freeGLState(struct OCIO_GLSLDrawState * /*state_r*/)
  578. {
  579. }
  580. const char *FallbackImpl::getVersionString(void)
  581. {
  582. return "fallback";
  583. }
  584. int FallbackImpl::getVersionHex(void)
  585. {
  586. return 0;
  587. }