HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PXL_Common.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: PXL_Defines.h (Pixel Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 #ifndef PXL_DEFINES_H
12 #define PXL_DEFINES_H
13 
14 #include <limits.h>
15 #include "PXL_API.h"
16 #include <SYS/SYS_Types.h>
17 #include <UT/UT_Assert.h>
18 #include <UT/UT_ComputeGPU.h>
19 
21 {
22  PXL_INT8 = 0,
28 };
29 
31 
33 {
34  PACK_SINGLE =0, // single channel
35  PACK_DUAL, // 2 channel interleaved + 1 black channel. (12B12B).
36  PACK_DUAL_NI, // 2 channel, non-interleaved (11111....12222222...2)
37  PACK_RGB, // RGB interleaved (rgbrgb...rgb)
38  PACK_RGBA, // RGBA interleaved
39  PACK_RGB_NI, // RGB non-interleaved (rrr...rggg...gbbb..b)
40  PACK_RGBA_NI, // RGBA non-interleaved
41  PACK_UV, // 2 channel interleaved.
42 
43  PACK_UNKNOWN = 255,
45 };
46 
47 PXL_API const char *PXLpacking(PXL_Packing p);
48 
49 /// Define typresolver structs to translate between the types associated with
50 /// the pixel storage and the C++ types. This can be used in templated
51 /// functions: @code
52 /// template <PXL_DataFormat FORMAT> void
53 /// function() { const PXL_TypeResolver<FORMAT>::CPPType *raster = ... }
54 /// @endcode
55 template <typename T> struct PXL_DataFormatResolver;
56 template <PXL_DataFormat> struct PXL_TypeResolver;
57 #define DEF_TYPERESOLVER(FORMAT, CPPTYPE) \
58  template <> struct PXL_DataFormatResolver<CPPTYPE> { \
59  static constexpr PXL_DataFormat format = FORMAT; \
60  }; \
61  template <> struct PXL_TypeResolver<FORMAT> { \
62  using T = CPPTYPE; \
63  }; \
64  /* end macro */
70 #undef DEF_TYPERESOLVER
71 
73 {
75 
79 
80  // For future support:
83 
84  // Append all new color spaces to this list here
86 
88 };
89 
91 PXL_API PXL_ColorSpace PXLgetColorSpace(const char *csname);
92 
93 inline const char *PXLcolorSpace(PXL_ColorSpace s)
94  { return PXLgetColorSpaceName(s); }
95 inline PXL_ColorSpace PXLcolorSpace(const char * s)
96  { return PXLgetColorSpace(s); }
97 
98 #define PXL_WHITE_8 UCHAR_MAX
99 #define PXL_WHITE_16 USHRT_MAX
100 #define PXL_WHITE_32 UINT_MAX
101 
102 PXL_API extern const int pxlDefinesDepth[6];
103 PXL_API extern const int pxlDefinesPComp[256];
104 PXL_API extern const int pxlDefinesPDepth[256];
105 PXL_API extern const unsigned int pxlDefinesWhite[6];
106 
108 {
109  switch(t)
110  {
111  default:
112  case PXL_INT8: return UT_GPU_UINT8;
113  case PXL_INT16: return UT_GPU_UINT16;
114  case PXL_INT32: return UT_GPU_UINT32;
115  case PXL_FLOAT32: return UT_GPU_FLOAT32;
116  case PXL_FLOAT16: return UT_GPU_FLOAT16;
117  }
118 
119  UT_ASSERT(!"Unknown type");
120  return UT_GPU_UINT8;
121 }
122 
124  { return pxlDefinesDepth[(int) d]; }
125 
127  { return pxlDefinesPComp[(int) p]; }
128 
130  { return pxlDefinesPDepth[(int) p]; }
131 
132 inline unsigned int PXLwhitePoint(PXL_DataFormat dt)
133  { return pxlDefinesWhite[ (int) dt]; }
134 
135 
136 // must be called before the following 3 CPU flag checks.
138 PXL_API bool PXLcpuHasMMX();
139 PXL_API int PXLcpuHasSSE();
140 PXL_API bool PXLcpuHasXMMX();
142 
143 inline int PXLclampChar(int t)
144 {
145  if(t < 0)
146  t = 0;
147  else if(t > 255)
148  t = 255;
149 
150  return t;
151 }
152 
153 inline int PXLclampShort(int t)
154 {
155  if(t < 0)
156  t = 0;
157  else if(t > 65535)
158  t = 65535;
159  return t;
160 }
161 
162 
163 #endif
PXL_API const int pxlDefinesPDepth[256]
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
int PXLpackingComponents(PXL_Packing p)
Definition: PXL_Common.h:126
unsigned short uint16
Definition: SYS_Types.h:38
int int32
Definition: SYS_Types.h:39
#define DEF_TYPERESOLVER(FORMAT, CPPTYPE)
Definition: PXL_Common.h:57
unsigned int PXLwhitePoint(PXL_DataFormat dt)
Definition: PXL_Common.h:132
PXL_API bool PXLcpuHasMMX()
GLdouble s
Definition: glad.h:3009
PXL_API const char * PXLdataFormat(PXL_DataFormat f)
PXL_API int PXLcpuHasSSE()
PXL_API bool PXLcpuHasCondMov()
float fpreal32
Definition: SYS_Types.h:200
#define PXL_API
Definition: PXL_API.h:10
PXL_API const char * PXLgetColorSpaceName(PXL_ColorSpace cs)
unsigned char uint8
Definition: SYS_Types.h:36
UT_GPUType
Definition: UT_ComputeGPU.h:42
GLfloat f
Definition: glcorearb.h:1926
UT_GPUType PXLconvertToUTGPUType(PXL_DataFormat t)
Definition: PXL_Common.h:107
int PXLpackingDepth(PXL_Packing p)
Definition: PXL_Common.h:129
PXL_Packing
Definition: PXL_Common.h:32
PXL_DataFormat
Definition: PXL_Common.h:20
GLdouble t
Definition: glad.h:2397
PXL_API const unsigned int pxlDefinesWhite[6]
PXL_API const int pxlDefinesDepth[6]
PXL_API bool PXLcpuHasXMMX()
PXL_ColorSpace
Definition: PXL_Common.h:72
const char * PXLcolorSpace(PXL_ColorSpace s)
Definition: PXL_Common.h:93
int PXLformatDepth(PXL_DataFormat d)
Definition: PXL_Common.h:123
int PXLclampChar(int t)
Definition: PXL_Common.h:143
PXL_API PXL_ColorSpace PXLgetColorSpace(const char *csname)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
int PXLclampShort(int t)
Definition: PXL_Common.h:153
PXL_API const int pxlDefinesPComp[256]
PXL_API const char * PXLpacking(PXL_Packing p)
PXL_API void PXLdetermineProcCaps()