00001 /* 00002 * Copyright (c) 2012 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 *---------------------------------------------------------------------------- 00026 * FullImageFilter. 00027 */ 00028 #ifndef _COP2_FULLIMAGEFILTER_H_ 00029 #define _COP2_FULLIMAGEFILTER_H_ 00030 00031 #include <UT/UT_Lock.h> 00032 00033 #include <COP2/COP2_MaskOp.h> 00034 00035 namespace HDK_Sample { 00036 00037 class COP2_FullImageFilter : public COP2_MaskOp 00038 { 00039 public: 00040 // Normal op stuff... 00041 static OP_Node *myConstructor(OP_Network*, const char *, 00042 OP_Operator *); 00043 static OP_TemplatePair myTemplatePair; 00044 static OP_VariablePair myVariablePair; 00045 static PRM_Template myTemplateList[]; 00046 static CH_LocalVariable myVariableList[]; 00047 static const char *myInputLabels[]; 00048 00049 00050 // static cookFullImage callback. 00051 static OP_ERROR filter(COP2_Context &context, 00052 const TIL_Region *input, 00053 TIL_Region *output, 00054 COP2_Node *me); 00055 // non static version, called by filter. 00056 OP_ERROR filterImage(COP2_Context &context, 00057 const TIL_Region *input, 00058 TIL_Region *output); 00059 00060 // since this is single threaded per-plane, hint this to the scheduler. 00061 // You can restrict threading so that: 00062 // maxp - a maximum of 'maxp' threads cooking the same plane in this 00063 // node at once. 00064 // maxn - a maximum of 'maxn' threads can be cooking in a single 00065 // instance of this node at once. 00066 // op - a maximum of 'op' threads can be cooking in instances of 00067 // this operator at once. 00068 00069 // This basically says that only 1 thread may cook a given plane at a time, 00070 // but several threads may be in this node cooking different planes. 00071 virtual void getMaxNumThreadsInCook(COP2_Context &, 00072 int &maxp, int &maxn, int &op) const 00073 { maxp = 1; maxn = op = TIL_MAX_THREADS; } 00074 00075 // For the output area (an area of a plane belonging to this node) 00076 // and a set of input areas, determine which input areas and which 00077 // parts of these areas are needed to cook the output area. 00078 virtual void getInputDependenciesForOutputArea( 00079 COP2_CookAreaInfo &output_area, 00080 const COP2_CookAreaList &input_areas, 00081 COP2_CookAreaList &needed_areas); 00082 00083 protected: 00084 virtual ~COP2_FullImageFilter(); 00085 virtual COP2_ContextData *newContextData(const TIL_Plane *p, 00086 int array_index, 00087 float t, 00088 int xres, int yres, 00089 int thread, 00090 int max_threads); 00091 00092 virtual OP_ERROR doCookMyTile(COP2_Context &context, 00093 TIL_TileList *tiles); 00094 00095 // if we expand or change the image bounds, we need to override this method 00096 // and set the new bounds. 00097 virtual void computeImageBounds(COP2_Context &context); 00098 00099 private: 00100 COP2_FullImageFilter(OP_Network *parent, const char *name, 00101 OP_Operator *entry); 00102 00103 float SIZE(float t) { return evalFloat("size", 0, t); } 00104 }; 00105 00106 class cop2_FullImageFilterData : public COP2_ContextData 00107 { 00108 public: 00109 cop2_FullImageFilterData() : mySize(0) {} 00110 virtual ~cop2_FullImageFilterData() {} 00111 00112 float mySize; 00113 UT_Lock myLock; 00114 }; 00115 00116 } // End HDK_Sample namespace 00117 00118 #endif 00119
1.5.9