diff options
author | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-03-17 22:38:45 +0000 |
---|---|---|
committer | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-03-17 22:38:45 +0000 |
commit | 356f94fc355f36c16e48555d10c2377dff4b7554 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Gem/develop/include/Gem/Utils | |
parent | 5c694f159b012d1d94bf15bfe580dec52e4fe797 (diff) |
Gem 096ed6ef786b7a9d6e11a437ff8526619c89a1fd osx/x86_64
built 'coverity_scan:096ed6ef786b7a9d6e11a437ff8526619c89a1fd' for osx/x86_64
Diffstat (limited to 'Gem/develop/include/Gem/Utils')
-rw-r--r-- | Gem/develop/include/Gem/Utils/Functions.h | 357 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/GLUtil.h | 100 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/GemMath.h | 85 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/GemString.h | 35 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/Matrix.h | 78 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/PixPete.h | 227 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/SIMD.h | 118 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/SynchedWorkerThread.h | 65 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/Thread.h | 66 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/ThreadMutex.h | 38 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/ThreadSemaphore.h | 39 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/Vector.h | 77 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/WorkerThread.h | 81 | ||||
-rw-r--r-- | Gem/develop/include/Gem/Utils/any.h | 318 |
14 files changed, 0 insertions, 1684 deletions
diff --git a/Gem/develop/include/Gem/Utils/Functions.h b/Gem/develop/include/Gem/Utils/Functions.h deleted file mode 100644 index b025e29..0000000 --- a/Gem/develop/include/Gem/Utils/Functions.h +++ /dev/null @@ -1,357 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - GemFuncUtil.h - - contains functions for graphics - - part of GEM - - Copyright (c) 1997-2000 Mark Danks. mark@danks.org - Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_UTILS_FUNCTIONS_H_ -#define _INCLUDE__GEM_UTILS_FUNCTIONS_H_ - -#include "Gem/ExportDef.h" - -/* this should be included for ALL platforms: - * should we define __MMX__ for windows in there ? - */ -#include "Utils/SIMD.h" -#include "Utils/GemMath.h" - -// for rand() -#include <stdlib.h> - -/////////////////////////////////////////////////////////////////////////////// -// powerOfTwo -// get the next higher 2^n-number (if value isn't 2^n by itself) -/////////////////////////////////////////////////////////////////////////////// -inline int powerOfTwo(int value) -{ -/* - 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); -} - -/////////////////////////////////////////////////////////////////////////////// -// min/max functions -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef MIN -template <class T> -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; } -#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); - 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); - return(v3); -} - -/////////////////////////////////////////////////////////////////////////////// -// Clamp functions -// -/////////////////////////////////////////////////////////////////////////////// -////////// -// Clamp a value high -inline unsigned char CLAMP_HIGH(int 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)); } - -////////// -// 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))); } - -////////// -// 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))); } - -////////// -// 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)); } - -///////// -// 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))); } - -/////////////////////////////////////////////////////////////////////////////// -// Multiply and interpolation -// -/////////////////////////////////////////////////////////////////////////////// -////////// -// Exactly multiply two unsigned chars -// 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)); } - -////////// -// 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))); } - -////////// -// Floating point LERP -template <class T> -inline T FLOAT_LERP(T p, T q, T a) - { return( a * (q - p) + p); } - - -/////////////////////////////////////////////////////////////////////////////// -// Step function -// -/////////////////////////////////////////////////////////////////////////////// -template <class T> -inline int stepFunc(T x, T a) - { return(x >= a); } - -/////////////////////////////////////////////////////////////////////////////// -// Pulse function -// -/////////////////////////////////////////////////////////////////////////////// -template <class T> -inline int pulseFunc(T x, T a, T b) - { return(stepFunc(a, x) - stepFunc(b, x)); } - -/////////////////////////////////////////////////////////////////////////////// -// Clamp function -// -/////////////////////////////////////////////////////////////////////////////// -template <class T> -inline T clampFunc(T x, T a, T b) - { 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)); } -*/ -/* - inline int GateInt(int nValue,int nMin,int nMax) - inline float GateFlt(float nValue,float nMin,float nMax) - inline void* GatePtr(void* pValue,void* pMin,void* pMax) -*/ - - -/////////////////////////////////////////////////////////////////////////////// -// absolute integer -// -/////////////////////////////////////////////////////////////////////////////// -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) { - int nOutValue=(inValue%nMax); - if (nOutValue<0)nOutValue=((nMax-1)+nOutValue); - return nOutValue; -} - -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); - return nOutValue; -} - - -/////////////////////////////////////////////////////////////////////////////// -// 2D-algebra -// -/////////////////////////////////////////////////////////////////////////////// -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)); -} -/////////////////////////////////////////////////////////////////////////////// -// 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; -} - -/////////////////////////////////////////////////////////////////////////////// -// higher algebra -// -/////////////////////////////////////////////////////////////////////////////// -inline float GetRandomFloat(void) { - return rand()/static_cast<float>(RAND_MAX); -} - - -/////////////////////////////////////////////////////////////////////////////// -// Smooth step function (3x^2 - 2x^3) -// -/////////////////////////////////////////////////////////////////////////////// -GEM_EXTERN extern float smoothStep(float x, float a, float b); -GEM_EXTERN extern int smoothStep(int x, int a, int b); -GEM_EXTERN extern unsigned char smoothStep(unsigned char x, unsigned char a, unsigned char b); - -/////////////////////////////////////////////////////////////////////////////// -// Bias function -// -// Remap unit interval (curve) -// If a == 0.5, then is linear mapping. -/////////////////////////////////////////////////////////////////////////////// -GEM_EXTERN extern float biasFunc(float x, float a); - -/////////////////////////////////////////////////////////////////////////////// -// Gain function -// -// Remap unit interval (S-curve) -// Will always return 0.5 when x is 0.5 -// If a == 0.5, then is linear mapping. -/////////////////////////////////////////////////////////////////////////////// -GEM_EXTERN extern float gainFunc(float x, float a); - -/////////////////////////////////////////////////////////////////////////////// -// Linear function -// -// val should be 0 <= val <= 1. -// ret should point at a float of enough dimensions to hold the returned value -// For instance, numDimen == 2, should have a ret[2] -// numDimen is the number of dimensions to compute -// npnts is the number of points per dimension. -// -/////////////////////////////////////////////////////////////////////////////// -GEM_EXTERN extern void linearFunc(float val, float *ret, int numDimen, int npnts, float *pnts); -GEM_EXTERN extern void linearFunc(double val, double *ret, int numDimen, int npnts, double *pnts); - -/////////////////////////////////////////////////////////////////////////////// -// Spline function -// -// val should be 0 <= val <= 1. -// ret should point at a float of enough dimensions to hold the returned value -// For instance, numDimen == 2, should have a ret[2] -// numDimen is the number of dimensions to compute -// nknots is the number of knots per dimension. -// There must be at least four knots! -// -// Thanks to -// _Texturing and Modeling: A Procedural Approach_ -// David S. Ebert, Ed. -/////////////////////////////////////////////////////////////////////////////// -GEM_EXTERN extern void splineFunc(float val, float *ret, int numDimen, int nknots, float *knot); -GEM_EXTERN extern void splineFunc(double val, double *ret, int numDimen, int nknots, double *knot); - - -/////////////////////////////////////////////////////////////////////////////// -// Pixel access functions -// -/////////////////////////////////////////////////////////////////////////////// -// -// Accelerated Pixel Manipulations -// This is sort on a vector operation on 8 chars at the same time .... could be -// implemented in MMX -// Alpha channel is not added !! (would be nr 3 and 7) - -#define ADD8_NOALPHA(a,b) \ - ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\ - ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\ - ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\ - ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\ - ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\ - ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\ - -#define SUB8_NOALPHA(a,b) \ - ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\ - ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\ - ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\ - ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\ - ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\ - ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\ - -#define ADD8(a,b) \ - ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\ - ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\ - ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\ - ((unsigned char*)(a))[3] = CLAMP_HIGH((int)((unsigned char*)(a))[3] + ((unsigned char*)(b))[3]);\ - ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\ - ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\ - ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\ - ((unsigned char*)(a))[7] = CLAMP_HIGH((int)((unsigned char*)(a))[7] + ((unsigned char*)(b))[7]);\ - -#define SUB8(a,b) \ - ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\ - ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\ - ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\ - ((unsigned char*)(a))[3] = CLAMP_LOW((int)((unsigned char*)(a))[3] - ((unsigned char*)(b))[3]);\ - ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\ - ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\ - ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\ - ((unsigned char*)(a))[7] = CLAMP_LOW((int)((unsigned char*)(a))[7] - ((unsigned char*)(b))[7]);\ - - - -#ifdef __APPLE__ -//Ian Ollman's function to determine the cache prefetch for altivec vec_dst() -#include <inttypes.h> - -inline uint32_t GetPrefetchConstant( int blockSizeInVectors, int blockCount, int blockStride ) -{ - 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 deleted file mode 100644 index c550c07..0000000 --- a/Gem/develop/include/Gem/Utils/GLUtil.h +++ /dev/null @@ -1,100 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - GemGLUtil.h - - contains functions for graphics - - part of GEM - - Copyright (c) 1997-2000 Mark Danks. mark@danks.org - Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_UTILS_GLUTIL_H_ -#define _INCLUDE__GEM_UTILS_GLUTIL_H_ - -#include "Gem/ExportDef.h" - -/* for t_symbol/t_atom */ -/* LATER get rid of that (std::string) */ -struct _atom; -struct _symbol; -#include <string> - -/* for GLenum */ -#include "Gem/GemGL.h" -#include "Gem/Exception.h" - - -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); -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) throw(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); - - - /* 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(); - 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 */ - -#endif // for header file - diff --git a/Gem/develop/include/Gem/Utils/GemMath.h b/Gem/develop/include/Gem/Utils/GemMath.h deleted file mode 100644 index 769edec..0000000 --- a/Gem/develop/include/Gem/Utils/GemMath.h +++ /dev/null @@ -1,85 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - Matrix class - - Copyright (c) 1997-1999 Mark Danks. mark@danks.org - Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_UTILS_GEMMATH_H_ -#define _INCLUDE__GEM_UTILS_GEMMATH_H_ -#include <math.h> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#ifdef __APPLE__ -# include <AvailabilityMacros.h> -# if defined (MAC_OS_X_VERSION_10_3) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 -# else - -#define sqrtf(v) (float)sqrt((double)(v)) -#define cosf(v) (float)cos((double)(v)) -#define sinf(v) (float)sin((double)(v)) -#define tanf(v) (float)tan((double)(v)) -#define logf(v) (float)log((double)(v)) -#define expf(v) (float)exp((double)(v)) - -#define atan2f(v,p) (float)atan2((double)(v), (double)(p)) -#define powf(v,p) (float)pow((double)(v), (double)(p)) - -# endif /* OSX_10_3 */ -#endif /* __APPLE__ */ - - -/////////////////////////////////////////////////////////////////////////////// -// Speedup found via Shark: ppc only -// -// If you do not require full precision, you can use the PowerPC floating-point -// reciprocal square-root estimate instruction (frsqrte) instead of calling sqrt(). -// -// If needed, you can increase the precision of the estimate returned by -// frsqrte (5-bits of precision) by using the Newton-Raphson method for improving -// the estimate (x0) for 1/sqrt(a) (x1 = 0.5 * x0 * [3.0 - a * x0 * x0]). -/////////////////////////////////////////////////////////////////////////////// -#ifdef __ppc__ -# include <ppc_intrinsics.h> -# ifdef sqrt -# undef sqrt -# endif -# ifdef sqrtf -# undef sqrtf -# endif - -# define sqrt fast_sqrtf -# define sqrtf fast_sqrtf - -inline double fast_sqrt(double x) -{ - 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); -} -#endif /* __ppc__ */ - -#ifdef _WIN32 -/* seems like there is no drand48() on w32 */ -/* JMZ: this should really return "double" instead of "float", - * but we need only float... */ -# define drand48() ((float)rand())/((float)RAND_MAX) -#endif /* _WIN32 */ - - -#endif // for header file diff --git a/Gem/develop/include/Gem/Utils/GemString.h b/Gem/develop/include/Gem/Utils/GemString.h deleted file mode 100644 index d134f50..0000000 --- a/Gem/develop/include/Gem/Utils/GemString.h +++ /dev/null @@ -1,35 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - - 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - - - -#ifndef _INCLUDE__GEM_GEM_STRING_H_ -#define _INCLUDE__GEM_GEM_STRING_H_ - -#include <string> -#include "Gem/ExportDef.h" - -class CPPExtern; -namespace gem { - - 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 UTF-8 string to wchar */ - GEM_EXTERN std::wstring toWstring(const char*str) throw(int); - }; -}; - -#endif /* _INCLUDE__GEM_GEM_BIDI_H_ */ diff --git a/Gem/develop/include/Gem/Utils/Matrix.h b/Gem/develop/include/Gem/Utils/Matrix.h deleted file mode 100644 index 0137f89..0000000 --- a/Gem/develop/include/Gem/Utils/Matrix.h +++ /dev/null @@ -1,78 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - Matrix class - - Copyright (c) 1997-1999 Mark Danks. mark@danks.org - Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_UTILS_MATRIX_H_ -#define _INCLUDE__GEM_UTILS_MATRIX_H_ - -#include "Gem/ExportDef.h" - -/*----------------------------------------------------------------- -------------------------------------------------------------------- -CLASS - Matrix - - 4x4 Matrix class - -DESCRIPTION - - Post-concatenation - Column-major - ------------------------------------------------------------------*/ -class GEM_EXTERN Matrix -{ - public: - - ////////// - // Constructor - // Sets the matrix to identity - Matrix(void); - - ////////// - // Set the matrix to the identity - void identity(void); - - ////////// - // Post mulitply the matrix - void multiply(Matrix *pMatrix); - - ////////// - void scale(float x, float y, float z); - - ////////// - void translate(float x, float y, float z); - - ////////// - void rotateX(float degrees); - - ////////// - void rotateY(float degrees); - - ////////// - void rotateZ(float degrees); - - ////////// - void transform(float srcX, float srcY, float srcZ, float *dstX, float *dstY, float *dstZ) const; - - ////////// - // The actual matrix values - float mat[4][4]; - - ////////// - // Utility functions - static void generateNormal(const float *v1, const float *v2, const float *v3, float *dst); -}; - - -#endif // for header file diff --git a/Gem/develop/include/Gem/Utils/PixPete.h b/Gem/develop/include/Gem/Utils/PixPete.h deleted file mode 100644 index cc8005a..0000000 --- a/Gem/develop/include/Gem/Utils/PixPete.h +++ /dev/null @@ -1,227 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - helper stuff for ports of Pete's Plugins - - http://www.petewarden.com - - Copyright (c) 2004-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ -#ifndef _INCLUDE__GEM_UTILS_PIXPETE_H_ -#define _INCLUDE__GEM_UTILS_PIXPETE_H_ - -#include <stdlib.h> - -// utility functions from PeteHelpers.h - -#ifndef _MSC_VER -# include <stdint.h> -typedef uint32_t U32; -typedef uint16_t U16; -typedef uint8_t U8; -#else -typedef unsigned long U32; -typedef unsigned short U16; -typedef unsigned char U8; -#endif - -/* is this only on my system ? - i thought Gem's YUV is UYVY and not YVYU - seems weird... (jmz) -*/ -#ifdef __APPLE__ - -# define SHIFT_ALPHA (24) -# define SHIFT_RED (16) -# define SHIFT_GREEN (8) -# define SHIFT_BLUE (0) - -# define SHIFT_U (24) -# define SHIFT_Y1 (16) -# define SHIFT_V (8) -# define SHIFT_Y2 (0) - -#else - -# define SHIFT_ALPHA (24) -# define SHIFT_RED (16) -# define SHIFT_GREEN (8) -# define SHIFT_BLUE (0) - -# define SHIFT_U (0) -# define SHIFT_Y1 (8) -# define SHIFT_V (16) -# define SHIFT_Y2 (24) -#endif - -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); -} - -typedef U32 PETE_PIXELDATA32; -#define SIZEOF_PETE_PIXELDATA32 (4) - -typedef U32 PETE_PIXELDATA24; -#define SIZEOF_PETE_PIXELDATA24 (3) - -typedef U16 PETE_PIXELDATA16; -#define SIZEOF_PETE_PIXELDATA16 (2) - -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); - - while (pCurrentSource<pSourceEnd) { - *((PETE_PIXELDATA32*)pCurrentOutput)= - *((PETE_PIXELDATA24*)pCurrentSource); - - pCurrentSource+=SIZEOF_PETE_PIXELDATA24; - pCurrentOutput+=SIZEOF_PETE_PIXELDATA32; - } -} - -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); - - while (pCurrentSource<pSourceEnd) { - *((PETE_PIXELDATA24*)pCurrentOutput)= - *((PETE_PIXELDATA32*)pCurrentSource); - - pCurrentSource+=SIZEOF_PETE_PIXELDATA32; - pCurrentOutput+=SIZEOF_PETE_PIXELDATA24; - } -} - -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)); - - while (pBuffer32Current>=pBufferStart) { - - *((PETE_PIXELDATA32*)pBuffer32Current)= - *((PETE_PIXELDATA24*)pBuffer24Current); - - pBuffer32Current-=SIZEOF_PETE_PIXELDATA32; - pBuffer24Current-=SIZEOF_PETE_PIXELDATA24; - } -} - -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); - - while (pCurrentSource<pSourceEnd) { - - 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 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); - - *((PETE_PIXELDATA32*)pCurrentOutput)=OutputColour; - - pCurrentSource+=SIZEOF_PETE_PIXELDATA16; - pCurrentOutput+=SIZEOF_PETE_PIXELDATA32; - - } - -} - -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); - - while (pCurrentSource<pSourceEnd) { - - 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 nMaskedRed=(nSourceRed>>3); - const int nMaskedGreen=(nSourceGreen>>2); - const int nMaskedBlue=(nSourceBlue>>3); - - PETE_PIXELDATA16 OutputColour= - (nMaskedRed<<11)| - (nMaskedGreen<<5)| - (nMaskedBlue<<0); - - *((PETE_PIXELDATA16*)pCurrentOutput)=OutputColour; - - pCurrentSource+=SIZEOF_PETE_PIXELDATA32; - pCurrentOutput+=SIZEOF_PETE_PIXELDATA16; - } -} -typedef void* SPete_MemHandle; - -inline SPete_MemHandle Pete_NewHandle(int nBytesToAlloc) { - return malloc(nBytesToAlloc); -} - -inline void Pete_FreeHandle(SPete_MemHandle InHandle) { - free(InHandle); -} - -inline void* Pete_LockHandle(SPete_MemHandle InHandle) { - return InHandle; -} - -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; - - const int nLuminance = - ((77 * nRed)+ - (150* nGreen)+ // used to be 50 which is plain wrong - (29 * nBlue)); - - return nLuminance; -} - -#endif /* _INCLUDE__GEM_UTILS_PIXPETE_H_ */ -// end of PeteHelpers.h stuff diff --git a/Gem/develop/include/Gem/Utils/SIMD.h b/Gem/develop/include/Gem/Utils/SIMD.h deleted file mode 100644 index 02db219..0000000 --- a/Gem/develop/include/Gem/Utils/SIMD.h +++ /dev/null @@ -1,118 +0,0 @@ - -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - include file for SIMD - - Copyright (c) 1997-1999 Mark Danks. mark@danks.org - Copyright (c) Günther Geiger. geiger@epy.co.at - Copyright (c) 2001-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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -/* - * compiler-issues: - * - * gcc: when gcc is invoked with "-mmmx" (or "-msse2" or "-maltivec") - * the defines __MMX__ (or corresponding) will be defined automatically - * - * vc6: you will have to install the microsoft processor-pack to use MMX/SSE2 - * you have to have the sp5 for vc6 installed (note: do not install sp6!!) - * vc6/vc7: (i think) you need to define __MMX__ (and friends) by hand - */ - -#ifndef _INCLUDE__GEM_UTILS_SIMD_H_ -#define _INCLUDE__GEM_UTILS_SIMD_H_ - -#define GEM_VECTORALIGNMENT 128 - -const int GEM_SIMD_NONE=0; -const int GEM_SIMD_MMX=1; -const int GEM_SIMD_SSE2=2; -const int GEM_SIMD_ALTIVEC=3; - -#if defined __APPLE__ -# if defined __VEC__ && !defined __APPLE_ALTIVEC__ -# undef __VEC__ -# endif - -# include <libkern/OSTypes.h> -#endif /* APPLE */ - -/* include for SIMD on PC's */ -#ifdef __SSE2__ -# include <emmintrin.h> -// for icc this should be <dvec.h> -typedef union{ - unsigned char c[16]; - __m128i v; -} vector_128; -#elif defined __VEC__ -/* for AltiVec (PowerPC) */ -typedef union{ - unsigned char c[16]; - vector unsigned char v; -} vector_128; -#endif - -#if defined __MMX__ -# include <mmintrin.h> -// for icc this should be <ivec.h> -typedef union{ - __m64 v; unsigned char c[8]; -} vector64i; - -#endif - - -#ifdef __SSE__ -#include <xmmintrin.h> - -typedef union{ - __m128 m; float f[4]; -} vector128f; -#endif - -#include "Gem/ExportDef.h" - - -/* this is a help-class to query the capabilities of the cpu - * whenever you want to use SIMD-optimized code, you should - * make sure you chose the code-block based on the "cpuid" value - * of this class and NOT simply on preprocessor defines. - * - * this class needs only be instantiated once (and it is done in GemMan) - * this sets the cpuid - */ -class GEM_EXTERN GemSIMD -{ - public: - GemSIMD(void); - virtual ~GemSIMD(void); - - /* this gets the "cpuid" (something like GEM_SIMD_NONE) */ - static int getCPU(void); - - /* change the cpuid returned by getCPU() - * you can only set the cpuid to something that is actually supported - * by your processor - */ - static int requestCPU(int cpuid); - - /* performs a runtime-check (if possible) to determine the capabilities - * of the CPU - * sets realcpuid appropriately and returns this value - */ - static int simd_runtime_check(void); - - private: - /* this is the maximum capability of the CPU */ - static int realcpuid; - /* this is the current chosen capability (normally this equals realcpuid) */ - static int cpuid; -}; - -#endif /* _INCLUDE__GEM_UTILS_SIMD_H_ */ diff --git a/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h b/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h deleted file mode 100644 index 6f5135e..0000000 --- a/Gem/develop/include/Gem/Utils/SynchedWorkerThread.h +++ /dev/null @@ -1,65 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - Synchedworkerthread.h - - part of GEM - - a worker thread that automatically dequeues in the main thread - - 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_GEM_SYNCHEDWORKERTHREAD_H_ -#define _INCLUDE__GEM_GEM_SYNCHEDWORKERTHREAD_H_ - -#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&); - - 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); - - /** - * 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; - - ////// - // 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 deleted file mode 100644 index ca861cc..0000000 --- a/Gem/develop/include/Gem/Utils/Thread.h +++ /dev/null @@ -1,66 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - Thread.h - - part of GEM - - simple platform independent thread abstraction - - Copyright (c) 2011-2012 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_GEM_THREAD_H_ -#define _INCLUDE__GEM_GEM_THREAD_H_ - -#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 - - - - -#endif /* _INCLUDE__GEM_GEM_THREAD_H_ */ diff --git a/Gem/develop/include/Gem/Utils/ThreadMutex.h b/Gem/develop/include/Gem/Utils/ThreadMutex.h deleted file mode 100644 index c2851b5..0000000 --- a/Gem/develop/include/Gem/Utils/ThreadMutex.h +++ /dev/null @@ -1,38 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - - 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_GEM_THREADMUTEX_H_ -#define _INCLUDE__GEM_GEM_THREADMUTEX_H_ - - -#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); - }; - }; -}; -#endif /* _INCLUDE__GEM_GEM_THREADMUTEX_H_ */ diff --git a/Gem/develop/include/Gem/Utils/ThreadSemaphore.h b/Gem/develop/include/Gem/Utils/ThreadSemaphore.h deleted file mode 100644 index 3a57a4c..0000000 --- a/Gem/develop/include/Gem/Utils/ThreadSemaphore.h +++ /dev/null @@ -1,39 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - - 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_GEM_THREADSEMAPHORE_H_ -#define _INCLUDE__GEM_GEM_THREADSEMAPHORE_H_ - - -#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&); - }; - }; -}; -#endif /* _INCLUDE__GEM_GEM_THREADSEMAPHORE_H_ */ diff --git a/Gem/develop/include/Gem/Utils/Vector.h b/Gem/develop/include/Gem/Utils/Vector.h deleted file mode 100644 index e427f04..0000000 --- a/Gem/develop/include/Gem/Utils/Vector.h +++ /dev/null @@ -1,77 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - vector-classes - - zmoelnig@iem.at, tigital@mac.com - - For information on usage and redistribution, and for a DISCLAIMER OF ALL - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_UTILS_VECTOR_H_ -#define _INCLUDE__GEM_UTILS_VECTOR_H_ - -#include "Gem/ExportDef.h" - - - -// This is our 2D point class. This will be used to store the UV coordinates. -class GEM_EXTERN CVector2 { -public: - float x, y; -}; - - -// This is our basic 3D point/vector class -class GEM_EXTERN CVector3 { -public: - // the elements of a vector: - float x, y, z; - - // 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); - - // 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 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 dot-multiply - float operator*(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 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 normalize the vector - CVector3 normalize(void) const; - - // here we compare 2 vectors on approx. equality - bool equals(CVector3 vVector, float epsilon) const; - - -}; - -#endif /* _INCLUDE__GEM_UTILS_VECTOR_H_ */ diff --git a/Gem/develop/include/Gem/Utils/WorkerThread.h b/Gem/develop/include/Gem/Utils/WorkerThread.h deleted file mode 100644 index 9ab2285..0000000 --- a/Gem/develop/include/Gem/Utils/WorkerThread.h +++ /dev/null @@ -1,81 +0,0 @@ -/*----------------------------------------------------------------- -LOG - GEM - Graphics Environment for Multimedia - - WorkerThread.h - - part of GEM - - baseclass for queueing/dequeueing workloads for threaded - - 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 - WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. - ------------------------------------------------------------------*/ - -#ifndef _INCLUDE__GEM_GEM_WORKERTHREAD_H_ -#define _INCLUDE__GEM_GEM_WORKERTHREAD_H_ - -#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 nott 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 deleted file mode 100644 index fc66b46..0000000 --- a/Gem/develop/include/Gem/Utils/any.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * (C) Copyright Christopher Diggins 2005 - * (C) Copyright Pablo Aguilar 2005 - * (C) Copyright Kevlin Henney 2001 - * - * Copyright (C) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at - * downloaded this code from http://www.codeproject.com/KB/cpp/dynamic_typing.aspx - * changed namespace/defines "cdiggins" to something "gem" - * - * Distributed under the Boost Software License, Version 1.0. (See - * accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef GEM_ANY_HPP -#define GEM_ANY_HPP - -#include "Gem/ExportDef.h" - -#ifdef _MSC_VER -# pragma warning( push ) -# pragma warning( disable: 4275 ) -#endif - -#include <stdexcept> -#include <typeinfo> -#include <algorithm> -#include <string> - - -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) throw() - { } - virtual const char* what(void) const throw() { - return result.c_str(); - } - const std::string result; - }; - - 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**); - }; - - // static functions for small value-types - - template<bool is_small> - struct fxns - { - 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); - } - }; - }; - - // static functions for big value-types (bigger than a void*) - - template<> - struct fxns<false> - { - 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 - { - 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; - } - }; - - 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(); - if (sizeof(T) <= sizeof(void*)) { - new(&object) T(x); - } - else { - object = new T(x); - } - } - - 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); - } - - virtual ~any(void) { - table->static_delete(&object); - } - - // assignment - - any& assign(const any& x) { - // are we copying between the same type? - - 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; - } - - 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 - - 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; - } - } - return *this; - } - - // assignment operator - - template<typename T> - any& operator=(T const& x) { - return assign(x); - } - any& operator=(const any& x) { - return assign(x); - } - - // utility functions - - any& swap(any& x) { - std::swap(table, x.table); - std::swap(object, x.object); - return *this; - } - - const std::type_info& get_type(void) const { - return table->get_type(); - } - - 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); - } - } - - /// 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 - - 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(); - } - - void reset(void) - { - if (empty()) return; - table->static_delete(&object); - table = any_detail::get_table<any_detail::empty>::get(); - object = NULL; - } - - // fields - - any_detail::fxn_ptr_table* table; - void* object; - }; - - // 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 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 -# pragma warning( pop ) -#endif - -#endif // GEM_ANY_HPP |