aboutsummaryrefslogtreecommitdiff
path: root/Gem/develop/include/Gem/Utils
diff options
context:
space:
mode:
authorTravis CI <zmoelnig@travis-ci.umlaeute.mur.at>2017-12-06 23:47:39 +0000
committerTravis CI <zmoelnig@travis-ci.umlaeute.mur.at>2017-12-06 23:47:39 +0000
commitc886922cc0b8c32ead0459b581f51ff60fdebbd4 (patch)
tree98c9b3036116ebfefde32c8c278639b767e2d305 /Gem/develop/include/Gem/Utils
parentff954ec3b2de3f0bce8aee70680469468896df7d (diff)
Gem 427a3d0e61d61e64e76facfa905c120356383bab osx/x86_64
built 'master:427a3d0e61d61e64e76facfa905c120356383bab' for osx/x86_64
Diffstat (limited to 'Gem/develop/include/Gem/Utils')
-rw-r--r--Gem/develop/include/Gem/Utils/Functions.h171
-rw-r--r--Gem/develop/include/Gem/Utils/GLUtil.h111
-rw-r--r--Gem/develop/include/Gem/Utils/GemMath.h12
-rw-r--r--Gem/develop/include/Gem/Utils/GemString.h22
-rw-r--r--Gem/develop/include/Gem/Utils/Matrix.h66
-rw-r--r--Gem/develop/include/Gem/Utils/PixPete.h229
-rw-r--r--Gem/develop/include/Gem/Utils/SIMD.h20
-rw-r--r--Gem/develop/include/Gem/Utils/SynchedWorkerThread.h80
-rw-r--r--Gem/develop/include/Gem/Utils/Thread.h89
-rw-r--r--Gem/develop/include/Gem/Utils/ThreadMutex.h41
-rw-r--r--Gem/develop/include/Gem/Utils/ThreadSemaphore.h43
-rw-r--r--Gem/develop/include/Gem/Utils/Vector.h56
-rw-r--r--Gem/develop/include/Gem/Utils/WorkerThread.h124
-rw-r--r--Gem/develop/include/Gem/Utils/any.h475
-rw-r--r--Gem/develop/include/Gem/Utils/nop.h1
15 files changed, 830 insertions, 710 deletions
diff --git a/Gem/develop/include/Gem/Utils/Functions.h b/Gem/develop/include/Gem/Utils/Functions.h
index b025e29..dd76ea9 100644
--- a/Gem/develop/include/Gem/Utils/Functions.h
+++ b/Gem/develop/include/Gem/Utils/Functions.h
@@ -34,22 +34,22 @@ LOG
///////////////////////////////////////////////////////////////////////////////
inline int powerOfTwo(int value)
{
-/*
- int x = 1;
- // while(x <= value) x <<= 1;
- while(x < value) x <<= 1;
- return(x);
-*/
+ /*
+ int x = 1;
+ // while(x <= value) x <<= 1;
+ while(x < value) x <<= 1;
+ return(x);
+ */
// optimization from "Hacker's Delight"
// - above loop executes in 4n+3 instructions, where n is the power of 2 of returned int
// - below code is branch-free and only 12 instructions!
- value = value - 1;
- value = value | (value >> 1);
- value = value | (value >> 2);
- value = value | (value >> 4);
- value = value | (value >> 8);
- value = value | (value >> 16);
- return (value + 1);
+ value = value - 1;
+ value = value | (value >> 1);
+ value = value | (value >> 2);
+ value = value | (value >> 4);
+ value = value | (value >> 8);
+ value = value | (value >> 16);
+ return (value + 1);
}
///////////////////////////////////////////////////////////////////////////////
@@ -58,23 +58,39 @@ inline int powerOfTwo(int value)
///////////////////////////////////////////////////////////////////////////////
#ifndef MIN
template <class T>
-inline T MIN(T x, T y) { return (x<y)?x:y; }
+inline T MIN(T x, T y)
+{
+ return (x<y)?x:y;
+}
#endif
#ifndef MAX
template <class T>
-inline T MAX(T x, T y) { return (x>y)?x:y; }
+inline T MAX(T x, T y)
+{
+ return (x>y)?x:y;
+}
#endif
template <class T>
-inline T TRI_MAX(T v1, T v2, T v3){
- if (v1 > v2 && v1 > v3) return(v1);
- if (v2 > v3) return(v2);
+inline T TRI_MAX(T v1, T v2, T v3)
+{
+ if (v1 > v2 && v1 > v3) {
+ return(v1);
+ }
+ if (v2 > v3) {
+ return(v2);
+ }
return(v3);
}
template <class T>
-inline T TRI_MIN(T v1, T v2, T v3){
- if (v1 < v2 && v1 < v3) return(v1);
- if (v2 < v3) return(v2);
+inline T TRI_MIN(T v1, T v2, T v3)
+{
+ if (v1 < v2 && v1 < v3) {
+ return(v1);
+ }
+ if (v2 < v3) {
+ return(v2);
+ }
return(v3);
}
@@ -85,34 +101,46 @@ inline T TRI_MIN(T v1, T v2, T v3){
//////////
// Clamp a value high
inline unsigned char CLAMP_HIGH(int x)
- { return((unsigned char )((x > 255) ? 255 : x)); }
+{
+ return((unsigned char )((x > 255) ? 255 : x));
+}
//////////
// Clamp a value low
inline unsigned char CLAMP_LOW(int x)
- { return((unsigned char )((x < 0) ? 0 : x)); }
+{
+ return((unsigned char )((x < 0) ? 0 : x));
+}
//////////
// Clamp an int to the range of an unsigned char
inline unsigned char CLAMP(int x)
- { return((unsigned char)((x > 255) ? 255 : ( (x < 0) ? 0 : x))); }
+{
+ return((unsigned char)((x > 255) ? 255 : ( (x < 0) ? 0 : x)));
+}
//////////
// Clamp a float to the range of an unsigned char
template <class T>
inline unsigned char CLAMP(T x)
-{ return((unsigned char)((x > (T)255) ? (T)255 : ( (x < (T)0) ? (T)0 : x))); }
+{
+ return((unsigned char)((x > (T)255) ? (T)255 : ( (x < (T)0) ? (T)0 : x)));
+}
//////////
// Clamp a float to 0. <= x <= 1.0
template <class T>
inline float FLOAT_CLAMP(T x)
- { return((x > 1.) ? 1. : ( (x < 0.) ? 0. : x)); }
+{
+ return((x > 1.) ? 1. : ( (x < 0.) ? 0. : x));
+}
/////////
// Clamp the Y channel of YUV (16%235)
inline unsigned char CLAMP_Y(int x)
- { return((unsigned char)((x > 235) ? 235 : ( (x < 16) ? 16 : x))); }
+{
+ return((unsigned char)((x > 235) ? 235 : ( (x < 16) ? 16 : x)));
+}
///////////////////////////////////////////////////////////////////////////////
// Multiply and interpolation
@@ -123,21 +151,27 @@ inline unsigned char CLAMP_Y(int x)
// This avoids a float value (important on Intel...)
// From Alvy Ray Smith paper
inline unsigned char INT_MULT(unsigned int a, unsigned int b)
- { int t = (unsigned int)a * (unsigned int)b + 0x80;
- return((unsigned char)(((t >> 8) + t) >> 8)); }
+{
+ int t = (unsigned int)a * (unsigned int)b + 0x80;
+ return((unsigned char)(((t >> 8) + t) >> 8));
+}
//////////
// Exactly LERPs two values
// This avoids a float value (important on Intel...)
// From Alvy Ray Smith paper
inline unsigned char INT_LERP(unsigned int p, unsigned int q, unsigned int a)
- { return((unsigned char)(p + INT_MULT(a, q - p))); }
+{
+ return((unsigned char)(p + INT_MULT(a, q - p)));
+}
//////////
// Floating point LERP
template <class T>
inline T FLOAT_LERP(T p, T q, T a)
- { return( a * (q - p) + p); }
+{
+ return( a * (q - p) + p);
+}
///////////////////////////////////////////////////////////////////////////////
@@ -146,7 +180,9 @@ inline T FLOAT_LERP(T p, T q, T a)
///////////////////////////////////////////////////////////////////////////////
template <class T>
inline int stepFunc(T x, T a)
- { return(x >= a); }
+{
+ return(x >= a);
+}
///////////////////////////////////////////////////////////////////////////////
// Pulse function
@@ -154,7 +190,9 @@ inline int stepFunc(T x, T a)
///////////////////////////////////////////////////////////////////////////////
template <class T>
inline int pulseFunc(T x, T a, T b)
- { return(stepFunc(a, x) - stepFunc(b, x)); }
+{
+ return(stepFunc(a, x) - stepFunc(b, x));
+}
///////////////////////////////////////////////////////////////////////////////
// Clamp function
@@ -162,7 +200,9 @@ inline int pulseFunc(T x, T a, T b)
///////////////////////////////////////////////////////////////////////////////
template <class T>
inline T clampFunc(T x, T a, T b)
- { return(x < a ? a : (x > b ? b : x)); }
+{
+ return(x < a ? a : (x > b ? b : x));
+}
/*
inline void* clampFunc(void* x, void* a, void* b)
{ return(x < a ? a : (x > b ? b : x)); }
@@ -178,24 +218,36 @@ inline void* clampFunc(void* x, void* a, void* b)
// absolute integer
//
///////////////////////////////////////////////////////////////////////////////
-inline int AbsInt(int inValue) { return (inValue>0)?inValue:-inValue; }
-static inline int GetSign(int inValue) { return (inValue<0)?-1:1; }
+inline int AbsInt(int inValue)
+{
+ return (inValue>0)?inValue:-inValue;
+}
+static inline int GetSign(int inValue)
+{
+ return (inValue<0)?-1:1;
+}
///////////////////////////////////////////////////////////////////////////////
// wrapping functions for integers
//
///////////////////////////////////////////////////////////////////////////////
-inline int GetTiled(int inValue,const int nMax) {
+inline int GetTiled(int inValue,const int nMax)
+{
int nOutValue=(inValue%nMax);
- if (nOutValue<0)nOutValue=((nMax-1)+nOutValue);
+ if (nOutValue<0) {
+ nOutValue=((nMax-1)+nOutValue);
+ }
return nOutValue;
}
-inline int GetMirrored(int inValue,const int nMax) {
+inline int GetMirrored(int inValue,const int nMax)
+{
const int nTwoMax=(nMax*2);
int nOutValue=GetTiled(inValue,nTwoMax);
- if (nOutValue>=nMax)nOutValue=((nTwoMax-1)-nOutValue);
+ if (nOutValue>=nMax) {
+ nOutValue=((nTwoMax-1)-nOutValue);
+ }
return nOutValue;
}
@@ -204,36 +256,40 @@ inline int GetMirrored(int inValue,const int nMax) {
// 2D-algebra
//
///////////////////////////////////////////////////////////////////////////////
-static inline void Get2dTangent(float inX,float inY,float* poutX,float* poutY) {
- *poutX=inY;
- *poutY=-inX;
+static inline void Get2dTangent(float inX,float inY,float* poutX,float* poutY)
+{
+ *poutX=inY;
+ *poutY=-inX;
}
///////////////////////////////////////////////////////////////////////////////
// 2D-dot product
///////////////////////////////////////////////////////////////////////////////
-static inline float Dot2d(float Ax,float Ay,float Bx,float By) {
- return ((Ax*Bx)+(Ay*By));
+static inline float Dot2d(float Ax,float Ay,float Bx,float By)
+{
+ return ((Ax*Bx)+(Ay*By));
}
///////////////////////////////////////////////////////////////////////////////
// 2D-vector normalization
///////////////////////////////////////////////////////////////////////////////
-static inline void Normalise2d(float* pX,float* pY) {
- const float MagSqr=Dot2d(*pX,*pY,*pX,*pY);
- float Magnitude=(float)sqrt(MagSqr);
- if (Magnitude<=0.0f) {
- Magnitude=0.001f;
- }
- const float RecipMag=1.0f/Magnitude;
-
- *pX*=RecipMag;
- *pY*=RecipMag;
+static inline void Normalise2d(float* pX,float* pY)
+{
+ const float MagSqr=Dot2d(*pX,*pY,*pX,*pY);
+ float Magnitude=(float)sqrt(MagSqr);
+ if (Magnitude<=0.0f) {
+ Magnitude=0.001f;
+ }
+ const float RecipMag=1.0f/Magnitude;
+
+ *pX*=RecipMag;
+ *pY*=RecipMag;
}
///////////////////////////////////////////////////////////////////////////////
// higher algebra
//
///////////////////////////////////////////////////////////////////////////////
-inline float GetRandomFloat(void) {
+inline float GetRandomFloat(void)
+{
return rand()/static_cast<float>(RAND_MAX);
}
@@ -348,10 +404,9 @@ GEM_EXTERN extern void splineFunc(double val, double *ret, int numDimen, int nkn
inline uint32_t GetPrefetchConstant( int blockSizeInVectors, int blockCount, int blockStride )
{
- return ((blockSizeInVectors << 24) & 0x1F000000) | ((blockCount << 16) & 0x00FF0000) | (blockStride & 0xFFFF);
+ return ((blockSizeInVectors << 24) & 0x1F000000) | ((blockCount << 16) & 0x00FF0000) | (blockStride & 0xFFFF);
}
#endif
#endif // for header file
-
diff --git a/Gem/develop/include/Gem/Utils/GLUtil.h b/Gem/develop/include/Gem/Utils/GLUtil.h
index 16fa492..15b18c8 100644
--- a/Gem/develop/include/Gem/Utils/GLUtil.h
+++ b/Gem/develop/include/Gem/Utils/GLUtil.h
@@ -30,8 +30,13 @@ struct _symbol;
#include "Gem/Exception.h"
-namespace gem {namespace utils {namespace gl {
-GEM_EXTERN extern GLenum glReportError (bool verbose=true);
+namespace gem
+{
+namespace utils
+{
+namespace gl
+{
+GEM_EXTERN extern GLenum glReportError (bool verbose=true);
GEM_EXTERN extern int getGLdefine(const char *name);
GEM_EXTERN extern int getGLdefine(const struct _symbol *name);
GEM_EXTERN extern int getGLdefine(const struct _atom *name);
@@ -39,62 +44,64 @@ GEM_EXTERN extern int getGLbitfield(int argc, struct _atom *argv);
- /* mapping between GLSL-program IDs and float */
- /* this can also return different IDs for different contexts */
- class GEM_EXTERN GLuintMap {
- public:
- GLuintMap(const std::string&name);
- virtual ~GLuintMap();
- GLuint get(float); // throws GemException
- /* map a GLuint to float; if float is 0, the new mapping is created,
- * else we just update an existing one
- * updating is especially useful with multiple contexts */
- float set(GLuint, float f=0);
+/* mapping between GLSL-program IDs and float */
+/* this can also return different IDs for different contexts */
+class GEM_EXTERN GLuintMap
+{
+public:
+ GLuintMap(const std::string&name);
+ virtual ~GLuintMap();
+ GLuint get(float); // throws GemException
+ /* map a GLuint to float; if float is 0, the new mapping is created,
+ * else we just update an existing one
+ * updating is especially useful with multiple contexts */
+ float set(GLuint, float f=0);
- void del(float);
+ void del(float);
- /* usage:
+ /* usage:
+ mapper=GLuintMap("glsl_program");
+ prog=glCreateProgram();
+ progMapped=mapper.set(prog);
+ // for multi-context, you probably want to have a single float map to multiple
+ // programIDs; you add (or update) an existing mapping with:
+ // progMapped=mapper.set(prog, progMapped));
+ outlet_float(m_out, mapper.get(progMapped));
+
+ // ... somewhere else
+ mapper=GLuintMap("glsl_program");
+ GLuint id = mapper.get(atom_getfloat(ap));
+ */
+
+ /* multi-context:
mapper=GLuintMap("glsl_program");
+ float progF=0;
+ switchContext(A);
prog=glCreateProgram();
- progMapped=mapper.set(prog);
- // for multi-context, you probably want to have a single float map to multiple
- // programIDs; you add (or update) an existing mapping with:
- // progMapped=mapper.set(prog, progMapped));
- outlet_float(m_out, mapper.get(progMapped));
+ progF=mapper.set(prog, progF);
+ print(prog,progF); // "3" "3.1415"
+ switchContext(B);
+ prog=glCreateProgram();
+ progF=mapper.set(prog, progF);
+ print(prog,progF); // "6" "3.1415"
- // ... somewhere else
+ // ...somewhere else
mapper=GLuintMap("glsl_program");
- GLuint id = mapper.get(atom_getfloat(ap));
- */
-
- /* multi-context:
- mapper=GLuintMap("glsl_program");
- float progF=0;
- switchContext(A);
- prog=glCreateProgram();
- progF=mapper.set(prog, progF);
- print(prog,progF); // "3" "3.1415"
- switchContext(B);
- prog=glCreateProgram();
- progF=mapper.set(prog, progF);
- print(prog,progF); // "6" "3.1415"
-
- // ...somewhere else
- mapper=GLuintMap("glsl_program");
- prog=mapper.get(progF);
- print(prog,progF); // "3" "3.1415"
- switchContext(B);
- prog=mapper.get(progF);
- print(prog,progF); // "6" "3.1415"
- */
- private:
- struct PIMPL;
- PIMPL*m_pimpl;
- GLuintMap();
- GLuintMap&operator=(const GLuintMap&);
- };
-};};}; /* namespace */
+ prog=mapper.get(progF);
+ print(prog,progF); // "3" "3.1415"
+ switchContext(B);
+ prog=mapper.get(progF);
+ print(prog,progF); // "6" "3.1415"
+ */
+private:
+ struct PIMPL;
+ PIMPL*m_pimpl;
+ GLuintMap();
+ GLuintMap&operator=(const GLuintMap&);
+};
+};
+};
+}; /* namespace */
#endif // for header file
-
diff --git a/Gem/develop/include/Gem/Utils/GemMath.h b/Gem/develop/include/Gem/Utils/GemMath.h
index 769edec..595c1d6 100644
--- a/Gem/develop/include/Gem/Utils/GemMath.h
+++ b/Gem/develop/include/Gem/Utils/GemMath.h
@@ -2,7 +2,7 @@
LOG
GEM - Graphics Environment for Multimedia
- Matrix class
+ Matrix class
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
@@ -63,14 +63,14 @@ LOG
inline double fast_sqrt(double x)
{
- register double est = __frsqrte(x);
- return x * 0.5 * est * __fnmsub(est * est, x, 3.0);
+ register double est = __frsqrte(x);
+ return x * 0.5 * est * __fnmsub(est * est, x, 3.0);
}
inline float fast_sqrtf(float x)
{
- register float est = (float)__frsqrte(x);
- return x * 0.5f * est * __fnmsubs(est * est, x, 3.0f);
+ register float est = (float)__frsqrte(x);
+ return x * 0.5f * est * __fnmsubs(est * est, x, 3.0f);
}
#endif /* __ppc__ */
@@ -82,4 +82,4 @@ inline float fast_sqrtf(float x)
#endif /* _WIN32 */
-#endif // for header file
+#endif // for header file
diff --git a/Gem/develop/include/Gem/Utils/GemString.h b/Gem/develop/include/Gem/Utils/GemString.h
index d767bf0..6e6c7de 100644
--- a/Gem/develop/include/Gem/Utils/GemString.h
+++ b/Gem/develop/include/Gem/Utils/GemString.h
@@ -2,7 +2,7 @@
LOG
GEM - Graphics Environment for Multimedia
- - bidirectional text support
+ - bidirectional text support
Copyright (c) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
@@ -19,18 +19,20 @@ LOG
#include "Gem/ExportDef.h"
class CPPExtern;
-namespace gem {
+namespace gem
+{
- namespace string {
+namespace string
+{
- /* convert a string to it's visual representation (UTF-8) */
- GEM_EXTERN std::wstring getVisualLine(const std::string&);
- GEM_EXTERN std::wstring getVisualLine(const std::wstring&);
+/* convert a string to it's visual representation (UTF-8) */
+GEM_EXTERN std::wstring getVisualLine(const std::string&);
+GEM_EXTERN std::wstring getVisualLine(const std::wstring&);
- /* convert a UTF-8 string to wchar */
- // throws 'int', holding the position of the char that couldn't be converted
- GEM_EXTERN std::wstring toWstring(const char*str);
- };
+/* convert a UTF-8 string to wchar */
+// throws 'int', holding the position of the char that couldn't be converted
+GEM_EXTERN std::wstring toWstring(const char*str);
+};
};
#endif /* _INCLUDE__GEM_GEM_BIDI_H_ */
diff --git a/Gem/develop/include/Gem/Utils/Matrix.h b/Gem/develop/include/Gem/Utils/Matrix.h
index 0137f89..4bc5c39 100644
--- a/Gem/develop/include/Gem/Utils/Matrix.h
+++ b/Gem/develop/include/Gem/Utils/Matrix.h
@@ -2,7 +2,7 @@
LOG
GEM - Graphics Environment for Multimedia
- Matrix class
+ Matrix class
Copyright (c) 1997-1999 Mark Danks. mark@danks.org
Copyright (c) Günther Geiger. geiger@epy.co.at
@@ -26,53 +26,53 @@ CLASS
DESCRIPTION
- Post-concatenation
- Column-major
+ Post-concatenation
+ Column-major
-----------------------------------------------------------------*/
class GEM_EXTERN Matrix
{
- public:
+public:
- //////////
- // Constructor
- // Sets the matrix to identity
- Matrix(void);
+ //////////
+ // Constructor
+ // Sets the matrix to identity
+ Matrix(void);
- //////////
- // Set the matrix to the identity
- void identity(void);
+ //////////
+ // Set the matrix to the identity
+ void identity(void);
- //////////
- // Post mulitply the matrix
- void multiply(Matrix *pMatrix);
+ //////////
+ // Post mulitply the matrix
+ void multiply(Matrix *pMatrix);
- //////////
- void scale(float x, float y, float z);
+ //////////
+ void scale(float x, float y, float z);
- //////////
- void translate(float x, float y, float z);
+ //////////
+ void translate(float x, float y, float z);
- //////////
- void rotateX(float degrees);
+ //////////
+ void rotateX(float degrees);
- //////////
- void rotateY(float degrees);
+ //////////
+ void rotateY(float degrees);
- //////////
- void rotateZ(float degrees);
+ //////////
+ void rotateZ(float degrees);
- //////////
- void transform(float srcX, float srcY, float srcZ, float *dstX, float *dstY, float *dstZ) const;
+ //////////
+ void transform(float srcX, float srcY, float srcZ, float *dstX, float *dstY, float *dstZ) const;
- //////////
- // The actual matrix values
- float mat[4][4];
+ //////////
+ // The actual matrix values
+ float mat[4][4];
- //////////
- // Utility functions
- static void generateNormal(const float *v1, const float *v2, const float *v3, float *dst);
+ //////////
+ // Utility functions
+ static void generateNormal(const float *v1, const float *v2, const float *v3, float *dst);
};
-#endif // for header file
+#endif // for header file
diff --git a/Gem/develop/include/Gem/Utils/PixPete.h b/Gem/develop/include/Gem/Utils/PixPete.h
index cc8005a..c0d141a 100644
--- a/Gem/develop/include/Gem/Utils/PixPete.h
+++ b/Gem/develop/include/Gem/Utils/PixPete.h
@@ -35,10 +35,10 @@ typedef unsigned char U8;
*/
#ifdef __APPLE__
-# define SHIFT_ALPHA (24)
-# define SHIFT_RED (16)
-# define SHIFT_GREEN (8)
-# define SHIFT_BLUE (0)
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
# define SHIFT_U (24)
# define SHIFT_Y1 (16)
@@ -47,10 +47,10 @@ typedef unsigned char U8;
#else
-# define SHIFT_ALPHA (24)
-# define SHIFT_RED (16)
-# define SHIFT_GREEN (8)
-# define SHIFT_BLUE (0)
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
# define SHIFT_U (0)
# define SHIFT_Y1 (8)
@@ -62,165 +62,178 @@ const float Pete_Pi=3.141582f;
const float Pete_TwoPi=(2.0f*Pete_Pi);
const float Pete_HalfPi=(0.5f*Pete_Pi);
-static inline void Pete_ZeroMemory(void* pMemory,int nCount) {
- char* pCurrent=(char*)pMemory;
- char* pEnd=(pCurrent+nCount);
- // while (pCurrent<pEnd) *pCurrent=0;
- // pCurrent+=1;
- // }
- while(pCurrent<pEnd)*pCurrent++=0;
-// memset(pMemory,0,nCount);
+static inline void Pete_ZeroMemory(void* pMemory,int nCount)
+{
+ char* pCurrent=(char*)pMemory;
+ char* pEnd=(pCurrent+nCount);
+ // while (pCurrent<pEnd) *pCurrent=0;
+ // pCurrent+=1;
+ // }
+ while(pCurrent<pEnd) {
+ *pCurrent++=0;
+ }
+// memset(pMemory,0,nCount);
}
-typedef U32 PETE_PIXELDATA32;
+typedef U32 PETE_PIXELDATA32;
#define SIZEOF_PETE_PIXELDATA32 (4)
-typedef U32 PETE_PIXELDATA24;
+typedef U32 PETE_PIXELDATA24;
#define SIZEOF_PETE_PIXELDATA24 (3)
-typedef U16 PETE_PIXELDATA16;
+typedef U16 PETE_PIXELDATA16;
#define SIZEOF_PETE_PIXELDATA16 (2)
-static inline void Pete_CopyAndConvert24BitTo32Bit(PETE_PIXELDATA24* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+static inline void Pete_CopyAndConvert24BitTo32Bit(PETE_PIXELDATA24* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount)
+{
- char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA24);
- char* pCurrentSource=((char*)pSource);
- char* pCurrentOutput=((char*)pOutput);
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA24);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
- while (pCurrentSource<pSourceEnd) {
- *((PETE_PIXELDATA32*)pCurrentOutput)=
- *((PETE_PIXELDATA24*)pCurrentSource);
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA32*)pCurrentOutput)=
+ *((PETE_PIXELDATA24*)pCurrentSource);
- pCurrentSource+=SIZEOF_PETE_PIXELDATA24;
- pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
- }
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA24;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+ }
}
-static inline void Pete_CopyAndConvert32BitTo24Bit(PETE_PIXELDATA32* pSource,PETE_PIXELDATA24* pOutput,int nPixelCount) {
+static inline void Pete_CopyAndConvert32BitTo24Bit(PETE_PIXELDATA32* pSource,PETE_PIXELDATA24* pOutput,int nPixelCount)
+{
- char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
- char* pCurrentSource=((char*)pSource);
- char* pCurrentOutput=((char*)pOutput);
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
- while (pCurrentSource<pSourceEnd) {
- *((PETE_PIXELDATA24*)pCurrentOutput)=
- *((PETE_PIXELDATA32*)pCurrentSource);
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA24*)pCurrentOutput)=
+ *((PETE_PIXELDATA32*)pCurrentSource);
- pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
- pCurrentOutput+=SIZEOF_PETE_PIXELDATA24;
- }
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA24;
+ }
}
-static inline void Pete_InPlaceConvert24BitTo32Bit(PETE_PIXELDATA24* pBuffer,int nPixelCount) {
- char* pBufferStart=(char*)pBuffer;
+static inline void Pete_InPlaceConvert24BitTo32Bit(PETE_PIXELDATA24* pBuffer,int nPixelCount)
+{
+ char* pBufferStart=(char*)pBuffer;
- char* pBuffer32Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA32));
- char* pBuffer24Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA24));
+ char* pBuffer32Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA32));
+ char* pBuffer24Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA24));
- while (pBuffer32Current>=pBufferStart) {
+ while (pBuffer32Current>=pBufferStart) {
- *((PETE_PIXELDATA32*)pBuffer32Current)=
- *((PETE_PIXELDATA24*)pBuffer24Current);
+ *((PETE_PIXELDATA32*)pBuffer32Current)=
+ *((PETE_PIXELDATA24*)pBuffer24Current);
- pBuffer32Current-=SIZEOF_PETE_PIXELDATA32;
- pBuffer24Current-=SIZEOF_PETE_PIXELDATA24;
- }
+ pBuffer32Current-=SIZEOF_PETE_PIXELDATA32;
+ pBuffer24Current-=SIZEOF_PETE_PIXELDATA24;
+ }
}
-static inline void Pete_CopyAndConvert16Bit565To32Bit(PETE_PIXELDATA16* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+static inline void Pete_CopyAndConvert16Bit565To32Bit(PETE_PIXELDATA16* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount)
+{
- char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA16);
- char* pCurrentSource=((char*)pSource);
- char* pCurrentOutput=((char*)pOutput);
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA16);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
- while (pCurrentSource<pSourceEnd) {
+ while (pCurrentSource<pSourceEnd) {
- PETE_PIXELDATA16 SourceColour=
- *((PETE_PIXELDATA16*)pCurrentSource);
+ PETE_PIXELDATA16 SourceColour=
+ *((PETE_PIXELDATA16*)pCurrentSource);
- const int nMaskedRed=(SourceColour>>11)&31;
- const int nMaskedGreen=(SourceColour>>5)&63;
- const int nMaskedBlue=(SourceColour>>0)&31;
+ const int nMaskedRed=(SourceColour>>11)&31;
+ const int nMaskedGreen=(SourceColour>>5)&63;
+ const int nMaskedBlue=(SourceColour>>0)&31;
- const int nNormalizedRed=(nMaskedRed<<3)|(nMaskedRed>>2);
- const int nNormalizedGreen=(nMaskedGreen<<2)|(nMaskedGreen>>4);
- const int nNormalizedBlue=(nMaskedBlue<<3)|(nMaskedBlue>>2);
+ const int nNormalizedRed=(nMaskedRed<<3)|(nMaskedRed>>2);
+ const int nNormalizedGreen=(nMaskedGreen<<2)|(nMaskedGreen>>4);
+ const int nNormalizedBlue=(nMaskedBlue<<3)|(nMaskedBlue>>2);
- const PETE_PIXELDATA32 OutputColour=
- (nNormalizedRed<<16)|
- (nNormalizedGreen<<8)|
- (nNormalizedBlue<<0);
+ const PETE_PIXELDATA32 OutputColour=
+ (nNormalizedRed<<16)|
+ (nNormalizedGreen<<8)|
+ (nNormalizedBlue<<0);
- *((PETE_PIXELDATA32*)pCurrentOutput)=OutputColour;
+ *((PETE_PIXELDATA32*)pCurrentOutput)=OutputColour;
- pCurrentSource+=SIZEOF_PETE_PIXELDATA16;
- pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA16;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
- }
+ }
}
-static inline void Pete_CopyAndConvert32BitTo16Bit565(PETE_PIXELDATA32* pSource,PETE_PIXELDATA16* pOutput,int nPixelCount) {
+static inline void Pete_CopyAndConvert32BitTo16Bit565(PETE_PIXELDATA32* pSource,PETE_PIXELDATA16* pOutput,int nPixelCount)
+{
- char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
- char* pCurrentSource=((char*)pSource);
- char* pCurrentOutput=((char*)pOutput);
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
- while (pCurrentSource<pSourceEnd) {
+ while (pCurrentSource<pSourceEnd) {
- PETE_PIXELDATA32 SourceColour=
- *((PETE_PIXELDATA32*)pCurrentSource);
+ PETE_PIXELDATA32 SourceColour=
+ *((PETE_PIXELDATA32*)pCurrentSource);
- const int nSourceRed=(SourceColour>>16)&0xff;
- const int nSourceGreen=(SourceColour>>8)&0xff;
- const int nSourceBlue=(SourceColour>>0)&0xff;
+ const int nSourceRed=(SourceColour>>16)&0xff;
+ const int nSourceGreen=(SourceColour>>8)&0xff;
+ const int nSourceBlue=(SourceColour>>0)&0xff;
- const int nMaskedRed=(nSourceRed>>3);
- const int nMaskedGreen=(nSourceGreen>>2);
- const int nMaskedBlue=(nSourceBlue>>3);
+ const int nMaskedRed=(nSourceRed>>3);
+ const int nMaskedGreen=(nSourceGreen>>2);
+ const int nMaskedBlue=(nSourceBlue>>3);
- PETE_PIXELDATA16 OutputColour=
- (nMaskedRed<<11)|
- (nMaskedGreen<<5)|
- (nMaskedBlue<<0);
+ PETE_PIXELDATA16 OutputColour=
+ (nMaskedRed<<11)|
+ (nMaskedGreen<<5)|
+ (nMaskedBlue<<0);
- *((PETE_PIXELDATA16*)pCurrentOutput)=OutputColour;
+ *((PETE_PIXELDATA16*)pCurrentOutput)=OutputColour;
- pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
- pCurrentOutput+=SIZEOF_PETE_PIXELDATA16;
- }
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA16;
+ }
}
typedef void* SPete_MemHandle;
-inline SPete_MemHandle Pete_NewHandle(int nBytesToAlloc) {
- return malloc(nBytesToAlloc);
+inline SPete_MemHandle Pete_NewHandle(int nBytesToAlloc)
+{
+ return malloc(nBytesToAlloc);
}
-inline void Pete_FreeHandle(SPete_MemHandle InHandle) {
- free(InHandle);
+inline void Pete_FreeHandle(SPete_MemHandle InHandle)
+{
+ free(InHandle);
}
-inline void* Pete_LockHandle(SPete_MemHandle InHandle) {
- return InHandle;
+inline void* Pete_LockHandle(SPete_MemHandle InHandle)
+{
+ return InHandle;
}
-inline void Pete_UnLockHandle(SPete_MemHandle InHandle) {
- // do nothing
+inline void Pete_UnLockHandle(SPete_MemHandle InHandle)
+{
+ // do nothing
}
const int cnBiggestSignedInt=0x7fffffff;
-inline int GetLuminance(const U32 inColour) {
- const int nRed=(inColour&(0xff<<SHIFT_RED))>>16;
- const int nGreen=(inColour&(0xff<<SHIFT_GREEN))>>8;
- const int nBlue=(inColour&(0xff<<SHIFT_BLUE))>>0;
+inline int GetLuminance(const U32 inColour)
+{
+ const int nRed=(inColour&(0xff<<SHIFT_RED))>>16;
+ const int nGreen=(inColour&(0xff<<SHIFT_GREEN))>>8;
+ const int nBlue=(inColour&(0xff<<SHIFT_BLUE))>>0;
- const int nLuminance =
- ((77 * nRed)+
- (150* nGreen)+ // used to be 50 which is plain wrong
- (29 * nBlue));
+ const int nLuminance =
+ ((77 * nRed)+
+ (150* nGreen)+ // used to be 50 which is plain wrong
+ (29 * nBlue));
- return nLuminance;
+ return nLuminance;
}
#endif /* _INCLUDE__GEM_UTILS_PIXPETE_H_ */
diff --git a/Gem/develop/include/Gem/Utils/SIMD.h b/Gem/develop/include/Gem/Utils/SIMD.h
index 02db219..335927c 100644
--- a/Gem/develop/include/Gem/Utils/SIMD.h
+++ b/Gem/develop/include/Gem/Utils/SIMD.h
@@ -46,13 +46,13 @@ const int GEM_SIMD_ALTIVEC=3;
#ifdef __SSE2__
# include <emmintrin.h>
// for icc this should be <dvec.h>
-typedef union{
+typedef union {
unsigned char c[16];
__m128i v;
} vector_128;
#elif defined __VEC__
/* for AltiVec (PowerPC) */
-typedef union{
+typedef union {
unsigned char c[16];
vector unsigned char v;
} vector_128;
@@ -61,8 +61,9 @@ typedef union{
#if defined __MMX__
# include <mmintrin.h>
// for icc this should be <ivec.h>
-typedef union{
- __m64 v; unsigned char c[8];
+typedef union {
+ __m64 v;
+ unsigned char c[8];
} vector64i;
#endif
@@ -71,8 +72,9 @@ typedef union{
#ifdef __SSE__
#include <xmmintrin.h>
-typedef union{
- __m128 m; float f[4];
+typedef union {
+ __m128 m;
+ float f[4];
} vector128f;
#endif
@@ -89,8 +91,8 @@ typedef union{
*/
class GEM_EXTERN GemSIMD
{
- public:
- GemSIMD(void);
+public:
+ GemSIMD(void);
virtual ~GemSIMD(void);
/* this gets the "cpuid" (something like GEM_SIMD_NONE) */
@@ -108,7 +110,7 @@ class GEM_EXTERN GemSIMD
*/
static int simd_runtime_check(void);
- private:
+private:
/* this is the maximum capability of the CPU */
static int realcpuid;
/* this is the current chosen capability (normally this equals realcpuid) */
diff --git a/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h b/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h
index 6f5135e..7c5fe0e 100644
--- a/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h
+++ b/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h
@@ -17,49 +17,55 @@ LOG
#include "Utils/WorkerThread.h"
-namespace gem { namespace thread {
- class GEM_EXTERN SynchedWorkerThread : public WorkerThread {
- private:
- class PIMPL;
- PIMPL*m_pimpl;
- friend class PIMPL;
- /* dummy implementations */
- SynchedWorkerThread(const SynchedWorkerThread&);
- SynchedWorkerThread&operator=(const SynchedWorkerThread&);
+namespace gem
+{
+namespace thread
+{
+class GEM_EXTERN SynchedWorkerThread : public WorkerThread
+{
+private:
+ class PIMPL;
+ PIMPL*m_pimpl;
+ friend class PIMPL;
+ /* dummy implementations */
+ SynchedWorkerThread(const SynchedWorkerThread&);
+ SynchedWorkerThread&operator=(const SynchedWorkerThread&);
- public:
- SynchedWorkerThread(bool autostart=true);
- virtual ~SynchedWorkerThread(void);
+public:
+ SynchedWorkerThread(bool autostart=true);
+ virtual ~SynchedWorkerThread(void);
- /*
- * turn on "polling" mode
- * when in polling mode, the calling thread has to call 'dequeue()' in order to
- * deqeue any DONE data
- * when in pushing mode, the data is pushed automatically within the RTE main thread
- *
- * returns TRUE is now in polling mode, or FALSE if now in pushing mode
- * (might be different from what was requested)
- *
- * this MUST be called from the main thread
- */
- virtual bool setPolling(bool value=true);
+ /*
+ * turn on "polling" mode
+ * when in polling mode, the calling thread has to call 'dequeue()' in order to
+ * deqeue any DONE data
+ * when in pushing mode, the data is pushed automatically within the RTE main thread
+ *
+ * returns TRUE is now in polling mode, or FALSE if now in pushing mode
+ * (might be different from what was requested)
+ *
+ * this MUST be called from the main thread
+ */
+ virtual bool setPolling(bool value=true);
- /**
- * deqeues the entire DONE queue
- * returns the number of elements dequeued
- */
- virtual unsigned int dequeue(void);
+ /**
+ * deqeues the entire DONE queue
+ * returns the number of elements dequeued
+ */
+ virtual unsigned int dequeue(void);
- protected:
- // this get's called from the main thread(!) with each
- // finished data chunk
- virtual void done(id_t ID, void*data) = 0;
+protected:
+ // this get's called from the main thread(!) with each
+ // finished data chunk
+ virtual void done(id_t ID, void*data) = 0;
- //////
- // tell RTE to call back asap
- virtual void signal(void);
+ //////
+ // tell RTE to call back asap
+ virtual void signal(void);
- };};};
+};
+};
+};
#endif /* _INCLUDE__GEM_GEM_SYNCHEDWORKERTHREAD_H_ */
diff --git a/Gem/develop/include/Gem/Utils/Thread.h b/Gem/develop/include/Gem/Utils/Thread.h
index ca861cc..3daa020 100644
--- a/Gem/develop/include/Gem/Utils/Thread.h
+++ b/Gem/develop/include/Gem/Utils/Thread.h
@@ -17,48 +17,53 @@ LOG
#include "Gem/ExportDef.h"
-namespace gem { namespace thread {
- /**
- * get the number of available CPUs on the system
- */
- GEM_EXTERN unsigned int getCPUCount(void);
-
- class GEM_EXTERN Thread {
- private:
- class PIMPL;
- PIMPL*m_pimpl;
- friend class PIMPL;
-
- Thread(const Thread&);
- Thread&operator=(const Thread&);
- public:
- Thread(void);
- virtual ~Thread(void);
-
- ////
- // start thread
- virtual bool start(void);
- ////
- // stop thread
- // waits for at most wait4usec microseconds
- // is wait4usec==0, waits until process terminates (e.g. forever)
- virtual bool stop(unsigned int wait4usec=0);
-
- protected:
- ////
- // the worker!
- // get's called from an alternative thread
- // if TRUE is returned, process() will be called again
- // until stop() is called
- // if FALSE is returned, the thread may exit
- virtual bool process(void) = 0;
- };
-
-
- ////////
- // wrapper around select() or whatever
- GEM_EXTERN void usleep(unsigned long usec);
-};}; // namespace
+namespace gem
+{
+namespace thread
+{
+/**
+ * get the number of available CPUs on the system
+ */
+GEM_EXTERN unsigned int getCPUCount(void);
+
+class GEM_EXTERN Thread
+{
+private:
+ class PIMPL;
+ PIMPL*m_pimpl;
+ friend class PIMPL;
+
+ Thread(const Thread&);
+ Thread&operator=(const Thread&);
+public:
+ Thread(void);
+ virtual ~Thread(void);
+
+ ////
+ // start thread
+ virtual bool start(void);
+ ////
+ // stop thread
+ // waits for at most wait4usec microseconds
+ // is wait4usec==0, waits until process terminates (e.g. forever)
+ virtual bool stop(unsigned int wait4usec=0);
+
+protected:
+ ////
+ // the worker!
+ // get's called from an alternative thread
+ // if TRUE is returned, process() will be called again
+ // until stop() is called
+ // if FALSE is returned, the thread may exit
+ virtual bool process(void) = 0;
+};
+
+
+////////
+// wrapper around select() or whatever
+GEM_EXTERN void usleep(unsigned long usec);
+};
+}; // namespace
diff --git a/Gem/develop/include/Gem/Utils/ThreadMutex.h b/Gem/develop/include/Gem/Utils/ThreadMutex.h
index c2851b5..208bcbf 100644
--- a/Gem/develop/include/Gem/Utils/ThreadMutex.h
+++ b/Gem/develop/include/Gem/Utils/ThreadMutex.h
@@ -2,7 +2,7 @@
LOG
GEM - Graphics Environment for Multimedia
- - locks a thread (wrapper around pthread_mutex)
+ - locks a thread (wrapper around pthread_mutex)
Copyright (c) 2011-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
@@ -16,23 +16,26 @@ LOG
#include "Gem/ExportDef.h"
-namespace gem {
- namespace thread {
- class GEM_EXTERN Mutex {
- private:
- class PIMPL;
- PIMPL*m_pimpl;
- public:
- Mutex(void);
- virtual ~Mutex(void);
-
- Mutex(const Mutex&);
- Mutex&operator=(const Mutex&);
-
- void lock (void);
- void unlock (void);
- bool trylock(void);
- };
- };
+namespace gem
+{
+namespace thread
+{
+class GEM_EXTERN Mutex
+{
+private:
+ class PIMPL;
+ PIMPL*m_pimpl;
+public:
+ Mutex(void);
+ virtual ~Mutex(void);
+
+ Mutex(const Mutex&);
+ Mutex&operator=(const Mutex&);
+
+ void lock (void);
+ void unlock (void);
+ bool trylock(void);
+};
+};
};
#endif /* _INCLUDE__GEM_GEM_THREADMUTEX_H_ */
diff --git a/Gem/develop/include/Gem/Utils/ThreadSemaphore.h b/Gem/develop/include/Gem/Utils/ThreadSemaphore.h
index 3a57a4c..4698fca 100644
--- a/Gem/develop/include/Gem/Utils/ThreadSemaphore.h
+++ b/Gem/develop/include/Gem/Utils/ThreadSemaphore.h
@@ -2,7 +2,7 @@
LOG
GEM - Graphics Environment for Multimedia
- - locks a thread (wrapper around pthread's cond_t)
+ - locks a thread (wrapper around pthread's cond_t)
Copyright (c) 2011-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
For information on usage and redistribution, and for a DISCLAIMER OF ALL
@@ -16,24 +16,27 @@ LOG
#include "Gem/ExportDef.h"
-namespace gem {
- namespace thread {
- class GEM_EXTERN Semaphore {
- private:
- class PIMPL;
- PIMPL*m_pimpl;
- public:
- Semaphore(void);
- virtual ~Semaphore(void);
- Semaphore(const Semaphore&);
-
- /** block the current thread until the Semaphore is thaw()ed again */
- void freeze (void);
- /** unblock any waiting threads */
- void thaw (void);
-
- virtual Semaphore&operator=(const Semaphore&);
- };
- };
+namespace gem
+{
+namespace thread
+{
+class GEM_EXTERN Semaphore
+{
+private:
+ class PIMPL;
+ PIMPL*m_pimpl;
+public:
+ Semaphore(void);
+ virtual ~Semaphore(void);
+ Semaphore(const Semaphore&);
+
+ /** block the current thread until the Semaphore is thaw()ed again */
+ void freeze (void);
+ /** unblock any waiting threads */
+ void thaw (void);
+
+ virtual Semaphore&operator=(const Semaphore&);
+};
+};
};
#endif /* _INCLUDE__GEM_GEM_THREADSEMAPHORE_H_ */
diff --git a/Gem/develop/include/Gem/Utils/Vector.h b/Gem/develop/include/Gem/Utils/Vector.h
index e427f04..0937048 100644
--- a/Gem/develop/include/Gem/Utils/Vector.h
+++ b/Gem/develop/include/Gem/Utils/Vector.h
@@ -19,14 +19,16 @@ LOG
// This is our 2D point class. This will be used to store the UV coordinates.
-class GEM_EXTERN CVector2 {
+class GEM_EXTERN CVector2
+{
public:
- float x, y;
+ float x, y;
};
// This is our basic 3D point/vector class
-class GEM_EXTERN CVector3 {
+class GEM_EXTERN CVector3
+{
public:
// the elements of a vector:
float x, y, z;
@@ -34,42 +36,42 @@ public:
// A default constructor
CVector3(void);
- // This is our constructor that allows us to initialize our data upon creating an instance
- CVector3(float X, float Y, float Z);
+ // This is our constructor that allows us to initialize our data upon creating an instance
+ CVector3(float X, float Y, float Z);
- // Here we overload the + operator so we can add vectors together
- CVector3 operator+(CVector3 vVector) const;
+ // Here we overload the + operator so we can add vectors together
+ CVector3 operator+(CVector3 vVector) const;
- // Here we overload the - operator so we can subtract vectors
- CVector3 operator-(CVector3 vVector) const;
+ // Here we overload the - operator so we can subtract vectors
+ CVector3 operator-(CVector3 vVector) const;
- // Here we overload the - operator so we can negate the vector
- CVector3 operator-(void) const;
+ // Here we overload the - operator so we can negate the vector
+ CVector3 operator-(void) const;
- // Here we overload the * operator so we can multiply by scalars
- CVector3 operator*(float num) const;
+ // Here we overload the * operator so we can multiply by scalars
+ CVector3 operator*(float num) const;
- // Here we overload the * operator so we can dot-multiply
- float operator*(CVector3 vVector) const;
+ // Here we overload the * operator so we can dot-multiply
+ float operator*(CVector3 vVector) const;
- // cross-multiplication
- CVector3 cross(CVector3 vVector) const;
+ // cross-multiplication
+ CVector3 cross(CVector3 vVector) const;
- // Here we overload the / operator so we can divide by a scalar
- CVector3 operator/(float num) const;
+ // Here we overload the / operator so we can divide by a scalar
+ CVector3 operator/(float num) const;
- // here we calculate the absolute-value of the vector
- float abs(void) const;
+ // here we calculate the absolute-value of the vector
+ float abs(void) const;
- // here we calculate the square of the absolute-value of the vector
- float abs2(void) const;
+ // here we calculate the square of the absolute-value of the vector
+ float abs2(void) const;
- // here we normalize the vector
- CVector3 normalize(void) const;
+ // here we normalize the vector
+ CVector3 normalize(void) const;
- // here we compare 2 vectors on approx. equality
- bool equals(CVector3 vVector, float epsilon) const;
+ // here we compare 2 vectors on approx. equality
+ bool equals(CVector3 vVector, float epsilon) const;
};
diff --git a/Gem/develop/include/Gem/Utils/WorkerThread.h b/Gem/develop/include/Gem/Utils/WorkerThread.h
index 36d4a4d..69f5066 100644
--- a/Gem/develop/include/Gem/Utils/WorkerThread.h
+++ b/Gem/develop/include/Gem/Utils/WorkerThread.h
@@ -17,65 +17,71 @@ LOG
#include "Gem/ExportDef.h"
-namespace gem { namespace thread {
- class GEM_EXTERN WorkerThread {
- private:
- class PIMPL;
- PIMPL*m_pimpl;
- friend class PIMPL;
- /* dummy implementations */
- WorkerThread(const WorkerThread&);
- WorkerThread&operator=(const WorkerThread&);
- public:
- WorkerThread(void);
- virtual ~WorkerThread(void);
-
- ////
- // start/stop thread(s)
- virtual bool start(void);
- virtual bool stop(bool wait=true);
-
- typedef unsigned int id_t;
- static const id_t INVALID;
- static const id_t IMMEDIATE;
-
- // queue a 'data' chunk onto the TODO queue
- // the returned 'ID' can be used to interact with the queues
- // if queuing failed, FALSE is returned and ID is set to INVALID
- virtual bool queue(id_t&ID, void*data);
-
- //////
- // cancel a datachunk from the TODO-queue
- // if the chunk was successfully removed, returns TRUE
- // (FALSE is returned, if e.g. the given datachunk was not found in the queue)
- // note that items already processed cannot be cancelled anymore
- virtual bool cancel(const id_t ID);
-
- // dequeue the next datachunk from the DONE queue
- // if the queue is empty, FALSE is returned and ID is set to INVALID
- virtual bool dequeue(id_t&ID, void*&data);
-
- protected:
-
- ////
- // the worker!
- // get's called from an alternative thread(s)
- // when the queue is non-empty,
- // the first element is removed from the TODO queue,
- // and this function is called with the 1st element as data
- // the result returned is added to the done queue (alongside the ID)
- virtual void* process(id_t ID, void*data) = 0;
-
- ////
- // this get's called to indicate that new data is in the DONE queue
- // you can use it to set a semaphore in the main thread, to fetch
- // the data
- // it get's called once after process() has been successful
- // and will not be called before dequeue has been called at least once
- //
- virtual void signal(void);
-
- };};};
+namespace gem
+{
+namespace thread
+{
+class GEM_EXTERN WorkerThread
+{
+private:
+ class PIMPL;
+ PIMPL*m_pimpl;
+ friend class PIMPL;
+ /* dummy implementations */
+ WorkerThread(const WorkerThread&);
+ WorkerThread&operator=(const WorkerThread&);
+public:
+ WorkerThread(void);
+ virtual ~WorkerThread(void);
+
+ ////
+ // start/stop thread(s)
+ virtual bool start(void);
+ virtual bool stop(bool wait=true);
+
+ typedef unsigned int id_t;
+ static const id_t INVALID;
+ static const id_t IMMEDIATE;
+
+ // queue a 'data' chunk onto the TODO queue
+ // the returned 'ID' can be used to interact with the queues
+ // if queuing failed, FALSE is returned and ID is set to INVALID
+ virtual bool queue(id_t&ID, void*data);
+
+ //////
+ // cancel a datachunk from the TODO-queue
+ // if the chunk was successfully removed, returns TRUE
+ // (FALSE is returned, if e.g. the given datachunk was not found in the queue)
+ // note that items already processed cannot be cancelled anymore
+ virtual bool cancel(const id_t ID);
+
+ // dequeue the next datachunk from the DONE queue
+ // if the queue is empty, FALSE is returned and ID is set to INVALID
+ virtual bool dequeue(id_t&ID, void*&data);
+
+protected:
+
+ ////
+ // the worker!
+ // get's called from an alternative thread(s)
+ // when the queue is non-empty,
+ // the first element is removed from the TODO queue,
+ // and this function is called with the 1st element as data
+ // the result returned is added to the done queue (alongside the ID)
+ virtual void* process(id_t ID, void*data) = 0;
+
+ ////
+ // this get's called to indicate that new data is in the DONE queue
+ // you can use it to set a semaphore in the main thread, to fetch
+ // the data
+ // it get's called once after process() has been successful
+ // and will not be called before dequeue has been called at least once
+ //
+ virtual void signal(void);
+
+};
+};
+};
#endif /* _INCLUDE__GEM_GEM_WORKERTHREAD_H_ */
diff --git a/Gem/develop/include/Gem/Utils/any.h b/Gem/develop/include/Gem/Utils/any.h
index 331a797..4ce48b0 100644
--- a/Gem/develop/include/Gem/Utils/any.h
+++ b/Gem/develop/include/Gem/Utils/any.h
@@ -30,304 +30,321 @@
namespace gem
{
- struct GEM_EXTERN bad_any_cast : std::bad_cast {
- bad_any_cast(const std::type_info& src, const std::type_info& dest)
- : result(std::string("bad cast (")+src.name() + "->" + dest.name()+")")
- { }
- virtual ~bad_any_cast(void)
+struct GEM_EXTERN bad_any_cast : std::bad_cast {
+ bad_any_cast(const std::type_info& src, const std::type_info& dest)
+ : result(std::string("bad cast (")+src.name() + "->" + dest.name()+")")
+ { }
+ virtual ~bad_any_cast(void)
#if __cplusplus <= 199711L
- throw()
+ throw()
#endif
- { }
- virtual const char* what(void) const
+ { }
+ virtual const char* what(void) const
#if __cplusplus > 199711L
- noexcept
+ noexcept
#else
- throw()
+ throw()
#endif
- {
- return result.c_str();
- }
- const std::string result;
- };
+ {
+ return result.c_str();
+ }
+ const std::string result;
+};
- namespace any_detail {
- // function pointer table
+namespace any_detail
+{
+// function pointer table
- struct fxn_ptr_table {
- const std::type_info& (*get_type)(void);
- void (*static_delete)(void**);
- void (*clone)(void* const*, void**);
- void (*move)(void* const*,void**);
- };
+struct fxn_ptr_table {
+ const std::type_info& (*get_type)(void);
+ void (*static_delete)(void**);
+ void (*clone)(void* const*, void**);
+ void (*move)(void* const*,void**);
+};
- // static functions for small value-types
+// static functions for small value-types
- template<bool is_small>
- struct fxns
+template<bool is_small>
+struct fxns {
+ template<typename T>
+ struct type {
+ static const std::type_info& get_type(void)
{
- template<typename T>
- struct type {
- static const std::type_info& get_type(void) {
- const std::type_info&res=typeid(T);
- // the following is a dummy use of the type_info struct
- // to make the template engine work properly on OSX/10.9
- static std::string _ = res.name();
- return res;
- }
- static void static_delete(void** x) {
- reinterpret_cast<T*>(x)->~T();
- }
- static void clone(void* const* src, void** dest) {
- new(dest) T(*reinterpret_cast<T const*>(src));
- }
- static void move(void* const* src, void** dest) {
- reinterpret_cast<T*>(dest)->~T();
- *reinterpret_cast<T*>(dest) = *reinterpret_cast<T const*>(src);
- }
- };
- };
+ const std::type_info&res=typeid(T);
+ // the following is a dummy use of the type_info struct
+ // to make the template engine work properly on OSX/10.9
+ static std::string _ = res.name();
+ return res;
+ }
+ static void static_delete(void** x)
+ {
+ reinterpret_cast<T*>(x)->~T();
+ }
+ static void clone(void* const* src, void** dest)
+ {
+ new(dest) T(*reinterpret_cast<T const*>(src));
+ }
+ static void move(void* const* src, void** dest)
+ {
+ reinterpret_cast<T*>(dest)->~T();
+ *reinterpret_cast<T*>(dest) = *reinterpret_cast<T const*>(src);
+ }
+ };
+};
- // static functions for big value-types (bigger than a void*)
+// static functions for big value-types (bigger than a void*)
- template<>
- struct fxns<false>
+template<>
+struct fxns<false> {
+ template<typename T>
+ struct type {
+ static const std::type_info& get_type(void)
{
- template<typename T>
- struct type {
- static const std::type_info& get_type(void) {
- const std::type_info&res=typeid(T);
- return res;
- }
- static void static_delete(void** x) {
- delete(*reinterpret_cast<T**>(x));
- }
- static void clone(void* const* src, void** dest) {
- *dest = new T(**reinterpret_cast<T* const*>(src));
- }
- static void move(void* const* src, void** dest) {
- (*reinterpret_cast<T**>(dest))->~T();
- **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src);
- }
- };
- };
-
- template<typename T>
- struct get_table
+ const std::type_info&res=typeid(T);
+ return res;
+ }
+ static void static_delete(void** x)
{
- static const bool is_small = sizeof(T) <= sizeof(void*);
-
- static fxn_ptr_table* get(void)
- {
- static fxn_ptr_table static_table = {
- fxns<is_small>::template type<T>::get_type
- , fxns<is_small>::template type<T>::static_delete
- , fxns<is_small>::template type<T>::clone
- , fxns<is_small>::template type<T>::move
- };
- return &static_table;
- }
- };
+ delete(*reinterpret_cast<T**>(x));
+ }
+ static void clone(void* const* src, void** dest)
+ {
+ *dest = new T(**reinterpret_cast<T* const*>(src));
+ }
+ static void move(void* const* src, void** dest)
+ {
+ (*reinterpret_cast<T**>(dest))->~T();
+ **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src);
+ }
+ };
+};
+
+template<typename T>
+struct get_table {
+ static const bool is_small = sizeof(T) <= sizeof(void*);
- struct empty {
+ static fxn_ptr_table* get(void)
+ {
+ static fxn_ptr_table static_table = {
+ fxns<is_small>::template type<T>::get_type
+ , fxns<is_small>::template type<T>::static_delete
+ , fxns<is_small>::template type<T>::clone
+ , fxns<is_small>::template type<T>::move
};
- } // namespace any_detail
+ return &static_table;
+ }
+};
+struct empty {
+};
+} // namespace any_detail
- struct GEM_EXTERN any
- {
- // structors
- template <typename T>
- any(const T& x) : table(NULL), object(NULL) {
- table = any_detail::get_table<T>::get();
+struct GEM_EXTERN any {
+ // structors
+
+ template <typename T>
+ any(const T& x) : table(NULL), object(NULL)
+ {
+ table = any_detail::get_table<T>::get();
#if defined(__GNUC__) && __GNUC__ >= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wplacement-new"
#endif
- if (sizeof(T) <= sizeof(void*)) {
- new(&object) T(x);
- }
- else {
- object = new T(x);
- }
+ if (sizeof(T) <= sizeof(void*)) {
+ new(&object) T(x);
+ } else {
+ object = new T(x);
+ }
#if defined(__GNUC__) && __GNUC__ >= 6
# pragma GCC diagnostic pop
#endif
- }
+ }
- any(void) : table(NULL), object(NULL) {
- table = any_detail::get_table<any_detail::empty>::get();
- object = NULL;
- }
+ any(void) : table(NULL), object(NULL)
+ {
+ table = any_detail::get_table<any_detail::empty>::get();
+ object = NULL;
+ }
- any(const any& x) : table(NULL), object(NULL) {
- table = any_detail::get_table<any_detail::empty>::get();
- assign(x);
- }
+ any(const any& x) : table(NULL), object(NULL)
+ {
+ table = any_detail::get_table<any_detail::empty>::get();
+ assign(x);
+ }
- virtual ~any(void) {
- table->static_delete(&object);
- }
+ virtual ~any(void)
+ {
+ table->static_delete(&object);
+ }
- // assignment
+ // assignment
- any& assign(const any& x) {
- // are we copying between the same type?
+ any& assign(const any& x)
+ {
+ // are we copying between the same type?
- if (table == x.table) {
- // if so, we can avoid reallocation
+ if (table == x.table) {
+ // if so, we can avoid reallocation
- table->move(&x.object, &object);
- }
- else {
- reset();
- x.table->clone(&x.object, &object);
- table = x.table;
- }
- return *this;
+ table->move(&x.object, &object);
+ } else {
+ reset();
+ x.table->clone(&x.object, &object);
+ table = x.table;
}
+ return *this;
+ }
- template <typename T>
- any& assign(const T& x)
- {
- // are we copying between the same type?
+ template <typename T>
+ any& assign(const T& x)
+ {
+ // are we copying between the same type?
- any_detail::fxn_ptr_table* x_table = any_detail::get_table<T>::get();
- if (table == x_table) {
- // if so, we can avoid deallocating and resuse memory
+ any_detail::fxn_ptr_table* x_table = any_detail::get_table<T>::get();
+ if (table == x_table) {
+ // if so, we can avoid deallocating and resuse memory
#if defined(__GNUC__) && __GNUC__ >= 6
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wplacement-new"
#endif
- if (sizeof(T) <= sizeof(void*)) {
- // create copy on-top of object pointer itself
- new(&object) T(x);
- }
- else {
- // create copy on-top of old version
- new(object) T(x);
- }
+ if (sizeof(T) <= sizeof(void*)) {
+ // create copy on-top of object pointer itself
+ new(&object) T(x);
+ } else {
+ // create copy on-top of old version
+ new(object) T(x);
+ }
+ } else {
+ reset();
+ if (sizeof(T) <= sizeof(void*)) {
+ // create copy on-top of object pointer itself
+ new(&object) T(x);
+ // update table pointer
+ table = x_table;
+ } else {
+ object = new T(x);
+ table = x_table;
}
- else {
- reset();
- if (sizeof(T) <= sizeof(void*)) {
- // create copy on-top of object pointer itself
- new(&object) T(x);
- // update table pointer
- table = x_table;
- }
- else {
- object = new T(x);
- table = x_table;
- }
#if defined(__GNUC__) && __GNUC__ >= 6
# pragma GCC diagnostic pop
#endif
- }
- return *this;
}
+ return *this;
+ }
- // assignment operator
-
- template<typename T>
- any& operator=(T const& x) {
- return assign(x);
- }
- any& operator=(const any& x) {
- return assign(x);
- }
+ // assignment operator
- // utility functions
+ template<typename T>
+ any& operator=(T const& x)
+ {
+ return assign(x);
+ }
+ any& operator=(const any& x)
+ {
+ return assign(x);
+ }
- any& swap(any& x) {
- std::swap(table, x.table);
- std::swap(object, x.object);
- return *this;
- }
+ // utility functions
- const std::type_info& get_type(void) const {
- return table->get_type();
- }
+ any& swap(any& x)
+ {
+ std::swap(table, x.table);
+ std::swap(object, x.object);
+ return *this;
+ }
- template<typename T>
- const T& cast(void) const {
- if (!compatible<T>()) {
- throw bad_any_cast(get_type(), typeid(T));
- }
- if (sizeof(T) <= sizeof(void*)) {
- return *reinterpret_cast<T const*>(&object);
- }
- else {
- return *reinterpret_cast<T const*>(object);
- }
- }
+ const std::type_info& get_type(void) const
+ {
+ return table->get_type();
+ }
- /// Returns true if the two types are the same.
- bool compatible(const any& x) const {
- return get_type() == x.get_type();
+ template<typename T>
+ const T& cast(void) const
+ {
+ if (!compatible<T>()) {
+ throw bad_any_cast(get_type(), typeid(T));
}
- /// Returns true if the two types are the same.
- template<typename T>
- bool compatible() const {
- return (get_type() == typeid(T));
+ if (sizeof(T) <= sizeof(void*)) {
+ return *reinterpret_cast<T const*>(&object);
+ } else {
+ return *reinterpret_cast<T const*>(object);
}
+ }
+
+ /// Returns true if the two types are the same.
+ bool compatible(const any& x) const
+ {
+ return get_type() == x.get_type();
+ }
+ /// Returns true if the two types are the same.
+ template<typename T>
+ bool compatible() const
+ {
+ return (get_type() == typeid(T));
+ }
// implicit casting is disabled by default
- #ifdef ANY_IMPLICIT_CASTING
- // automatic casting operator
+#ifdef ANY_IMPLICIT_CASTING
+ // automatic casting operator
- template<typename T>
- operator T(void) const {
- return cast<T>();
- }
- #endif // implicit casting
+ template<typename T>
+ operator T(void) const
+ {
+ return cast<T>();
+ }
+#endif // implicit casting
- bool empty(void) const {
- return table == any_detail::get_table<any_detail::empty>::get();
- }
+ bool empty(void) const
+ {
+ return table == any_detail::get_table<any_detail::empty>::get();
+ }
- void reset(void)
- {
- if (empty()) return;
- table->static_delete(&object);
- table = any_detail::get_table<any_detail::empty>::get();
- object = NULL;
+ void reset(void)
+ {
+ if (empty()) {
+ return;
}
+ table->static_delete(&object);
+ table = any_detail::get_table<any_detail::empty>::get();
+ object = NULL;
+ }
- // fields
+ // fields
- any_detail::fxn_ptr_table* table;
- void* object;
- };
+ any_detail::fxn_ptr_table* table;
+ void* object;
+};
- // boost::any-like casting
+// boost::any-like casting
- template<typename T>
- T* any_cast(any* this_) {
- if (this_->get_type() != typeid(T)) {
- throw bad_any_cast(this_->get_type(), typeid(T));
- }
- if (sizeof(T) <= sizeof(void*)) {
- return reinterpret_cast<T*>(&this_->object);
- }
- else {
- return reinterpret_cast<T*>(this_->object);
- }
+template<typename T>
+T* any_cast(any* this_)
+{
+ if (this_->get_type() != typeid(T)) {
+ throw bad_any_cast(this_->get_type(), typeid(T));
}
-
- template<typename T>
- T const* any_cast(any const* this_) {
- return any_cast<T>(const_cast<any*>(this_));
+ if (sizeof(T) <= sizeof(void*)) {
+ return reinterpret_cast<T*>(&this_->object);
+ } else {
+ return reinterpret_cast<T*>(this_->object);
}
+}
- template<typename T>
- T const& any_cast(any const& this_){
- return *any_cast<T>(const_cast<any*>(&this_));
- }
+template<typename T>
+T const* any_cast(any const* this_)
+{
+ return any_cast<T>(const_cast<any*>(this_));
+}
+
+template<typename T>
+T const& any_cast(any const& this_)
+{
+ return *any_cast<T>(const_cast<any*>(&this_));
+}
}
#ifdef _MSC_VER
diff --git a/Gem/develop/include/Gem/Utils/nop.h b/Gem/develop/include/Gem/Utils/nop.h
index 0be005b..8431ef2 100644
--- a/Gem/develop/include/Gem/Utils/nop.h
+++ b/Gem/develop/include/Gem/Utils/nop.h
@@ -26,4 +26,3 @@ static inline void gem__nop_post(const char*fmt, ...) { ; }
#define nop_post gem__nop_post
#endif // for header file
-