00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _COP2_KEYBASE_H_
00021 #define _COP2_KEYBASE_H_
00022
00023 #include "COP2_API.h"
00024 #include "COP2_MaskOp.h"
00025
00026 #include <TIL/TIL_CompOptions.h>
00027 class TIL_TileList;
00028 class COP2_Context;
00029 class RE_OGLComputeGPU;
00030
00031 enum cop2_InterpType
00032 {
00033 COP2_KEY_INTERP_LINEAR =0,
00034 COP2_KEY_INTERP_EASE_IN =1,
00035 COP2_KEY_INTERP_EASE_OUT =2,
00036 COP2_KEY_INTERP_HALF_COS =3,
00037 COP2_KEY_INTERP_GAUSSIAN =4
00038 };
00039
00040 typedef float (*cop2_InterpFunc) (float w);
00041 typedef float (*cop2_Interpolate) (float v1, float v2, float w);
00042 typedef float (*COP2_KeyFunction) (void *data, const float val[4]);
00043
00044 class COP2_API COP2_KeyBase : public COP2_MaskOp
00045 {
00046 public:
00047 virtual bool hasSpillParms() const;
00048 virtual void setColorParms(float hmin, float hmax,
00049 float smin, float smax,
00050 float lmin, float lmax,
00051 bool add, float t);
00052
00053 virtual void setSpillParms(float hmin, float hmax,
00054 float smin, float smax,
00055 float lmin, float lmax,
00056 bool add, float t);
00057
00058 virtual void setStateControl(int state);
00059
00060
00061 static float hueInterp(float v1, float v2, float w);
00062 static float linear(float v1, float v2, float w);
00063
00064
00065 static float hueComp(float h, float hue1, float hue2, float spill = 0.0f,
00066 float (*ifunc)(float) = 0);
00067 static float linearComp(float v, float v1, float v2, float spill = 0.0f,
00068 float (*ifunc)(float) = 0);
00069
00070
00071 static void expandRegion(float h, float s, float l,
00072 float &hmin, float &hmax,
00073 float &smin, float &smax,
00074 float &lmin, float &lmax);
00075
00076 static cop2_InterpFunc getInterpolation(cop2_InterpType type);
00077 protected:
00078
00079 virtual const char *getKeyPlane(COP2_Context &context);
00080 virtual int getSuperSample(COP2_Context & ) { return 1; }
00081
00082 virtual bool convertToColorSpace(COP2_Context &context,
00083 const float *c1,
00084 const float *c2,
00085 const float *c3,
00086 const float *c4,
00087 float *&d1,
00088 float *&d2,
00089 float *&d3,
00090 float *&d4,
00091 int size);
00092
00093 virtual COP2_KeyFunction getKeyFunction(COP2_Context &context,
00094 void *&data);
00095
00096 virtual void colorFunction(COP2_Context &context,
00097 float val[4], float key);
00098
00099 virtual cop2_Interpolate getInterpFunction(COP2_Context &context,
00100 int component);
00101
00102 protected:
00103 COP2_KeyBase(OP_Network *parent,
00104 const char *name,
00105 OP_Operator *entry);
00106 virtual ~COP2_KeyBase();
00107
00108 virtual OP_ERROR doCookMyTile(COP2_Context &context,
00109 TIL_TileList *tilelist);
00110
00111 OP_ERROR doGPUCook(COP2_Context &context,
00112 TIL_TileList *tilelist,
00113 const TIL_Plane *keyplane,
00114 int supersample);
00115 void doKeyOperation(TIL_TileList *tiles,
00116 int supersample,
00117 COP2_Context &context,
00118 const float *c1,
00119 const float *c2,
00120 const float *c3,
00121 const float *c4);
00122
00123 virtual void getInputDependenciesForOutputArea(
00124 COP2_CookAreaInfo &output_area,
00125 const COP2_CookAreaList &input_areas,
00126 COP2_CookAreaList &needed_areas);
00127
00128 virtual void getShaderAndConstants(COP2_Context &context,
00129 UT_String &shader_funcs,
00130 RE_OGLComputeGPU &engine);
00131 };
00132
00133 #endif