/src/nuke/OCIOCDLTransform/OCIOCDLTransform.h

http://github.com/imageworks/OpenColorIO · C Header · 137 lines · 52 code · 33 blank · 52 comment · 0 complexity · 727dcdf9db3f922366d97141bc83fde7 MD5 · raw file

  1. #ifndef INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_
  2. #define INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_
  3. // Include these early, for Nuke's headers under gcc 4.4.2.
  4. #include <memory>
  5. #include <cstdarg>
  6. #include <DDImage/PixelIop.h>
  7. #include <DDImage/Row.h>
  8. #include <DDImage/Knob.h>
  9. #include <OpenColorIO/OpenColorIO.h>
  10. namespace OCIO = OCIO_NAMESPACE;
  11. /*!
  12. * Iop that uses OpenColorIO to apply an ASC CDL transform
  13. */
  14. class OCIOCDLTransform : public DD::Image::PixelIop {
  15. protected:
  16. // ASC CDL grade numbers
  17. float m_slope[3];
  18. float m_offset[3];
  19. float m_power[3];
  20. float m_saturation;
  21. static const char* dirs[];
  22. int m_dirindex;
  23. bool m_readFromFile;
  24. // ID used for exporting grades into .cc/.ccc files
  25. const char* m_file;
  26. std::string m_cccid;
  27. DD::Image::Knob* m_slopeKnob;
  28. DD::Image::Knob* m_offsetKnob;
  29. DD::Image::Knob* m_powerKnob;
  30. DD::Image::Knob* m_saturationKnob;
  31. DD::Image::Knob* m_fileKnob;
  32. DD::Image::Knob* m_cccidKnob;
  33. OCIO::ConstProcessorRcPtr m_processor;
  34. bool m_firstLoad;
  35. /*! Controlled by hidden "version" knob, incremented to redraw image */
  36. int m_reload_version;
  37. public:
  38. OCIOCDLTransform(Node *node);
  39. virtual ~OCIOCDLTransform();
  40. static const DD::Image::Op::Description description;
  41. /*! Return the command name that will be stored in Nuke scripts. */
  42. virtual const char *Class() const;
  43. /*!
  44. * Return a name for this class that will be shown to the user. The
  45. * default implementation returns Class(). You can return a different
  46. * (ie more user-friendly) name instead here, and there is no need for
  47. * this to be unique.
  48. *
  49. * Nuke currently will remove any trailing digits and underscores from
  50. * this and add a new number to make a unique name for the new node.
  51. *
  52. * \return "OCIOCDLTransform"
  53. */
  54. virtual const char *displayName() const;
  55. /*!
  56. * Return help information for this node. This information is in the
  57. * pop-up window that the user gets when they hit the [?] button in
  58. * the lower-left corner of the control panel.
  59. */
  60. virtual const char *node_help() const;
  61. /*!
  62. * Define the knobs that will be presented in the control panel.
  63. */
  64. virtual void knobs(DD::Image::Knob_Callback f);
  65. //! The will handle the knob changes.
  66. virtual int knob_changed(DD::Image::Knob*);
  67. void refreshKnobEnabledState();
  68. void loadCDLFromFile();
  69. /*!
  70. * Specify the channels required from input n to produce the channels
  71. * in mask by modifying mask in-place. (At least one channel in the
  72. * input is assumed.)
  73. *
  74. * Since OCIOCDLTransform conversions can have channel cross-talk, any rgb
  75. * output channel requires all its rgb bretheren. (Non-rgb
  76. * are passed through.)
  77. */
  78. virtual void in_channels(int n, DD::Image::ChannelSet& mask) const;
  79. /*!
  80. * Calculate the output pixel data.
  81. * \param rowY vertical line number
  82. * \param rowX inclusive left bound
  83. * \param rowXBound exclusive right bound
  84. * \param outputChannels a subset of out_channels(), the required channels to be produced
  85. */
  86. virtual void pixel_engine(
  87. const DD::Image::Row& in,
  88. int rowY, int rowX, int rowXBound,
  89. DD::Image::ChannelMask outputChannels,
  90. DD::Image::Row& out);
  91. protected:
  92. /*!
  93. * Check that colorspaces are available, and that the transform
  94. * is not a noop. (As OCIO whether a given transform is a noop, since it
  95. * can do more analysis than just name matching.)
  96. */
  97. virtual void _validate(bool for_real);
  98. /*!
  99. * Ensure Node hash is reflects all parameters
  100. */
  101. void append(DD::Image::Hash& nodehash);
  102. };
  103. static DD::Image::Op* build(Node *node);
  104. #endif // INCLUDED_OCIO_NUKE_CDLTRANSFORM_H_