/src/nuke/OCIOColorSpace/OCIOColorSpace.h

http://github.com/imageworks/OpenColorIO · C Header · 120 lines · 47 code · 26 blank · 47 comment · 0 complexity · 86a005581748906dc691254b8dea8235 MD5 · raw file

  1. #ifndef INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_H_
  2. #define INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_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 perform colorspace conversions
  13. */
  14. class OCIOColorSpace : public DD::Image::PixelIop {
  15. protected:
  16. bool m_hasColorSpaces; //!< Were colorspaces found for both input and output? If not, always error.
  17. int m_inputColorSpaceIndex; //!< index of input colorspace selection from the pulldown list knob
  18. int m_outputColorSpaceIndex;
  19. std::vector<std::string> m_colorSpaceNames; //!< list of input and output colorspace names (memory for const char* s below)
  20. std::vector<const char*> m_inputColorSpaceCstrNames; //!< list for the pulldown list knob (used raw)
  21. std::vector<const char*> m_outputColorSpaceCstrNames;
  22. OCIO::ConstContextRcPtr getLocalContext();
  23. OCIO::ConstProcessorRcPtr m_processor;
  24. public:
  25. OCIOColorSpace(Node *node);
  26. virtual ~OCIOColorSpace();
  27. // These are public so the nuke wrapper can introspect into it
  28. // TODO: use 'friend' instead
  29. std::string m_contextKey1;
  30. std::string m_contextValue1;
  31. std::string m_contextKey2;
  32. std::string m_contextValue2;
  33. std::string m_contextKey3;
  34. std::string m_contextValue3;
  35. std::string m_contextKey4;
  36. std::string m_contextValue4;
  37. static const DD::Image::Op::Description description;
  38. /*! Return the command name that will be stored in Nuke scripts. */
  39. virtual const char *Class() const;
  40. /*!
  41. * Return a name for this class that will be shown to the user. The
  42. * default implementation returns Class(). You can return a different
  43. * (ie more user-friendly) name instead here, and there is no need for
  44. * this to be unique.
  45. *
  46. * Nuke currently will remove any trailing digits and underscores from
  47. * this and add a new number to make a unique name for the new node.
  48. *
  49. * \return "OCIOColorSpace"
  50. */
  51. virtual const char *displayName() const;
  52. /*!
  53. * Return help information for this node. This information is in the
  54. * pop-up window that the user gets when they hit the [?] button in
  55. * the lower-left corner of the control panel.
  56. */
  57. virtual const char *node_help() const;
  58. /*!
  59. * Define the knobs that will be presented in the control panel.
  60. */
  61. virtual void knobs(DD::Image::Knob_Callback f);
  62. /*!
  63. * Specify the channels required from input n to produce the channels
  64. * in mask by modifying mask in-place. (At least one channel in the
  65. * input is assumed.)
  66. *
  67. * Since colorspace conversions can have channel cross-talk, any rgb
  68. * output channel requires all its rgb bretheren. (Non-rgb
  69. * are passed through.)
  70. */
  71. virtual void in_channels(int n, DD::Image::ChannelSet& mask) const;
  72. /*!
  73. * Calculate the output pixel data.
  74. * \param rowY vertical line number
  75. * \param rowX inclusive left bound
  76. * \param rowXBound exclusive right bound
  77. * \param outputChannels a subset of out_channels(), the required channels to be produced
  78. */
  79. virtual void pixel_engine(
  80. const DD::Image::Row& in,
  81. int rowY, int rowX, int rowXBound,
  82. DD::Image::ChannelMask outputChannels,
  83. DD::Image::Row& out);
  84. virtual void append(DD::Image::Hash& hash);
  85. protected:
  86. /*!
  87. * Check that colorspaces are available, and that the transform
  88. * is not a noop. (As OCIO whether a given transform is a noop, since it
  89. * can do more analysis than just name matching.)
  90. */
  91. virtual void _validate(bool for_real);
  92. };
  93. static DD::Image::Op* build(Node *node);
  94. #endif // INCLUDED_OCIO_NUKE_COLORSPACECONVERSION_H_