HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP2_Context.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_ContextData.C
7  *
8  * COMMENTS:
9  * Class to contain context-dependent data for multi-context cooks
10  * (usually accessing a COP at several different times during a cook).
11  * COPs that generate static data before cooking should add a class
12  * that derives from this class.
13  *
14  */
15 #ifndef _COP2_CONTEXTDATA_H_
16 #define _COP2_CONTEXTDATA_H_
17 
18 #include "COP2_API.h"
19 #include <UT/UT_SmallObject.h>
20 #include <TIL/TIL_Defines.h>
21 #include <TIL/TIL_Plane.h>
22 
23 class COP2_Node;
24 class COP2_Context;
25 
26 
28  : public UT_SmallObject<COP2_ContextData,
29  UT_SMALLOBJECT_CLEANPAGES_OFF, 31,
30  UT_SMALLOBJECT_THREADSAFE_ON, 512>
31 {
32 public:
34  virtual ~COP2_ContextData();
35 
36 protected:
37  // override to determine under which cases to create a new context data
38  virtual bool createPerPlane() const { return false; }
39  virtual bool createPerRes() const { return true; }
40  virtual bool createPerTime() const { return true; }
41  virtual bool createPerThread() const{ return false; }
42 
43 private:
44  // Specific instance expression flags
45  void setExpressionFlags(bool plane, bool array, bool res);
46 
47  bool hasPlaneExpr() const { return myExprPlane; }
48  bool hasArrayExpr() const { return myExprArray; }
49  bool hasResExpr() const { return myExprRes; }
50 
51  short changeRefCount(short count);
52 
53  int64 getMemSize() const;
54 
55  short myCount;
56  unsigned char myExprPlane : 1,
57  myExprArray : 1,
58  myExprRes : 1;
59 
60  friend class COP2_Context;
61  friend class COP2_Node;
62 };
63 
65  : public UT_SmallObject<COP2_Context,
66  UT_SMALLOBJECT_CLEANPAGES_OFF, 160,
67  UT_SMALLOBJECT_THREADSAFE_ON, 256>
68 {
69 public:
71 
72  // context information.
73  union {
75  COP2_Context *myNext; // used by allocators.
76  };
77  fpreal getTime() const { return myTime; }
78  void setTime(fpreal t) { myTime = t; }
79  int xres() const { return myXres; }
80  int yres() const { return myYres; }
81  void setXres(int xres) { myXres = xres; }
82  void setYres(int yres) { myYres = yres; }
83 
85  float myTime;
87  int myXres;
88  int myYres;
89  int myXsize;
90  int myYsize;
91  int myXorig;
92  int myYorig;
93 
94  // Image bounds modification routines.
95  void setImageBounds(int x1, int y1, int x2, int y2);
96  void enlargeImageBounds(int x, int y);
97  void enlargeImageBounds(float x, float y);
98 
99  // Image bounds query. Returns false if they are not set.
100  bool getImageBounds(int &x1, int &y1, int &x2, int &y2);
101  bool areBoundsSet() const { return myBoundsInit; }
102 
103 private:
104  // only COP2_Node can allocate.
105  COP2_Context(COP2_Node *node);
106  ~COP2_Context();
107  void reset();
108 
109  bool dataMatch(const TIL_Plane *plane, int array, float time,
110  int xres, int yres, int thread) const;
111 
112  bool contextMatch(const TIL_Plane *plane, int array, float time,
113  int xres, int yres, int thread) const;
114 
115  void set(const TIL_Plane *plane, int arrayindex, float t,
116  int xres, int yres, int thread, bool ownsplane = true);
117 
118  void setData(COP2_ContextData *data);
119  void setPendingData(bool pd) { myPendingData = pd; }
120  bool isPendingData() const { return myPendingData; }
121 
122  int64 getMemSize() const;
123 
124  TIL_FastLock myLock;
125  COP2_ContextData *myData;
126  COP2_Node *myCop;
127  volatile unsigned myBoundsInit :1,
128  myPlaneOwner :1,
129  myPendingData :1;
130 
131  friend class COP2_Node;
132  friend class COP2_CookScheduler;
133 };
134 
135 #endif
int yres() const
Definition: COP2_Context.h:80
void setTime(fpreal t)
Definition: COP2_Context.h:78
virtual bool createPerThread() const
Definition: COP2_Context.h:41
GT_API const UT_StringHolder time
void setYres(int yres)
Definition: COP2_Context.h:82
fpreal getTime() const
Definition: COP2_Context.h:77
int xres() const
Definition: COP2_Context.h:79
GLint y
Definition: glcorearb.h:102
COP2_Context * myNext
Definition: COP2_Context.h:75
void setXres(int xres)
Definition: COP2_Context.h:81
long long int64
Definition: SYS_Types.h:107
GLboolean * data
Definition: glcorearb.h:130
virtual bool createPerRes() const
Definition: COP2_Context.h:39
GLint GLsizei count
Definition: glcorearb.h:404
bool areBoundsSet() const
Definition: COP2_Context.h:101
double fpreal
Definition: SYS_Types.h:270
#define COP2_API
Definition: COP2_API.h:10
virtual bool createPerTime() const
Definition: COP2_Context.h:40
GLint GLenum GLint x
Definition: glcorearb.h:408
virtual bool createPerPlane() const
Definition: COP2_Context.h:38
const TIL_Plane * myPlane
Definition: COP2_Context.h:74