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 {
32  PACK_SINGLE =0, // single channel
33  PACK_DUAL, // 2 channel interleaved + 1 black channel. (12B12B).
34  PACK_DUAL_NI, // 2 channel, non-interleaved (11111....12222222...2)
35  PACK_RGB, // RGB interleaved (rgbrgb...rgb)
36  PACK_RGBA, // RGBA interleaved
37  PACK_RGB_NI, // RGB non-interleaved (rrr...rggg...gbbb..b)
38  PACK_RGBA_NI, // RGBA non-interleaved
39  PACK_UV, // 2 channel interleaved.
40 
41  PACK_UNKNOWN = 255,
43 };
44 
45 /// Define typresolver structs to translate between the types associated with
46 /// the pixel storage and the C++ types. This can be used in templated
47 /// functions: @code
48 /// template <PXL_DataFormat FORMAT> void
49 /// function() { const PXL_TypeResolver<FORMAT>::CPPType *raster = ... }
50 /// @endcode
51 template <typename T> struct PXL_DataFormatResolver;
52 template <PXL_DataFormat> struct PXL_TypeResolver;
53 #define DEF_TYPERESOLVER(FORMAT, CPPTYPE) \
54  template <> struct PXL_DataFormatResolver<CPPTYPE> { \
55  static constexpr PXL_DataFormat format = FORMAT; \
56  }; \
57  template <> struct PXL_TypeResolver<FORMAT> { \
58  using T = CPPTYPE; \
59  }; \
60  /* end macro */
66 #undef DEF_TYPERESOLVER
67 
69 {
71 
76 
77  // For future support:
80 
81  // Append all new color spaces to this list here
82 
84 };
85 
87 PXL_API PXL_ColorSpace PXLgetColorSpace(const char *csname);
88 
89 
90 #define PXL_WHITE_8 UCHAR_MAX
91 #define PXL_WHITE_16 USHRT_MAX
92 #define PXL_WHITE_32 UINT_MAX
93 
94 PXL_API extern const int pxlDefinesDepth[6];
95 PXL_API extern const int pxlDefinesPComp[256];
96 PXL_API extern const int pxlDefinesPDepth[256];
97 PXL_API extern const unsigned int pxlDefinesWhite[6];
98 
100 {
101  switch(t)
102  {
103  default:
104  case PXL_INT8: return UT_GPU_UINT8;
105  case PXL_INT16: return UT_GPU_UINT16;
106  case PXL_INT32: return UT_GPU_UINT32;
107  case PXL_FLOAT32: return UT_GPU_FLOAT32;
108  case PXL_FLOAT16: return UT_GPU_FLOAT16;
109  }
110 
111  UT_ASSERT(!"Unknown type");
112  return UT_GPU_UINT8;
113 }
114 
116  { return pxlDefinesDepth[(int) d]; }
117 
119  { return pxlDefinesPComp[(int) p]; }
120 
122  { return pxlDefinesPDepth[(int) p]; }
123 
124 inline unsigned int PXLwhitePoint(PXL_DataFormat dt)
125  { return pxlDefinesWhite[ (int) dt]; }
126 
127 
128 // must be called before the following 3 CPU flag checks.
130 PXL_API bool PXLcpuHasMMX();
131 PXL_API int PXLcpuHasSSE();
132 PXL_API bool PXLcpuHasXMMX();
134 
135 inline int PXLclampChar(int t)
136 {
137  if(t < 0)
138  t = 0;
139  else if(t > 255)
140  t = 255;
141 
142  return t;
143 }
144 
145 inline int PXLclampShort(int t)
146 {
147  if(t < 0)
148  t = 0;
149  else if(t > 65535)
150  t = 65535;
151  return t;
152 }
153 
154 
155 #endif
PXL_API const int pxlDefinesPDepth[256]
int PXLpackingComponents(PXL_Packing p)
Definition: PXL_Common.h:118
unsigned short uint16
Definition: SYS_Types.h:38
int int32
Definition: SYS_Types.h:39
#define DEF_TYPERESOLVER(FORMAT, CPPTYPE)
Definition: PXL_Common.h:53
unsigned int PXLwhitePoint(PXL_DataFormat dt)
Definition: PXL_Common.h:124
PXL_API bool PXLcpuHasMMX()
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:41
UT_GPUType PXLconvertToUTGPUType(PXL_DataFormat t)
Definition: PXL_Common.h:99
int PXLpackingDepth(PXL_Packing p)
Definition: PXL_Common.h:121
PXL_Packing
Definition: PXL_Common.h:30
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
PXL_DataFormat
Definition: PXL_Common.h:20
PXL_API const unsigned int pxlDefinesWhite[6]
GLfloat GLfloat p
Definition: glew.h:16321
PXL_API const int pxlDefinesDepth[6]
PXL_API bool PXLcpuHasXMMX()
PXL_ColorSpace
Definition: PXL_Common.h:68
int PXLformatDepth(PXL_DataFormat d)
Definition: PXL_Common.h:115
int PXLclampChar(int t)
Definition: PXL_Common.h:135
PXL_API PXL_ColorSpace PXLgetColorSpace(const char *csname)
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
int PXLclampShort(int t)
Definition: PXL_Common.h:145
PXL_API const int pxlDefinesPComp[256]
GLdouble GLdouble t
Definition: glew.h:1398
PXL_API void PXLdetermineProcCaps()