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  // Was planned for arrays, but arrays were ultimately not implemented,
81  // so this should always return 1. If arrays WERE implemented, this
82  // would return the number of layers, which are a separate thing from
83  // the vector size. That is, you could have 4 layers of vector3.
84  int getArraySize() const { return myArraySize; }
85  void setArraySize(int n);
86 
87  // Vector size of the data: RGB = 3, RGBA = 4, R = 1.
88  int getVectorSize() const { return myVectorSize; }
89  void setVectorSize(int n);
90 
91  // vector components names.
92  inline const char * getSubName(int i) const
93  { return (i>=0 && i<myVectorSize) ? mySubName[i] : 0; }
94 
95  void setSubName(const char *subname, int i);
96  int hasElement(const char *planename);
97 
98  // returns whether the vector element is 'enabled'. If it is,
99  // COP2_Node::inputTile() and similar functions will cook and return the
100  // tile corresponding to the element. Otherwise, it will be passed
101  // through. setScoped sets all the components to enabled or not.
102  // isScoped returns true if ALL the components are scoped, false otherwise
103  inline int getPlaneMask(int i) const
104  { return (i>=0 && i<myVectorSize) ? myPlaneMask[i]:0; }
105 
106  void setPlaneMask(int enable, int i);
107  void copyPlaneMask(const TIL_Plane &plane);
108  inline void setScoped(int enable)
109  { for(int i=myVectorSize; i--;) myPlaneMask[i]=(char)enable; }
110 
111  bool isScoped() const;
112  bool isPartiallyScoped() const;
113  bool scopeMatches(const TIL_Plane &plane) const;
114 
115  // returns whether the array element i is enabled, similar to getPlaneMask
116  int getArrayMask(int i) const;
117  void setArrayMask(int start, int end, int step);
118 
119  // methods for dealing with constant planes
120  bool isConstantPlane() const;
121  bool isConstantComponent(int i) const;
122  bool isAnyComponentConstant() const;
123  void setConstantFlag(int i, bool enable);
124 
125  // black white/point stuff.
126  int usesBlackWhitePoints() const;
127  void getBlackWhitePoints(unsigned int &b,
128  unsigned int &w) const
129  { b = myBlackPoint; w = myWhitePoint; }
130  void getBlackWhitePoints(float &b, float &w) const;
131  void setBlackWhitePoints(unsigned int b, unsigned int w);
132 
133  void debugPrint(std::ostream &os) const;
134  int64 getMemSize() const;
135 
137  const UT_StringHolder &ocio = UT_StringHolder())
138  {
139  myColorSpace = cs;
140  myOCIOColorSpace = ocio;
141  }
142  PXL_ColorSpace getColorSpace() const { return myColorSpace; }
143  const UT_StringHolder &getOCIOColorSpace() const { return myOCIOColorSpace; }
144 
145  unsigned getHash() const;
146 
147  void dump() const;
148  void dump(UT_JSONWriter &w) const;
149 
150 private:
151  const char *myName;
152  unsigned short myArraySize;
153  unsigned char myFormat;
154  unsigned char myTypeInfo;
155  unsigned char myVectorSize;
156 
157  const char *mySubName[PLANE_MAX_VECTOR_SIZE];
158 
159  // masking.
160  signed char myPlaneMask[PLANE_MAX_VECTOR_SIZE];
161  int myArrayMaskStart;
162  int myArrayMaskEnd;
163  int myArrayMaskStep;
164 
165  // members for dealing with constant (color and alpha) planes.
166  char myConstantFlag[PLANE_MAX_VECTOR_SIZE];
167 
168  PXL_ColorSpace myColorSpace;
169  UT_StringHolder myOCIOColorSpace;
170 
171  // black/white points.
172  unsigned int myBlackPoint;
173  unsigned int myWhitePoint;
174  unsigned int myNameAlloc :1,
175  myComp0Alloc :1,
176  myComp1Alloc :1,
177  myComp2Alloc :1,
178  myComp3Alloc :1;
179 };
180 
181 
182 #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:103
void getBlackWhitePoints(unsigned int &b, unsigned int &w) const
Definition: TIL_Plane.h:127
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:64
const UT_StringHolder & getOCIOColorSpace() const
Definition: TIL_Plane.h:143
int getArraySize() const
Definition: TIL_Plane.h:84
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:92
#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: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
LeafData & operator=(const LeafData &)=delete
PXL_ColorSpace
Definition: PXL_Common.h:72
PXL_ColorSpace getColorSpace() const
Definition: TIL_Plane.h:142
TIL_TypeInfo
Definition: TIL_Defines.h:74
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
int getVectorSize() const
Definition: TIL_Plane.h:88
#define TIL_API
Definition: TIL_API.h:10
void setColorSpace(PXL_ColorSpace cs, const UT_StringHolder &ocio=UT_StringHolder())
Definition: TIL_Plane.h:136
void setScoped(int enable)
Definition: TIL_Plane.h:108