HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP2_MaskOp.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: COP2_MaskOp.h
7  *
8  * COMMENTS:
9  * Base class for pixel operations that are maskable.
10  */
11 #ifndef __COP2_MaskOp_h__
12 #define __COP2_MaskOp_h__
13 
14 #include "COP2_API.h"
15 #include <UT/UT_IntArray.h>
16 #include <UT/UT_FloatArray.h>
17 
18 #include "COP2_PixelBase.h"
19 
20 #define ARG_MASKOP_AMOUNT "effectamount"
21 #define ARG_MASKOP_MASKINPUT "maskinput"
22 #define ARG_MASKOP_MASKPLANE "maskplane"
23 #define ARG_MASKOP_RESIZEMASK "maskresize"
24 #define ARG_MASKOP_MASKINVERT "maskinvert"
25 
27 {
28 public:
30  static PRM_Template myTemplateList[];
31 
32  // override if the mask and op inputs are different from 0 and 1. Op is the
33  // input with the planes being operated on; Mask is the input containing
34  // the mask.
35  virtual int getOpInput() const { return 0; }
36  virtual int getMaskInput() const { return 1; }
37 
38  virtual const char *inputConnectorLabel(unsigned idx);
39 
40  virtual int getAuxInput() const { return getMaskInput(); }
41  virtual void getAuxInputName(OP_ConnectorId& name_out)
42  { getUniqueInputName(name_out, getMaskInput(), true); }
43 
44  virtual COP2_Node * getPassThroughInput(COP2_Context &) { return this; }
45 
46  // override if you don't want this class to do the mask operation (ie,
47  // blur may handle the mask itself).
48  virtual bool doNormalMask(COP2_Context &) { return true; }
49 
50  // override if the frame scope dropoff effect is not handled by the
51  // derived class.
52  virtual bool isFrameEffectHandled() { return true; }
53 
54  int getMaskFromInput();
55 
56  virtual void computeImageBounds(COP2_Context &context);
57 
58  bool getMaskBounds(float t, int xres, int yres, int thread,
59  int &x1,int &y1, int &x2, int &y2);
60 
61  bool getMaskBounds(COP2_Context &context,
62  int &x1,int &y1, int &x2, int &y2)
63  { return getMaskBounds(context.myTime,
64  context.myXres, context.myYres,
65  context.myThreadIndex, x1,y1,x2,y2); }
66 
67  virtual void modifyViewMatrix(int input,
68  COP2_Context &context,
69  UT_Matrix4 &matrix,
70  float zoom);
71 protected:
72  COP2_MaskOp(OP_Network *parent, const char *name, OP_Operator *entry);
73  virtual ~COP2_MaskOp();
74 
75  virtual bool updateParmsFlags();
76 
77  virtual TIL_Sequence * cookSequenceInfo(OP_ERROR &error);
78 
79  // initializes all the mask parms for the mask op (normally done in
80  // COP2_MaskOp::cookSequenceInfo above; however, if your node doesn't call
81  // COP2_MaskOp's version, call setupMaskParms() at the end of your
82  // cookSequenceInfo() method.
83  void setupMaskParms();
84 
85  virtual float getFrameScopeEffect(int image_index);
86 
87  // Override this method rather than cookMyTile().
88  virtual OP_ERROR doCookMyTile(COP2_Context &context,
89  TIL_TileList *tiles) = 0;
90 
91  // Do NOT override this method; this method implements the masking
92  // operation.
93  virtual OP_ERROR cookMyTile(COP2_Context &context,
94  TIL_TileList *tiles);
95 
97  COP2_CookAreaInfo &output_area,
98  const COP2_CookAreaList &input_areas,
99  COP2_CookAreaList &needed_areas);
100 
101  // utility function to add the mask dependency. Called by the above method.
102  // If you don't call COP2_MaskOp's getInputDep...Area(), call this
103  // method in your own getInputDep...Area() method.
104  void getMaskDependency(COP2_CookAreaInfo &output_area,
105  const COP2_CookAreaList &input_areas,
106  COP2_CookAreaList &needed_areas);
107 
108  TIL_Region *getMaskRegion(COP2_Context &context,
109  const TIL_Plane *plane, float t,
110  int x1, int y1, int x2, int y2);
111 
112  float * getMaskData(COP2_Context &context, int x1,int y1,
113  int x2,int y2, int component = 0);
114 
115  virtual float AMOUNT(float t) { return evalFloat(ARG_MASKOP_AMOUNT, 0, t);}
116  virtual int MASK_INPUT() { return evalInt(ARG_MASKOP_MASKINPUT, 0, 0); }
117  virtual void MASK_PLANE(UT_String &s)
118  { evalString(s, ARG_MASKOP_MASKPLANE, 0, 0); }
119  virtual int MASK_INVERT() { return evalInt(ARG_MASKOP_MASKINVERT, 0,0); }
120  virtual int MASK_RESIZE() { return evalInt(ARG_MASKOP_RESIZEMASK, 0,0); }
121 
122  bool getMask(int &pindex, int &cindex);
123 
124  float getAmount(int image_index);
125 
129  bool myHasMask;
134 };
135 
136 #endif
virtual bool updateParmsFlags()
virtual void getAuxInputName(OP_ConnectorId &name_out)
Definition: COP2_MaskOp.h:41
bool myMaskInvert
Definition: COP2_MaskOp.h:128
#define ARG_MASKOP_RESIZEMASK
Definition: COP2_MaskOp.h:23
virtual TIL_Sequence * cookSequenceInfo(OP_ERROR &err)
#define ARG_MASKOP_MASKINVERT
Definition: COP2_MaskOp.h:24
bool myMaskResize
Definition: COP2_MaskOp.h:130
virtual int MASK_RESIZE()
Definition: COP2_MaskOp.h:120
fpreal evalFloat(int pi, int vi, fpreal t) const
static OP_TemplatePair myTemplatePair
Definition: COP2_MaskOp.h:29
UT_ErrorSeverity
Definition: UT_Error.h:25
#define ARG_MASKOP_AMOUNT
Definition: COP2_MaskOp.h:20
virtual COP2_Node * getPassThroughInput(COP2_Context &)
Definition: COP2_MaskOp.h:44
bool myHasMask
Definition: COP2_MaskOp.h:129
UT_IntArray myAmountIndex
Definition: COP2_MaskOp.h:132
friend class COP2_MaskOp
Definition: COP2_Node.h:1638
UT_String myMaskPlane
Definition: COP2_MaskOp.h:127
virtual bool isFrameEffectHandled()
Definition: COP2_MaskOp.h:52
virtual OP_ERROR cookMyTile(COP2_Context &context, TIL_TileList *tiles)
void evalString(UT_String &val, int pi, int vi, fpreal t) const
virtual int getAuxInput() const
Definition: COP2_MaskOp.h:40
virtual int MASK_INPUT()
Definition: COP2_MaskOp.h:116
GLuint const GLchar * name
Definition: glcorearb.h:785
void getUniqueInputName(OP_ConnectorId &id_out, int idx, bool grow)
virtual int getMaskInput() const
Definition: COP2_MaskOp.h:36
virtual int MASK_INVERT()
Definition: COP2_MaskOp.h:119
bool getMaskBounds(COP2_Context &context, int &x1, int &y1, int &x2, int &y2)
Definition: COP2_MaskOp.h:61
virtual void modifyViewMatrix(int input, COP2_Context &context, UT_Matrix4 &matrix, float zoom)
virtual void computeImageBounds(COP2_Context &context)
#define COP2_API
Definition: COP2_API.h:10
virtual float AMOUNT(float t)
Definition: COP2_MaskOp.h:115
UT_Lock myAmountLock
Definition: COP2_MaskOp.h:131
#define ARG_MASKOP_MASKPLANE
Definition: COP2_MaskOp.h:22
virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo &output_area, const COP2_CookAreaList &input_areas, COP2_CookAreaList &needed_areas)
virtual const char * inputConnectorLabel(unsigned idx)
#define ARG_MASKOP_MASKINPUT
Definition: COP2_MaskOp.h:21
exint evalInt(int pi, int vi, fpreal t) const
UT_FloatArray myAmountValue
Definition: COP2_MaskOp.h:133
virtual int getOpInput() const
Definition: COP2_MaskOp.h:35
virtual bool doNormalMask(COP2_Context &)
Definition: COP2_MaskOp.h:48
virtual int getMaskInput() const
Definition: COP2_Node.h:359
virtual float getFrameScopeEffect(int image_index)
virtual void MASK_PLANE(UT_String &s)
Definition: COP2_MaskOp.h:117