egl/sfopenvg/riDefs.h
branchEGL_MERGE
changeset 57 2bf8a359aa2f
child 88 a5a3a8cb368e
equal deleted inserted replaced
14:0be82064630b 57:2bf8a359aa2f
       
     1 #ifndef __RIDEFS_H
       
     2 #define __RIDEFS_H
       
     3 
       
     4 /*------------------------------------------------------------------------
       
     5  *
       
     6  * OpenVG 1.1 Reference Implementation
       
     7  * -----------------------------------
       
     8  *
       
     9  * Copyright (c) 2007 The Khronos Group Inc.
       
    10  *
       
    11  * Permission is hereby granted, free of charge, to any person obtaining a
       
    12  * copy of this software and /or associated documentation files
       
    13  * (the "Materials "), to deal in the Materials without restriction,
       
    14  * including without limitation the rights to use, copy, modify, merge,
       
    15  * publish, distribute, sublicense, and/or sell copies of the Materials,
       
    16  * and to permit persons to whom the Materials are furnished to do so,
       
    17  * subject to the following conditions: 
       
    18  *
       
    19  * The above copyright notice and this permission notice shall be included 
       
    20  * in all copies or substantial portions of the Materials. 
       
    21  *
       
    22  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    25  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
       
    26  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
       
    27  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
       
    28  * THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    29  *
       
    30  *//**
       
    31  * \file
       
    32  * \brief	Platform- and compiler-dependent type and macro definitions.
       
    33  * \note	
       
    34  *//*-------------------------------------------------------------------*/
       
    35 
       
    36 #include <float.h>
       
    37 #include <math.h>
       
    38 #include <assert.h>
       
    39 #include <new>	//for bad_alloc
       
    40 #include <egl.h>
       
    41 
       
    42 #ifdef USE_NEW_ELEAVE
       
    43 //this is sometimes useful to include so that alloc fails ca be caught.
       
    44 //I have found intermittent OOM (-4) problems when rasterizing the tiger image
       
    45 #include <e32std.h>
       
    46 #endif
       
    47 
       
    48 namespace OpenVGRI
       
    49 {
       
    50 
       
    51 //make for-clause scope c++ standard compliant on msvc
       
    52 #if defined (_MSC_VER)
       
    53 #	if !defined (for)
       
    54 		__forceinline bool getFalse (void) { return false; }
       
    55 #		define for if(getFalse()); else for
       
    56 #	endif // for
       
    57 
       
    58 #pragma warning(disable:4710)	//disable function not inlined warning
       
    59 #pragma warning(disable:4714)	//disable function not __forceinlined warning
       
    60 #endif  // _MSC_VER
       
    61 
       
    62 //=======================================================================
       
    63 
       
    64 typedef int				RIint32;
       
    65 typedef unsigned int	RIuint32;
       
    66 typedef short			RIint16;
       
    67 typedef unsigned short	RIuint16;
       
    68 typedef signed char		RIint8;
       
    69 typedef unsigned char	RIuint8;
       
    70 typedef float			RIfloat32;
       
    71 //TODO add compile-time assertions to guarantee the sizes
       
    72 
       
    73 #if defined (_MSC_VER) // MSVC WIN32
       
    74 #	define RI_INLINE __forceinline
       
    75 #elif defined __APPLE__ || defined (__GNUC__) || defined (__GCC32__) || (__SYMBIAN32__)
       
    76 #	define RI_INLINE inline
       
    77 #endif
       
    78 
       
    79 /*!< Unsigned int that can hold a pointer to any type */
       
    80 /*!< Signed int that can hold a pointer to any type */
       
    81 #if defined (_MSC_VER) && (_MSC_VER >= 1300)
       
    82 typedef uintptr_t		RIuintptr;
       
    83 typedef intptr_t		RIintptr;
       
    84 #else
       
    85 typedef unsigned long   RIuintptr;
       
    86 typedef signed long     RIintptr;
       
    87 #endif
       
    88 
       
    89 #define RI_UINT32_MAX (0xffffffffu)
       
    90 #define RI_INT32_MAX  (0x7fffffff)
       
    91 #define RI_INT32_MIN  (-0x7fffffff-1)
       
    92 
       
    93 /* maximum mantissa is 23 */
       
    94 #define RI_MANTISSA_BITS 23
       
    95 
       
    96 /* maximum exponent is 8 */
       
    97 #define RI_EXPONENT_BITS 8
       
    98 
       
    99 typedef union
       
   100 {
       
   101 	RIfloat32	f;
       
   102 	RIuint32	i;
       
   103 } RIfloatInt;
       
   104 
       
   105 RI_INLINE float	getFloatMax()
       
   106 {
       
   107 	RIfloatInt v;
       
   108 	v.i = (((1<<(RI_EXPONENT_BITS-1))-1+127) << 23) | (((1<<RI_MANTISSA_BITS)-1) << (23-RI_MANTISSA_BITS));
       
   109 	return v.f;
       
   110 }
       
   111 #define RI_FLOAT_MAX  getFloatMax()
       
   112 
       
   113 #define RI_MAX_IMAGE_WIDTH				16384
       
   114 #define RI_MAX_IMAGE_HEIGHT				16384
       
   115 #define RI_MAX_IMAGE_PIXELS				(RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
       
   116 #define RI_MAX_IMAGE_BYTES				(4*RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
       
   117 #define RI_MAX_DASH_COUNT				256
       
   118 #define RI_MAX_COLOR_RAMP_STOPS			256
       
   119 #define RI_MAX_KERNEL_SIZE				256
       
   120 #define RI_MAX_SEPARABLE_KERNEL_SIZE	256
       
   121 #define RI_MAX_GAUSSIAN_STD_DEVIATION	16.0f
       
   122 #define RI_MAX_SCISSOR_RECTANGLES		256
       
   123 #define RI_MAX_EDGES					262144
       
   124 #define RI_MAX_SAMPLES					32
       
   125 #define RI_NUM_TESSELLATED_SEGMENTS		256
       
   126 
       
   127 #define RI_DEBUG
       
   128 
       
   129 #ifdef RI_DEBUG
       
   130 #	define RI_ASSERT assert
       
   131 #else
       
   132 #	define RI_ASSERT
       
   133 #endif
       
   134 
       
   135 #define RI_UNREF(X) ((void)(X))
       
   136 #define RI_APIENTRY EXPORT_C
       
   137 
       
   138 #ifdef USE_NEW_ELEAVE
       
   139 #define RI_NEW(TYPE, PARAMS)           (new(ELeave) TYPE PARAMS)
       
   140 #define RI_NEW_ARRAY(TYPE, ITEMS)      (new(ELeave) TYPE[ITEMS])
       
   141 #else
       
   142 #define RI_NEW(TYPE, PARAMS)           (new TYPE PARAMS)
       
   143 #define RI_NEW_ARRAY(TYPE, ITEMS)      (new TYPE[ITEMS])
       
   144 #endif
       
   145 #define RI_DELETE(PARAMS)              (delete (PARAMS))
       
   146 #define RI_DELETE_ARRAY(PARAMS)        (delete[] (PARAMS))
       
   147 
       
   148 bool			isValidImageFormat(int format);
       
   149 bool      isValidImageFormat(EGLNativePixmapType f);
       
   150 
       
   151 //=======================================================================
       
   152 
       
   153 }	//namespace OpenVGRI
       
   154 
       
   155 #endif /* __RIDEFS_H */