00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _COP2_CONTEXTDATA_H_
00025 #define _COP2_CONTEXTDATA_H_
00026
00027 #include "COP2_API.h"
00028 #include <UT/UT_SmallObject.h>
00029 #include <TIL/TIL_Defines.h>
00030 #include <TIL/TIL_Plane.h>
00031
00032 class COP2_Node;
00033 class COP2_Context;
00034
00035
00036 class COP2_API COP2_ContextData
00037 : public UT_SmallObject<COP2_ContextData,
00038 UT_SMALLOBJECT_CLEANPAGES_OFF, 31,
00039 UT_SMALLOBJECT_THREADSAFE_ON, 512>
00040 {
00041 public:
00042 COP2_ContextData();
00043 virtual ~COP2_ContextData();
00044
00045 protected:
00046
00047 virtual bool createPerPlane() const { return false; }
00048 virtual bool createPerRes() const { return true; }
00049 virtual bool createPerTime() const { return true; }
00050 virtual bool createPerThread() const{ return false; }
00051
00052 private:
00053
00054 void setExpressionFlags(bool plane, bool array, bool res);
00055
00056 bool hasPlaneExpr() const { return myExprPlane; }
00057 bool hasArrayExpr() const { return myExprArray; }
00058 bool hasResExpr() const { return myExprRes; }
00059
00060 short changeRefCount(short count);
00061
00062 int64 getMemSize() const;
00063
00064 short myCount;
00065 unsigned char myExprPlane : 1,
00066 myExprArray : 1,
00067 myExprRes : 1;
00068
00069 friend class COP2_Context;
00070 friend class COP2_Node;
00071 };
00072
00073 class COP2_API COP2_Context
00074 : public UT_SmallObject<COP2_Context,
00075 UT_SMALLOBJECT_CLEANPAGES_OFF, 160,
00076 UT_SMALLOBJECT_THREADSAFE_ON, 256>
00077 {
00078 public:
00079 COP2_ContextData *data();
00080
00081
00082 union {
00083 const TIL_Plane *myPlane;
00084 COP2_Context *myNext;
00085 };
00086 int myArrayIndex;
00087 float myTime;
00088 int myThreadIndex;
00089 int myXres;
00090 int myYres;
00091 int myXsize;
00092 int myYsize;
00093 int myXorig;
00094 int myYorig;
00095
00096
00097 void setImageBounds(int x1, int y1, int x2, int y2);
00098 void enlargeImageBounds(int x, int y);
00099 void enlargeImageBounds(float x, float y);
00100
00101
00102 bool getImageBounds(int &x1, int &y1, int &x2, int &y2);
00103 bool areBoundsSet() const { return myBoundsInit; }
00104
00105 private:
00106
00107 COP2_Context(COP2_Node *node);
00108 ~COP2_Context();
00109 void reset();
00110
00111 bool dataMatch(const TIL_Plane *plane, int array, float time,
00112 int xres, int yres, int thread) const;
00113
00114 bool contextMatch(const TIL_Plane *plane, int array, float time,
00115 int xres, int yres, int thread) const;
00116
00117 void set(const TIL_Plane *plane, int arrayindex, float t,
00118 int xres, int yres, int thread, bool ownsplane = true);
00119
00120 void setData(COP2_ContextData *data);
00121 void setPendingData(bool pd) { myPendingData = pd; }
00122 bool isPendingData() const { return myPendingData; }
00123
00124 int64 getMemSize() const;
00125
00126 TIL_FastLock myLock;
00127 COP2_ContextData *myData;
00128 COP2_Node *myCop;
00129 volatile unsigned myBoundsInit :1,
00130 myPlaneOwner :1,
00131 myPendingData :1;
00132
00133 friend class COP2_Node;
00134 friend class COP2_CookScheduler;
00135 };
00136
00137 #endif