PageRenderTime 79ms CodeModel.GetById 68ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

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