HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_Plane.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: TIL_Plane.h (Tile Image Library, C++)
7  *
8  * COMMENTS:
9  * Defines the information for a single plane of an image (Red, Depth,
10  * Alpha, etc). Does not contain any actual image data.
11  */
12 #ifndef TIL_PLANE_H
13 #define TIL_PLANE_H
14 
15 #include "TIL_API.h"
16 #include <UT/UT_SmallObject.h>
17 #include <iosfwd>
18 #include <string.h>
19 
20 #include "TIL_Defines.h"
21 
23  public UT_SmallObject<TIL_Plane,
24  UT_SMALLOBJECT_CLEANPAGES_OFF, 250,
25  UT_SMALLOBJECT_THREADSAFE_ON>
26 {
27 public:
28  TIL_Plane(const char *name, TIL_DataFormat format,
29  const char *n1=0,
30  const char *n2=0,
31  const char *n3=0,
32  const char *n4=0,
33  TIL_TypeInfo typeinfo = TIL_TI_UNDEFINED);
34  TIL_Plane(const TIL_Plane &);
35  TIL_Plane();
36  ~TIL_Plane();
37 
38  int64 getMemoryUsage(bool inclusive) const;
39 
40  // WARNING: The assignment operator does NOT preserve the constant
41  // flags.
42  TIL_Plane & operator=(const TIL_Plane &);
43 
44  // equality based on name ONLY. matches() does exact vector/name/type
45  // equality (but no array size comparison).
46  inline int operator==(const TIL_Plane &eq) const
47  { return (strcmp(eq.getName(), getName()) == 0); }
48 
49  inline int operator!=(const TIL_Plane &eq) const
50  { return (strcmp(eq.getName(), getName()) != 0); }
51 
52  bool matches(const TIL_Plane &) const;
53  bool isCompatible(const TIL_Plane &) const;
54 
55  // name of this plane. must be unique within a sequence. should only be
56  // called by TIL_Sequence, to avoid different planes with the same name.
57  const char * getName() const { return myName; }
58  void setName(const char *name);
59 
60  bool isAlphaPlane() const;
61  bool isColorPlane() const;
62  bool isPointPlane() const;
63  bool isNormalPlane() const;
64  bool isDepthPlane() const;
65  bool isGeometricPlane() const;
66 
67  // the data format of this plane (int8, float32, etc)
68  TIL_DataFormat getFormat() const { return (TIL_DataFormat)myFormat; }
69  void setFormat(TIL_DataFormat format);
70 
71  // the type of this plane (color, normal, vector, etc)
72  TIL_TypeInfo getTypeInfo() const { return (TIL_TypeInfo)myTypeInfo; }
73  void setTypeInfo(TIL_TypeInfo typeinfo)
74  { myTypeInfo = (unsigned char)typeinfo; }
75 
76  // the number of layers this plane has (1 normally). Different from
77  // the vector size in that you can have 4 layers of a vector3.
78  int getArraySize() const { return myArraySize; }
79  void setArraySize(int n);
80 
81  // Vector size of the data: RGB = 3, RGBA = 4, R = 1.
82  int getVectorSize() const { return myVectorSize; }
83  void setVectorSize(int n);
84 
85  // vector components names.
86  inline const char * getSubName(int i) const
87  { return (i>=0 && i<myVectorSize) ? mySubName[i] : 0; }
88 
89  void setSubName(const char *subname, int i);
90  int hasElement(const char *planename);
91 
92  // returns whether the vector element is 'enabled'. If it is,
93  // COP2_Node::inputTile() and similar functions will cook and return the
94  // tile corresponding to the element. Otherwise, it will be passed
95  // through. setScoped sets all the components to enabled or not.
96  // isScoped returns true if ALL the components are scoped, false otherwise
97  inline int getPlaneMask(int i) const
98  { return (i>=0 && i<myVectorSize) ? myPlaneMask[i]:0; }
99 
100  void setPlaneMask(int enable, int i);
101  void copyPlaneMask(const TIL_Plane &plane);
102  inline void setScoped(int enable)
103  { for(int i=myVectorSize; i--;) myPlaneMask[i]=(char)enable; }
104 
105  bool isScoped() const;
106  bool isPartiallyScoped() const;
107  bool scopeMatches(const TIL_Plane &plane) const;
108 
109  // returns whether the array element i is enabled, similar to getPlaneMask
110  int getArrayMask(int i) const;
111  void setArrayMask(int start, int end, int step);
112 
113  // methods for dealing with constant planes
114  bool isConstantPlane() const;
115  bool isConstantComponent(int i) const;
116  bool isAnyComponentConstant() const;
117  void setConstantFlag(int i, bool enable);
118 
119  // black white/point stuff.
120  int usesBlackWhitePoints() const;
121  void getBlackWhitePoints(unsigned int &b,
122  unsigned int &w) const
123  { b = myBlackPoint; w = myWhitePoint; }
124  void getBlackWhitePoints(float &b, float &w) const;
125  void setBlackWhitePoints(unsigned int b, unsigned int w);
126 
127  void debugPrint(std::ostream &os) const;
128  int64 getMemSize() const;
129 
130  unsigned getHash() const;
131 
132 private:
133  const char * myName;
134  unsigned short myArraySize;
135  unsigned char myFormat;
136  unsigned char myTypeInfo;
137  unsigned char myVectorSize;
138 
139  const char * mySubName[PLANE_MAX_VECTOR_SIZE];
140 
141  // masking.
142  signed char myPlaneMask[PLANE_MAX_VECTOR_SIZE];
143  int myArrayMaskStart;
144  int myArrayMaskEnd;
145  int myArrayMaskStep;
146 
147  // members for dealing with constant (color and alpha) planes.
148  char myConstantFlag[PLANE_MAX_VECTOR_SIZE];
149 
150  // black/white points.
151  unsigned int myBlackPoint;
152  unsigned int myWhitePoint;
153  unsigned int myNameAlloc :1,
154  myComp0Alloc :1,
155  myComp1Alloc :1,
156  myComp2Alloc :1,
157  myComp3Alloc :1;
158 };
159 
160 
161 #endif
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLboolean enable
Definition: glew.h:2750
GLuint start
Definition: glcorearb.h:475
int operator==(const TIL_Plane &eq) const
Definition: TIL_Plane.h:46
GLuint const GLchar * name
Definition: glcorearb.h:786
int getPlaneMask(int i) const
Definition: TIL_Plane.h:97
void getBlackWhitePoints(unsigned int &b, unsigned int &w) const
Definition: TIL_Plane.h:121
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
int operator!=(const TIL_Plane &eq) const
Definition: TIL_Plane.h:49
#define TIL_DataFormat
Definition: TIL_Defines.h:64
int getArraySize() const
Definition: TIL_Plane.h:78
const char * getName() const
Definition: TIL_Plane.h:57
GLuint GLuint end
Definition: glcorearb.h:475
void setTypeInfo(TIL_TypeInfo typeinfo)
Definition: TIL_Plane.h:73
const char * getSubName(int i) const
Definition: TIL_Plane.h:86
#define PLANE_MAX_VECTOR_SIZE
Definition: TIL_Defines.h:166
long long int64
Definition: SYS_Types.h:116
TIL_DataFormat getFormat() const
Definition: TIL_Plane.h:68
TIL_TypeInfo getTypeInfo() const
Definition: TIL_Plane.h:72
GLdouble n
Definition: glcorearb.h:2008
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
TIL_TypeInfo
Definition: TIL_Defines.h:74
int getVectorSize() const
Definition: TIL_Plane.h:82
#define TIL_API
Definition: TIL_API.h:10
void setScoped(int enable)
Definition: TIL_Plane.h:102