HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
COP2_FullImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * FullImageFilter.
27  */
28 #ifndef _COP2_FULLIMAGEFILTER_H_
29 #define _COP2_FULLIMAGEFILTER_H_
30 
31 #include <UT/UT_Lock.h>
32 
33 #include <COP2/COP2_MaskOp.h>
34 
35 namespace HDK_Sample {
36 
38 {
39 public:
40  // Normal op stuff...
41  static OP_Node *myConstructor(OP_Network*, const char *,
42  OP_Operator *);
47  static const char *myInputLabels[];
48 
49 
50  // static cookFullImage callback.
51  static OP_ERROR filter(COP2_Context &context,
52  const TIL_Region *input,
53  TIL_Region *output,
54  COP2_Node *me);
55  // non static version, called by filter.
57  const TIL_Region *input,
58  TIL_Region *output);
59 
60  // since this is single threaded per-plane, hint this to the scheduler.
61  // You can restrict threading so that:
62  // maxp - a maximum of 'maxp' threads cooking the same plane in this
63  // node at once.
64  // maxn - a maximum of 'maxn' threads can be cooking in a single
65  // instance of this node at once.
66  // op - a maximum of 'op' threads can be cooking in instances of
67  // this operator at once.
68 
69  // This basically says that only 1 thread may cook a given plane at a time,
70  // but several threads may be in this node cooking different planes.
72  int &maxp, int &maxn, int &op) const
73  { maxp = 1; maxn = op = TIL_MAX_THREADS; }
74 
75  // For the output area (an area of a plane belonging to this node)
76  // and a set of input areas, determine which input areas and which
77  // parts of these areas are needed to cook the output area.
79  COP2_CookAreaInfo &output_area,
80  const COP2_CookAreaList &input_areas,
81  COP2_CookAreaList &needed_areas);
82 
83 protected:
84  virtual ~COP2_FullImageFilter();
85  virtual COP2_ContextData *newContextData(const TIL_Plane *p,
86  int array_index,
87  float t,
88  int xres, int yres,
89  int thread,
90  int max_threads);
91 
92  virtual OP_ERROR doCookMyTile(COP2_Context &context,
93  TIL_TileList *tiles);
94 
95  // if we expand or change the image bounds, we need to override this method
96  // and set the new bounds.
97  virtual void computeImageBounds(COP2_Context &context);
98 
99 private:
100  COP2_FullImageFilter(OP_Network *parent, const char *name,
101  OP_Operator *entry);
102 
103  fpreal SIZE(fpreal t) { return evalFloat("size", 0, t); }
104 };
105 
107 {
108 public:
111 
112  float mySize;
114 };
115 
116 } // End HDK_Sample namespace
117 
118 #endif
119 
virtual void getMaxNumThreadsInCook(COP2_Context &, int &maxp, int &maxn, int &op) const
static OP_TemplatePair myTemplatePair
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual void getInputDependenciesForOutputArea(COP2_CookAreaInfo &output_area, const COP2_CookAreaList &input_areas, COP2_CookAreaList &needed_areas)
OP_ERROR filterImage(COP2_Context &context, const TIL_Region *input, TIL_Region *output)
virtual COP2_ContextData * newContextData(const TIL_Plane *p, int array_index, float t, int xres, int yres, int thread, int max_threads)
static OP_ERROR filter(COP2_Context &context, const TIL_Region *input, TIL_Region *output, COP2_Node *me)
GLuint const GLchar * name
Definition: glcorearb.h:785
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
double fpreal
Definition: SYS_Types.h:269
virtual void computeImageBounds(COP2_Context &context)
static OP_VariablePair myVariablePair
#define TIL_MAX_THREADS
Definition: TIL_Defines.h:37
static CH_LocalVariable myVariableList[]
virtual OP_ERROR doCookMyTile(COP2_Context &context, TIL_TileList *tiles)