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