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