Merge fixes for bugs 1362, 1666, 1863, KhronosRI and bld.inf.
authorPat Downey <patd@symbian.org>
Wed, 02 Jun 2010 13:14:22 +0100
changeset 89 509acdbd8bdd
parent 85 cdf2f6e5c390 (current diff)
parent 81 511d0a99d8bd (diff)
child 102 f4d9a5ce4604
Merge fixes for bugs 1362, 1666, 1863, KhronosRI and bld.inf.
windowing/windowserver/nga/CLIENT/RWINDOW.CPP
--- a/graphicsaccelaration/vgi/group/bld.inf	Thu May 27 14:13:51 2010 +0300
+++ b/graphicsaccelaration/vgi/group/bld.inf	Wed Jun 02 13:14:22 2010 +0100
@@ -21,9 +21,9 @@
 #include <platform_paths.hrh>
 
 PRJ_EXPORTS
-//../inc/vg/vgcontext.h     OS_LAYER_PLATFORM_EXPORT_PATH(vg/vgcontext.h)
-//../inc/vg/vgcontext_symbian.h     OS_LAYER_PLATFORM_EXPORT_PATH(vg/vgcontext_symbian.h)
+../inc/vg/vgcontext.h     OS_LAYER_PLATFORM_EXPORT_PATH(vg/vgcontext.h)
+../inc/vg/vgcontext_symbian.h     OS_LAYER_PLATFORM_EXPORT_PATH(vg/vgcontext_symbian.h)
 ../rom/libvgi.iby CORE_OS_LAYER_IBY_EXPORT_PATH(libvgi.iby)
 
 PRJ_MMPFILES
-libvgi.mmp
+// libvgi.mmp
--- a/opengles/openglesinterface/group/opengles_stub/opengles_defgen_stub.mmp	Thu May 27 14:13:51 2010 +0300
+++ b/opengles/openglesinterface/group/opengles_stub/opengles_defgen_stub.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -19,7 +19,7 @@
 // 
 //
  
-TARGET			opengles11.dll
+TARGET			libGLESv1_CM.dll
 TARGETTYPE		dll
 CAPABILITY		All -TCB
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/bwins/libvgiu.def	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,15 @@
+EXPORTS
+   	VGIInitialize @ 1 NONAME
+   	VGICopyToTarget @ 2 NONAME
+   	VGITerminate @ 3 NONAME
+   	VGIResize @ 4 NONAME
+	VGIBindToImage @ 5 NONAME
+	VGIUnBindImage @ 6 NONAME
+	?VGISymbianCopyToBitmap@@YAHPAVCFbsBitmap@@0W4VGICopyToTargetHint@@@Z @ 7 NONAME
+	?VGISymbianInitialize@@YAHVTSize@@W4VGIColorSpace@@@Z @ 8 NONAME
+	?VGISymbianResize@@YAHVTSize@@@Z @ 9 NONAME
+	?VGISymbianTerminate@@YAXXZ @ 10 NONAME
+	?VGISymbianBindToImage@@YAHK@Z @ 11 NONAME
+	?VGISymbianUnBindImage@@YAHXZ @ 12 NONAME
+	?VGISymbianInitializeEx@@YAHVTSize@@W4VGIColorSpace@@HH@Z @ 13  NONAME
+	VGIInitializeEx @ 14  NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/bwins/sflibopenvgrefimplu.def	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,134 @@
+EXPORTS
+; NEW:
+	?do_vgImageSubData@@YAXKPBXJW4VGImageFormat@@JJJJ@Z @ 1  NONAME ; void do_vgImageSubData(unsigned long, void const *, long, enum VGImageFormat, long, long, long, long)
+	?do_eglInitialize@@YAHHPAH0@Z @ 2  NONAME ; int do_eglInitialize(int, int *, int *)
+	?do_vgColorMatrix@@YAXKKPBM@Z @ 3  NONAME ; void do_vgColorMatrix(unsigned long, unsigned long, float const *)
+	?do_vgDrawGlyph@@YAXKKKW4VGboolean@@@Z @ 4  NONAME ; void do_vgDrawGlyph(unsigned long, unsigned long, unsigned long, enum VGboolean)
+	?do_vgDestroyPath@@YAXK@Z @ 5  NONAME ; void do_vgDestroyPath(unsigned long)
+	?do_vgDestroyMaskLayer@@YAXK@Z @ 6  NONAME ; void do_vgDestroyMaskLayer(unsigned long)
+	?do_vgCreatePath@@YAKJW4VGPathDatatype@@MMJJK@Z @ 7  NONAME ; unsigned long do_vgCreatePath(long, enum VGPathDatatype, float, float, long, long, unsigned long)
+	?do_vgWritePixels@@YAXPBXJW4VGImageFormat@@JJJJ@Z @ 8  NONAME ; void do_vgWritePixels(void const *, long, enum VGImageFormat, long, long, long, long)
+	?do_vgSetfv@@YAXW4VGParamType@@JPBM@Z @ 9  NONAME ; void do_vgSetfv(enum VGParamType, long, float const *)
+	?do_eglWaitNative@@YAHH@Z @ 10  NONAME ; int do_eglWaitNative(int)
+	?do_vgHardwareQuery@@YA?AW4VGHardwareQueryResult@@W4VGHardwareQueryType@@J@Z @ 11  NONAME ; enum VGHardwareQueryResult do_vgHardwareQuery(enum VGHardwareQueryType, long)
+	?do_eglWaitGL@@YAHXZ @ 12  NONAME ; int do_eglWaitGL(void)
+	?do_vgFinish@@YAXXZ @ 13  NONAME ; void do_vgFinish(void)
+	?do_vgSetPaint@@YAXKK@Z @ 14  NONAME ; void do_vgSetPaint(unsigned long, unsigned long)
+	?do_vgSetParameteriv@@YAXKJJPBJ@Z @ 15  NONAME ; void do_vgSetParameteriv(unsigned long, long, long, long const *)
+	?do_vgPathTransformedBounds@@YAXKPAM000@Z @ 16  NONAME ; void do_vgPathTransformedBounds(unsigned long, float *, float *, float *, float *)
+	?do_eglSwapBuffers@@YAHHH@Z @ 17  NONAME ; int do_eglSwapBuffers(int, int)
+	?do_eglCreatePixmapSurface@@YAHHHPAXPBH@Z @ 18  NONAME ; int do_eglCreatePixmapSurface(int, int, void *, int const *)
+	?do_eglCreatePbufferFromClientBuffer@@YAHHHHHPBH@Z @ 19  NONAME ; int do_eglCreatePbufferFromClientBuffer(int, int, int, int, int const *)
+	?do_vgSeparableConvolve@@YAXKKJJJJPBF0MMW4VGTilingMode@@@Z @ 20  NONAME ; void do_vgSeparableConvolve(unsigned long, unsigned long, long, long, long, long, short const *, short const *, float, float, enum VGTilingMode)
+	?do_vgConvolve@@YAXKKJJJJPBFMMW4VGTilingMode@@@Z @ 21  NONAME ; void do_vgConvolve(unsigned long, unsigned long, long, long, long, long, short const *, float, float, enum VGTilingMode)
+	?do_vgSetParameterf@@YAXKJM@Z @ 22  NONAME ; void do_vgSetParameterf(unsigned long, long, float)
+	?do_vgSetPixels@@YAXJJKJJJJ@Z @ 23  NONAME ; void do_vgSetPixels(long, long, unsigned long, long, long, long, long)
+	?do_vgLookup@@YAXKKPBE000W4VGboolean@@1@Z @ 24  NONAME ; void do_vgLookup(unsigned long, unsigned long, unsigned char const *, unsigned char const *, unsigned char const *, unsigned char const *, enum VGboolean, enum VGboolean)
+	?do_vgGetParameterfv@@YAXKJJPAM@Z @ 25  NONAME ; void do_vgGetParameterfv(unsigned long, long, long, float *)
+	?do_vgSetColor@@YAXKK@Z @ 26  NONAME ; void do_vgSetColor(unsigned long, unsigned long)
+	?do_vgFlush@@YAXXZ @ 27  NONAME ; void do_vgFlush(void)
+	?do_vgPointAlongPath@@YAXKJJMPAM000@Z @ 28  NONAME ; void do_vgPointAlongPath(unsigned long, long, long, float, float *, float *, float *, float *)
+	?do_vgGetiv@@YAXW4VGParamType@@JPAJ@Z @ 29  NONAME ; void do_vgGetiv(enum VGParamType, long, long *)
+	?do_vgGetColor@@YAKK@Z @ 30  NONAME ; unsigned long do_vgGetColor(unsigned long)
+	?do_vgShear@@YAXMM@Z @ 31  NONAME ; void do_vgShear(float, float)
+	?do_vgGetMatrix@@YAXPAM@Z @ 32  NONAME ; void do_vgGetMatrix(float *)
+	?do_vgClearImage@@YAXKJJJJ@Z @ 33  NONAME ; void do_vgClearImage(unsigned long, long, long, long, long)
+	?do_vgGetImageSubData@@YAXKPAXJW4VGImageFormat@@JJJJ@Z @ 34  NONAME ; void do_vgGetImageSubData(unsigned long, void *, long, enum VGImageFormat, long, long, long, long)
+	?do_vgCopyMask@@YAXKJJJJJJ@Z @ 35  NONAME ; void do_vgCopyMask(unsigned long, long, long, long, long, long, long)
+	?do_vgGetVectorSize@@YAJW4VGParamType@@@Z @ 36  NONAME ; long do_vgGetVectorSize(enum VGParamType)
+	?do_eglCreateWindowSurface@@YAHHHPAXPBH@Z @ 37  NONAME ; int do_eglCreateWindowSurface(int, int, void *, int const *)
+	?do_vgGetPathCapabilities@@YAKK@Z @ 38  NONAME ; unsigned long do_vgGetPathCapabilities(unsigned long)
+	?do_vguComputeWarpQuadToSquare@@YA?AW4VGUErrorCode@@MMMMMMMMPAM@Z @ 39  NONAME ; enum VGUErrorCode do_vguComputeWarpQuadToSquare(float, float, float, float, float, float, float, float, float *)
+	?do_eglQueryContext@@YAHHHHPAH@Z @ 40  NONAME ; int do_eglQueryContext(int, int, int, int *)
+	?do_vgGetfv@@YAXW4VGParamType@@JPAM@Z @ 41  NONAME ; void do_vgGetfv(enum VGParamType, long, float *)
+	?do_vgGetPaint@@YAKW4VGPaintMode@@@Z @ 42  NONAME ; unsigned long do_vgGetPaint(enum VGPaintMode)
+	?do_eglCreateContext@@YAHHHHPBH@Z @ 43  NONAME ; int do_eglCreateContext(int, int, int, int const *)
+	?do_vgDestroyImage@@YAXK@Z @ 44  NONAME ; void do_vgDestroyImage(unsigned long)
+	?do_vgDestroyFont@@YAXK@Z @ 45  NONAME ; void do_vgDestroyFont(unsigned long)
+	?do_vgReadPixels@@YAXPAXJW4VGImageFormat@@JJJJ@Z @ 46  NONAME ; void do_vgReadPixels(void *, long, enum VGImageFormat, long, long, long, long)
+	?do_vgDrawImage@@YAXK@Z @ 47  NONAME ; void do_vgDrawImage(unsigned long)
+	?do_eglGetCurrentContext@@YAHXZ @ 48  NONAME ; int do_eglGetCurrentContext(void)
+	?do_vgSetGlyphToImage@@YAXKKKQBM0@Z @ 49  NONAME ; void do_vgSetGlyphToImage(unsigned long, unsigned long, unsigned long, float const * const, float const * const)
+	?do_eglGetDisplay@@YAHH@Z @ 50  NONAME ; int do_eglGetDisplay(int)
+	?do_vgDestroyPaint@@YAXK@Z @ 51  NONAME ; void do_vgDestroyPaint(unsigned long)
+	?do_vguPolygon@@YA?AW4VGUErrorCode@@KPBMJW4VGboolean@@@Z @ 52  NONAME ; enum VGUErrorCode do_vguPolygon(unsigned long, float const *, long, enum VGboolean)
+	?do_vgGeti@@YAJW4VGParamType@@@Z @ 53  NONAME ; long do_vgGeti(enum VGParamType)
+	?do_vgCopyPixels@@YAXJJJJJJ@Z @ 54  NONAME ; void do_vgCopyPixels(long, long, long, long, long, long)
+	?do_eglDestroyContext@@YAHHH@Z @ 55  NONAME ; int do_eglDestroyContext(int, int)
+	?do_eglReleaseTexImage@@YAHHHH@Z @ 56  NONAME ; int do_eglReleaseTexImage(int, int, int)
+	?do_vgPathBounds@@YAXKPAM000@Z @ 57  NONAME ; void do_vgPathBounds(unsigned long, float *, float *, float *, float *)
+	?do_vgSeti@@YAXW4VGParamType@@J@Z @ 58  NONAME ; void do_vgSeti(enum VGParamType, long)
+	?do_vgMask@@YAXKW4VGMaskOperation@@JJJJ@Z @ 59  NONAME ; void do_vgMask(unsigned long, enum VGMaskOperation, long, long, long, long)
+	?do_vgGetPixels@@YAXKJJJJJJ@Z @ 60  NONAME ; void do_vgGetPixels(unsigned long, long, long, long, long, long, long)
+	?do_vgGetParameterf@@YAMKJ@Z @ 61  NONAME ; float do_vgGetParameterf(unsigned long, long)
+	?do_vgDrawGlyphs@@YAXKJPBKPBM1KW4VGboolean@@@Z @ 62  NONAME ; void do_vgDrawGlyphs(unsigned long, long, unsigned long const *, float const *, float const *, unsigned long, enum VGboolean)
+	?do_vgTransformPath@@YAXKK@Z @ 63  NONAME ; void do_vgTransformPath(unsigned long, unsigned long)
+	?do_eglQueryAPI@@YAHXZ @ 64  NONAME ; int do_eglQueryAPI(void)
+	?do_vguEllipse@@YA?AW4VGUErrorCode@@KMMMM@Z @ 65  NONAME ; enum VGUErrorCode do_vguEllipse(unsigned long, float, float, float, float)
+	?do_vgLoadIdentity@@YAXXZ @ 66  NONAME ; void do_vgLoadIdentity(void)
+	?do_vgLookupSingle@@YAXKKPBKW4VGImageChannel@@W4VGboolean@@2@Z @ 67  NONAME ; void do_vgLookupSingle(unsigned long, unsigned long, unsigned long const *, enum VGImageChannel, enum VGboolean, enum VGboolean)
+	?do_eglChooseConfig@@YAHHPBHPAHH1@Z @ 68  NONAME ; int do_eglChooseConfig(int, int const *, int *, int, int *)
+	?do_vgRotate@@YAXM@Z @ 69  NONAME ; void do_vgRotate(float)
+	?do_vgInterpolatePath@@YA?AW4VGboolean@@KKKM@Z @ 70  NONAME ; enum VGboolean do_vgInterpolatePath(unsigned long, unsigned long, unsigned long, float)
+	?do_vgAppendPath@@YAXKK@Z @ 71  NONAME ; void do_vgAppendPath(unsigned long, unsigned long)
+	?do_vgPathLength@@YAMKJJ@Z @ 72  NONAME ; float do_vgPathLength(unsigned long, long, long)
+	?do_eglMakeCurrent@@YAHHHHH@Z @ 73  NONAME ; int do_eglMakeCurrent(int, int, int, int)
+	?do_vguArc@@YA?AW4VGUErrorCode@@KMMMMMMW4VGUArcType@@@Z @ 74  NONAME ; enum VGUErrorCode do_vguArc(unsigned long, float, float, float, float, float, float, enum VGUArcType)
+	?do_vgScale@@YAXMM@Z @ 75  NONAME ; void do_vgScale(float, float)
+	?do_vgCopyImage@@YAXKJJKJJJJW4VGboolean@@@Z @ 76  NONAME ; void do_vgCopyImage(unsigned long, long, long, unsigned long, long, long, long, long, enum VGboolean)
+	?do_vgGetParameteriv@@YAXKJJPAJ@Z @ 77  NONAME ; void do_vgGetParameteriv(unsigned long, long, long, long *)
+	?do_eglQuerySurface@@YAHHHHPAH@Z @ 78  NONAME ; int do_eglQuerySurface(int, int, int, int *)
+	?do_vguRect@@YA?AW4VGUErrorCode@@KMMMM@Z @ 79  NONAME ; enum VGUErrorCode do_vguRect(unsigned long, float, float, float, float)
+	?do_eglCreatePbufferSurface@@YAHHHPBH@Z @ 80  NONAME ; int do_eglCreatePbufferSurface(int, int, int const *)
+	?do_vgChildImage@@YAKKJJJJ@Z @ 81  NONAME ; unsigned long do_vgChildImage(unsigned long, long, long, long, long)
+	?do_vguComputeWarpQuadToQuad@@YA?AW4VGUErrorCode@@MMMMMMMMMMMMMMMMPAM@Z @ 82  NONAME ; enum VGUErrorCode do_vguComputeWarpQuadToQuad(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float *)
+	?do_eglGetConfigAttrib@@YAHHHHPAH@Z @ 83  NONAME ; int do_eglGetConfigAttrib(int, int, int, int *)
+	?do_vgGetParent@@YAKK@Z @ 84  NONAME ; unsigned long do_vgGetParent(unsigned long)
+	?do_eglSurfaceAttrib@@YAHHHHH@Z @ 85  NONAME ; int do_eglSurfaceAttrib(int, int, int, int)
+	?do_vguComputeWarpSquareToQuad@@YA?AW4VGUErrorCode@@MMMMMMMMPAM@Z @ 86  NONAME ; enum VGUErrorCode do_vguComputeWarpSquareToQuad(float, float, float, float, float, float, float, float, float *)
+	?do_eglGetProcAddress@@YAP6AXZZPBD@Z @ 87  NONAME ; void (*)(...) do_eglGetProcAddress(char const *)
+	?do_eglDestroySurface@@YAHHH@Z @ 88  NONAME ; int do_eglDestroySurface(int, int)
+	?do_vgGetString@@YAPBEW4VGStringID@@@Z @ 89  NONAME ; unsigned char const * do_vgGetString(enum VGStringID)
+	?do_vguLine@@YA?AW4VGUErrorCode@@KMMMM@Z @ 90  NONAME ; enum VGUErrorCode do_vguLine(unsigned long, float, float, float, float)
+	?do_vgRemovePathCapabilities@@YAXKK@Z @ 91  NONAME ; void do_vgRemovePathCapabilities(unsigned long, unsigned long)
+	?do_vgMultMatrix@@YAXPBM@Z @ 92  NONAME ; void do_vgMultMatrix(float const *)
+	?do_vgGetParameteri@@YAJKJ@Z @ 93  NONAME ; long do_vgGetParameteri(unsigned long, long)
+	?do_eglGetCurrentSurface@@YAHH@Z @ 94  NONAME ; int do_eglGetCurrentSurface(int)
+	?do_eglBindTexImage@@YAHHHH@Z @ 95  NONAME ; int do_eglBindTexImage(int, int, int)
+	?do_vgModifyPathCoords@@YAXKJJPBX@Z @ 96  NONAME ; void do_vgModifyPathCoords(unsigned long, long, long, void const *)
+	?do_vgSetParameterfv@@YAXKJJPBM@Z @ 97  NONAME ; void do_vgSetParameterfv(unsigned long, long, long, float const *)
+	?do_vgDrawPath@@YAXKK@Z @ 98  NONAME ; void do_vgDrawPath(unsigned long, unsigned long)
+	?do_vgGaussianBlur@@YAXKKMMW4VGTilingMode@@@Z @ 99  NONAME ; void do_vgGaussianBlur(unsigned long, unsigned long, float, float, enum VGTilingMode)
+	?do_vgGetError@@YA?AW4VGErrorCode@@XZ @ 100  NONAME ; enum VGErrorCode do_vgGetError(void)
+	?do_vgFillMaskLayer@@YAXKJJJJM@Z @ 101  NONAME ; void do_vgFillMaskLayer(unsigned long, long, long, long, long, float)
+	?do_eglCopyBuffers@@YAHHHPAX@Z @ 102  NONAME ; int do_eglCopyBuffers(int, int, void *)
+	?do_vgClear@@YAXJJJJ@Z @ 103  NONAME ; void do_vgClear(long, long, long, long)
+	?do_vgSetParameteri@@YAXKJJ@Z @ 104  NONAME ; void do_vgSetParameteri(unsigned long, long, long)
+	?do_vgSetGlyphToPath@@YAXKKKW4VGboolean@@QBM1@Z @ 105  NONAME ; void do_vgSetGlyphToPath(unsigned long, unsigned long, unsigned long, enum VGboolean, float const * const, float const * const)
+	?do_vgCreateFont@@YAKJ@Z @ 106  NONAME ; unsigned long do_vgCreateFont(long)
+	?do_eglSwapInterval@@YAHHH@Z @ 107  NONAME ; int do_eglSwapInterval(int, int)
+	?do_vgClearGlyph@@YAXKK@Z @ 108  NONAME ; void do_vgClearGlyph(unsigned long, unsigned long)
+	?do_eglBindAPI@@YAHH@Z @ 109  NONAME ; int do_eglBindAPI(int)
+	?do_vgAppendPathData@@YAXKJPBEPBX@Z @ 110  NONAME ; void do_vgAppendPathData(unsigned long, long, unsigned char const *, void const *)
+	?do_vgClearPath@@YAXKK@Z @ 111  NONAME ; void do_vgClearPath(unsigned long, unsigned long)
+	?do_vgGetParameterVectorSize@@YAJKJ@Z @ 112  NONAME ; long do_vgGetParameterVectorSize(unsigned long, long)
+	?do_eglGetCurrentDisplay@@YAHXZ @ 113  NONAME ; int do_eglGetCurrentDisplay(void)
+	?do_vgSetf@@YAXW4VGParamType@@M@Z @ 114  NONAME ; void do_vgSetf(enum VGParamType, float)
+	?do_vguRoundRect@@YA?AW4VGUErrorCode@@KMMMMMM@Z @ 115  NONAME ; enum VGUErrorCode do_vguRoundRect(unsigned long, float, float, float, float, float, float)
+	?do_vgTranslate@@YAXMM@Z @ 116  NONAME ; void do_vgTranslate(float, float)
+	?do_eglWaitClient@@YAHXZ @ 117  NONAME ; int do_eglWaitClient(void)
+	?do_vgGetf@@YAMW4VGParamType@@@Z @ 118  NONAME ; float do_vgGetf(enum VGParamType)
+	?do_vgCreateImage@@YAKW4VGImageFormat@@JJK@Z @ 119  NONAME ; unsigned long do_vgCreateImage(enum VGImageFormat, long, long, unsigned long)
+	?do_eglQueryString@@YAPBDHH@Z @ 120  NONAME ; char const * do_eglQueryString(int, int)
+	?do_vgCreatePaint@@YAKXZ @ 121  NONAME ; unsigned long do_vgCreatePaint(void)
+	?do_eglGetError@@YAHXZ @ 122  NONAME ; int do_eglGetError(void)
+	?do_vgLoadMatrix@@YAXPBM@Z @ 123  NONAME ; void do_vgLoadMatrix(float const *)
+	?do_eglTerminate@@YAHH@Z @ 124  NONAME ; int do_eglTerminate(int)
+	?do_eglReleaseThread@@YAHXZ @ 125  NONAME ; int do_eglReleaseThread(void)
+	?do_vgPaintPattern@@YAXKK@Z @ 126  NONAME ; void do_vgPaintPattern(unsigned long, unsigned long)
+	?do_vgSetiv@@YAXW4VGParamType@@JPBJ@Z @ 127  NONAME ; void do_vgSetiv(enum VGParamType, long, long const *)
+	?do_vgRenderToMask@@YAXKKW4VGMaskOperation@@@Z @ 128  NONAME ; void do_vgRenderToMask(unsigned long, unsigned long, enum VGMaskOperation)
+	?do_vgCreateMaskLayer@@YAKJJ@Z @ 129  NONAME ; unsigned long do_vgCreateMaskLayer(long, long)
+	?do_eglGetConfigs@@YAHHPAHH0@Z @ 130  NONAME ; int do_eglGetConfigs(int, int *, int, int *)
+	_E32Dll=__E32Dll	; Entry point for emulation
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/eabi/libvgiu.def	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,15 @@
+EXPORTS
+   	VGIInitialize @ 1 NONAME
+   	VGICopyToTarget @ 2 NONAME
+   	VGITerminate @ 3 NONAME
+   	VGIResize @ 4 NONAME
+	VGIBindToImage @ 5 NONAME
+	VGIUnBindImage @ 6 NONAME
+	_Z16VGISymbianResize5TSize @ 7 NONAME
+	_Z19VGISymbianTerminatev @ 8 NONAME
+	_Z20VGISymbianInitialize5TSize13VGIColorSpace @ 9 NONAME
+	_Z22VGISymbianCopyToBitmapP10CFbsBitmapS0_19VGICopyToTargetHint @ 10 NONAME
+	_Z21VGISymbianBindToImagem @ 11 NONAME
+	_Z21VGISymbianUnBindImagev @ 12 NONAME
+	VGIInitializeEx @ 13  NONAME
+	_Z22VGISymbianInitializeEx5TSize13VGIColorSpaceii @ 14  NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/eabi/sflibopenvgrefimplu.def	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,132 @@
+EXPORTS
+	_Z10do_vgClearllll @ 1 NONAME
+	_Z10do_vgFlushv @ 2 NONAME
+	_Z10do_vgGetfv11VGParamTypelPf @ 3 NONAME
+	_Z10do_vgGetiv11VGParamTypelPl @ 4 NONAME
+	_Z10do_vgScaleff @ 5 NONAME
+	_Z10do_vgSetfv11VGParamTypelPKf @ 6 NONAME
+	_Z10do_vgSetiv11VGParamTypelPKl @ 7 NONAME
+	_Z10do_vgShearff @ 8 NONAME
+	_Z10do_vguLinemffff @ 9 NONAME
+	_Z10do_vguRectmffff @ 10 NONAME
+	_Z11do_vgFinishv @ 11 NONAME
+	_Z11do_vgLookupmmPKhS0_S0_S0_9VGbooleanS1_ @ 12 NONAME
+	_Z11do_vgRotatef @ 13 NONAME
+	_Z12do_eglWaitGLv @ 14 NONAME
+	_Z13do_eglBindAPIi @ 15 NONAME
+	_Z13do_vgConvolvemmllllPKsff12VGTilingMode @ 16 NONAME
+	_Z13do_vgCopyMaskmllllll @ 17 NONAME
+	_Z13do_vgDrawPathmm @ 18 NONAME
+	_Z13do_vgGetColorm @ 19 NONAME
+	_Z13do_vgGetErrorv @ 20 NONAME
+	_Z13do_vgGetPaint11VGPaintMode @ 21 NONAME
+	_Z13do_vgSetColormm @ 22 NONAME
+	_Z13do_vgSetPaintmm @ 23 NONAME
+	_Z13do_vguEllipsemffff @ 24 NONAME
+	_Z13do_vguPolygonmPKfl9VGboolean @ 25 NONAME
+	_Z14do_eglGetErrorv @ 26 NONAME
+	_Z14do_eglQueryAPIv @ 27 NONAME
+	_Z14do_vgClearPathmm @ 28 NONAME
+	_Z14do_vgCopyImagemllmllll9VGboolean @ 29 NONAME
+	_Z14do_vgDrawGlyphmmm9VGboolean @ 30 NONAME
+	_Z14do_vgDrawImagem @ 31 NONAME
+	_Z14do_vgGetMatrixPf @ 32 NONAME
+	_Z14do_vgGetParentm @ 33 NONAME
+	_Z14do_vgGetPixelsmllllll @ 34 NONAME
+	_Z14do_vgGetString10VGStringID @ 35 NONAME
+	_Z14do_vgSetPixelsllmllll @ 36 NONAME
+	_Z14do_vgTranslateff @ 37 NONAME
+	_Z15do_eglTerminatei @ 38 NONAME
+	_Z15do_vgAppendPathmm @ 39 NONAME
+	_Z15do_vgChildImagemllll @ 40 NONAME
+	_Z15do_vgClearGlyphmm @ 41 NONAME
+	_Z15do_vgClearImagemllll @ 42 NONAME
+	_Z15do_vgCopyPixelsllllll @ 43 NONAME
+	_Z15do_vgCreateFontl @ 44 NONAME
+	_Z15do_vgCreatePathl14VGPathDatatypeffllm @ 45 NONAME
+	_Z15do_vgDrawGlyphsmlPKmPKfS2_m9VGboolean @ 46 NONAME
+	_Z15do_vgLoadMatrixPKf @ 47 NONAME
+	_Z15do_vgMultMatrixPKf @ 48 NONAME
+	_Z15do_vgPathBoundsmPfS_S_S_ @ 49 NONAME
+	_Z15do_vgPathLengthmll @ 50 NONAME
+	_Z15do_vgReadPixelsPvl13VGImageFormatllll @ 51 NONAME
+	_Z15do_vguRoundRectmffffff @ 52 NONAME
+	_Z16do_eglGetConfigsiPiiS_ @ 53 NONAME
+	_Z16do_eglGetDisplayi @ 54 NONAME
+	_Z16do_eglInitializeiPiS_ @ 55 NONAME
+	_Z16do_eglWaitClientv @ 56 NONAME
+	_Z16do_eglWaitNativei @ 57 NONAME
+	_Z16do_vgColorMatrixmmPKf @ 58 NONAME
+	_Z16do_vgCreateImage13VGImageFormatllm @ 59 NONAME
+	_Z16do_vgCreatePaintv @ 60 NONAME
+	_Z16do_vgDestroyFontm @ 61 NONAME
+	_Z16do_vgDestroyPathm @ 62 NONAME
+	_Z16do_vgWritePixelsPKvl13VGImageFormatllll @ 63 NONAME
+	_Z17do_eglCopyBuffersiiPv @ 64 NONAME
+	_Z17do_eglMakeCurrentiiii @ 65 NONAME
+	_Z17do_eglQueryStringii @ 66 NONAME
+	_Z17do_eglSwapBuffersii @ 67 NONAME
+	_Z17do_vgDestroyImagem @ 68 NONAME
+	_Z17do_vgDestroyPaintm @ 69 NONAME
+	_Z17do_vgGaussianBlurmmff12VGTilingMode @ 70 NONAME
+	_Z17do_vgImageSubDatamPKvl13VGImageFormatllll @ 71 NONAME
+	_Z17do_vgLoadIdentityv @ 72 NONAME
+	_Z17do_vgLookupSinglemmPKm14VGImageChannel9VGbooleanS2_ @ 73 NONAME
+	_Z17do_vgPaintPatternmm @ 74 NONAME
+	_Z17do_vgRenderToMaskmm15VGMaskOperation @ 75 NONAME
+	_Z18do_eglBindTexImageiii @ 76 NONAME
+	_Z18do_eglChooseConfigiPKiPiiS1_ @ 77 NONAME
+	_Z18do_eglQueryContextiiiPi @ 78 NONAME
+	_Z18do_eglQuerySurfaceiiiPi @ 79 NONAME
+	_Z18do_eglSwapIntervalii @ 80 NONAME
+	_Z18do_vgFillMaskLayermllllf @ 81 NONAME
+	_Z18do_vgGetParameterfml @ 82 NONAME
+	_Z18do_vgGetParameteriml @ 83 NONAME
+	_Z18do_vgGetVectorSize11VGParamType @ 84 NONAME
+	_Z18do_vgHardwareQuery19VGHardwareQueryTypel @ 85 NONAME
+	_Z18do_vgSetParameterfmlf @ 86 NONAME
+	_Z18do_vgSetParameterimll @ 87 NONAME
+	_Z18do_vgTransformPathmm @ 88 NONAME
+	_Z19do_eglCreateContextiiiPKi @ 89 NONAME
+	_Z19do_eglReleaseThreadv @ 90 NONAME
+	_Z19do_eglSurfaceAttribiiii @ 91 NONAME
+	_Z19do_vgAppendPathDatamlPKhPKv @ 92 NONAME
+	_Z19do_vgGetParameterfvmllPf @ 93 NONAME
+	_Z19do_vgGetParameterivmllPl @ 94 NONAME
+	_Z19do_vgPointAlongPathmllfPfS_S_S_ @ 95 NONAME
+	_Z19do_vgSetGlyphToPathmmm9VGbooleanPKfS1_ @ 96 NONAME
+	_Z19do_vgSetParameterfvmllPKf @ 97 NONAME
+	_Z19do_vgSetParameterivmllPKl @ 98 NONAME
+	_Z20do_eglDestroyContextii @ 99 NONAME
+	_Z20do_eglDestroySurfaceii @ 100 NONAME
+	_Z20do_eglGetProcAddressPKc @ 101 NONAME
+	_Z20do_vgCreateMaskLayerll @ 102 NONAME
+	_Z20do_vgGetImageSubDatamPvl13VGImageFormatllll @ 103 NONAME
+	_Z20do_vgInterpolatePathmmmf @ 104 NONAME
+	_Z20do_vgSetGlyphToImagemmmPKfS0_ @ 105 NONAME
+	_Z21do_eglGetConfigAttribiiiPi @ 106 NONAME
+	_Z21do_eglReleaseTexImageiii @ 107 NONAME
+	_Z21do_vgDestroyMaskLayerm @ 108 NONAME
+	_Z21do_vgModifyPathCoordsmllPKv @ 109 NONAME
+	_Z22do_vgSeparableConvolvemmllllPKsS0_ff12VGTilingMode @ 110 NONAME
+	_Z23do_eglGetCurrentContextv @ 111 NONAME
+	_Z23do_eglGetCurrentDisplayv @ 112 NONAME
+	_Z23do_eglGetCurrentSurfacei @ 113 NONAME
+	_Z24do_vgGetPathCapabilitiesm @ 114 NONAME
+	_Z25do_eglCreatePixmapSurfaceiiPvPKi @ 115 NONAME
+	_Z25do_eglCreateWindowSurfaceiiPvPKi @ 116 NONAME
+	_Z26do_eglCreatePbufferSurfaceiiPKi @ 117 NONAME
+	_Z26do_vgPathTransformedBoundsmPfS_S_S_ @ 118 NONAME
+	_Z27do_vgGetParameterVectorSizeml @ 119 NONAME
+	_Z27do_vgRemovePathCapabilitiesmm @ 120 NONAME
+	_Z27do_vguComputeWarpQuadToQuadffffffffffffffffPf @ 121 NONAME
+	_Z29do_vguComputeWarpQuadToSquareffffffffPf @ 122 NONAME
+	_Z29do_vguComputeWarpSquareToQuadffffffffPf @ 123 NONAME
+	_Z35do_eglCreatePbufferFromClientBufferiiiiPKi @ 124 NONAME
+	_Z9do_vgGetf11VGParamType @ 125 NONAME
+	_Z9do_vgGeti11VGParamType @ 126 NONAME
+	_Z9do_vgMaskm15VGMaskOperationllll @ 127 NONAME
+	_Z9do_vgSetf11VGParamTypef @ 128 NONAME
+	_Z9do_vgSeti11VGParamTypel @ 129 NONAME
+	_Z9do_vguArcmffffff10VGUArcType @ 130 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/egl/egl.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of EGL interface
+*/
+
+#include <egl.h>
+#include "eglinternal.h"
+#include <stdarg.h>
+
+
+extern "C" {
+
+EXPORT_C EGLint eglGetError(void)
+	{
+	return do_eglGetError();
+	}
+EXPORT_C EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+	{
+	return do_eglGetDisplay(display_id);
+	}
+EXPORT_C EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+	{
+	return do_eglInitialize(dpy, major, minor);
+	}
+EXPORT_C EGLBoolean eglTerminate(EGLDisplay dpy)
+	{
+	return do_eglTerminate(dpy);
+	}
+EXPORT_C const char* eglQueryString(EGLDisplay dpy, EGLint name)
+	{
+	return do_eglQueryString(dpy, name);
+	}
+EXPORT_C EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,EGLint config_size, EGLint *num_config)
+	{
+	return do_eglGetConfigs(dpy, configs,config_size, num_config);
+	}
+EXPORT_C EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,EGLConfig *configs, EGLint config_size,EGLint *num_config)
+	{
+	return do_eglChooseConfig(dpy, attrib_list,configs, config_size,num_config);
+    }
+EXPORT_C EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,EGLint attribute, EGLint *value)
+	{
+	return do_eglGetConfigAttrib(dpy, config,attribute, value);
+	}
+EXPORT_C EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,EGLNativeWindowType win,const EGLint *attrib_list)
+	{
+	return do_eglCreateWindowSurface(dpy, config,win,attrib_list);
+	}
+EXPORT_C EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,const EGLint *attrib_list)
+	{
+	return do_eglCreatePbufferSurface(dpy, config,attrib_list);
+	}
+EXPORT_C EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,EGLNativePixmapType pixmap,const EGLint *attrib_list)
+	{
+	return do_eglCreatePixmapSurface(dpy, config,pixmap,attrib_list);
+	}
+EXPORT_C EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+	{
+	return do_eglDestroySurface(dpy, surface);
+	}
+EXPORT_C EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface,EGLint attribute, EGLint *value)
+	{
+	return do_eglQuerySurface(dpy, surface,attribute, value);
+	}
+EXPORT_C EGLBoolean eglBindAPI(EGLenum api)
+	{
+	return do_eglBindAPI(api);
+	}
+EXPORT_C EGLenum eglQueryAPI(void)
+	{
+	return do_eglQueryAPI();
+	}
+EXPORT_C EGLBoolean eglWaitClient(void)
+	{
+	return do_eglWaitClient();
+	}
+EXPORT_C EGLBoolean eglReleaseThread(void)
+	{
+	return do_eglReleaseThread();
+	}
+EXPORT_C EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,EGLConfig config, const EGLint *attrib_list)
+	{
+	return do_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer,config, attrib_list);
+	}
+EXPORT_C EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,EGLint attribute, EGLint value)
+	{
+	return do_eglSurfaceAttrib(dpy, surface,attribute, value);
+	}
+EXPORT_C EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+	{
+	return do_eglBindTexImage(dpy, surface, buffer);
+	}
+EXPORT_C EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+	{
+	return do_eglReleaseTexImage(dpy, surface, buffer);
+	}
+EXPORT_C EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+	{
+	return do_eglSwapInterval(dpy, interval);
+	}
+EXPORT_C EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,EGLContext share_context,const EGLint *attrib_list)
+	{
+	return do_eglCreateContext(dpy, config,share_context,attrib_list);
+	}
+EXPORT_C EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+	{
+	return do_eglDestroyContext(dpy, ctx);
+	}
+EXPORT_C EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,EGLSurface read, EGLContext ctx)
+	{
+	return do_eglMakeCurrent(dpy, draw,read, ctx);
+	}
+EXPORT_C EGLContext eglGetCurrentContext(void)
+	{
+	return do_eglGetCurrentContext();
+	}
+EXPORT_C EGLSurface eglGetCurrentSurface(EGLint readdraw)
+	{
+	return do_eglGetCurrentSurface(readdraw);
+	}
+EXPORT_C EGLDisplay eglGetCurrentDisplay(void)
+	{
+	return do_eglGetCurrentDisplay();
+	}
+EXPORT_C EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx,EGLint attribute, EGLint *value)
+	{
+	return do_eglQueryContext(dpy, ctx,attribute, value);
+	}
+EXPORT_C EGLBoolean eglWaitGL(void)
+	{
+	return do_eglWaitGL();
+	}
+EXPORT_C EGLBoolean eglWaitNative(EGLint engine)
+	{
+	return do_eglWaitNative(engine);
+	}
+EXPORT_C EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+	{
+	return do_eglSwapBuffers(dpy, surface);
+	}
+EXPORT_C EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,EGLNativePixmapType target)
+	{
+	return do_eglCopyBuffers(dpy, surface,target);
+	}
+
+typedef void (*eglfPtr)(...);
+EXPORT_C void (*eglGetProcAddress(const char *procname))(...)
+	{
+    eglfPtr pname = do_eglGetProcAddress(procname);
+    return pname;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/bld.inf	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* top level bld.inf for building reference openvg
+*/
+
+PRJ_PLATFORMS
+DEFAULT	
+
+
+PRJ_EXPORTS
+../sfopenvg/symbian/eglosnativewindowtype.h
+sfopenvg.iby /epoc32/rom/include/sfopenvg.iby
+
+PRJ_MMPFILES
+openvg.mmp
+openvgu.mmp
+egl.mmp
+vgi.mmp
+sfopenvg.mmp
+
+// PRJ_TESTMMPFILES
+#include "..\test\group\bld.inf"
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/egl.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* egl mmp file
+*/
+
+#include <egl\egluids.hrh> // For uids
+
+target          libEGL_sw.dll 		// Destination filename
+
+targettype      dll				// Binary build type
+uid             KUidSharedDllUidValue KUidEGLDllUidValue		// File uids
+VENDORID 0x70000001
+CAPABILITY	ALL -tcb
+//noexportlibrary
+
+userinclude     ..\sfopenvg\include //for internal egl functions e.g. do_eglXXX
+
+OS_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(egl) // EGL include files
+
+
+
+sourcepath      ..\egl		// Relative path to source files
+
+
+source          egl.cpp
+
+
+library         euser.lib     		// Mandatory
+library			sflibopenvgrefimpl.lib
+
+
+#ifdef WINS
+DEFFILE         \epoc32\include\def\win32\libegl13.def	// WINS/WINSCW def file
+#else
+DEFFILE         \epoc32\include\def\eabi\libegl13.def	// ARM def file
+#endif // WINS
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/openvg.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* openvg mmp file
+*/
+#include <vg\openvguids.hrh> // For uids
+
+target          libopenvg_sw.dll		// Destination filename
+
+targettype      dll				// Binary build type
+uid             KUidSharedDllUidValue KUidOpenVGDllUidValue		// File uids
+CAPABILITY      ALL -tcb
+vendorid        0x70000001
+
+//noexportlibrary
+
+MACRO       __OPENVGHEADERS_USE_VG_1_1
+
+userinclude     ..\sfopenvg\include //for internal openvg functions e.g. do_vgXXX
+
+OS_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // EGL include files
+
+
+sourcepath      ..\openvg		// Relative path to source files
+
+source openvg.cpp
+
+library         euser.lib     		// Mandatory
+library			sflibopenvgrefimpl.lib
+
+#ifdef WINS
+DEFFILE         \epoc32\include\def\win32\libopenvg11.def	// WINS/WINSCW def file
+#else
+DEFFILE         \epoc32\include\def\eabi\libopenvg11.def	// ARM def file
+#endif // WINS
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/openvgu.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* openvgu mmp file
+*/
+#include <vg\openvguids.hrh> // For uids
+
+target          libopenvgu_sw.dll		// Destination filename
+targettype      dll				// Binary build type
+uid             KUidSharedDllUidValue KUidVGUDllUidValue		// File uids
+CAPABILITY      CAP_GENERAL_DLL
+vendorid        0x70000001
+//noexportlibrary
+
+userinclude     ..\sfopenvg\include //for internal egl functions e.g. do_eglXXX
+
+OS_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // EGL include files
+
+macro __OPENVGHEADERS_USE_VG_1_1
+
+sourcepath      ..\openvgu		// Relative path to source files
+
+source          vgu.cpp
+
+library         euser.lib     		// Mandatory
+library			sflibopenvgrefimpl.lib
+
+#ifdef WINS
+DEFFILE         \epoc32\include\def\win32\libopenvgu11.def	// WINS/WINSCW def file
+#else
+DEFFILE         \epoc32\include\def\eabi\libopenvgu11.def	// ARM def file
+#endif // WINS
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/sfopenvg.iby	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:  
+* Component IBY file for the SF OpenVG reference implementation.
+*/
+
+#ifndef __SFOPENVG_IBY__
+#define __SFOPENVG_IBY__
+
+file=ABI_DIR\BUILD_DIR\libopenvg.dll           sys\bin\libopenvg.dll
+file=ABI_DIR\BUILD_DIR\libopenvgu.dll          sys\bin\libopenvgu.dll
+file=ABI_DIR\BUILD_DIR\libEGL.dll              sys\bin\libegl.dll
+file=ABI_DIR\BUILD_DIR\sflibopenvgrefimpl.dll  sys\bin\sflibopenvgrefimpl.dll
+
+// VGI included from elsewhere
+// file=ABI_DIR\BUILD_DIR\libvgi.dll              sys\bin\libvgi.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/sfopenvg.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* sfopenvg mmp file
+*/
+#include <vg\openvguids.hrh> // For uids
+
+target          sflibopenvgrefimpl.dll		// Destination filename
+
+targettype      dll				// Binary build type
+uid             KUidSharedDllUidValue 0x10281CA6		// File uids
+CAPABILITY      ALL -tcb
+vendorid        0x70000001
+
+
+MACRO       __OPENVGHEADERS_USE_VG_1_1
+
+MACRO 			USE_NEW_ELEAVE //swictch on to use new(ELeave) rather new in alloc's
+					 		   //useful to trap OOM failures
+MACRO  		BUILD_WITH_PRIVATE_EGL //enable this to compile this dll exporting the private form of the EGL functions.
+								   //These are the ones starting do_XX (e.g. do_eglInitialize).
+								   //This should be enabled when you wish to have a separate EGL library (e.g. libegl.dll)
+								   //which will export the ELG APIs.
+								   //If this macro is supressed then this dll will export the true EGL APIs
+								   //see riMiniEgl.cpp
+MACRO 		BUILD_WITH_PRIVATE_VGU //same meaning as macro BUILD_WITH_PRIVATE_EGL except applies to the VGU API.
+								   //see riVGU.cpp
+
+MACRO 		BUILD_WITH_PRIVATE_OPENVG //same meaning as macro BUILD_WITH_PRIVATE_EGL except applies to the OpenVG API.
+								   //see riAPI.cpp
+								   
+userinclude     ..\sfopenvg			// Local include files
+userinclude     ..\sfopenvg\include			// Local include files
+
+OS_LAYER_SYSTEMINCLUDE
+OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
+
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // OpenGL ES include files
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(egl) // EGL include files
+
+
+
+sourcepath      ..\sfopenvg		// Relative path to source files
+
+source riApi.cpp
+source riContext.cpp
+source riFont.cpp
+source riImage.cpp
+source riMath.cpp
+source riMiniEGL.cpp
+source riPath.cpp
+source riPixelPipe.cpp
+source riRasterizer.cpp
+source riVGU.cpp
+
+//for EGL
+SOURCEPATH ..\sfopenvg\symbian
+SOURCE riEGLOS.cpp
+
+library			    libopenvg_sw.lib
+library         euser.lib     		// Mandatory
+library         fbscli.lib    		// For CFbsBitmap, etc
+library         bitgdi.lib    		// For CFbsBitmapDevice, CFbsBitGc, etc
+library         ws32.lib      		// For RWindow, Direct Screen Access, etc
+library         libstdcpp.lib      		// standard lib
+library         libc.lib      		// standard lib
+library         libm.lib      		// standard lib
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/vgi.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* vgi mmp file
+*/
+#include <egl\egluids.hrh> // For UID2 uid
+
+target          libvgi.dll		// Destination filename
+targettype      dll				// Binary build type
+//uid             KUidSharedDllUidValue KUidVGUDllUidValue		// File uids
+uid               0x1000008D            0x0ede0f2d 
+CAPABILITY      all -tcb
+vendorid        0x70000001
+
+
+OS_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // OpenGL ES include files
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(egl) // EGL include files
+
+macro __OPENVGHEADERS_USE_VG_1_1
+
+sourcepath      ..\vgi		// Relative path to source files
+
+source          vgi.cpp
+
+library         euser.lib     		// Mandatory
+library			libegl_sw.lib
+library			fbscli.lib
+
+deffile         libvgi.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/openvg/openvg.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,456 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of OpenVG interface
+*/
+#include <openvg.h>
+#include "openvginternal.h"
+
+extern "C" {
+
+EXPORT_C VGErrorCode   vgGetError(void)
+   {
+   return do_vgGetError();
+   }
+
+EXPORT_C void   vgFlush(void)
+   {
+   return do_vgFlush();
+   }
+
+EXPORT_C void   vgFinish(void)
+   {
+   return do_vgFinish();
+   }
+
+EXPORT_C void  vgSetf (VGParamType type, VGfloat value)
+   {
+   return do_vgSetf(type,value);
+   }
+
+EXPORT_C void   vgSeti (VGParamType type, VGint value)
+   {
+   return do_vgSeti(type,value);
+   }
+
+EXPORT_C void   vgSetfv(VGParamType type, VGint count ,const VGfloat* values)
+   {
+   return do_vgSetfv(type,count,values);
+   }
+
+EXPORT_C void   vgSetiv(VGParamType type, VGint count ,const VGint* values)
+   {
+   return do_vgSetiv(type,count,values);
+   }
+
+EXPORT_C VGfloat   vgGetf(VGParamType type)
+   {
+   return do_vgGetf(type);
+   }
+
+EXPORT_C VGint     vgGeti(VGParamType type)
+   {
+   return do_vgGeti(type);
+   }
+
+EXPORT_C VGint     vgGetVectorSize(VGParamType type)
+   {
+   return do_vgGetVectorSize(type);
+   }
+
+EXPORT_C void      vgGetfv(VGParamType type, VGint count ,VGfloat* values)
+   {
+   return do_vgGetfv(type,count,values);
+   }
+
+EXPORT_C void      vgGetiv(VGParamType type, VGint count ,VGint* values)
+   {
+   return do_vgGetiv(type,count,values);
+   }
+
+EXPORT_C void   vgSetParameterf(VGHandle object ,VGint paramType ,VGfloat value)
+   {
+   return do_vgSetParameterf(object,paramType,value);
+   }
+
+EXPORT_C void   vgSetParameteri(VGHandle object ,VGint paramType ,VGint value)
+   {
+   return do_vgSetParameteri(object,paramType,value);
+   }
+
+EXPORT_C void   vgSetParameterfv(VGHandle object ,VGint paramType ,VGint count ,const VGfloat* values)
+   {
+   return do_vgSetParameterfv(object,paramType,count,values);
+   }
+
+EXPORT_C void   vgSetParameteriv(VGHandle object ,VGint paramType ,VGint count ,const VGint* values)
+   {
+   return do_vgSetParameteriv(object,paramType,count,values);
+   }
+
+EXPORT_C VGfloat   vgGetParameterf(VGHandle object ,VGint paramType)
+   {
+   return do_vgGetParameterf(object,paramType);
+   }
+
+EXPORT_C VGint   vgGetParameteri(VGHandle object ,VGint paramType)
+   {
+   return do_vgGetParameteri(object,paramType);
+   }
+
+EXPORT_C VGint   vgGetParameterVectorSize(VGHandle object ,VGint paramType)
+   {
+   return do_vgGetParameterVectorSize(object,paramType);
+   }
+
+EXPORT_C void   vgGetParameterfv(VGHandle object ,VGint paramType ,VGint count ,VGfloat* values)
+   {
+   return do_vgGetParameterfv(object,paramType,count,values);
+   }
+
+EXPORT_C void   vgGetParameteriv(VGHandle object ,VGint paramType ,VGint count ,VGint* values)
+   {
+   return do_vgGetParameteriv(object,paramType,count,values);
+   }
+
+EXPORT_C void   vgLoadIdentity(void)
+   {
+   return do_vgLoadIdentity();
+   }
+
+EXPORT_C void   vgLoadMatrix(const VGfloat* m)
+   {
+   return do_vgLoadMatrix(m);
+   }
+
+EXPORT_C void   vgGetMatrix(VGfloat* m)
+   {
+   return do_vgGetMatrix(m);
+   }
+
+EXPORT_C void   vgMultMatrix(const  VGfloat* m)
+   {
+   return do_vgMultMatrix(m);
+   }
+
+EXPORT_C void   vgTranslate(VGfloat tx, VGfloat ty)
+   {
+   return do_vgTranslate(tx,ty);
+   }
+
+EXPORT_C void   vgScale(VGfloat sx, VGfloat sy)
+   {
+   return do_vgScale(sx,sy);
+   }
+
+EXPORT_C void   vgShear(VGfloat shx, VGfloat shy)
+   {
+   return do_vgShear(shx,shy);
+   }
+
+EXPORT_C void   vgRotate(VGfloat angle)
+   {
+   return do_vgRotate(angle);
+   }
+
+EXPORT_C void   vgMask(VGHandle mask, VGMaskOperation operation ,VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgMask(mask,operation,x,y,width,height);
+   }
+
+EXPORT_C void   vgRenderToMask(VGPath path ,VGbitfield paintModes ,VGMaskOperation operation)
+   {
+   return do_vgRenderToMask(path,paintModes,operation);
+   }
+
+EXPORT_C VGMaskLayer   vgCreateMaskLayer(VGint width, VGint height)
+   {
+   return do_vgCreateMaskLayer(width,height);
+   }
+
+EXPORT_C void   vgDestroyMaskLayer(VGMaskLayer maskLayer)
+   {
+   return do_vgDestroyMaskLayer(maskLayer);
+   }
+
+EXPORT_C void   vgFillMaskLayer(VGMaskLayer maskLayer ,VGint x, VGint y ,VGint width, VGint height ,VGfloat value)
+   {
+   return do_vgFillMaskLayer(maskLayer,x,y,width,height,value);
+   }
+
+EXPORT_C void   vgCopyMask(VGMaskLayer maskLayer ,VGint sx, VGint sy ,VGint dx, VGint dy ,VGint width, VGint height)
+   {
+   return do_vgCopyMask(maskLayer,sx,sy,dx,dy,width,height);
+   }
+
+EXPORT_C void   vgClear(VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgClear(x,y,width,height);
+   }
+
+EXPORT_C VGPath   vgCreatePath(VGint pathFormat ,VGPathDatatype datatype ,VGfloat scale, VGfloat bias ,VGint segmentCapacityHint ,VGint coordCapacityHint ,VGbitfield capabilities)
+   {
+   return do_vgCreatePath(pathFormat,datatype,scale,bias,segmentCapacityHint,coordCapacityHint,capabilities);
+   }
+
+EXPORT_C void   vgClearPath(VGPath path, VGbitfield capabilities)
+   {
+   return do_vgClearPath(path,capabilities);
+   }
+
+EXPORT_C void   vgDestroyPath(VGPath path)
+   {
+   return do_vgDestroyPath(path);
+   }
+
+EXPORT_C void   vgRemovePathCapabilities(VGPath path ,VGbitfield capabilities)
+   {
+   return do_vgRemovePathCapabilities(path,capabilities);
+   }
+
+EXPORT_C VGbitfield   vgGetPathCapabilities(VGPath path)
+   {
+   return do_vgGetPathCapabilities(path);
+   }
+
+EXPORT_C void   vgAppendPath(VGPath dstPath, VGPath srcPath)
+   {
+   return do_vgAppendPath(dstPath,srcPath);
+   }
+
+EXPORT_C void   vgAppendPathData(VGPath dstPath ,VGint numSegments ,const  VGubyte* pathSegments ,const  void* pathData)
+   {
+   return do_vgAppendPathData(dstPath,numSegments,pathSegments,pathData);
+   }
+
+EXPORT_C void   vgModifyPathCoords(VGPath dstPath ,VGint startIndex ,VGint numSegments ,const void* pathData)
+   {
+   return do_vgModifyPathCoords(dstPath,startIndex,numSegments,pathData);
+   }
+
+EXPORT_C void   vgTransformPath(VGPath dstPath, VGPath srcPath)
+   {
+   return do_vgTransformPath(dstPath,srcPath);
+   }
+
+EXPORT_C VGboolean   vgInterpolatePath(VGPath dstPath ,VGPath startPath ,VGPath endPath ,VGfloat amount)
+   {
+   return do_vgInterpolatePath(dstPath,startPath,endPath,amount);
+   }
+
+EXPORT_C VGfloat   vgPathLength(VGPath path ,VGint startSegment ,VGint numSegments)
+   {
+   return do_vgPathLength(path,startSegment,numSegments);
+   }
+
+EXPORT_C void   vgPointAlongPath(VGPath path ,VGint startSegment ,VGint numSegments ,VGfloat distance ,VGfloat* x, VGfloat* y ,VGfloat* tangentX ,VGfloat* tangentY)
+   {
+   return do_vgPointAlongPath(path,startSegment,numSegments,distance,x,y,tangentX,tangentY);
+   }
+
+EXPORT_C void   vgPathBounds(VGPath path ,VGfloat* minX ,VGfloat* minY ,VGfloat* width ,VGfloat* height)
+   {
+   return do_vgPathBounds(path,minX,minY,width,height);
+   }
+
+EXPORT_C void   vgPathTransformedBounds(VGPath path ,VGfloat* minX ,VGfloat* minY ,VGfloat* width ,VGfloat* height)
+   {
+   return do_vgPathTransformedBounds(path,minX,minY,width,height);
+   }
+
+EXPORT_C void   vgDrawPath(VGPath path, VGbitfield paintModes)
+   {
+   return do_vgDrawPath(path,paintModes);
+   }
+
+EXPORT_C VGPaint   vgCreatePaint(void)
+   {
+   return do_vgCreatePaint();
+   }
+
+EXPORT_C void   vgDestroyPaint(VGPaint paint)
+   {
+   return do_vgDestroyPaint(paint);
+   }
+
+EXPORT_C void   vgSetPaint(VGPaint paint, VGbitfield paintModes)
+   {
+   return do_vgSetPaint(paint,paintModes);
+   }
+
+EXPORT_C VGPaint   vgGetPaint(VGPaintMode paintMode)
+   {
+   return do_vgGetPaint(paintMode);
+   }
+
+EXPORT_C void   vgSetColor(VGPaint paint, VGuint rgba)
+   {
+   return do_vgSetColor(paint,rgba);
+   }
+
+EXPORT_C VGuint   vgGetColor(VGPaint paint)
+   {
+   return do_vgGetColor(paint);
+   }
+
+EXPORT_C void   vgPaintPattern(VGPaint paint, VGImage pattern)
+   {
+   return do_vgPaintPattern(paint,pattern);
+   }
+
+EXPORT_C VGImage   vgCreateImage(VGImageFormat format ,VGint width, VGint height ,VGbitfield allowedQuality)
+   {
+   return do_vgCreateImage(format,width,height,allowedQuality);
+   }
+
+EXPORT_C void   vgDestroyImage(VGImage image)
+   {
+   return do_vgDestroyImage(image);
+   }
+
+EXPORT_C void   vgClearImage(VGImage image ,VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgClearImage(image,x,y,width,height);
+   }
+
+EXPORT_C void   vgImageSubData(VGImage image ,const void* data ,VGint dataStride ,VGImageFormat dataFormat ,VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgImageSubData(image,data,dataStride,dataFormat,x,y,width,height);
+   }
+
+EXPORT_C void   vgGetImageSubData(VGImage image ,void* data ,VGint dataStride ,VGImageFormat dataFormat ,VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgGetImageSubData(image,data,dataStride,dataFormat,x,y,width,height);
+   }
+
+EXPORT_C VGImage   vgChildImage(VGImage parent ,VGint x, VGint y ,VGint width, VGint height)
+   {
+   return do_vgChildImage(parent,x,y,width,height);
+   }
+
+EXPORT_C VGImage   vgGetParent(VGImage image)
+   {
+   return do_vgGetParent(image);
+   }
+
+EXPORT_C void   vgCopyImage(VGImage dst, VGint dx, VGint dy ,VGImage src, VGint sx, VGint sy ,VGint width, VGint height ,VGboolean dither)
+   {
+   return do_vgCopyImage(dst,dx,dy,src,sx,sy,width,height,dither);
+   }
+
+EXPORT_C void   vgDrawImage(VGImage image)
+   {
+   return do_vgDrawImage(image);
+   }
+
+EXPORT_C void   vgSetPixels(VGint dx, VGint dy ,VGImage src, VGint sx, VGint sy ,VGint width, VGint height)
+   {
+   return do_vgSetPixels(dx,dy,src,sx,sy,width,height);
+   }
+
+EXPORT_C void   vgWritePixels(const void* data, VGint dataStride ,VGImageFormat dataFormat ,VGint dx, VGint dy ,VGint width, VGint height)
+   {
+   return do_vgWritePixels(data,dataStride,dataFormat,dx,dy,width,height);
+   }
+
+EXPORT_C void   vgGetPixels(VGImage dst, VGint dx, VGint dy ,VGint sx, VGint sy ,VGint width, VGint height)
+   {
+   return do_vgGetPixels(dst,dx,dy,sx,sy,width,height);
+   }
+
+EXPORT_C void   vgReadPixels(void* data, VGint dataStride ,VGImageFormat dataFormat ,VGint sx, VGint sy ,VGint width, VGint height)
+   {
+   return do_vgReadPixels(data,dataStride,dataFormat,sx,sy,width,height);
+   }
+
+EXPORT_C void   vgCopyPixels(VGint dx, VGint dy ,VGint sx, VGint sy ,VGint width, VGint height)
+   {
+   return do_vgCopyPixels(dx,dy,sx,sy,width,height);
+   }
+
+EXPORT_C VGFont   vgCreateFont(VGint glyphCapacityHint)
+   {
+   return do_vgCreateFont(glyphCapacityHint);
+   }
+
+EXPORT_C void   vgDestroyFont(VGFont font)
+   {
+   return do_vgDestroyFont(font);
+   }
+
+EXPORT_C void   vgSetGlyphToPath(VGFont font ,VGuint glyphIndex ,VGPath path ,VGboolean isHinted ,const VGfloat glyphOrigin [2] ,const VGfloat escapement[2])
+   {
+   return do_vgSetGlyphToPath(font,glyphIndex,path,isHinted,glyphOrigin,escapement);
+   }
+
+EXPORT_C void   vgSetGlyphToImage(VGFont font ,VGuint glyphIndex ,VGImage image ,const VGfloat glyphOrigin [2] ,const VGfloat escapement[2])
+   {
+   return do_vgSetGlyphToImage(font,glyphIndex,image,glyphOrigin,escapement);
+   }
+
+EXPORT_C void   vgClearGlyph(VGFont font ,VGuint glyphIndex)
+   {
+   return do_vgClearGlyph(font,glyphIndex);
+   }
+
+EXPORT_C void   vgDrawGlyph(VGFont font ,VGuint glyphIndex ,VGbitfield paintModes ,VGboolean allowAutoHinting)
+   {
+   return do_vgDrawGlyph(font,glyphIndex,paintModes,allowAutoHinting);
+   }
+
+EXPORT_C void   vgDrawGlyphs(VGFont font ,VGint glyphCount ,const VGuint* glyphIndices ,const VGfloat* adjustments_x ,const VGfloat* adjustments_y ,VGbitfield paintModes ,VGboolean allowAutoHinting)
+   {
+   return do_vgDrawGlyphs(font,glyphCount,glyphIndices,adjustments_x,adjustments_y,paintModes,allowAutoHinting);
+   }
+
+EXPORT_C void   vgColorMatrix(VGImage dst, VGImage src ,const VGfloat* matrix)
+   {
+   return do_vgColorMatrix(dst,src,matrix);
+   }
+
+EXPORT_C void   vgConvolve(VGImage dst, VGImage src ,VGint kernelWidth, VGint kernelHeight ,VGint shiftX, VGint shiftY ,const VGshort* kernel ,VGfloat scale ,VGfloat bias ,VGTilingMode tilingMode)
+   {
+   return do_vgConvolve(dst,src,kernelWidth,kernelHeight,shiftX,shiftY,kernel,scale,bias,tilingMode);
+   }
+
+EXPORT_C void   vgSeparableConvolve(VGImage dst, VGImage src ,VGint kernelWidth ,VGint kernelHeight ,VGint shiftX, VGint shiftY ,const VGshort* kernelX ,const VGshort* kernelY ,VGfloat scale ,VGfloat bias ,VGTilingMode tilingMode)
+   {
+   return do_vgSeparableConvolve(dst,src,kernelWidth,kernelHeight,shiftX,shiftY,kernelX,kernelY,scale,bias,tilingMode);
+   }
+
+EXPORT_C void   vgGaussianBlur(VGImage dst, VGImage src ,VGfloat stdDeviationX ,VGfloat stdDeviationY ,VGTilingMode tilingMode)
+   {
+   return do_vgGaussianBlur(dst,src,stdDeviationX,stdDeviationY,tilingMode);
+   }
+
+EXPORT_C void   vgLookup(VGImage dst, VGImage src ,const VGubyte* redLUT ,const VGubyte* greenLUT ,const VGubyte* blueLUT ,const VGubyte* alphaLUT ,VGboolean outputLinear ,VGboolean outputPremultiplied)
+   {
+   return do_vgLookup(dst,src,redLUT,greenLUT,blueLUT,alphaLUT,outputLinear,outputPremultiplied);
+   }
+
+EXPORT_C void   vgLookupSingle(VGImage dst, VGImage src ,const VGuint* lookupTable ,VGImageChannel sourceChannel ,VGboolean outputLinear ,VGboolean outputPremultiplied)
+   {
+   return do_vgLookupSingle(dst,src,lookupTable,sourceChannel,outputLinear,outputPremultiplied);
+   }
+
+EXPORT_C VGHardwareQueryResult   vgHardwareQuery        (VGHardwareQueryType key ,VGint setting)
+   {
+   return do_vgHardwareQuery(key,setting);
+   }
+
+EXPORT_C const VGubyte *   vgGetString(VGStringID name)
+   {
+   return do_vgGetString(name);
+   }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/openvgu/vgu.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,125 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of VGU interface
+*/
+
+#include <e32base.h>
+#include <vgu.h>
+
+#include "vguinternal.h" //contains do_vguXX fucntion declarations
+
+extern "C" {
+
+EXPORT_C VGUErrorCode vguLine(VGPath path, VGfloat x0, VGfloat y0, VGfloat x1, VGfloat y1)
+{
+return do_vguLine(path, x0, y0, x1, y1);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguPolygon(VGPath path, const VGfloat * points, VGint count, VGboolean closed)
+{
+return do_vguPolygon(path, points, count, closed);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height)
+{
+return do_vguRect(path, x, y, width, height);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguRoundRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat arcWidth, VGfloat arcHeight)
+{
+return do_vguRoundRect(path, x, y, width, height, arcWidth, arcHeight);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguEllipse(VGPath path, VGfloat cx, VGfloat cy, VGfloat width, VGfloat height)
+{
+return do_vguEllipse(path, cx, cy, width, height);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguArc(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, VGUArcType arcType)
+{
+return do_vguArc(path, x, y, width, height, startAngle, angleExtent, arcType);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+{
+return do_vguComputeWarpQuadToSquare(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, matrix);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat * matrix)
+{
+return do_vguComputeWarpSquareToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, matrix);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EXPORT_C VGUErrorCode vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+{
+return do_vguComputeWarpQuadToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, matrix);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/eglinternal.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Declaration of EGL like interface . Basically every EGL API names but prefixed with do_ e.g. do_eglInitialize
+*/
+
+#ifndef EGLINTERNAL_H
+#define EGLINTERNAL_H
+
+#include <egl.h>
+
+
+/*
+ * defines set of internal egl functiosn that are 1:1 with the published egl functions.
+ * E.g. eglInitialize -> do_eglInitialize
+ * 
+ * These do_XXX fucntions are called from the libegl.dll (which is a shim) to be processed here
+ */
+
+IMPORT_C EGLint do_eglGetError(void);
+IMPORT_C EGLDisplay do_eglGetDisplay(EGLNativeDisplayType display_id);
+IMPORT_C EGLBoolean do_eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
+IMPORT_C EGLBoolean do_eglTerminate(EGLDisplay dpy);
+IMPORT_C const char* do_eglQueryString(EGLDisplay dpy, EGLint name);
+IMPORT_C EGLBoolean do_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,EGLint config_size, EGLint *num_config);
+IMPORT_C EGLBoolean do_eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,EGLConfig *configs, EGLint config_size,EGLint *num_config);
+IMPORT_C EGLBoolean do_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,EGLint attribute, EGLint *value);
+IMPORT_C EGLSurface do_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,EGLNativeWindowType win,const EGLint *attrib_list);
+IMPORT_C EGLSurface do_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,const EGLint *attrib_list);
+IMPORT_C EGLSurface do_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,EGLNativePixmapType pixmap,const EGLint *attrib_list);
+IMPORT_C EGLBoolean do_eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
+IMPORT_C EGLBoolean do_eglQuerySurface(EGLDisplay dpy, EGLSurface surface,EGLint attribute, EGLint *value);
+IMPORT_C EGLBoolean do_eglBindAPI(EGLenum api);
+IMPORT_C EGLenum do_eglQueryAPI(void);
+IMPORT_C EGLBoolean do_eglWaitClient(void);
+IMPORT_C EGLBoolean do_eglReleaseThread(void);
+IMPORT_C EGLSurface do_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,EGLConfig config, const EGLint *attrib_list);
+IMPORT_C EGLBoolean do_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,EGLint attribute, EGLint value);
+IMPORT_C EGLBoolean do_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+IMPORT_C EGLBoolean do_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+IMPORT_C EGLBoolean do_eglSwapInterval(EGLDisplay dpy, EGLint interval);
+IMPORT_C EGLContext do_eglCreateContext(EGLDisplay dpy, EGLConfig config,EGLContext share_context,const EGLint *attrib_list);
+IMPORT_C EGLBoolean do_eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
+IMPORT_C EGLBoolean do_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,EGLSurface read, EGLContext ctx);
+IMPORT_C EGLContext do_eglGetCurrentContext(void);
+IMPORT_C EGLSurface do_eglGetCurrentSurface(EGLint readdraw);
+IMPORT_C EGLDisplay do_eglGetCurrentDisplay(void);
+IMPORT_C EGLBoolean do_eglQueryContext(EGLDisplay dpy, EGLContext ctx,EGLint attribute, EGLint *value);
+IMPORT_C EGLBoolean do_eglWaitGL(void);
+IMPORT_C EGLBoolean do_eglWaitNative(EGLint engine);
+IMPORT_C EGLBoolean do_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
+IMPORT_C EGLBoolean do_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,EGLNativePixmapType target);
+IMPORT_C void (* EGLAPIENTRY do_eglGetProcAddress (const char *procname))(...);
+
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/openvginternal.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of a OpenVG like interface. Basically every OpenVG API names but prefixed with do_ e.g. do_vgSetf
+*/
+
+#ifndef OPENVGINTERNAL_H
+#define OPENVGINTERNAL_H
+
+#include <openvg.h>
+
+/*
+ * defines set of internal vgu functions that are 1:1 with the published openvg functions. 
+ * E.g. vgSetf -> do_vgSetf
+ * 
+ * These do_XXX fucntions are called from the libopenvg.dll (which is a shim) to be processed here
+ */
+
+IMPORT_C VGErrorCode do_vgGetError(void);
+IMPORT_C void do_vgFlush(void);
+IMPORT_C void do_vgFinish(void);
+IMPORT_C void do_vgSetf(VGParamType type, VGfloat value);
+IMPORT_C void do_vgSeti(VGParamType type, VGint value);
+IMPORT_C void do_vgSetfv(VGParamType type, VGint count ,const VGfloat* values);
+IMPORT_C void do_vgSetiv(VGParamType type, VGint count ,const VGint* values);
+IMPORT_C VGfloat do_vgGetf(VGParamType type);
+IMPORT_C VGint do_vgGeti(VGParamType type);
+IMPORT_C VGint do_vgGetVectorSize(VGParamType type);
+IMPORT_C void do_vgGetfv(VGParamType type, VGint count ,VGfloat* values);
+IMPORT_C void do_vgGetiv(VGParamType type, VGint count ,VGint* values);
+IMPORT_C void do_vgSetParameterf(VGHandle object ,VGint paramType ,VGfloat value);
+IMPORT_C void do_vgSetParameteri(VGHandle object ,VGint paramType ,VGint value);
+IMPORT_C void do_vgSetParameterfv(VGHandle object ,VGint paramType ,VGint count ,const VGfloat* values);
+IMPORT_C void do_vgSetParameteriv(VGHandle object ,VGint paramType ,VGint count ,const VGint* values);
+IMPORT_C VGfloat do_vgGetParameterf(VGHandle object ,VGint paramType);
+IMPORT_C VGint do_vgGetParameteri(VGHandle object ,VGint paramType);
+IMPORT_C VGint do_vgGetParameterVectorSize(VGHandle object ,VGint paramType);
+IMPORT_C void do_vgGetParameterfv(VGHandle object ,VGint paramType ,VGint count ,VGfloat* values);
+IMPORT_C void do_vgGetParameteriv(VGHandle object ,VGint paramType ,VGint count ,VGint* values);
+IMPORT_C void do_vgLoadIdentity(void);
+IMPORT_C void do_vgLoadMatrix(const VGfloat* m);
+IMPORT_C void do_vgGetMatrix(VGfloat* m);
+IMPORT_C void do_vgMultMatrix(const  VGfloat* m);
+IMPORT_C void do_vgTranslate(VGfloat tx, VGfloat ty);
+IMPORT_C void do_vgScale(VGfloat sx, VGfloat sy);
+IMPORT_C void do_vgShear(VGfloat shx, VGfloat shy);
+IMPORT_C void do_vgRotate(VGfloat angle);
+IMPORT_C void do_vgMask(VGHandle mask, VGMaskOperation operation ,VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C void do_vgRenderToMask(VGPath path ,VGbitfield paintModes ,VGMaskOperation operation);
+IMPORT_C VGMaskLayer do_vgCreateMaskLayer(VGint width, VGint height);
+IMPORT_C void do_vgDestroyMaskLayer(VGMaskLayer maskLayer);
+IMPORT_C void do_vgFillMaskLayer(VGMaskLayer maskLayer ,VGint x, VGint y ,VGint width, VGint height ,VGfloat value);
+IMPORT_C void do_vgCopyMask(VGMaskLayer maskLayer ,VGint sx, VGint sy ,VGint dx, VGint dy ,VGint width, VGint height);
+IMPORT_C void do_vgClear(VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C VGPath do_vgCreatePath(VGint pathFormat ,VGPathDatatype datatype ,VGfloat scale, VGfloat bias ,VGint segmentCapacityHint ,VGint coordCapacityHint ,VGbitfield capabilities);
+IMPORT_C void do_vgClearPath(VGPath path, VGbitfield capabilities);
+IMPORT_C void do_vgDestroyPath(VGPath path);
+IMPORT_C void do_vgRemovePathCapabilities(VGPath path ,VGbitfield capabilities);
+IMPORT_C VGbitfield do_vgGetPathCapabilities(VGPath path);
+IMPORT_C void do_vgAppendPath(VGPath dstPath, VGPath srcPath);
+IMPORT_C void do_vgAppendPathData(VGPath dstPath ,VGint numSegments ,const  VGubyte* pathSegments ,const  void* pathData);
+IMPORT_C void do_vgModifyPathCoords(VGPath dstPath ,VGint startIndex ,VGint numSegments ,const void* pathData);
+IMPORT_C void do_vgTransformPath(VGPath dstPath, VGPath srcPath);
+IMPORT_C VGboolean do_vgInterpolatePath(VGPath dstPath ,VGPath startPath ,VGPath endPath ,VGfloat amount);
+IMPORT_C VGfloat do_vgPathLength(VGPath path ,VGint startSegment ,VGint numSegments);
+IMPORT_C void do_vgPointAlongPath(VGPath path ,VGint startSegment ,VGint numSegments ,VGfloat distance ,VGfloat* x, VGfloat* y ,VGfloat* tangentX ,VGfloat* tangentY);
+IMPORT_C void do_vgPathBounds(VGPath path ,VGfloat* minX ,VGfloat* minY ,VGfloat* width ,VGfloat* height);
+IMPORT_C void do_vgPathTransformedBounds(VGPath path ,VGfloat* minX ,VGfloat* minY ,VGfloat* width ,VGfloat* height);
+IMPORT_C void do_vgDrawPath(VGPath path, VGbitfield paintModes);
+IMPORT_C VGPaint do_vgCreatePaint(void);
+IMPORT_C void do_vgDestroyPaint(VGPaint paint);
+IMPORT_C void do_vgSetPaint(VGPaint paint, VGbitfield paintModes);
+IMPORT_C VGPaint do_vgGetPaint(VGPaintMode paintMode);
+IMPORT_C void do_vgSetColor(VGPaint paint, VGuint rgba);
+IMPORT_C VGuint do_vgGetColor(VGPaint paint);
+IMPORT_C void do_vgPaintPattern(VGPaint paint, VGImage pattern);
+IMPORT_C VGImage do_vgCreateImage(VGImageFormat format ,VGint width, VGint height ,VGbitfield allowedQuality);
+IMPORT_C void do_vgDestroyImage(VGImage image);
+IMPORT_C void do_vgClearImage(VGImage image ,VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C void do_vgImageSubData(VGImage image ,const void* data ,VGint dataStride ,VGImageFormat dataFormat ,VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C void do_vgGetImageSubData(VGImage image ,void* data ,VGint dataStride ,VGImageFormat dataFormat ,VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C VGImage do_vgChildImage(VGImage parent ,VGint x, VGint y ,VGint width, VGint height);
+IMPORT_C VGImage do_vgGetParent(VGImage image);
+IMPORT_C void do_vgCopyImage(VGImage dst, VGint dx, VGint dy ,VGImage src, VGint sx, VGint sy ,VGint width, VGint height ,VGboolean dither);
+IMPORT_C void do_vgDrawImage(VGImage image);
+IMPORT_C void do_vgSetPixels(VGint dx, VGint dy ,VGImage src, VGint sx, VGint sy ,VGint width, VGint height);
+IMPORT_C void do_vgWritePixels(const void* data, VGint dataStride ,VGImageFormat dataFormat ,VGint dx, VGint dy ,VGint width, VGint height);
+IMPORT_C void do_vgGetPixels(VGImage dst, VGint dx, VGint dy ,VGint sx, VGint sy ,VGint width, VGint height);
+IMPORT_C void do_vgReadPixels(void* data, VGint dataStride ,VGImageFormat dataFormat ,VGint sx, VGint sy ,VGint width, VGint height);
+IMPORT_C void do_vgCopyPixels(VGint dx, VGint dy ,VGint sx, VGint sy ,VGint width, VGint height);
+IMPORT_C VGFont do_vgCreateFont(VGint glyphCapacityHint);
+IMPORT_C void do_vgDestroyFont(VGFont font);
+IMPORT_C void do_vgSetGlyphToPath(VGFont font ,VGuint glyphIndex ,VGPath path ,VGboolean isHinted ,const VGfloat glyphOrigin [2] ,const VGfloat escapement[2]);
+IMPORT_C void do_vgSetGlyphToImage(VGFont font ,VGuint glyphIndex ,VGImage image ,const VGfloat glyphOrigin [2] ,const VGfloat escapement[2]);
+IMPORT_C void do_vgClearGlyph(VGFont font ,VGuint glyphIndex);
+IMPORT_C void do_vgDrawGlyph(VGFont font ,VGuint glyphIndex ,VGbitfield paintModes ,VGboolean allowAutoHinting);
+IMPORT_C void do_vgDrawGlyphs(VGFont font ,VGint glyphCount ,const VGuint* glyphIndices ,const VGfloat* adjustments_x ,const VGfloat* adjustments_y ,VGbitfield paintModes ,VGboolean allowAutoHinting);
+IMPORT_C void do_vgColorMatrix(VGImage dst, VGImage src ,const VGfloat* matrix);
+IMPORT_C void do_vgConvolve(VGImage dst, VGImage src ,VGint kernelWidth, VGint kernelHeight ,VGint shiftX, VGint shiftY ,const VGshort* kernel ,VGfloat scale ,VGfloat bias ,VGTilingMode tilingMode);
+IMPORT_C void do_vgSeparableConvolve(VGImage dst, VGImage src ,VGint kernelWidth ,VGint kernelHeight ,VGint shiftX, VGint shiftY ,const VGshort* kernelX ,const VGshort* kernelY ,VGfloat scale ,VGfloat bias ,VGTilingMode tilingMode);
+IMPORT_C void do_vgGaussianBlur(VGImage dst, VGImage src ,VGfloat stdDeviationX ,VGfloat stdDeviationY ,VGTilingMode tilingMode);
+IMPORT_C void do_vgLookup(VGImage dst, VGImage src ,const VGubyte* redLUT ,const VGubyte* greenLUT ,const VGubyte* blueLUT ,const VGubyte* alphaLUT ,VGboolean outputLinear ,VGboolean outputPremultiplied);
+IMPORT_C void do_vgLookupSingle(VGImage dst, VGImage src ,const VGuint* lookupTable ,VGImageChannel sourceChannel ,VGboolean outputLinear ,VGboolean outputPremultiplied);
+IMPORT_C VGHardwareQueryResult do_vgHardwareQuery(VGHardwareQueryType key ,VGint setting);
+IMPORT_C const VGubyte * do_vgGetString(VGStringID name);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/vguinternal.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of VGU like interface. Basically every VGU API names but prefixed with do_ e.g. do_vguLine
+*/
+
+#ifndef VGUINTERNAL_H
+#define VGUINTERNAL_H
+
+#include <vgu.h>
+
+/*
+ * defines set of internal vgu functions that are 1:1 with the published vgu functions.
+ * E.g. vguLine -> do_vguLine
+ * 
+ * These do_XXX fucntions are called from the libopenvgu.dll (which is a shim) to be processed here
+ */
+
+IMPORT_C VGUErrorCode do_vguLine(VGPath path, VGfloat x0, VGfloat y0, VGfloat x1, VGfloat y1);
+IMPORT_C VGUErrorCode do_vguPolygon(VGPath path, const VGfloat * points, VGint count, VGboolean closed);
+IMPORT_C VGUErrorCode do_vguRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height);
+IMPORT_C VGUErrorCode do_vguRoundRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat arcWidth, VGfloat arcHeight);
+IMPORT_C VGUErrorCode do_vguEllipse(VGPath path, VGfloat cx, VGfloat cy, VGfloat width, VGfloat height);
+IMPORT_C VGUErrorCode do_vguArc(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, VGUArcType arcType);
+IMPORT_C VGUErrorCode do_vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix);
+IMPORT_C VGUErrorCode do_vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat * matrix);
+IMPORT_C VGUErrorCode do_vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riApi.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,4038 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementations of OpenVG API functions.
+ * \note	The actual processing is done in Path, Image, Rasterizer and PixelPipe classes.
+ *//*-------------------------------------------------------------------*/
+
+#include "openvg.h"
+#include "egl.h"
+#include "riContext.h"
+#include "riRasterizer.h"
+#include "riPixelPipe.h"
+#include "riPath.h"
+#include <stdio.h>
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+#include "openvginternal.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/* EGL&OS functions for use in an OpenVG implementation */
+void* eglvgGetCurrentVGContext(void);
+bool  eglvgIsInUse(void* image);
+void  OSAcquireMutex(void);
+void  OSReleaseMutex(void);
+
+
+#define RI_NO_RETVAL
+
+//this must be the first line in an API function
+#define RI_GET_CONTEXT(RETVAL) \
+	OSAcquireMutex(); \
+	VGContext* context = (VGContext*)eglvgGetCurrentVGContext(); \
+	if(!context) \
+	{ \
+		OSReleaseMutex(); \
+		return RETVAL;\
+	}
+
+#define RI_IF_ERROR(COND, ERRORCODE, RETVAL) \
+	if(COND) { context->setError(ERRORCODE); OSReleaseMutex(); return RETVAL; }
+
+//all API functions must call this as their last operation (also functions that don't return values)
+//NOTE: don't evaluate anything or read state in RETVAL (it'll be executed after the mutex has been released)
+#define RI_RETURN(RETVAL) \
+	{ OSReleaseMutex(); \
+	return RETVAL; }
+
+static bool isAligned(const void* ptr, int alignment)
+{
+	RI_ASSERT(alignment == 1 || alignment == 2 || alignment == 4);
+	if(((RIuintptr)ptr) & (alignment-1))
+		return false;
+	return true;
+}
+
+static bool isAligned(const void* ptr, VGImageFormat format)
+{
+	RI_ASSERT(isValidImageFormat(format));
+	int alignment = Color::formatToDescriptor(format).bitsPerPixel >> 3;
+	if(alignment <= 1)
+		return true;	//one bit or byte per pixel
+	return isAligned(ptr, alignment);
+}
+
+bool isValidImageFormat(int f)
+{
+	if(f < VG_sRGBX_8888 || f > VG_lABGR_8888_PRE)
+		return false;
+	return true;
+}
+
+bool isValidImageFormat(EGLNativePixmapType f)
+  {
+#warning TODO: implement isValidImageFormat for EGLNativePixmapType arg
+  return false;
+  }
+
+}	//namespace OpenVGRI
+
+using namespace OpenVGRI;
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgFlush(void)
+#else
+void RI_APIENTRY vgFlush(void)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	//the RI doesn't cache anything, so this is a no-op
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-----
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgFinish(void)
+#else
+void RI_APIENTRY vgFinish(void)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	//the RI doesn't cache anything, so this is a no-op
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGErrorCode RI_APIENTRY do_vgGetError(void)
+#else
+VGErrorCode RI_APIENTRY vgGetError(void)
+#endif
+{
+	RI_GET_CONTEXT(VG_NO_CONTEXT_ERROR);
+	VGErrorCode error = context->m_error;
+	context->m_error = VG_NO_ERROR;
+	RI_RETURN(error);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+namespace OpenVGRI
+{
+
+RIfloat inputFloat(VGfloat f)
+{
+	//this function is used for all floating point input values
+	if(RI_ISNAN(f)) return 0.0f;	//convert NaN to zero
+	return RI_CLAMP(f, -RI_FLOAT_MAX, RI_FLOAT_MAX);	//clamp +-inf to +-RIfloat max
+}
+
+Vector2 inputVector2(const Vector2& v)
+{
+    return Vector2(inputFloat(v.x), inputFloat(v.y));
+}
+
+Color inputColor(const Color& c)
+{
+    Color r = c;
+    r.r = inputFloat(r.r);
+    r.g = inputFloat(r.g);
+    r.b = inputFloat(r.b);
+    r.a = inputFloat(r.a);
+    return r;
+}
+
+static int inputFloatToInt(VGfloat value)
+{
+	double v = (double)floor(value);
+	v = v > (double)RI_INT32_MAX ? (double)RI_INT32_MAX : v;
+	v = v < (double)RI_INT32_MIN ? (double)RI_INT32_MIN : v;
+	return (int)v;
+}
+
+static int paramToInt(const void* values, bool floats, int count, int i)
+{
+	RI_ASSERT(i >= 0);
+	if(i >= count || !values)
+		return 0;
+	if(floats)
+		return inputFloatToInt(((const VGfloat*)values)[i]);
+	return (int)((const VGint*)values)[i];
+}
+
+static RIfloat paramToFloat(const void* values, bool floats, int count, int i)
+{
+	RI_ASSERT(i >= 0);
+	if(i >= count || !values)
+		return 0.0f;
+	if(floats)
+		return ((const VGfloat*)values)[i];
+	return (RIfloat)((const VGint*)values)[i];
+}
+
+static void floatToParam(void* output, bool outputFloats, int count, int i, VGfloat value)
+{
+	RI_ASSERT(i >= 0);
+	RI_ASSERT(output);
+	if(i >= count)
+		return;
+	if(outputFloats)
+		((VGfloat*)output)[i] = value;
+	else
+		((VGint*)output)[i] = (VGint)inputFloatToInt(value);
+}
+
+static void intToParam(void* output, bool outputFloats, int count, int i, VGint value)
+{
+	RI_ASSERT(i >= 0);
+	RI_ASSERT(output);
+	if(i >= count)
+		return;
+	if(outputFloats)
+		((VGfloat*)output)[i] = (VGfloat)value;
+	else
+		((VGint*)output)[i] = value;
+}
+
+}	//namespace OpenVGRI
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void setifv(VGContext* context, VGParamType type, VGint count, const void* values, bool floats)
+{
+	RI_ASSERT(context);
+	RI_ASSERT(!count || (count && values));
+
+	int ivalue = paramToInt(values, floats, count, 0);
+	RIfloat fvalue = paramToFloat(values, floats, count, 0);
+
+	switch(type)
+	{
+	case VG_MATRIX_MODE:
+		if(count != 1 || ivalue < VG_MATRIX_PATH_USER_TO_SURFACE || ivalue > VG_MATRIX_GLYPH_USER_TO_SURFACE)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_matrixMode = (VGMatrixMode)ivalue;
+		break;
+
+	case VG_FILL_RULE:
+		if(count != 1 || ivalue < VG_EVEN_ODD || ivalue > VG_NON_ZERO)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_fillRule = (VGFillRule)ivalue;
+		break;
+
+	case VG_IMAGE_QUALITY:
+		if(count != 1 || ivalue < VG_IMAGE_QUALITY_NONANTIALIASED || ivalue > VG_IMAGE_QUALITY_BETTER)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_imageQuality = (VGImageQuality)ivalue;
+		break;
+
+	case VG_RENDERING_QUALITY:
+		if(count != 1 || ivalue < VG_RENDERING_QUALITY_NONANTIALIASED || ivalue > VG_RENDERING_QUALITY_BETTER)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_renderingQuality = (VGRenderingQuality)ivalue;
+		break;
+
+	case VG_BLEND_MODE:
+		if(count != 1 || ivalue < VG_BLEND_SRC || ivalue > VG_BLEND_ADDITIVE)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_blendMode = (VGBlendMode)ivalue;
+		break;
+
+	case VG_IMAGE_MODE:
+		if(count != 1 || ivalue < VG_DRAW_IMAGE_NORMAL || ivalue > VG_DRAW_IMAGE_STENCIL)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_imageMode = (VGImageMode)ivalue;
+		break;
+
+	case VG_SCISSOR_RECTS:
+	{
+		if(count & 3)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }	//count must be a multiple of four
+		try
+		{
+			Array<Rectangle> scissor;
+			for(int i=0;i<RI_INT_MIN(count, RI_MAX_SCISSOR_RECTANGLES*4);i+=4)
+			{
+				Rectangle s;
+				s.x = paramToInt(values, floats, count, i+0);
+				s.y = paramToInt(values, floats, count, i+1);
+				s.width = paramToInt(values, floats, count, i+2);
+				s.height = paramToInt(values, floats, count, i+3);
+				scissor.push_back(s);	//throws bad_alloc
+			}
+			context->m_scissor.swap(scissor);	//replace context data
+		}
+		catch(std::bad_alloc)
+		{
+			context->setError(VG_OUT_OF_MEMORY_ERROR);
+		}
+		break;
+	}
+
+	case VG_COLOR_TRANSFORM:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_colorTransform = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_COLOR_TRANSFORM_VALUES:
+		if(count != 8 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+        {
+            for(int i=0;i<8;i++)
+            {
+                context->m_inputColorTransformValues[i] = paramToFloat(values, floats, count, i);
+                context->m_colorTransformValues[i] = inputFloat(context->m_inputColorTransformValues[i]);
+            }
+        }
+		break;
+
+	case VG_STROKE_LINE_WIDTH:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputStrokeLineWidth = fvalue;
+        context->m_strokeLineWidth = inputFloat(fvalue);
+		break;
+
+	case VG_STROKE_CAP_STYLE:
+		if(count != 1 || ivalue < VG_CAP_BUTT || ivalue > VG_CAP_SQUARE)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_strokeCapStyle = (VGCapStyle)ivalue;
+		break;
+
+	case VG_STROKE_JOIN_STYLE:
+		if(count != 1 || ivalue < VG_JOIN_MITER || ivalue > VG_JOIN_BEVEL)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_strokeJoinStyle = (VGJoinStyle)ivalue;
+		break;
+
+	case VG_STROKE_MITER_LIMIT:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputStrokeMiterLimit = fvalue;
+		context->m_strokeMiterLimit = inputFloat(fvalue);
+		break;
+
+	case VG_STROKE_DASH_PATTERN:
+	{
+		try
+		{
+			Array<RIfloat> inputStrokeDashPattern;
+			Array<RIfloat> strokeDashPattern;
+			for(int i=0;i<RI_INT_MIN(count, RI_MAX_DASH_COUNT);i++)
+            {
+                RIfloat v = paramToFloat(values, floats, count, i);
+				inputStrokeDashPattern.push_back(v);	//throws bad_alloc
+				strokeDashPattern.push_back(inputFloat(v));	//throws bad_alloc
+            }
+			context->m_inputStrokeDashPattern.swap(inputStrokeDashPattern);	//replace context data
+			context->m_strokeDashPattern.swap(strokeDashPattern);	//replace context data
+		}
+		catch(std::bad_alloc)
+		{
+			context->setError(VG_OUT_OF_MEMORY_ERROR);
+		}
+		break;
+	}
+
+	case VG_STROKE_DASH_PHASE:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputStrokeDashPhase = fvalue;
+		context->m_strokeDashPhase = inputFloat(fvalue);
+		break;
+
+	case VG_STROKE_DASH_PHASE_RESET:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_strokeDashPhaseReset = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_TILE_FILL_COLOR:
+		if(count != 4 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputTileFillColor.set(paramToFloat(values, floats, count, 0),
+									 paramToFloat(values, floats, count, 1),
+									 paramToFloat(values, floats, count, 2),
+									 paramToFloat(values, floats, count, 3),
+									 Color::sRGBA);
+        context->m_tileFillColor = inputColor(context->m_inputTileFillColor);
+		break;
+
+	case VG_GLYPH_ORIGIN:
+		if(count != 2 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputGlyphOrigin.x = paramToFloat(values, floats, count, 0);
+		context->m_inputGlyphOrigin.y = paramToFloat(values, floats, count, 1);
+		context->m_glyphOrigin = inputVector2(context->m_inputGlyphOrigin);
+		break;
+
+	case VG_CLEAR_COLOR:
+		if(count != 4 || !values) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_inputClearColor.set(paramToFloat(values, floats, count, 0),
+								  paramToFloat(values, floats, count, 1),
+								  paramToFloat(values, floats, count, 2),
+								  paramToFloat(values, floats, count, 3),
+								  Color::sRGBA);
+        context->m_clearColor = inputColor(context->m_inputClearColor);
+		break;
+
+	case VG_MASKING:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_masking = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_SCISSORING:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_scissoring = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_PIXEL_LAYOUT:
+		if(count != 1 || ivalue < VG_PIXEL_LAYOUT_UNKNOWN || ivalue > VG_PIXEL_LAYOUT_BGR_HORIZONTAL)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_pixelLayout = (VGPixelLayout)ivalue;
+		break;
+
+	case VG_SCREEN_LAYOUT:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		break;	//setting read-only values has no effect
+
+	case VG_FILTER_FORMAT_LINEAR:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_filterFormatLinear = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_FILTER_FORMAT_PREMULTIPLIED:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		context->m_filterFormatPremultiplied = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_FILTER_CHANNEL_MASK:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		//undefined bits are ignored
+		context->m_filterChannelMask = (VGbitfield)ivalue;
+		break;
+
+	case VG_MAX_SCISSOR_RECTS:
+	case VG_MAX_DASH_COUNT:
+	case VG_MAX_KERNEL_SIZE:
+	case VG_MAX_SEPARABLE_KERNEL_SIZE:
+	case VG_MAX_COLOR_RAMP_STOPS:
+	case VG_MAX_IMAGE_WIDTH:
+	case VG_MAX_IMAGE_HEIGHT:
+	case VG_MAX_IMAGE_PIXELS:
+	case VG_MAX_IMAGE_BYTES:
+	case VG_MAX_FLOAT:
+	case VG_MAX_GAUSSIAN_STD_DEVIATION:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		break;	//setting read-only values has no effect
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetf(VGParamType type, VGfloat value)
+#else
+void RI_APIENTRY vgSetf(VGParamType type, VGfloat value)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+				type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//vector type value
+	VGfloat values[1] = {value};
+	setifv(context, type, 1, values, true);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSeti(VGParamType type, VGint value)
+#else
+void RI_APIENTRY vgSeti(VGParamType type, VGint value)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+				type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//vector type value
+	VGint values[1] = {value};
+	setifv(context, type, 1, values, false);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetiv(VGParamType type, VGint count, const VGint * values)
+#else 
+void RI_APIENTRY vgSetiv(VGParamType type, VGint count, const VGint * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count < 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR((!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	setifv(context, type, count, values, false);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetfv(VGParamType type, VGint count, const VGfloat * values)
+#else
+void RI_APIENTRY vgSetfv(VGParamType type, VGint count, const VGfloat * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count < 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR((!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	setifv(context, type, count, values, true);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void getifv(VGContext* context, VGParamType type, VGint count, void* values, bool floats)
+{
+	switch(type)
+	{
+	case VG_MATRIX_MODE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_matrixMode);
+		break;
+
+	case VG_FILL_RULE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_fillRule);
+		break;
+
+	case VG_IMAGE_QUALITY:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_imageQuality);
+		break;
+
+	case VG_RENDERING_QUALITY:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_renderingQuality);
+		break;
+
+	case VG_BLEND_MODE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_blendMode);
+		break;
+
+	case VG_IMAGE_MODE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_imageMode);
+		break;
+
+	case VG_SCISSOR_RECTS:
+	{
+		if(count > context->m_scissor.size()*4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		for(int i=0;i<context->m_scissor.size();i++)
+		{
+			intToParam(values, floats, count, i*4+0, context->m_scissor[i].x);
+			intToParam(values, floats, count, i*4+1, context->m_scissor[i].y);
+			intToParam(values, floats, count, i*4+2, context->m_scissor[i].width);
+			intToParam(values, floats, count, i*4+3, context->m_scissor[i].height);
+		}
+		break;
+	}
+
+	case VG_COLOR_TRANSFORM:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_colorTransform);
+		break;
+
+	case VG_COLOR_TRANSFORM_VALUES:
+		if(count > 8) { context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+        {
+            for(int i=0;i<count;i++)
+            {
+                floatToParam(values, floats, count, i, context->m_inputColorTransformValues[i]);
+            }
+        }
+		break;
+
+	case VG_STROKE_LINE_WIDTH:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputStrokeLineWidth);
+		break;
+
+	case VG_STROKE_CAP_STYLE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_strokeCapStyle);
+		break;
+
+	case VG_STROKE_JOIN_STYLE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_strokeJoinStyle);
+		break;
+
+	case VG_STROKE_MITER_LIMIT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputStrokeMiterLimit);
+		break;
+
+	case VG_STROKE_DASH_PATTERN:
+	{
+		if(count > context->m_inputStrokeDashPattern.size())	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		for(int i=0;i<context->m_inputStrokeDashPattern.size();i++)
+			floatToParam(values, floats, count, i, context->m_inputStrokeDashPattern[i]);
+		break;
+	}
+
+	case VG_STROKE_DASH_PHASE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputStrokeDashPhase);
+		break;
+
+	case VG_STROKE_DASH_PHASE_RESET:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_strokeDashPhaseReset);
+		break;
+
+	case VG_TILE_FILL_COLOR:
+		if(count > 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputTileFillColor.r);
+		floatToParam(values, floats, count, 1, context->m_inputTileFillColor.g);
+		floatToParam(values, floats, count, 2, context->m_inputTileFillColor.b);
+		floatToParam(values, floats, count, 3, context->m_inputTileFillColor.a);
+		break;
+
+	case VG_CLEAR_COLOR:
+		if(count > 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputClearColor.r);
+		floatToParam(values, floats, count, 1, context->m_inputClearColor.g);
+		floatToParam(values, floats, count, 2, context->m_inputClearColor.b);
+		floatToParam(values, floats, count, 3, context->m_inputClearColor.a);
+		break;
+
+	case VG_GLYPH_ORIGIN:
+		if(count > 2)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, context->m_inputGlyphOrigin.x);
+		floatToParam(values, floats, count, 1, context->m_inputGlyphOrigin.y);
+		break;
+
+	case VG_MASKING:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_masking);
+		break;
+
+	case VG_SCISSORING:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_scissoring);
+		break;
+
+	case VG_PIXEL_LAYOUT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_pixelLayout);
+		break;
+
+	case VG_SCREEN_LAYOUT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, VG_PIXEL_LAYOUT_UNKNOWN);
+		break;
+
+	case VG_FILTER_FORMAT_LINEAR:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_filterFormatLinear);
+		break;
+
+	case VG_FILTER_FORMAT_PREMULTIPLIED:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_filterFormatPremultiplied);
+		break;
+
+	case VG_FILTER_CHANNEL_MASK:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, context->m_filterChannelMask);
+		break;
+
+	case VG_MAX_SCISSOR_RECTS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_SCISSOR_RECTANGLES);
+		break;
+
+	case VG_MAX_DASH_COUNT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_DASH_COUNT);
+		break;
+
+	case VG_MAX_KERNEL_SIZE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_KERNEL_SIZE);
+		break;
+
+	case VG_MAX_SEPARABLE_KERNEL_SIZE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_SEPARABLE_KERNEL_SIZE);
+		break;
+
+	case VG_MAX_COLOR_RAMP_STOPS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_COLOR_RAMP_STOPS);
+		break;
+
+	case VG_MAX_IMAGE_WIDTH:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_IMAGE_WIDTH);
+		break;
+
+	case VG_MAX_IMAGE_HEIGHT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_IMAGE_HEIGHT);
+		break;
+
+	case VG_MAX_IMAGE_PIXELS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_IMAGE_PIXELS);
+		break;
+
+	case VG_MAX_IMAGE_BYTES:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, RI_MAX_IMAGE_BYTES);
+		break;
+
+	case VG_MAX_FLOAT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, RI_FLOAT_MAX);
+		break;
+
+	case VG_MAX_GAUSSIAN_STD_DEVIATION:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, RI_MAX_GAUSSIAN_STD_DEVIATION);
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGfloat RI_APIENTRY do_vgGetf(VGParamType type)
+#else
+VGfloat RI_APIENTRY vgGetf(VGParamType type)
+#endif
+{
+	RI_GET_CONTEXT(0.0f);
+	RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+				type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, 0.0f);	//vector type value
+	RIfloat ret = 0.0f;
+	getifv(context, type, 1, &ret, true);
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGint RI_APIENTRY do_vgGeti(VGParamType type)
+#else
+VGint RI_APIENTRY vgGeti(VGParamType type)
+#endif
+{
+	RI_GET_CONTEXT(0);
+	RI_IF_ERROR(type == VG_SCISSOR_RECTS || type == VG_STROKE_DASH_PATTERN || type == VG_TILE_FILL_COLOR ||
+				type == VG_CLEAR_COLOR, VG_ILLEGAL_ARGUMENT_ERROR, 0);	//vector type value
+	VGint ret = 0;
+	getifv(context, type, 1, &ret, false);
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetiv(VGParamType type, VGint count, VGint * values)
+#else
+void RI_APIENTRY vgGetiv(VGParamType type, VGint count, VGint * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	getifv(context, type, count, values, false);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetfv(VGParamType type, VGint count, VGfloat * values)
+#else
+void RI_APIENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	getifv(context, type, count, values, true);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGint RI_APIENTRY do_vgGetVectorSize(VGParamType type)
+#else
+VGint RI_APIENTRY vgGetVectorSize(VGParamType type)
+#endif
+{
+	RI_GET_CONTEXT(0);
+	VGint ret = 0;
+	switch(type)
+	{
+	case VG_MATRIX_MODE:
+	case VG_FILL_RULE:
+	case VG_IMAGE_QUALITY:
+	case VG_RENDERING_QUALITY:
+	case VG_BLEND_MODE:
+	case VG_IMAGE_MODE:
+		ret = 1;
+		break;
+
+	case VG_SCISSOR_RECTS:
+		ret = 4*context->m_scissor.size();
+		break;
+
+    case VG_COLOR_TRANSFORM:
+        ret = 1;
+        break;
+
+    case VG_COLOR_TRANSFORM_VALUES:
+        ret = 8;
+        break;
+
+	case VG_STROKE_LINE_WIDTH:
+	case VG_STROKE_CAP_STYLE:
+	case VG_STROKE_JOIN_STYLE:
+	case VG_STROKE_MITER_LIMIT:
+		ret = 1;
+		break;
+
+	case VG_STROKE_DASH_PATTERN:
+		ret = context->m_inputStrokeDashPattern.size();
+		break;
+
+	case VG_STROKE_DASH_PHASE:
+	case VG_STROKE_DASH_PHASE_RESET:
+		ret = 1;
+		break;
+
+	case VG_TILE_FILL_COLOR:
+	case VG_CLEAR_COLOR:
+		ret = 4;
+		break;
+
+	case VG_GLYPH_ORIGIN:
+		ret = 2;
+		break;
+
+	case VG_MASKING:
+	case VG_SCISSORING:
+	case VG_PIXEL_LAYOUT:
+	case VG_SCREEN_LAYOUT:
+	case VG_FILTER_FORMAT_LINEAR:
+	case VG_FILTER_FORMAT_PREMULTIPLIED:
+	case VG_FILTER_CHANNEL_MASK:
+	case VG_MAX_SCISSOR_RECTS:
+	case VG_MAX_DASH_COUNT:
+	case VG_MAX_KERNEL_SIZE:
+	case VG_MAX_SEPARABLE_KERNEL_SIZE:
+	case VG_MAX_COLOR_RAMP_STOPS:
+	case VG_MAX_IMAGE_WIDTH:
+	case VG_MAX_IMAGE_HEIGHT:
+	case VG_MAX_IMAGE_PIXELS:
+	case VG_MAX_IMAGE_BYTES:
+	case VG_MAX_FLOAT:
+	case VG_MAX_GAUSSIAN_STD_DEVIATION:
+		ret = 1;
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void setPaintParameterifv(VGContext* context, Paint* paint, VGPaintParamType paramType, VGint count, const void* values, bool floats)
+{
+	RI_ASSERT(context);
+	RI_ASSERT(paint);
+
+	int ivalue = paramToInt(values, floats, count, 0);
+
+	switch(paramType)
+	{
+	case VG_PAINT_TYPE:
+		if(count != 1 || ivalue < VG_PAINT_TYPE_COLOR || ivalue > VG_PAINT_TYPE_PATTERN)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_paintType = (VGPaintType)ivalue;
+		break;
+
+	case VG_PAINT_COLOR:
+		if(count != 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_inputPaintColor.set(paramToFloat(values, floats, count, 0),
+									 paramToFloat(values, floats, count, 1),
+									 paramToFloat(values, floats, count, 2),
+									 paramToFloat(values, floats, count, 3),
+									 Color::sRGBA);
+		paint->m_paintColor = inputColor(paint->m_inputPaintColor);
+		paint->m_paintColor.clamp();
+		paint->m_paintColor.premultiply();
+		break;
+
+	case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+		if(count != 1 || ivalue < VG_COLOR_RAMP_SPREAD_PAD || ivalue > VG_COLOR_RAMP_SPREAD_REFLECT)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_colorRampSpreadMode = (VGColorRampSpreadMode)ivalue;
+		break;
+
+	case VG_PAINT_COLOR_RAMP_STOPS:
+	{
+		int numStops = count/5;
+		if(count != numStops*5)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }	//count must be a multiple of five
+		try
+		{
+			Array<Paint::GradientStop> colorRampStops;
+			Array<Paint::GradientStop> inputColorRampStops;
+			RIfloat prevOffset = -RI_FLOAT_MAX;
+			bool valid = true;
+			for(int i=0;i<RI_INT_MIN(numStops, RI_MAX_COLOR_RAMP_STOPS);i++)	//NOTE: ignores the final stop if there is not enough parameters
+			{
+				Paint::GradientStop gs;
+				gs.offset = paramToFloat(values, floats, count, i*5);
+				gs.color.set(paramToFloat(values, floats, count, i*5+1),
+							 paramToFloat(values, floats, count, i*5+2),
+							 paramToFloat(values, floats, count, i*5+3),
+							 paramToFloat(values, floats, count, i*5+4),
+							 Color::sRGBA);
+				inputColorRampStops.push_back(gs);
+
+				if(gs.offset < prevOffset)
+					valid = false;	//decreasing sequence, ignore it
+
+				if(gs.offset >= 0.0f && gs.offset <= 1.0f)
+				{
+					gs.color.clamp();
+
+					if(!colorRampStops.size() && gs.offset > 0.0f)
+					{	//the first valid stop is not at 0, replicate the first one
+						RIfloat tmp = gs.offset;
+						gs.offset = 0.0f;
+						colorRampStops.push_back(gs);	//throws bad_alloc
+						gs.offset = tmp;
+					}
+					colorRampStops.push_back(gs);	//throws bad_alloc
+				}
+				prevOffset = gs.offset;
+			}
+			if(valid && colorRampStops.size() && colorRampStops[colorRampStops.size()-1].offset < 1.0f)
+			{	//there is at least one stop, but the last one is not at 1, replicate the last one
+				Paint::GradientStop gs = colorRampStops[colorRampStops.size()-1];
+				gs.offset = 1.0f;
+				colorRampStops.push_back(gs);	//throws bad_alloc
+			}
+			if(!valid || !colorRampStops.size())
+			{	//there are no valid stops, add implicit stops
+				colorRampStops.clear();
+				Paint::GradientStop gs;
+				gs.offset = 0.0f;
+				gs.color.set(0,0,0,1,Color::sRGBA);
+				colorRampStops.push_back(gs);	//throws bad_alloc
+				gs.offset = 1.0f;
+				gs.color.set(1,1,1,1,Color::sRGBA);
+				colorRampStops.push_back(gs);	//throws bad_alloc
+			}
+			RI_ASSERT(colorRampStops.size() >= 2 && colorRampStops.size() <= RI_MAX_COLOR_RAMP_STOPS);
+			paint->m_colorRampStops.swap(colorRampStops);	//set paint array
+			paint->m_inputColorRampStops.swap(inputColorRampStops);	//set paint array
+		}
+		catch(std::bad_alloc)
+		{
+			context->setError(VG_OUT_OF_MEMORY_ERROR);
+		}
+		break;
+	}
+
+	case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+		if(count != 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_colorRampPremultiplied = ivalue ? VG_TRUE : VG_FALSE;
+		break;
+
+	case VG_PAINT_LINEAR_GRADIENT:
+		if(count != 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_inputLinearGradientPoint0.set(paramToFloat(values, floats, count, 0),
+										  paramToFloat(values, floats, count, 1));
+		paint->m_inputLinearGradientPoint1.set(paramToFloat(values, floats, count, 2),
+										  paramToFloat(values, floats, count, 3));
+        paint->m_linearGradientPoint0 = inputVector2(paint->m_inputLinearGradientPoint0);
+        paint->m_linearGradientPoint1 = inputVector2(paint->m_inputLinearGradientPoint1);
+		break;
+
+	case VG_PAINT_RADIAL_GRADIENT:
+		if(count != 5)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_inputRadialGradientCenter.set(paramToFloat(values, floats, count, 0),
+										  paramToFloat(values, floats, count, 1));
+		paint->m_inputRadialGradientFocalPoint.set(paramToFloat(values, floats, count, 2),
+											  paramToFloat(values, floats, count, 3));
+		paint->m_inputRadialGradientRadius = paramToFloat(values, floats, count, 4);
+        paint->m_radialGradientCenter = inputVector2(paint->m_inputRadialGradientCenter);
+        paint->m_radialGradientFocalPoint = inputVector2(paint->m_inputRadialGradientFocalPoint);
+        paint->m_radialGradientRadius = inputFloat(paint->m_inputRadialGradientRadius);
+		break;
+
+	case VG_PAINT_PATTERN_TILING_MODE:
+		if(count != 1 || ivalue < VG_TILE_FILL || ivalue > VG_TILE_REFLECT)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		paint->m_patternTilingMode = (VGTilingMode)ivalue;
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetParameterf(VGHandle object, VGint paramType, VGfloat value)
+#else
+void RI_APIENTRY vgSetParameterf(VGHandle object, VGint paramType, VGfloat value)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isMaskLayer = context->isValidMaskLayer(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+	RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+				paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL); //vector valued parameter
+	VGfloat values[1] = {value};
+	if(isImage)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPath)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+		setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, values, true);
+	}
+	else if(isMaskLayer)
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+    else
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+        if (paramType != VG_FONT_NUM_GLYPHS)
+    		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+    }
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetParameteri(VGHandle object, VGint paramType, VGint value)
+#else
+void RI_APIENTRY vgSetParameteri(VGHandle object, VGint paramType, VGint value)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isMaskLayer = context->isValidMaskLayer(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+	RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+				paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//vector valued parameter
+	VGint values[1] = {value};
+	if(isImage)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPath)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+		setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, values, false);
+	}
+	else if(isMaskLayer)
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+    else
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+        if (paramType != VG_FONT_NUM_GLYPHS)
+    		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+    }
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetParameterfv(VGHandle object, VGint paramType, VGint count, const VGfloat * values)
+#else
+void RI_APIENTRY vgSetParameterfv(VGHandle object, VGint paramType, VGint count, const VGfloat * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count < 0 || (!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isMaskLayer = context->isValidMaskLayer(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+	if(isImage)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPath)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+		setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, true);
+	}
+	else if(isMaskLayer)
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+    else
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+        if (paramType != VG_FONT_NUM_GLYPHS)
+    		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+    }
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetParameteriv(VGHandle object, VGint paramType, VGint count, const VGint * values)
+#else
+void RI_APIENTRY vgSetParameteriv(VGHandle object, VGint paramType, VGint count, const VGint * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count < 0 || (!values && count > 0) || (values && !isAligned(values,4)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isMaskLayer = context->isValidMaskLayer(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isMaskLayer && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL); //invalid object handle
+	if(isImage)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isPath && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_IMAGE_FORMAT || paramType > VG_IMAGE_HEIGHT)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPath)
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPaint && !isMaskLayer && !isFont);
+		if(paramType < VG_PATH_FORMAT || paramType > VG_PATH_NUM_COORDS)
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isMaskLayer && !isFont);
+		setPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, false);
+	}
+	else if(isMaskLayer)
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isFont);
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+	}
+    else
+	{	//read only, the function does nothing
+		RI_ASSERT(!isImage && !isPath && !isPaint && !isMaskLayer && isFont);
+        if (paramType != VG_FONT_NUM_GLYPHS)
+    		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+    }
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void getPaintParameterifv(VGContext* context, Paint* paint, VGPaintParamType type, VGint count, void* values, bool floats)
+{
+	switch(type)
+	{
+	case VG_PAINT_TYPE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, paint->m_paintType);
+		break;
+
+	case VG_PAINT_COLOR:
+		if(count > 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, paint->m_inputPaintColor.r);
+		floatToParam(values, floats, count, 1, paint->m_inputPaintColor.g);
+		floatToParam(values, floats, count, 2, paint->m_inputPaintColor.b);
+		floatToParam(values, floats, count, 3, paint->m_inputPaintColor.a);
+		break;
+
+	case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, paint->m_colorRampSpreadMode);
+		break;
+
+	case VG_PAINT_COLOR_RAMP_STOPS:
+		{
+			if(count > paint->m_inputColorRampStops.size()*5)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+			int j = 0;
+			for(int i=0;i<paint->m_inputColorRampStops.size();i++)
+			{
+				floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].offset);
+				floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.r);
+				floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.g);
+				floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.b);
+				floatToParam(values, floats, count, j++, paint->m_inputColorRampStops[i].color.a);
+			}
+			break;
+		}
+
+	case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, paint->m_colorRampPremultiplied);
+		break;
+
+	case VG_PAINT_LINEAR_GRADIENT:
+		if(count > 4)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, paint->m_inputLinearGradientPoint0.x);
+		floatToParam(values, floats, count, 1, paint->m_inputLinearGradientPoint0.y);
+		floatToParam(values, floats, count, 2, paint->m_inputLinearGradientPoint1.x);
+		floatToParam(values, floats, count, 3, paint->m_inputLinearGradientPoint1.y);
+		break;
+
+	case VG_PAINT_RADIAL_GRADIENT:
+		if(count > 5)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, paint->m_inputRadialGradientCenter.x);
+		floatToParam(values, floats, count, 1, paint->m_inputRadialGradientCenter.y);
+		floatToParam(values, floats, count, 2, paint->m_inputRadialGradientFocalPoint.x);
+		floatToParam(values, floats, count, 3, paint->m_inputRadialGradientFocalPoint.y);
+		floatToParam(values, floats, count, 4, paint->m_inputRadialGradientRadius);
+		break;
+
+	case VG_PAINT_PATTERN_TILING_MODE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, paint->m_patternTilingMode);
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void getPathParameterifv(VGContext* context, Path* path, VGPathParamType type, VGint count, void* values, bool floats)
+{
+	switch(type)
+	{
+	case VG_PATH_FORMAT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, path->getFormat());
+		break;
+
+	case VG_PATH_DATATYPE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, path->getDatatype());
+		break;
+
+	case VG_PATH_SCALE:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, path->getScale());
+		break;
+
+	case VG_PATH_BIAS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		floatToParam(values, floats, count, 0, path->getBias());
+		break;
+
+	case VG_PATH_NUM_SEGMENTS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, path->getNumSegments());
+		break;
+
+	case VG_PATH_NUM_COORDS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, path->getNumCoordinates());
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void getImageParameterifv(VGContext* context, Image* image, VGImageParamType type, VGint count, void* values, bool floats)
+{
+	switch(type)
+	{
+	case VG_IMAGE_FORMAT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		RI_ASSERT(isValidImageFormat(image->getDescriptor().format));
+		intToParam(values, floats, count, 0, image->getDescriptor().format);
+		break;
+
+	case VG_IMAGE_WIDTH:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, image->getWidth());
+		break;
+
+	case VG_IMAGE_HEIGHT:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, image->getHeight());
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void getFontParameterifv(VGContext* context, Font* font, VGFontParamType type, VGint count, void* values, bool floats)
+{
+	switch(type)
+	{
+	case VG_FONT_NUM_GLYPHS:
+		if(count > 1)	{ context->setError(VG_ILLEGAL_ARGUMENT_ERROR); return; }
+		intToParam(values, floats, count, 0, font->getNumGlyphs());
+		break;
+
+	default:
+		context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid VGParamType
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGfloat RI_APIENTRY do_vgGetParameterf(VGHandle object, VGint paramType)
+#else
+VGfloat RI_APIENTRY vgGetParameterf(VGHandle object, VGint paramType)
+#endif
+{
+	RI_GET_CONTEXT(0.0f);
+	RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+				paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, 0.0f);	//vector valued parameter
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0.0f);	//invalid object handle
+	VGfloat ret = 0.0f;
+	if(isImage)
+	{
+		RI_ASSERT(!isPath && !isPaint && !isFont);
+		getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, 1, &ret, true);
+	}
+	else if(isPath)
+	{
+		RI_ASSERT(!isImage && !isPaint && !isFont);
+		getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, 1, &ret, true);
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isFont);
+		getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, &ret, true);
+	}
+	else
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+		getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, 1, &ret, true);
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGint RI_APIENTRY do_vgGetParameteri(VGHandle object, VGint paramType)
+#else
+VGint RI_APIENTRY vgGetParameteri(VGHandle object, VGint paramType)
+#endif
+{
+	RI_GET_CONTEXT(0);
+	RI_IF_ERROR(paramType == VG_PAINT_COLOR || paramType == VG_PAINT_COLOR_RAMP_STOPS || paramType == VG_PAINT_LINEAR_GRADIENT ||
+				paramType == VG_PAINT_RADIAL_GRADIENT, VG_ILLEGAL_ARGUMENT_ERROR, 0);	//vector valued parameter
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0);	//invalid object handle
+	VGint ret = 0;
+	if(isImage)
+	{
+		RI_ASSERT(!isPath && !isPaint && !isFont);
+		getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, 1, &ret, false);
+	}
+	else if(isPath)
+	{
+		RI_ASSERT(!isImage && !isPaint && !isFont);
+		getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, 1, &ret, false);
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isFont);
+		getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, 1, &ret, false);
+	}
+	else
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+		getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, 1, &ret, false);
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat * values)
+#else
+void RI_APIENTRY vgGetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count <= 0 || !values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid object handle
+	if(isImage)
+	{
+		RI_ASSERT(!isPath && !isPaint && !isFont);
+		getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, count, values, true);
+	}
+	else if(isPath)
+	{
+		RI_ASSERT(!isImage && !isPaint && !isFont);
+		getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, count, values, true);
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isFont);
+		getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, true);
+	}
+	else
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+		getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, count, values, true);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetParameteriv(VGHandle object, VGint paramType, VGint count, VGint * values)
+#else
+void RI_APIENTRY vgGetParameteriv(VGHandle object, VGint paramType, VGint count, VGint * values)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(count <= 0 || !values || !isAligned(values,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid object handle
+	if(isImage)
+	{
+		RI_ASSERT(!isPath && !isPaint && !isFont);
+		getImageParameterifv(context, (Image*)object, (VGImageParamType)paramType, count, values, false);
+	}
+	else if(isPath)
+	{
+		RI_ASSERT(!isImage && !isPaint && !isFont);
+		getPathParameterifv(context, (Path*)object, (VGPathParamType)paramType, count, values, false);
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isFont);
+		getPaintParameterifv(context, (Paint*)object, (VGPaintParamType)paramType, count, values, false);
+	}
+	else
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+		getFontParameterifv(context, (Font*)object, (VGFontParamType)paramType, count, values, false);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGint RI_APIENTRY do_vgGetParameterVectorSize(VGHandle object, VGint paramType)
+#else
+VGint RI_APIENTRY vgGetParameterVectorSize(VGHandle object, VGint paramType)
+#endif
+{
+	RI_GET_CONTEXT(0);
+	bool isImage = context->isValidImage(object);
+	bool isPath = context->isValidPath(object);
+	bool isPaint = context->isValidPaint(object);
+	bool isFont = context->isValidFont(object);
+	RI_IF_ERROR(!isImage && !isPath && !isPaint && !isFont, VG_BAD_HANDLE_ERROR, 0);	//invalid object handle
+	int ret = 0;
+	if(isImage)
+	{
+		RI_ASSERT(!isPath && !isPaint && !isFont);
+		switch(paramType)
+		{
+		case VG_IMAGE_FORMAT:
+		case VG_IMAGE_WIDTH:
+		case VG_IMAGE_HEIGHT:
+			ret = 1;
+			break;
+
+		default:
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid paramType
+			break;
+		}
+	}
+	else if(isPath)
+	{
+		RI_ASSERT(!isImage && !isPaint && !isFont);
+		switch(paramType)
+		{
+		case VG_PATH_FORMAT:
+		case VG_PATH_DATATYPE:
+		case VG_PATH_SCALE:
+		case VG_PATH_BIAS:
+		case VG_PATH_NUM_SEGMENTS:
+		case VG_PATH_NUM_COORDS:
+			ret = 1;
+			break;
+
+		default:
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid paramType
+			break;
+		}
+	}
+	else if(isPaint)
+	{
+		RI_ASSERT(!isImage && !isPath && !isFont);
+		switch(paramType)
+		{
+		case VG_PAINT_TYPE:
+		case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
+		case VG_PAINT_PATTERN_TILING_MODE:
+			ret = 1;
+			break;
+
+		case VG_PAINT_COLOR:
+		case VG_PAINT_LINEAR_GRADIENT:
+			ret = 4;
+			break;
+
+		case VG_PAINT_COLOR_RAMP_STOPS:
+			ret = ((Paint*)object)->m_inputColorRampStops.size() * 5;
+			break;
+
+		case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
+			ret = 1;
+			break;
+
+		case VG_PAINT_RADIAL_GRADIENT:
+			ret = 5;
+			break;
+			
+		default:
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid paramType
+			break;
+		}
+	}
+	else
+	{
+		RI_ASSERT(!isImage && !isPath && !isPaint && isFont);
+		switch(paramType)
+		{
+		case VG_FONT_NUM_GLYPHS:
+			ret = 1;
+			break;
+
+		default:
+			context->setError(VG_ILLEGAL_ARGUMENT_ERROR);	//invalid paramType
+			break;
+		}
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static Matrix3x3* getCurrentMatrix(VGContext* context)
+{
+	RI_ASSERT(context);
+	switch(context->m_matrixMode)
+	{
+	case VG_MATRIX_PATH_USER_TO_SURFACE:
+		return &context->m_pathUserToSurface;
+
+	case VG_MATRIX_IMAGE_USER_TO_SURFACE:
+		return &context->m_imageUserToSurface;
+
+	case VG_MATRIX_FILL_PAINT_TO_USER:
+		return &context->m_fillPaintToUser;
+
+	case VG_MATRIX_STROKE_PAINT_TO_USER:
+		return &context->m_strokePaintToUser;
+
+	default:
+		RI_ASSERT(context->m_matrixMode == VG_MATRIX_GLYPH_USER_TO_SURFACE);
+		return &context->m_glyphUserToSurface;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgLoadIdentity(void)
+#else
+void RI_APIENTRY vgLoadIdentity(void)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	Matrix3x3* d = getCurrentMatrix(context);
+	d->identity();
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgLoadMatrix(const VGfloat * m)
+#else
+void RI_APIENTRY vgLoadMatrix(const VGfloat * m)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	Matrix3x3* d = getCurrentMatrix(context);
+	d->set(inputFloat(m[0]), inputFloat(m[3]), inputFloat(m[6]),
+		   inputFloat(m[1]), inputFloat(m[4]), inputFloat(m[7]),
+		   inputFloat(m[2]), inputFloat(m[5]), inputFloat(m[8]));
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetMatrix(VGfloat * m)
+#else
+void RI_APIENTRY vgGetMatrix(VGfloat * m)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	Matrix3x3* d = getCurrentMatrix(context);
+	m[0] = (*d)[0][0];
+	m[1] = (*d)[1][0];
+	m[2] = (*d)[2][0];
+	m[3] = (*d)[0][1];
+	m[4] = (*d)[1][1];
+	m[5] = (*d)[2][1];
+	m[6] = (*d)[0][2];
+	m[7] = (*d)[1][2];
+	m[8] = (*d)[2][2];
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgMultMatrix(const VGfloat * m)
+#else
+void RI_APIENTRY vgMultMatrix(const VGfloat * m)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!m || !isAligned(m,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	Matrix3x3 n(inputFloat(m[0]), inputFloat(m[3]), inputFloat(m[6]),
+				inputFloat(m[1]), inputFloat(m[4]), inputFloat(m[7]),
+				inputFloat(m[2]), inputFloat(m[5]), inputFloat(m[8]));
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+		n[2].set(0,0,1);
+
+	Matrix3x3* d = getCurrentMatrix(context);
+	*d *= n;
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);	//force affinity
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgTranslate(VGfloat tx, VGfloat ty)
+#else
+void RI_APIENTRY vgTranslate(VGfloat tx, VGfloat ty)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	Matrix3x3 n(1, 0, inputFloat(tx),
+				0, 1, inputFloat(ty),
+				0, 0, 1 );
+	Matrix3x3* d = getCurrentMatrix(context);
+	*d *= n;
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);	//force affinity
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgScale(VGfloat sx, VGfloat sy)
+#else
+void RI_APIENTRY vgScale(VGfloat sx, VGfloat sy)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	Matrix3x3 n(inputFloat(sx), 0,              0,
+				0,              inputFloat(sy), 0,
+				0,              0,              1 );
+	Matrix3x3* d = getCurrentMatrix(context);
+	*d *= n;
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);	//force affinity
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgShear(VGfloat shx, VGfloat shy)
+#else
+void RI_APIENTRY vgShear(VGfloat shx, VGfloat shy)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	Matrix3x3 n(1,               inputFloat(shx), 0,
+				inputFloat(shy), 1,               0,
+				0,               0,               1);
+	Matrix3x3* d = getCurrentMatrix(context);
+	*d *= n;
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);	//force affinity
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgRotate(VGfloat angle)
+#else
+void RI_APIENTRY vgRotate(VGfloat angle)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RIfloat a = RI_DEG_TO_RAD(inputFloat(angle));
+	Matrix3x3 n((RIfloat)cos(a), -(RIfloat)sin(a), 0,
+				(RIfloat)sin(a),  (RIfloat)cos(a), 0,
+				0,              0,             1 );
+	Matrix3x3* d = getCurrentMatrix(context);
+	*d *= n;
+	if(context->m_matrixMode != VG_MATRIX_IMAGE_USER_TO_SURFACE)
+	{
+		(*d)[2].set(0,0,1);	//force affinity
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgMask(VGHandle mask, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height)
+#else
+void RI_APIENTRY vgMask(VGHandle mask, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+    bool isImage = context->isValidImage(mask);
+    bool isMaskLayer = context->isValidMaskLayer(mask);
+	RI_IF_ERROR(operation != VG_CLEAR_MASK && operation != VG_FILL_MASK && !isImage && !isMaskLayer, VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(operation != VG_CLEAR_MASK && operation != VG_FILL_MASK && isImage && eglvgIsInUse((Image*)mask), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(operation < VG_CLEAR_MASK || operation > VG_SUBTRACT_MASK, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+	RI_IF_ERROR(isMaskLayer && drawable->getNumSamples() != ((Surface*)mask)->getNumSamples(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    if(!drawable || !drawable->getMaskBuffer())
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment or context has no mask buffer
+    }
+    if(isImage)
+        drawable->getMaskBuffer()->mask((Image*)mask, operation, x, y, width, height);
+    else
+        drawable->getMaskBuffer()->mask((Surface*)mask, operation, x, y, width, height);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void renderStroke(const VGContext* context, int w, int h, int numSamples, Path* path, Rasterizer& rasterizer, const PixelPipe* pixelPipe, const Matrix3x3& userToSurface)
+{
+    RI_ASSERT(context);
+    RI_ASSERT(w > 0 && h > 0 && numSamples >= 1 && numSamples <= 32);
+
+    RIuint32* covBuffer = RI_NEW_ARRAY(RIuint32, w*h);
+    memset(covBuffer, 0, w*h*sizeof(RIuint32));
+
+    rasterizer.setup(0, 0, w, h, VG_NON_ZERO, NULL, covBuffer);
+    path->stroke(userToSurface, rasterizer, context->m_strokeDashPattern, context->m_strokeDashPhase, context->m_strokeDashPhaseReset ? true : false,
+                 context->m_strokeLineWidth, context->m_strokeCapStyle, context->m_strokeJoinStyle, RI_MAX(context->m_strokeMiterLimit, 1.0f));	//throws bad_alloc
+
+    int sx,sy,ex,ey;
+    rasterizer.getBBox(sx,sy,ex,ey);
+    RI_ASSERT(sx >= 0 && sx <= w);
+    RI_ASSERT(sy >= 0 && sy <= h);
+    RI_ASSERT(ex >= 0 && ex <= w);
+    RI_ASSERT(ey >= 0 && ey <= h);
+
+    for(int j=sy;j<ey;j++)
+    {
+        for(int i=sx;i<ex;i++)
+        {
+            unsigned int c = covBuffer[j*w+i];
+            if(c)
+            {
+                int coverage = 0;
+                for(int k=0;k<numSamples;k++)
+                {
+                    if(c & (1<<k))
+                        coverage++;
+                }
+                pixelPipe->pixelPipe(i, j, (RIfloat)coverage/(RIfloat)numSamples, c);
+            }
+        }
+    }
+    RI_DELETE_ARRAY(covBuffer);
+}
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgRenderToMask(VGPath path, VGbitfield paintModes, VGMaskOperation operation)
+#else
+void RI_APIENTRY vgRenderToMask(VGPath path, VGbitfield paintModes, VGMaskOperation operation)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!paintModes || (paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid paint mode
+	RI_IF_ERROR(operation < VG_CLEAR_MASK || operation > VG_SUBTRACT_MASK, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* curr = context->getCurrentDrawable();
+    if(!curr || !curr->getMaskBuffer())
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment or context has no mask buffer
+    }
+
+    if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+    {
+        Surface* dummy = NULL;
+        curr->getMaskBuffer()->mask(dummy, operation, 0, 0, curr->getWidth(), curr->getHeight());
+        RI_RETURN(RI_NO_RETVAL);
+    }
+
+	try
+	{
+        Drawable drawable(Color::formatToDescriptor(VG_A_8), curr->getWidth(), curr->getHeight(), curr->getNumSamples(), 1);    //TODO 0 mask bits (mask buffer is not used)
+
+        Rasterizer rasterizer;
+        if(context->m_scissoring)
+            rasterizer.setScissor(context->m_scissor);	//throws bad_alloc
+        int numSamples = rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable.getNumSamples());
+
+        PixelPipe pixelPipe;
+        pixelPipe.setDrawable(&drawable);
+        pixelPipe.setMask(false);
+        pixelPipe.setPaint(NULL);   //use default paint (solid color alpha = 1)
+        pixelPipe.setBlendMode(VG_BLEND_SRC);   //write solid color * coverage to dest
+
+        Matrix3x3 userToSurface = context->m_pathUserToSurface;
+        userToSurface[2].set(0,0,1);	//force affinity
+
+        if(paintModes & VG_FILL_PATH)
+        {
+            drawable.getColorBuffer()->clear(Color(0,0,0,0,drawable.getColorBuffer()->getDescriptor().internalFormat), 0, 0, drawable.getWidth(), drawable.getHeight());
+            ((Path*)path)->fill(userToSurface, rasterizer);	//throws bad_alloc
+            rasterizer.setup(0, 0, drawable.getWidth(), drawable.getHeight(), context->m_fillRule, &pixelPipe, NULL);
+            rasterizer.fill();	//throws bad_alloc
+            curr->getMaskBuffer()->mask(drawable.getColorBuffer(), operation, 0, 0, drawable.getWidth(), drawable.getHeight());
+        }
+
+        if(paintModes & VG_STROKE_PATH && context->m_strokeLineWidth > 0.0f)
+        {
+            drawable.getColorBuffer()->clear(Color(0,0,0,0,drawable.getColorBuffer()->getDescriptor().internalFormat), 0, 0, drawable.getWidth(), drawable.getHeight());
+            renderStroke(context, drawable.getWidth(), drawable.getHeight(), numSamples, (Path*)path, rasterizer, &pixelPipe, userToSurface);
+            curr->getMaskBuffer()->mask(drawable.getColorBuffer(), operation, 0, 0, drawable.getWidth(), drawable.getHeight());
+        }
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGMaskLayer RI_APIENTRY do_vgCreateMaskLayer(VGint width, VGint height)
+#else
+VGMaskLayer RI_APIENTRY vgCreateMaskLayer(VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+	RI_IF_ERROR(width > RI_MAX_IMAGE_WIDTH || height > RI_MAX_IMAGE_HEIGHT || width*height > RI_MAX_IMAGE_PIXELS ||
+				width*height > RI_MAX_IMAGE_BYTES, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+    Drawable* curr = context->getCurrentDrawable();
+    if(!curr || !curr->getMaskBuffer())
+        RI_RETURN(VG_INVALID_HANDLE);   //no current drawing surface
+
+	Surface* layer = NULL;
+	try
+	{
+		layer = RI_NEW(Surface, (Color::formatToDescriptor(VG_A_8), width, height, curr->getNumSamples()));	//throws bad_alloc
+		RI_ASSERT(layer);
+		context->m_maskLayerManager->addResource(layer, context);	//throws bad_alloc
+        layer->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+		RI_RETURN((VGMaskLayer)layer);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(layer);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDestroyMaskLayer(VGMaskLayer maskLayer)
+#else
+void RI_APIENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid handle
+
+	context->m_maskLayerManager->removeResource((Surface*)maskLayer);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgFillMaskLayer(VGMaskLayer maskLayer, VGint x, VGint y, VGint width, VGint height, VGfloat value)
+#else
+void RI_APIENTRY vgFillMaskLayer(VGMaskLayer maskLayer, VGint x, VGint y, VGint width, VGint height, VGfloat value)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid handle
+    RI_IF_ERROR(value < 0.0f || value > 1.0f, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Surface* layer = (Surface*)maskLayer;
+    RI_IF_ERROR(width <= 0 || height <= 0 || x < 0 || y < 0 || x > layer->getWidth()-width || y > layer->getHeight()-height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    layer->clear(Color(1,1,1,value,Color::sRGBA), x, y, width, height);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgCopyMask(VGMaskLayer maskLayer, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgCopyMask(VGMaskLayer maskLayer, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidMaskLayer(maskLayer), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid handle
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable || !drawable->getMaskBuffer())
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment or context has no mask buffer
+    }
+    Surface* layer = (Surface*)maskLayer;
+    RI_IF_ERROR(width <= 0 || height <= 0 || drawable->getNumSamples() != layer->getNumSamples(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    try
+    {   //copy drawing surface mask to mask layer
+        layer->blit(drawable->getMaskBuffer(), sx, sy, dx, dy, width, height);	//throws bad_alloc
+    }
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+    RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgClear(VGint x, VGint y, VGint width, VGint height)
+#else
+void RI_APIENTRY vgClear(VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+
+	try
+	{
+		if(context->m_scissoring)
+			drawable->getColorBuffer()->clear(context->m_clearColor, x, y, width, height, context->m_scissor);	//throws bad_alloc
+		else
+			drawable->getColorBuffer()->clear(context->m_clearColor, x, y, width, height);
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGPath RI_APIENTRY do_vgCreatePath(VGint pathFormat, VGPathDatatype datatype, VGfloat scale, VGfloat bias, VGint segmentCapacityHint, VGint coordCapacityHint, VGbitfield capabilities)
+#else
+VGPath RI_APIENTRY vgCreatePath(VGint pathFormat, VGPathDatatype datatype, VGfloat scale, VGfloat bias, VGint segmentCapacityHint, VGint coordCapacityHint, VGbitfield capabilities)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(pathFormat != VG_PATH_FORMAT_STANDARD, VG_UNSUPPORTED_PATH_FORMAT_ERROR, VG_INVALID_HANDLE);
+	RI_IF_ERROR(datatype < VG_PATH_DATATYPE_S_8 || datatype > VG_PATH_DATATYPE_F, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+	RIfloat s = inputFloat(scale);
+	RIfloat b = inputFloat(bias);
+	RI_IF_ERROR(s == 0.0f, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+	capabilities &= VG_PATH_CAPABILITY_ALL;	//undefined bits are ignored
+
+	Path* path = NULL;
+	try
+	{
+		path = RI_NEW(Path, (pathFormat, datatype, s, b, segmentCapacityHint, coordCapacityHint, capabilities));	//throws bad_alloc
+		RI_ASSERT(path);
+		context->m_pathManager->addResource(path, context);	//throws bad_alloc
+		RI_RETURN((VGPath)path);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(path);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgClearPath(VGPath path, VGbitfield capabilities)
+#else
+void RI_APIENTRY vgClearPath(VGPath path, VGbitfield capabilities)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	capabilities &= VG_PATH_CAPABILITY_ALL;	//undefined bits are ignored
+	((Path*)path)->clear(capabilities);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDestroyPath(VGPath path)
+#else
+void RI_APIENTRY vgDestroyPath(VGPath path)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+
+	context->m_pathManager->removeResource((Path*)path);
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgRemovePathCapabilities(VGPath path, VGbitfield capabilities)
+#else
+void RI_APIENTRY vgRemovePathCapabilities(VGPath path, VGbitfield capabilities)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	capabilities &= VG_PATH_CAPABILITY_ALL;	//undefined bits are ignored
+
+	VGbitfield caps = ((Path*)path)->getCapabilities();
+	caps &= ~capabilities;
+	((Path*)path)->setCapabilities(caps);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGbitfield RI_APIENTRY do_vgGetPathCapabilities(VGPath path)
+#else
+VGbitfield RI_APIENTRY vgGetPathCapabilities(VGPath path)
+#endif
+{
+	RI_GET_CONTEXT(0);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, 0);	//invalid path handle
+	VGbitfield ret = ((Path*)path)->getCapabilities();
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgAppendPathData(VGPath dstPath, VGint numSegments, const VGubyte * pathSegments, const void * pathData)
+#else
+void RI_APIENTRY vgAppendPathData(VGPath dstPath, VGint numSegments, const VGubyte * pathSegments, const void * pathData)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(dstPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	Path* p = (Path*)dstPath;
+	RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_APPEND_TO), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//no append cap
+	RI_IF_ERROR(numSegments <= 0 || !pathSegments || !pathData, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//no segments or data
+	RI_IF_ERROR((p->getDatatype() == VG_PATH_DATATYPE_S_16 && !isAligned(pathData,2)) ||
+				((p->getDatatype() == VG_PATH_DATATYPE_S_32 || p->getDatatype() == VG_PATH_DATATYPE_F) && !isAligned(pathData,4)),
+				VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid alignment
+	for(int i=0;i<numSegments;i++)
+	{
+		VGPathSegment c = (VGPathSegment)(pathSegments[i] & 0x1e);
+		RI_IF_ERROR(c < VG_CLOSE_PATH || c > VG_LCWARC_TO, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid segment
+		RI_IF_ERROR(c & ~0x1f, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//reserved bits are nonzero
+	}
+
+	try
+	{
+		p->appendData((const RIuint8*)pathSegments, numSegments, (const RIuint8*)pathData);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgModifyPathCoords(VGPath dstPath, VGint startIndex, VGint numSegments, const void * pathData)
+#else
+void RI_APIENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex, VGint numSegments, const void * pathData)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(dstPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	Path* p = (Path*)dstPath;
+	RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_MODIFY), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//no modify cap
+	RI_IF_ERROR(!pathData || startIndex < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startIndex, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//no segments
+	RI_IF_ERROR((p->getDatatype() == VG_PATH_DATATYPE_S_16 && !isAligned(pathData,2)) ||
+				((p->getDatatype() == VG_PATH_DATATYPE_S_32 || p->getDatatype() == VG_PATH_DATATYPE_F) && !isAligned(pathData,4)),
+				VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid alignment
+	p->modifyCoords(startIndex, numSegments, (const RIuint8*)pathData);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgAppendPath(VGPath dstPath, VGPath srcPath)
+#else
+void RI_APIENTRY vgAppendPath(VGPath dstPath, VGPath srcPath)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(srcPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_APPEND_TO) ||
+				!(((Path*)srcPath)->getCapabilities() & VG_PATH_CAPABILITY_APPEND_FROM), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//invalid caps
+
+	try
+	{
+		((Path*)dstPath)->append((Path*)srcPath);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgTransformPath(VGPath dstPath, VGPath srcPath)
+#else
+void RI_APIENTRY vgTransformPath(VGPath dstPath, VGPath srcPath)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(srcPath), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_TRANSFORM_TO) ||
+				!(((Path*)srcPath)->getCapabilities() & VG_PATH_CAPABILITY_TRANSFORM_FROM), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//invalid caps
+	try
+	{
+		((Path*)dstPath)->transform((Path*)srcPath, context->m_pathUserToSurface);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static bool drawPath(VGContext* context, VGPath path, const Matrix3x3& userToSurfaceMatrix, VGbitfield paintModes)
+{
+	//set up rendering surface and mask buffer
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+        return false;   //no EGL surface is current at the moment
+
+	Rasterizer rasterizer;
+	if(context->m_scissoring)
+		rasterizer.setScissor(context->m_scissor);	//throws bad_alloc
+	int numSamples = rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable->getNumSamples());
+
+	PixelPipe pixelPipe;
+	pixelPipe.setDrawable(drawable);
+	pixelPipe.setMask(context->m_masking ? true : false);
+	pixelPipe.setBlendMode(context->m_blendMode);
+	pixelPipe.setTileFillColor(context->m_tileFillColor);
+	pixelPipe.setImageQuality(context->m_imageQuality);
+    pixelPipe.setColorTransform(context->m_colorTransform ? true : false, context->m_colorTransformValues);
+
+	Matrix3x3 userToSurface = userToSurfaceMatrix;
+	userToSurface[2].set(0,0,1);	//force affinity
+
+	if(paintModes & VG_FILL_PATH)
+	{
+		pixelPipe.setPaint((Paint*)context->m_fillPaint);
+
+		Matrix3x3 surfaceToPaintMatrix = userToSurface * context->m_fillPaintToUser;
+		if(surfaceToPaintMatrix.invert())
+		{
+			surfaceToPaintMatrix[2].set(0,0,1);		//force affinity
+			pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+
+            rasterizer.setup(0, 0, drawable->getWidth(), drawable->getHeight(), context->m_fillRule, &pixelPipe, NULL);
+			((Path*)path)->fill(userToSurface, rasterizer);	//throws bad_alloc
+			rasterizer.fill();	//throws bad_alloc
+		}
+	}
+
+	if(paintModes & VG_STROKE_PATH && context->m_strokeLineWidth > 0.0f)
+	{
+		pixelPipe.setPaint((Paint*)context->m_strokePaint);
+
+		Matrix3x3 surfaceToPaintMatrix = userToSurface * context->m_strokePaintToUser;
+		if(surfaceToPaintMatrix.invert())
+		{
+			surfaceToPaintMatrix[2].set(0,0,1);		//force affinity
+			pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+
+            renderStroke(context, drawable->getWidth(), drawable->getHeight(), numSamples, (Path*)path, rasterizer, &pixelPipe, userToSurface);
+		}
+	}
+	return true;
+}
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDrawPath(VGPath path, VGbitfield paintModes)
+#else
+void RI_APIENTRY vgDrawPath(VGPath path, VGbitfield paintModes)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!paintModes || (paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid paint mode
+
+	try
+	{
+		if(!drawPath(context, path, context->m_pathUserToSurface, paintModes))
+		{
+			RI_RETURN(RI_NO_RETVAL);
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGfloat RI_APIENTRY do_vgPathLength(VGPath path, VGint startSegment, VGint numSegments)
+#else
+VGfloat RI_APIENTRY vgPathLength(VGPath path, VGint startSegment, VGint numSegments)
+#endif
+
+{
+	RI_GET_CONTEXT(-1.0f);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, -1.0f);	//invalid path handle
+	Path* p = (Path*)path;
+	RI_IF_ERROR(!(p->getCapabilities() & VG_PATH_CAPABILITY_PATH_LENGTH), VG_PATH_CAPABILITY_ERROR, -1.0f);	//invalid caps
+	RI_IF_ERROR(startSegment < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startSegment, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, -1.0f);
+	RIfloat pathLength = -1.0f;
+	try
+	{
+		pathLength = p->getPathLength(startSegment, numSegments);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(pathLength);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgPointAlongPath(VGPath path, VGint startSegment, VGint numSegments, VGfloat distance, VGfloat * x, VGfloat * y, VGfloat * tangentX, VGfloat * tangentY)
+#else
+void RI_APIENTRY vgPointAlongPath(VGPath path, VGint startSegment, VGint numSegments, VGfloat distance, VGfloat * x, VGfloat * y, VGfloat * tangentX, VGfloat * tangentY)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	Path* p = (Path*)path;
+	RI_IF_ERROR((x && y && !(p->getCapabilities() & VG_PATH_CAPABILITY_POINT_ALONG_PATH)) ||
+				(tangentX && tangentY && !(p->getCapabilities() & VG_PATH_CAPABILITY_TANGENT_ALONG_PATH)), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//invalid caps
+	RI_IF_ERROR(startSegment < 0 || numSegments <= 0 || RI_INT_ADDSATURATE(startSegment, numSegments) > p->getNumSegments(), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!isAligned(x,4) || !isAligned(y,4) || !isAligned(tangentX,4) || !isAligned(tangentY,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	try
+	{
+		Vector2 point, tangent;
+		p->getPointAlong(startSegment, numSegments, distance, point, tangent);	//throws bad_alloc
+		if(x && y)
+		{
+			*x = point.x;
+			*y = point.y;
+		}
+		if(tangentX && tangentY)
+		{
+			tangent.normalize();
+			*tangentX = tangent.x;
+			*tangentY = tangent.y;
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgPathBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+#else
+void RI_APIENTRY vgPathBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!(((Path*)path)->getCapabilities() & VG_PATH_CAPABILITY_PATH_BOUNDS), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//invalid caps
+	RI_IF_ERROR(!minx || !miny || !width || !height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!isAligned(minx,4) || !isAligned(miny,4) || !isAligned(width,4) || !isAligned(height,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	try
+	{
+		RIfloat pminx,pminy,pmaxx,pmaxy;
+		((Path*)path)->getPathBounds(pminx, pminy, pmaxx, pmaxy);	//throws bad_alloc
+		*minx = pminx;
+		*miny = pminy;
+		*width = pmaxx - pminx;
+		*height = pmaxy - pminy;
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgPathTransformedBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+#else
+void RI_APIENTRY vgPathTransformedBounds(VGPath path, VGfloat * minx, VGfloat * miny, VGfloat * width, VGfloat * height)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+	RI_IF_ERROR(!(((Path*)path)->getCapabilities() & VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS), VG_PATH_CAPABILITY_ERROR, RI_NO_RETVAL);	//invalid caps
+	RI_IF_ERROR(!minx || !miny || !width || !height, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!isAligned(minx,4) || !isAligned(miny,4) || !isAligned(width,4) || !isAligned(height,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	try
+	{
+		RIfloat pminx, pminy, pmaxx, pmaxy;
+		((Path*)path)->getPathTransformedBounds(context->m_pathUserToSurface, pminx, pminy, pmaxx, pmaxy);	//throws bad_alloc
+		*minx = pminx;
+		*miny = pminy;
+		*width = pmaxx - pminx;
+		*height = pmaxy - pminy;
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGboolean RI_APIENTRY do_vgInterpolatePath(VGPath dstPath, VGPath startPath, VGPath endPath, VGfloat amount)
+#else
+VGboolean RI_APIENTRY vgInterpolatePath(VGPath dstPath, VGPath startPath, VGPath endPath, VGfloat amount)
+#endif
+
+{
+	RI_GET_CONTEXT(VG_FALSE);
+	RI_IF_ERROR(!context->isValidPath(dstPath) || !context->isValidPath(startPath) || !context->isValidPath(endPath), VG_BAD_HANDLE_ERROR, VG_FALSE);	//invalid path handle
+	RI_IF_ERROR(!(((Path*)dstPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_TO) ||
+				!(((Path*)startPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_FROM) ||
+				!(((Path*)endPath)->getCapabilities() & VG_PATH_CAPABILITY_INTERPOLATE_FROM), VG_PATH_CAPABILITY_ERROR, VG_FALSE);	//invalid caps
+	VGboolean ret = VG_FALSE;
+	try
+	{
+		if(((Path*)dstPath)->interpolate((const Path*)startPath, (const Path*)endPath, inputFloat(amount)))	//throws bad_alloc
+			ret = VG_TRUE;
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGPaint RI_APIENTRY do_vgCreatePaint(void)
+#else
+VGPaint RI_APIENTRY vgCreatePaint(void)
+#endif
+
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	Paint* paint = NULL;
+	try
+	{
+		paint = RI_NEW(Paint, ());	//throws bad_alloc
+		RI_ASSERT(paint);
+		context->m_paintManager->addResource(paint, context);	//throws bad_alloc
+		RI_RETURN((VGPaint)paint);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(paint);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDestroyPaint(VGPaint paint)
+#else
+void RI_APIENTRY vgDestroyPaint(VGPaint paint)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid paint handle
+
+	context->m_paintManager->removeResource((Paint*)paint);
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetPaint(VGPaint paint, VGbitfield paintModes)
+#else
+void RI_APIENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(paint && !context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid paint handle
+	RI_IF_ERROR(!paintModes || paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid paint mode
+
+	context->releasePaint(paintModes);
+
+	if(paintModes & VG_FILL_PATH)
+	{
+		if(paint)
+			((Paint*)paint)->addReference();
+		context->m_fillPaint = paint;
+	}
+	if(paintModes & VG_STROKE_PATH)
+	{
+		if(paint)
+			((Paint*)paint)->addReference();
+		context->m_strokePaint = paint;
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetColor(VGPaint paint, VGuint rgba)
+#else
+void RI_APIENTRY vgSetColor(VGPaint paint, VGuint rgba)
+#endif
+
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid paint handle
+	Paint* p = (Paint*)paint;
+	p->m_inputPaintColor.unpack(rgba, Color::formatToDescriptor(VG_sRGBA_8888));
+	p->m_paintColor = inputColor(p->m_inputPaintColor);
+	p->m_paintColor.clamp();
+	p->m_paintColor.premultiply();
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGuint RI_APIENTRY do_vgGetColor(VGPaint paint)
+#else
+VGuint RI_APIENTRY vgGetColor(VGPaint paint)
+#endif
+
+{
+	RI_GET_CONTEXT(0);
+	RI_IF_ERROR(!context->isValidPaint(paint), VG_BAD_HANDLE_ERROR, 0);	//invalid paint handle
+	unsigned int ret = ((Paint*)paint)->m_inputPaintColor.pack(Color::formatToDescriptor(VG_sRGBA_8888));
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGPaint RI_APIENTRY do_vgGetPaint(VGPaintMode paintMode)
+#else
+VGPaint RI_APIENTRY vgGetPaint(VGPaintMode paintMode)
+#endif
+
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(paintMode != VG_FILL_PATH && paintMode != VG_STROKE_PATH, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);	//invalid paint mode
+
+	if(paintMode == VG_FILL_PATH)
+	{
+		RI_RETURN(context->m_fillPaint);
+	}
+	RI_RETURN(context->m_strokePaint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgPaintPattern(VGPaint paint, VGImage image)
+#else
+void RI_APIENTRY vgPaintPattern(VGPaint paint, VGImage image)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidPaint(paint) || (image != VG_INVALID_HANDLE && !context->isValidImage(image)), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid handle
+	Image* img = (Image*)image;
+	Paint* pnt = (Paint*)paint;
+	RI_IF_ERROR(image != VG_INVALID_HANDLE && eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	Image* pattern = pnt->m_pattern;
+	if(pattern)
+	{
+		pattern->removeInUse();
+		if(!pattern->removeReference())
+			RI_DELETE(pattern);
+	}
+	pnt->m_pattern = img;
+	if(img)
+	{
+		img->addReference();
+		img->addInUse();
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGImage RI_APIENTRY do_vgCreateImage(VGImageFormat format, VGint width, VGint height, VGbitfield allowedQuality)
+#else
+VGImage RI_APIENTRY vgCreateImage(VGImageFormat format, VGint width, VGint height, VGbitfield allowedQuality)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(!isValidImageFormat(format), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, VG_INVALID_HANDLE);
+	RI_IF_ERROR(width <= 0 || height <= 0 || !allowedQuality ||
+				(allowedQuality & ~(VG_IMAGE_QUALITY_NONANTIALIASED | VG_IMAGE_QUALITY_FASTER | VG_IMAGE_QUALITY_BETTER)), VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+	RI_IF_ERROR(width > RI_MAX_IMAGE_WIDTH || height > RI_MAX_IMAGE_HEIGHT || width*height > RI_MAX_IMAGE_PIXELS ||
+				((width*Color::formatToDescriptor(format).bitsPerPixel+7)/8)*height > RI_MAX_IMAGE_BYTES, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+	Image* image = NULL;
+	try
+	{
+		image = RI_NEW(Image, (Color::formatToDescriptor(format), width, height, allowedQuality));	//throws bad_alloc
+		RI_ASSERT(image);
+		context->m_imageManager->addResource(image, context);	//throws bad_alloc
+		RI_RETURN((VGImage)image);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(image);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDestroyImage(VGImage image)
+#else
+void RI_APIENTRY vgDestroyImage(VGImage image)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid image handle
+
+	context->m_imageManager->removeResource((Image*)image);
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgClearImage(VGImage image, VGint x, VGint y, VGint width, VGint height)
+#else
+void RI_APIENTRY vgClearImage(VGImage image, VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* img = (Image*)image;
+	RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	img->clear(context->m_clearColor, x, y, width, height);
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgImageSubData(VGImage image, const void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+#else
+void RI_APIENTRY vgImageSubData(VGImage image, const void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* img = (Image*)image;
+	RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	{
+		Image input(Color::formatToDescriptor(dataFormat), width, height, dataStride, const_cast<RIuint8*>((const RIuint8*)data));
+		input.addReference();
+		try
+		{
+			img->blit(input, 0, 0, x, y, width, height, false);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+		}
+		input.removeReference();
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetImageSubData(VGImage image, void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+#else
+void RI_APIENTRY vgGetImageSubData(VGImage image, void * data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* img = (Image*)image;
+	RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	{
+		Image output(Color::formatToDescriptor(dataFormat), width, height, dataStride, (RIuint8*)data);
+		output.addReference();
+		try
+		{
+			output.blit(*img, x, y, 0, 0, width, height, false);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+		}
+		output.removeReference();
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGImage RI_APIENTRY do_vgChildImage(VGImage parent, VGint x, VGint y, VGint width, VGint height)
+#else
+VGImage RI_APIENTRY vgChildImage(VGImage parent, VGint x, VGint y, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(!context->isValidImage(parent), VG_BAD_HANDLE_ERROR, VG_INVALID_HANDLE);
+	Image* p = (Image*)parent;
+	RI_IF_ERROR(eglvgIsInUse((Image*)parent), VG_IMAGE_IN_USE_ERROR, VG_INVALID_HANDLE);
+	RI_IF_ERROR(x < 0 || x >= p->getWidth() || y < 0 || y >= p->getHeight() ||
+				width <= 0 || height <= 0 || RI_INT_ADDSATURATE(x, width) > p->getWidth() || RI_INT_ADDSATURATE(y, height) > p->getHeight(), VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+	Image* child = NULL;
+	try
+	{
+		child = RI_NEW(Image, (p, x, y, width, height));	//throws bad_alloc
+		RI_ASSERT(child);
+		context->m_imageManager->addResource(child, context);	//throws bad_alloc
+		RI_RETURN((VGImage)child);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(child);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGImage RI_APIENTRY do_vgGetParent(VGImage image)
+#else
+VGImage RI_APIENTRY vgGetParent(VGImage image)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, VG_INVALID_HANDLE);
+	VGImage ret = image;	//if image has no ancestors, image is returned.
+
+    //The vgGetParent function returns the closest valid ancestor (i.e., one that has not been the target of a vgDestroyImage call)
+    // of the given image.
+	Image* im = ((Image*)image)->getParent();
+    for(;im;im = im->getParent())
+    {
+		if(context->isValidImage((VGImage)im))
+		{	//the parent is valid and alive
+			ret = (VGImage)im;
+            break;
+		}
+	}
+	RI_RETURN(ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgCopyImage(VGImage dst, VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height, VGboolean dither)
+#else
+void RI_APIENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height, VGboolean dither)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(eglvgIsInUse((Image*)dst) || eglvgIsInUse((Image*)src), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	try
+	{
+		((Image*)dst)->blit(*(Image*)src, sx, sy, dx, dy, width, height, dither ? true : false);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static bool drawImage(VGContext* context, VGImage image, const Matrix3x3& userToSurfaceMatrix)
+{
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+        return false;   //no EGL surface is current at the moment
+
+	Image* img = (Image*)image;
+	//transform image corners into the surface space
+	Vector3 p0(0, 0, 1);
+	Vector3 p1(0, (RIfloat)img->getHeight(), 1);
+	Vector3 p2((RIfloat)img->getWidth(), (RIfloat)img->getHeight(), 1);
+	Vector3 p3((RIfloat)img->getWidth(), 0, 1);
+	p0 = userToSurfaceMatrix * p0;
+	p1 = userToSurfaceMatrix * p1;
+	p2 = userToSurfaceMatrix * p2;
+	p3 = userToSurfaceMatrix * p3;
+	if(p0.z <= 0.0f || p1.z <= 0.0f || p2.z <= 0.0f || p3.z <= 0.0f)
+		return false;
+
+	//projection
+	p0 *= 1.0f/p0.z;
+	p1 *= 1.0f/p1.z;
+	p2 *= 1.0f/p2.z;
+	p3 *= 1.0f/p3.z;
+
+	Rasterizer rasterizer;
+	if(context->m_scissoring)
+		rasterizer.setScissor(context->m_scissor);	//throws bad_alloc
+	rasterizer.setupSamplingPattern(context->m_renderingQuality, drawable->getNumSamples());
+
+	PixelPipe pixelPipe;
+	pixelPipe.setTileFillColor(context->m_tileFillColor);
+	pixelPipe.setPaint((Paint*)context->m_fillPaint);
+	pixelPipe.setImageQuality(context->m_imageQuality);
+	pixelPipe.setBlendMode(context->m_blendMode);
+	pixelPipe.setDrawable(drawable);
+	pixelPipe.setMask(context->m_masking ? true : false);
+    pixelPipe.setColorTransform(context->m_colorTransform ? true : false, context->m_colorTransformValues);
+
+	Matrix3x3 surfaceToImageMatrix = userToSurfaceMatrix;
+	Matrix3x3 surfaceToPaintMatrix = userToSurfaceMatrix * context->m_fillPaintToUser;
+	if(surfaceToImageMatrix.invert() && surfaceToPaintMatrix.invert())
+	{
+		VGImageMode imode = context->m_imageMode;
+		if(!surfaceToPaintMatrix.isAffine())
+			imode = VG_DRAW_IMAGE_NORMAL;	//if paint matrix is not affine, always use normal image mode
+		surfaceToPaintMatrix[2].set(0,0,1);	//force affine
+
+		pixelPipe.setImage(img, imode);
+		pixelPipe.setSurfaceToPaintMatrix(surfaceToPaintMatrix);
+		pixelPipe.setSurfaceToImageMatrix(surfaceToImageMatrix);
+
+		rasterizer.addEdge(Vector2(p0.x,p0.y), Vector2(p1.x,p1.y));	//throws bad_alloc
+		rasterizer.addEdge(Vector2(p1.x,p1.y), Vector2(p2.x,p2.y));	//throws bad_alloc
+		rasterizer.addEdge(Vector2(p2.x,p2.y), Vector2(p3.x,p3.y));	//throws bad_alloc
+		rasterizer.addEdge(Vector2(p3.x,p3.y), Vector2(p0.x,p0.y));	//throws bad_alloc
+        rasterizer.setup(0, 0, drawable->getWidth(), drawable->getHeight(), VG_EVEN_ODD, &pixelPipe, NULL);
+		rasterizer.fill();	//throws bad_alloc
+	}
+	return true;
+}
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDrawImage(VGImage image)
+#else
+void RI_APIENTRY vgDrawImage(VGImage image)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* img = (Image*)image;
+	RI_IF_ERROR(eglvgIsInUse(img), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+
+	try
+	{
+		if(!drawImage(context, image, context->m_imageUserToSurface))
+		{
+			RI_RETURN(RI_NO_RETVAL);
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetPixels(VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgSetPixels(VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(eglvgIsInUse((Image*)src), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+	try
+	{
+		if(context->m_scissoring)
+			drawable->getColorBuffer()->blit(*(Image*)src, sx, sy, dx, dy, width, height, context->m_scissor);	//throws bad_alloc
+		else
+			drawable->getColorBuffer()->blit(*(Image*)src, sx, sy, dx, dy, width, height);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgWritePixels(const void * data, VGint dataStride, VGImageFormat dataFormat, VGint dx, VGint dy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgWritePixels(const void * data, VGint dataStride, VGImageFormat dataFormat, VGint dx, VGint dy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+	{
+		Image input(Color::formatToDescriptor(dataFormat), width, height, dataStride, const_cast<RIuint8*>((const RIuint8*)data));
+		input.addReference();
+		try
+		{
+			if(context->m_scissoring)
+				drawable->getColorBuffer()->blit(input, 0, 0, dx, dy, width, height, context->m_scissor);	//throws bad_alloc
+			else
+				drawable->getColorBuffer()->blit(input, 0, 0, dx, dy, width, height);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+		}
+		input.removeReference();
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGetPixels(VGImage dst, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(eglvgIsInUse((Image*)dst), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+	try
+	{
+		((Image*)dst)->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgReadPixels(void* data, VGint dataStride, VGImageFormat dataFormat, VGint sx, VGint sy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgReadPixels(void* data, VGint dataStride, VGImageFormat dataFormat, VGint sx, VGint sy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!isValidImageFormat(dataFormat), VG_UNSUPPORTED_IMAGE_FORMAT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!data || !isAligned(data, dataFormat) || width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+	{
+		Image output(Color::formatToDescriptor(dataFormat), width, height, dataStride, (RIuint8*)data);
+		output.addReference();
+		try
+		{
+			output.blit(drawable->getColorBuffer(), sx, sy, 0, 0, width, height);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+		}
+		output.removeReference();
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgCopyPixels(VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#else
+void RI_APIENTRY vgCopyPixels(VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(width <= 0 || height <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+    Drawable* drawable = context->getCurrentDrawable();
+    if(!drawable)
+    {
+        RI_RETURN(RI_NO_RETVAL);	//no EGL surface is current at the moment
+    }
+	try
+	{
+		if(context->m_scissoring)
+			drawable->getColorBuffer()->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height, context->m_scissor);	//throws bad_alloc
+		else
+			drawable->getColorBuffer()->blit(drawable->getColorBuffer(), sx, sy, dx, dy, width, height);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgColorMatrix(VGImage dst, VGImage src, const VGfloat * matrix)
+#else
+void RI_APIENTRY vgColorMatrix(VGImage dst, VGImage src, const VGfloat * matrix)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!matrix || !isAligned(matrix,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+
+	RIfloat m[20];
+	for(int i=0;i<20;i++)
+	{
+		m[i] = inputFloat(matrix[i]);
+	}
+	try
+	{
+		d->colorMatrix(*s, m, context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernel, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+#else
+void RI_APIENTRY vgConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernel, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!kernel || !isAligned(kernel,2) || kernelWidth <= 0 || kernelHeight <= 0 || kernelWidth > RI_MAX_KERNEL_SIZE || kernelHeight > RI_MAX_KERNEL_SIZE, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+	try
+	{
+		d->convolve(*s, kernelWidth, kernelHeight, shiftX, shiftY, (const RIint16*)kernel, inputFloat(scale), inputFloat(bias), tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSeparableConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernelX, const VGshort * kernelY, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+#else
+void RI_APIENTRY vgSeparableConvolve(VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort * kernelX, const VGshort * kernelY, VGfloat scale, VGfloat bias, VGTilingMode tilingMode)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!kernelX || !kernelY || !isAligned(kernelX,2) || !isAligned(kernelY,2) || kernelWidth <= 0 || kernelHeight <= 0 || kernelWidth > RI_MAX_SEPARABLE_KERNEL_SIZE || kernelHeight > RI_MAX_SEPARABLE_KERNEL_SIZE, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+	try
+	{
+		d->separableConvolve(*s, kernelWidth, kernelHeight, shiftX, shiftY, (const RIint16*)kernelX, (const RIint16*)kernelY,
+										 inputFloat(scale), inputFloat(bias), tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false,
+										 context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgGaussianBlur(VGImage dst, VGImage src, VGfloat stdDeviationX, VGfloat stdDeviationY, VGTilingMode tilingMode)
+#else
+void RI_APIENTRY vgGaussianBlur(VGImage dst, VGImage src, VGfloat stdDeviationX, VGfloat stdDeviationY, VGTilingMode tilingMode)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RIfloat sx = inputFloat(stdDeviationX);
+	RIfloat sy = inputFloat(stdDeviationY);
+	RI_IF_ERROR(sx <= 0.0f || sy <= 0.0f || sx > (RIfloat)RI_MAX_GAUSSIAN_STD_DEVIATION || sy > (RIfloat)RI_MAX_GAUSSIAN_STD_DEVIATION, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(tilingMode < VG_TILE_FILL || tilingMode > VG_TILE_REFLECT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+	try
+	{
+		d->gaussianBlur(*s, sx, sy, tilingMode, context->m_tileFillColor, context->m_filterFormatLinear ? true : false,
+						context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgLookup(VGImage dst, VGImage src, const VGubyte * redLUT, const VGubyte * greenLUT, const VGubyte * blueLUT, const VGubyte * alphaLUT, VGboolean outputLinear, VGboolean outputPremultiplied)
+#else
+void RI_APIENTRY vgLookup(VGImage dst, VGImage src, const VGubyte * redLUT, const VGubyte * greenLUT, const VGubyte * blueLUT, const VGubyte * alphaLUT, VGboolean outputLinear, VGboolean outputPremultiplied)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!redLUT || !greenLUT || !blueLUT || !alphaLUT, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+	try
+	{
+		d->lookup(*s, (const RIuint8*)redLUT, (const RIuint8*)greenLUT, (const RIuint8*)blueLUT, (const RIuint8*)alphaLUT,
+				  outputLinear ? true : false, outputPremultiplied ? true : false, context->m_filterFormatLinear ? true : false,
+				  context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgLookupSingle(VGImage dst, VGImage src, const VGuint * lookupTable, VGImageChannel sourceChannel, VGboolean outputLinear, VGboolean outputPremultiplied)
+#else
+void RI_APIENTRY vgLookupSingle(VGImage dst, VGImage src, const VGuint * lookupTable, VGImageChannel sourceChannel, VGboolean outputLinear, VGboolean outputPremultiplied)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidImage(dst) || !context->isValidImage(src), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);
+	Image* d = (Image*)dst;
+	Image* s = (Image*)src;
+	RI_IF_ERROR(eglvgIsInUse(d) || eglvgIsInUse(s), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(d->overlaps(s), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(!lookupTable || !isAligned(lookupTable,4), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	const Color::Descriptor& desc = s->getDescriptor();
+	RI_ASSERT(Color::isValidDescriptor(desc));
+	//give an error if src is in rgb format and the source channel is not valid
+	RI_IF_ERROR((!desc.isLuminance() && !desc.isAlphaOnly()) && (sourceChannel != VG_RED && sourceChannel != VG_GREEN && sourceChannel != VG_BLUE && sourceChannel != VG_ALPHA), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	unsigned int channelMask = context->m_filterChannelMask & (VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA);	//undefined bits are ignored
+	try
+	{
+		d->lookupSingle(*s, (const RIuint32*)lookupTable, sourceChannel, outputLinear ? true : false, outputPremultiplied ? true : false,
+						context->m_filterFormatLinear ? true : false, context->m_filterFormatPremultiplied ? true : false, channelMask);
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGHardwareQueryResult RI_APIENTRY do_vgHardwareQuery(VGHardwareQueryType key, VGint setting)
+#else
+VGHardwareQueryResult RI_APIENTRY vgHardwareQuery(VGHardwareQueryType key, VGint setting)
+#endif
+{
+	RI_GET_CONTEXT(VG_HARDWARE_UNACCELERATED);
+	RI_IF_ERROR(key != VG_IMAGE_FORMAT_QUERY && key != VG_PATH_DATATYPE_QUERY, VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+	RI_IF_ERROR(key == VG_IMAGE_FORMAT_QUERY && !isValidImageFormat(setting), VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+	RI_IF_ERROR(key == VG_PATH_DATATYPE_QUERY && (setting < VG_PATH_DATATYPE_S_8 || setting > VG_PATH_DATATYPE_F), VG_ILLEGAL_ARGUMENT_ERROR, VG_HARDWARE_UNACCELERATED);
+	RI_RETURN(VG_HARDWARE_UNACCELERATED);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+RI_APIENTRY const VGubyte * do_vgGetString(VGStringID name)
+#else
+RI_APIENTRY const VGubyte * vgGetString(VGStringID name)
+#endif
+{
+	static const VGubyte vendor[] = "Khronos Group";
+	static const VGubyte renderer[] = {"OpenVG 1.1 Reference Implementation May 13 2008"};
+	static const VGubyte version[] = "1.1";
+	static const VGubyte extensions[] = "";
+	const VGubyte* r = NULL;
+	RI_GET_CONTEXT(NULL);
+	switch(name)
+	{
+	case VG_VENDOR:
+		r = vendor;
+		break;
+	case VG_RENDERER:
+		r = renderer;
+		break;
+	case VG_VERSION:
+		r = version;
+		break;
+	case VG_EXTENSIONS:
+		r = extensions;
+		break;
+	default:
+		break;
+	}
+	RI_RETURN(r);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+VGFont RI_APIENTRY do_vgCreateFont(VGint glyphCapacityHint)
+#else
+VGFont RI_APIENTRY vgCreateFont(VGint glyphCapacityHint)
+#endif
+{
+	RI_GET_CONTEXT(VG_INVALID_HANDLE);
+	RI_IF_ERROR(glyphCapacityHint < 0, VG_ILLEGAL_ARGUMENT_ERROR, VG_INVALID_HANDLE);
+
+	Font* font = NULL;
+	try
+	{
+		font = RI_NEW(Font, (glyphCapacityHint));	//throws bad_alloc
+		RI_ASSERT(font);
+		context->m_fontManager->addResource(font, context);	//throws bad_alloc
+		RI_RETURN((VGFont)font);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(font);
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+		RI_RETURN(VG_INVALID_HANDLE);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDestroyFont(VGFont font)
+#else
+void RI_APIENTRY vgDestroyFont(VGFont font)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+
+	context->m_fontManager->removeResource((Font*)font);
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetGlyphToPath(VGFont font, VGuint glyphIndex, VGPath path, VGboolean isHinted, const VGfloat glyphOrigin[2], const VGfloat escapement[2])
+#else
+void RI_APIENTRY vgSetGlyphToPath(VGFont font, VGuint glyphIndex, VGPath path, VGboolean isHinted, const VGfloat glyphOrigin[2], const VGfloat escapement[2])
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+	RI_IF_ERROR(path != VG_INVALID_HANDLE && !context->isValidPath(path), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid path handle
+    RI_IF_ERROR(!glyphOrigin || !escapement || !isAligned(glyphOrigin,sizeof(VGfloat)) || !isAligned(escapement,sizeof(VGfloat)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	Font* f = (Font*)font;
+
+	try
+	{
+        f->setGlyphToPath(glyphIndex, path, isHinted ? true : false, Vector2(inputFloat(glyphOrigin[0]), inputFloat(glyphOrigin[1])), Vector2(inputFloat(escapement[0]), inputFloat(escapement[1])));
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgSetGlyphToImage(VGFont font, VGuint glyphIndex, VGImage image, const VGfloat glyphOrigin[2], const VGfloat escapement[2])
+#else
+void RI_APIENTRY vgSetGlyphToImage(VGFont font, VGuint glyphIndex, VGImage image, const VGfloat glyphOrigin[2], const VGfloat escapement[2])
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+    if(image != VG_INVALID_HANDLE)
+    {
+        RI_IF_ERROR(!context->isValidImage(image), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid image handle
+        RI_IF_ERROR(eglvgIsInUse((Image*)image), VG_IMAGE_IN_USE_ERROR, RI_NO_RETVAL); //image in use
+    }
+    RI_IF_ERROR(!glyphOrigin || !escapement || !isAligned(glyphOrigin,sizeof(VGfloat)) || !isAligned(escapement,sizeof(VGfloat)), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	Font* f = (Font*)font;
+
+	try
+	{
+        f->setGlyphToImage(glyphIndex, image, Vector2(inputFloat(glyphOrigin[0]), inputFloat(glyphOrigin[1])), Vector2(inputFloat(escapement[0]), inputFloat(escapement[1])));
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgClearGlyph(VGFont font, VGuint glyphIndex)
+#else
+void RI_APIENTRY vgClearGlyph(VGFont font, VGuint glyphIndex)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+	Font* f = (Font*)font;
+    Font::Glyph* g = f->findGlyph(glyphIndex);
+    RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);   //glyphIndex not defined
+
+	f->clearGlyph(g);
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDrawGlyph(VGFont font, VGuint glyphIndex, VGbitfield paintModes, VGboolean allowAutoHinting)
+#else
+void RI_APIENTRY vgDrawGlyph(VGFont font, VGuint glyphIndex, VGbitfield paintModes, VGboolean allowAutoHinting)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+	RI_IF_ERROR(paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid paint mode
+	Font* f = (Font*)font;
+    Font::Glyph* g = f->findGlyph(glyphIndex);
+    RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);   //glyphIndex not defined
+    RI_UNREF(allowAutoHinting); //RI doesn't implement autohinting
+
+	try
+	{
+        if(paintModes)
+        {
+            Matrix3x3 userToSurfaceMatrix = context->m_glyphUserToSurface;
+            Vector2 t = context->m_glyphOrigin - g->m_origin;
+            Matrix3x3 n(1, 0, t.x,
+                        0, 1, t.y,
+                        0, 0, 1 );
+            userToSurfaceMatrix *= n;
+            userToSurfaceMatrix[2].set(0,0,1);		//force affinity
+
+            bool ret = true;
+            if(g->m_image != VG_INVALID_HANDLE)
+                ret = drawImage(context, g->m_image, userToSurfaceMatrix);
+            else if(g->m_path != VG_INVALID_HANDLE)
+                ret = drawPath(context, g->m_path, userToSurfaceMatrix, paintModes);
+            if(!ret)
+            {
+                RI_RETURN(RI_NO_RETVAL);
+            }
+        }
+
+        context->m_glyphOrigin += g->m_escapement;
+        context->m_inputGlyphOrigin = context->m_glyphOrigin;
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+void RI_APIENTRY do_vgDrawGlyphs(VGFont font, VGint glyphCount, const VGuint *glyphIndices, const VGfloat *adjustments_x, const VGfloat *adjustments_y, VGbitfield paintModes, VGboolean allowAutoHinting)
+#else
+void RI_APIENTRY vgDrawGlyphs(VGFont font, VGint glyphCount, const VGuint *glyphIndices, const VGfloat *adjustments_x, const VGfloat *adjustments_y, VGbitfield paintModes, VGboolean allowAutoHinting)
+#endif
+{
+	RI_GET_CONTEXT(RI_NO_RETVAL);
+	RI_IF_ERROR(!context->isValidFont(font), VG_BAD_HANDLE_ERROR, RI_NO_RETVAL);	//invalid font handle
+	RI_IF_ERROR(!glyphIndices || !isAligned(glyphIndices, sizeof(VGuint)) || glyphCount <= 0, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR((adjustments_x && !isAligned(adjustments_x, sizeof(VGfloat))) || (adjustments_y && !isAligned(adjustments_y, sizeof(VGfloat))), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);
+	RI_IF_ERROR(paintModes & ~(VG_FILL_PATH | VG_STROKE_PATH), VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);	//invalid paint mode
+	Font* f = (Font*)font;
+	for(int i=0;i<glyphCount;i++)
+	{
+        Font::Glyph* g = f->findGlyph(glyphIndices[i]);
+        RI_IF_ERROR(!g, VG_ILLEGAL_ARGUMENT_ERROR, RI_NO_RETVAL);   //glyphIndex not defined
+    }
+    RI_UNREF(allowAutoHinting); //RI doesn't implement autohinting
+
+	try
+	{
+		for(int i=0;i<glyphCount;i++)
+		{
+            Font::Glyph* g = f->findGlyph(glyphIndices[i]);
+
+            if(paintModes)
+            {
+                Matrix3x3 userToSurfaceMatrix = context->m_glyphUserToSurface;
+                Vector2 t = context->m_glyphOrigin - g->m_origin;
+                Matrix3x3 n(1, 0, t.x,
+                            0, 1, t.y,
+                            0, 0, 1 );
+                userToSurfaceMatrix *= n;
+                userToSurfaceMatrix[2].set(0,0,1);		//force affinity
+
+                bool ret = true;
+                if(g->m_image != VG_INVALID_HANDLE)
+                    ret = drawImage(context, g->m_image, userToSurfaceMatrix);
+                else if(g->m_path != VG_INVALID_HANDLE)
+                    ret = drawPath(context, g->m_path, userToSurfaceMatrix, paintModes);
+                if(!ret)
+                {
+                    RI_RETURN(RI_NO_RETVAL);
+                }
+            }
+
+            context->m_glyphOrigin += g->m_escapement;
+            if(adjustments_x)
+                context->m_glyphOrigin.x += inputFloat(adjustments_x[i]);
+            if(adjustments_y)
+                context->m_glyphOrigin.y += inputFloat(adjustments_y[i]);
+            context->m_inputGlyphOrigin = context->m_glyphOrigin;
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		context->setError(VG_OUT_OF_MEMORY_ERROR);
+	}
+
+	RI_RETURN(RI_NO_RETVAL);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riArray.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,211 @@
+#ifndef __RIARRAY_H
+#define __RIARRAY_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Array class.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef __RIDEFS_H
+#include "riDefs.h"
+#endif
+
+#include <string.h>	//for memcpy
+
+namespace OpenVGRI
+{
+
+//=======================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief	An array class similar to std::vector.
+* \param	
+* \return	
+* \note		Follows std::vector's naming convention (except resizeAndReallocate).
+*//*-------------------------------------------------------------------*/
+
+template <class Item> class Array
+{
+public:
+	Array() : m_array(NULL), m_size(0), m_allocated(0) {}	//throws bad_alloc
+	~Array()
+	{
+		RI_DELETE_ARRAY(m_array);
+	}
+
+	void		swap(Array& s)
+	{
+		Item* tarray = m_array;
+		m_array = s.m_array;
+		s.m_array = tarray;
+
+		int tsize = m_size;
+		m_size = s.m_size;
+		s.m_size = tsize;
+
+		int tallocated = m_allocated;
+		m_allocated = s.m_allocated;
+		s.m_allocated = tallocated;
+	}
+
+	//if more room is needed, reallocate, otherwise return
+	void		reserve( int items )	//throws bad_alloc
+	{
+		RI_ASSERT( items >= 0 );
+		if( items <= m_allocated )
+			return;	//if there is room already, return
+
+		RI_ASSERT( items > m_allocated );
+
+		Item* newa = RI_NEW_ARRAY(Item, items);	//throws bad_alloc if runs out of memory
+		for(int i=0;i<m_size;i++)
+			newa[i] = m_array[i];
+		RI_DELETE_ARRAY(m_array);
+		m_array = newa;
+		m_allocated = items;
+		//doesn't change size
+	}
+
+	//reserve and change size
+	void		resize( int items )	//throws bad_alloc
+	{
+		reserve( items );	//throws bad_alloc if runs out of memory
+		m_size = items;
+	}
+
+	//resize and allocate exactly the correct amount of memory
+	void		resizeAndReallocate( int items )	//throws bad_alloc
+	{
+		RI_ASSERT( items >= 0 );
+		if( items == m_allocated )
+		{
+			m_size = items;
+			return;
+		}
+
+		if( items == 0 )
+		{
+			RI_DELETE_ARRAY(m_array);
+			m_size = 0;
+			m_allocated = 0;
+			return;
+		}
+
+		Item* newa = RI_NEW_ARRAY(Item, items);	//throws bad_alloc if runs out of memory
+		int copySize = (m_size < items) ? m_size : items;	//min(m_size,items)
+		for(int i=0;i<copySize;i++)
+			newa[i] = m_array[i];
+		RI_DELETE_ARRAY(m_array);
+		m_array = newa;
+		m_allocated = items;
+		m_size = items;		//changes also size
+	}
+	void		clear()
+	{
+		m_size = 0;
+	}
+
+    //sort array (needs operator< defined for Item. Define it with < for increasing order and > for decreasing.)
+	void		sort()
+	{
+		if(m_size <= 1)
+			return;
+		quicksort(0, m_size - 1);
+	}
+
+    //remove the first occurrence of an item from the array
+    bool        remove(const Item& item)
+    {
+        int i=0;
+        for(;i<m_size;i++)
+        {
+            if(m_array[i] == item)
+                break;
+        }
+        if(i >= m_size)
+            return false;   //not found
+        for(;i<m_size-1;i++)
+        {
+            m_array[i] = m_array[i+1];
+        }
+        m_size--;
+        return true;
+    }
+
+	RI_INLINE void			push_back( const Item& item )	//throws bad_alloc
+	{
+		if( m_size >= m_allocated )
+			reserve( (!m_allocated) ? 8 : m_allocated * 2 );	//by default, reserve 8. throws bad_alloc if runs out of memory
+		m_array[m_size++] = item;
+	}
+	RI_INLINE int			size() const				{ return m_size; }
+	RI_INLINE Item&			operator[](int i)			{ RI_ASSERT(i >= 0 && i < m_size); return m_array[i]; }
+	RI_INLINE const Item&	operator[](int i) const		{ RI_ASSERT(i >= 0 && i < m_size); return m_array[i]; }
+
+private:
+	Array(const Array& s);				//!< Not allowed.
+	void operator=(const Array& s);		//!< Not allowed.
+
+	void quicksort(int left, int right)
+	{
+		int i = left, j = right;
+		Item x = m_array[(left+right)>>1];
+
+		do
+		{    
+			while (m_array[i] < x)
+				i++;
+			while (x < m_array[j])
+				j--;
+			if (i<=j)
+			{
+				Item tmp = m_array[i];
+				m_array[i] = m_array[j];
+				m_array[j] = tmp;
+				i++;
+				j--;
+			}
+		} while (i<=j);
+
+		if(left < j) quicksort(left, j);
+		if(i < right) quicksort(i, right);
+	}
+
+
+	Item*		m_array;
+	int			m_size;
+	int			m_allocated;
+};
+
+//=======================================================================
+
+}	//namespace OpenVGRI
+
+#endif /* __RIARRAY_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riContext.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,329 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of VGContext functions.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riContext.h"
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	VGContext constructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+VGContext::VGContext(VGContext* shareContext) :
+	// Mode settings
+	m_matrixMode(VG_MATRIX_PATH_USER_TO_SURFACE),
+	m_fillRule(VG_EVEN_ODD),
+	m_imageQuality(VG_IMAGE_QUALITY_FASTER),
+	m_renderingQuality(VG_RENDERING_QUALITY_BETTER),
+	m_blendMode(VG_BLEND_SRC_OVER),
+	m_imageMode(VG_DRAW_IMAGE_NORMAL),
+
+	// Scissor rectangles
+	m_scissor(),
+		
+	// Stroke parameters
+	m_strokeLineWidth(1.0f),
+	m_inputStrokeLineWidth(1.0f),
+	m_strokeCapStyle(VG_CAP_BUTT),
+	m_strokeJoinStyle(VG_JOIN_MITER),
+	m_strokeMiterLimit(4.0f),
+	m_inputStrokeMiterLimit(4.0f),
+	m_strokeDashPattern(),
+	m_inputStrokeDashPattern(),
+	m_strokeDashPhase(0.0f),
+	m_inputStrokeDashPhase(0.0f),
+	m_strokeDashPhaseReset(VG_FALSE),
+		
+	// Edge fill color for vgConvolve and pattern paint
+	m_tileFillColor(0,0,0,0, Color::sRGBA),
+	m_inputTileFillColor(0,0,0,0, Color::sRGBA),
+		
+	// Color for vgClear
+	m_clearColor(0,0,0,0, Color::sRGBA),
+	m_inputClearColor(0,0,0,0, Color::sRGBA),
+
+    m_glyphOrigin(0.0f, 0.0f),
+    m_inputGlyphOrigin(0.0f, 0.0f),
+
+	m_masking(VG_FALSE),
+	m_scissoring(VG_FALSE),
+
+	m_pixelLayout(VG_PIXEL_LAYOUT_UNKNOWN),
+
+	m_filterFormatLinear(VG_FALSE),
+	m_filterFormatPremultiplied(VG_FALSE),
+	m_filterChannelMask(VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA),
+
+	// Matrices
+	m_pathUserToSurface(),
+	m_imageUserToSurface(),
+	m_glyphUserToSurface(),
+	m_fillPaintToUser(),
+	m_strokePaintToUser(),
+
+	m_fillPaint(VG_INVALID_HANDLE),
+	m_strokePaint(VG_INVALID_HANDLE),
+
+    m_colorTransform(VG_FALSE),
+    m_colorTransformValues(),
+    m_inputColorTransformValues(),
+
+	m_error(VG_NO_ERROR),
+
+	m_imageManager(NULL),
+	m_pathManager(NULL),
+	m_paintManager(NULL),
+	m_fontManager(NULL),
+	m_maskLayerManager(NULL),
+
+    m_eglDrawable(NULL)
+{
+	if(shareContext)
+	{
+		m_imageManager = shareContext->m_imageManager;
+		m_pathManager = shareContext->m_pathManager;
+		m_paintManager = shareContext->m_paintManager;
+		m_fontManager = shareContext->m_fontManager;
+		m_maskLayerManager = shareContext->m_maskLayerManager;
+	}
+	else
+	{
+		try
+		{
+			m_imageManager = RI_NEW(OpenVGRI::ResourceManager<Image>, ());	//throws bad_alloc
+			m_pathManager = RI_NEW(OpenVGRI::ResourceManager<Path>, ());	//throws bad_alloc
+			m_paintManager = RI_NEW(OpenVGRI::ResourceManager<Paint>, ());	//throws bad_alloc
+			m_fontManager = RI_NEW(OpenVGRI::ResourceManager<Font>, ());	//throws bad_alloc
+			m_maskLayerManager = RI_NEW(OpenVGRI::ResourceManager<Surface>, ());	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+			RI_DELETE(m_imageManager);
+			RI_DELETE(m_pathManager);
+			RI_DELETE(m_paintManager);
+			RI_DELETE(m_fontManager);
+			RI_DELETE(m_maskLayerManager);
+			throw;
+		}
+	}
+	RI_ASSERT(m_imageManager);
+	RI_ASSERT(m_pathManager);
+	RI_ASSERT(m_paintManager);
+	RI_ASSERT(m_fontManager);
+	RI_ASSERT(m_maskLayerManager);
+	m_imageManager->addReference();
+	m_pathManager->addReference();
+	m_paintManager->addReference();
+	m_fontManager->addReference();
+	m_maskLayerManager->addReference();
+
+    m_inputColorTransformValues[0] = 1.0f;
+    m_inputColorTransformValues[1] = 1.0f;
+    m_inputColorTransformValues[2] = 1.0f;
+    m_inputColorTransformValues[3] = 1.0f;
+    m_inputColorTransformValues[4] = 0.0f;
+    m_inputColorTransformValues[5] = 0.0f;
+    m_inputColorTransformValues[6] = 0.0f;
+    m_inputColorTransformValues[7] = 0.0f;
+    m_colorTransformValues[0] = 1.0f;
+    m_colorTransformValues[1] = 1.0f;
+    m_colorTransformValues[2] = 1.0f;
+    m_colorTransformValues[3] = 1.0f;
+    m_colorTransformValues[4] = 0.0f;
+    m_colorTransformValues[5] = 0.0f;
+    m_colorTransformValues[6] = 0.0f;
+    m_colorTransformValues[7] = 0.0f;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	VGContext destructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+VGContext::~VGContext()
+{
+	releasePaint(VG_FILL_PATH | VG_STROKE_PATH);
+    setDefaultDrawable(NULL);
+
+	//destroy own images, paths and paints
+	while(Image* i = m_imageManager->getFirstResource(this))
+		m_imageManager->removeResource(i);
+	while(Path* p = m_pathManager->getFirstResource(this))
+		m_pathManager->removeResource(p);
+	while(Paint* t = m_paintManager->getFirstResource(this))
+		m_paintManager->removeResource(t);
+	while(Font* t = m_fontManager->getFirstResource(this))
+		m_fontManager->removeResource(t);
+	while(Surface* t = m_maskLayerManager->getFirstResource(this))
+		m_maskLayerManager->removeResource(t);
+
+	//decrease the reference count of resource managers
+	if(!m_imageManager->removeReference())
+		RI_DELETE(m_imageManager);
+	if(!m_pathManager->removeReference())
+		RI_DELETE(m_pathManager);
+	if(!m_paintManager->removeReference())
+		RI_DELETE(m_paintManager);
+	if(!m_fontManager->removeReference())
+		RI_DELETE(m_fontManager);
+	if(!m_maskLayerManager->removeReference())
+		RI_DELETE(m_maskLayerManager);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Sets new default drawable.
+* \param	drawable New drawable or NULL when context is unbound
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void VGContext::setDefaultDrawable(Drawable* drawable)
+{
+	if(m_eglDrawable)
+	{
+		if(!m_eglDrawable->removeReference())
+			RI_DELETE(m_eglDrawable);
+	}
+	m_eglDrawable = drawable;
+	if(m_eglDrawable)
+	{
+		m_eglDrawable->addReference();
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the given image is generated through any
+*			context that is shared with this one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidImage(VGImage image)
+{
+	return m_imageManager->isValid((Image*)image);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the given path is generated through any
+*			context that is shared with this one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidPath(VGPath path)
+{
+	return m_pathManager->isValid((Path*)path);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the given paint is generated through any
+*			context that is shared with this one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidPaint(VGPaint paint)
+{
+	return m_paintManager->isValid((Paint*)paint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the given font is generated through any
+*			context that is shared with this one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidFont(VGFont font)
+{
+	return m_fontManager->isValid((Font*)font);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the given mask layer is generated through any
+*			context that is shared with this one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool VGContext::isValidMaskLayer(VGMaskLayer layer)
+{
+	return m_maskLayerManager->isValid((Surface*)layer);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Releases the given paint objects of the context.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void VGContext::releasePaint(VGbitfield paintModes)
+{
+	if(paintModes & VG_FILL_PATH)
+	{
+		//release previous paint
+		Paint* prev = (Paint*)m_fillPaint;
+		if(prev)
+		{
+			if(!prev->removeReference())
+				RI_DELETE(prev);
+		}
+		m_fillPaint = VG_INVALID_HANDLE;
+	}
+	if(paintModes & VG_STROKE_PATH)
+	{
+		//release previous paint
+		Paint* prev = (Paint*)m_strokePaint;
+		if(prev)
+		{
+			if(!prev->removeReference())
+				RI_DELETE(prev);
+		}
+		m_strokePaint = VG_INVALID_HANDLE;
+	}
+}
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riContext.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,277 @@
+#ifndef __RICONTEXT_H
+#define __RICONTEXT_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	VGContext class. Used for storing OpenVG state.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef OPENVG_H
+#include "openvg.h"
+#endif
+
+#ifndef __RIDEFS_H
+#include "riDefs.h"
+#endif
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIIMAGE_H
+#include "riImage.h"
+#endif
+
+#ifndef __RIPATH_H
+#include "riPath.h"
+#endif
+
+#ifndef __RIFONT_H
+#include "riFont.h"
+#endif
+
+#ifndef __RIARRAY_H
+#include "riArray.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+class VGContext;
+
+/*-------------------------------------------------------------------*//*!
+* \brief	A list of resources (Images, Paths, or Paints) shared by a
+*			set of contexts.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+template <class Resource> class ResourceManager
+{
+public:
+	ResourceManager() :
+		m_referenceCount(0),
+		m_resources()
+	{
+	}
+
+	~ResourceManager()
+	{
+		RI_ASSERT(m_referenceCount == 0);
+		RI_ASSERT(m_resources.size() == 0);
+	}
+
+	void			addReference()
+	{
+		m_referenceCount++;
+	}
+
+	int				removeReference()
+	{
+		m_referenceCount--;
+		RI_ASSERT(m_referenceCount >= 0);
+		return m_referenceCount;
+	}
+
+	void			addResource(Resource* resource, VGContext* context)
+	{
+		Entry r;
+		r.resource = resource;
+		r.context = context;
+		m_resources.push_back(r);	//throws bad_alloc
+		resource->addReference();
+	}
+
+	void			removeResource(Resource* resource)
+	{
+		if(!resource->removeReference())
+			RI_DELETE(resource);
+
+		int i=0;
+		bool found = false;
+		for(;i<m_resources.size();i++)
+		{
+			if(m_resources[i].resource == resource)
+			{
+				found = true;
+				break;
+			}
+		}
+		RI_ASSERT(found);
+
+		for(;i<m_resources.size()-1;i++)
+		{
+			m_resources[i] = m_resources[i+1];
+		}
+		m_resources.resize(m_resources.size()-1);
+	}
+
+	bool			isValid(Resource* resource)
+	{
+		for(int i=0;i<m_resources.size();i++)
+		{
+			if(m_resources[i].resource == resource)
+				return true;
+		}
+		return false;
+	}
+
+	Resource*		getFirstResource(VGContext* context)
+	{
+		for(int i=0;i<m_resources.size();i++)
+		{
+			if(m_resources[i].context == context)
+				return m_resources[i].resource;
+		}
+		return NULL;
+	}
+
+private:
+	ResourceManager(const ResourceManager&);
+	ResourceManager operator=(const ResourceManager&);
+
+	struct Entry
+	{
+		Resource*	resource;
+		VGContext*	context;
+	};
+
+	int				m_referenceCount;
+	Array<Entry>	m_resources;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class VGContext
+{
+public:
+	VGContext(VGContext* shareContext);	//throws bad_alloc
+	~VGContext();
+
+    void            setDefaultDrawable(Drawable* drawable); //called from EGL
+    Drawable*       getCurrentDrawable()        { return m_eglDrawable; }
+
+	bool			isValidImage(VGImage image);
+	bool			isValidPath(VGPath path);
+	bool			isValidPaint(VGPaint paint);
+	bool			isValidFont(VGFont font);
+	bool			isValidMaskLayer(VGMaskLayer layer);
+
+	void			releasePaint(VGbitfield paintModes);
+
+	void			setError(VGErrorCode error)		{ if(m_error == VG_NO_ERROR) m_error = error; }
+
+	// Mode settings
+	VGMatrixMode					m_matrixMode;
+	VGFillRule						m_fillRule;
+	VGImageQuality					m_imageQuality;
+	VGRenderingQuality				m_renderingQuality;
+	VGBlendMode						m_blendMode;
+	VGImageMode						m_imageMode;
+	
+	// Scissor rectangles
+	Array<Rectangle>				m_scissor;
+
+	// Stroke parameters
+	RIfloat							m_strokeLineWidth;
+	RIfloat							m_inputStrokeLineWidth;
+	VGCapStyle						m_strokeCapStyle;
+	VGJoinStyle						m_strokeJoinStyle;
+	RIfloat							m_strokeMiterLimit;
+	RIfloat							m_inputStrokeMiterLimit;
+	Array<RIfloat>					m_strokeDashPattern;
+	Array<RIfloat>					m_inputStrokeDashPattern;
+	RIfloat							m_strokeDashPhase;
+	RIfloat							m_inputStrokeDashPhase;
+	VGboolean						m_strokeDashPhaseReset;
+
+	// Edge fill color for vgConvolve and pattern paint
+	Color							m_tileFillColor;
+	Color							m_inputTileFillColor;
+
+	// Color for vgClear
+	Color							m_clearColor;
+	Color							m_inputClearColor;
+
+    Vector2                         m_glyphOrigin;
+    Vector2                         m_inputGlyphOrigin;
+
+	VGboolean						m_masking;
+	VGboolean						m_scissoring;
+
+	VGPixelLayout					m_pixelLayout;
+
+	VGboolean						m_filterFormatLinear;
+	VGboolean						m_filterFormatPremultiplied;
+	VGbitfield						m_filterChannelMask;
+
+	// Matrices
+	Matrix3x3						m_pathUserToSurface;
+	Matrix3x3						m_imageUserToSurface;
+	Matrix3x3						m_glyphUserToSurface;
+	Matrix3x3						m_fillPaintToUser;
+	Matrix3x3						m_strokePaintToUser;
+
+	VGPaint							m_fillPaint;
+	VGPaint							m_strokePaint;
+
+    VGboolean                       m_colorTransform;
+    RIfloat                         m_colorTransformValues[8];
+    RIfloat                         m_inputColorTransformValues[8];
+
+	VGErrorCode						m_error;
+
+	ResourceManager<Image>*			m_imageManager;
+	ResourceManager<Path>*			m_pathManager;
+	ResourceManager<Paint>*			m_paintManager;
+	ResourceManager<Font>*			m_fontManager;
+	ResourceManager<Surface>*		m_maskLayerManager;
+private:
+	Drawable*                       m_eglDrawable;
+
+	VGContext(const VGContext&);			//!< Not allowed.
+	void operator=(const VGContext&);		//!< Not allowed.
+};
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+//==============================================================================================
+
+#endif /* __RICONTEXT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riDefs.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,155 @@
+#ifndef __RIDEFS_H
+#define __RIDEFS_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Platform- and compiler-dependent type and macro definitions.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include <float.h>
+#include <math.h>
+#include <assert.h>
+#include <new>	//for bad_alloc
+#include <egl.h>
+
+#ifdef USE_NEW_ELEAVE
+//this is sometimes useful to include so that alloc fails ca be caught.
+//I have found intermittent OOM (-4) problems when rasterizing the tiger image
+#include <e32std.h>
+#endif
+
+namespace OpenVGRI
+{
+
+//make for-clause scope c++ standard compliant on msvc
+#if defined (_MSC_VER)
+#	if !defined (for)
+		__forceinline bool getFalse (void) { return false; }
+#		define for if(getFalse()); else for
+#	endif // for
+
+#pragma warning(disable:4710)	//disable function not inlined warning
+#pragma warning(disable:4714)	//disable function not __forceinlined warning
+#endif  // _MSC_VER
+
+//=======================================================================
+
+typedef int				RIint32;
+typedef unsigned int	RIuint32;
+typedef short			RIint16;
+typedef unsigned short	RIuint16;
+typedef signed char		RIint8;
+typedef unsigned char	RIuint8;
+typedef float			RIfloat32;
+//TODO add compile-time assertions to guarantee the sizes
+
+#if defined (_MSC_VER) // MSVC WIN32
+#	define RI_INLINE __forceinline
+#elif defined __APPLE__ || defined (__GNUC__) || defined (__GCC32__) || (__SYMBIAN32__)
+#	define RI_INLINE inline
+#endif
+
+/*!< Unsigned int that can hold a pointer to any type */
+/*!< Signed int that can hold a pointer to any type */
+#if defined (_MSC_VER) && (_MSC_VER >= 1300)
+typedef uintptr_t		RIuintptr;
+typedef intptr_t		RIintptr;
+#else
+typedef unsigned long   RIuintptr;
+typedef signed long     RIintptr;
+#endif
+
+#define RI_UINT32_MAX (0xffffffffu)
+#define RI_INT32_MAX  (0x7fffffff)
+#define RI_INT32_MIN  (-0x7fffffff-1)
+
+/* maximum mantissa is 23 */
+#define RI_MANTISSA_BITS 23
+
+/* maximum exponent is 8 */
+#define RI_EXPONENT_BITS 8
+
+typedef union
+{
+	RIfloat32	f;
+	RIuint32	i;
+} RIfloatInt;
+
+RI_INLINE float	getFloatMax()
+{
+	RIfloatInt v;
+	v.i = (((1<<(RI_EXPONENT_BITS-1))-1+127) << 23) | (((1<<RI_MANTISSA_BITS)-1) << (23-RI_MANTISSA_BITS));
+	return v.f;
+}
+#define RI_FLOAT_MAX  getFloatMax()
+
+#define RI_MAX_IMAGE_WIDTH				16384
+#define RI_MAX_IMAGE_HEIGHT				16384
+#define RI_MAX_IMAGE_PIXELS				(RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
+#define RI_MAX_IMAGE_BYTES				(4*RI_MAX_IMAGE_WIDTH*RI_MAX_IMAGE_HEIGHT)
+#define RI_MAX_DASH_COUNT				256
+#define RI_MAX_COLOR_RAMP_STOPS			256
+#define RI_MAX_KERNEL_SIZE				256
+#define RI_MAX_SEPARABLE_KERNEL_SIZE	256
+#define RI_MAX_GAUSSIAN_STD_DEVIATION	16.0f
+#define RI_MAX_SCISSOR_RECTANGLES		256
+#define RI_MAX_EDGES					262144
+#define RI_MAX_SAMPLES					32
+#define RI_NUM_TESSELLATED_SEGMENTS		256
+
+#define RI_DEBUG
+
+#ifdef RI_DEBUG
+#	define RI_ASSERT assert
+#else
+#	define RI_ASSERT
+#endif
+
+#define RI_UNREF(X) ((void)(X))
+#define RI_APIENTRY EXPORT_C
+
+#ifdef USE_NEW_ELEAVE
+#define RI_NEW(TYPE, PARAMS)           (new(ELeave) TYPE PARAMS)
+#define RI_NEW_ARRAY(TYPE, ITEMS)      (new(ELeave) TYPE[ITEMS])
+#else
+#define RI_NEW(TYPE, PARAMS)           (new TYPE PARAMS)
+#define RI_NEW_ARRAY(TYPE, ITEMS)      (new TYPE[ITEMS])
+#endif
+#define RI_DELETE(PARAMS)              (delete (PARAMS))
+#define RI_DELETE_ARRAY(PARAMS)        (delete[] (PARAMS))
+
+bool			isValidImageFormat(int format);
+bool      isValidImageFormat(EGLNativePixmapType f);
+
+//=======================================================================
+
+}	//namespace OpenVGRI
+
+#endif /* __RIDEFS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riFont.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,203 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of Font class.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riFont.h"
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Font constructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Font::Font(int capacityHint) :
+	m_referenceCount(0),
+	m_glyphs()
+{
+	RI_ASSERT(capacityHint >= 0);
+	m_glyphs.reserve(capacityHint);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Font destructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Font::~Font()
+{
+	//remove references to paths and images
+	for(int i=0;i<m_glyphs.size();i++)
+		clearGlyph(&m_glyphs[i]);
+	RI_ASSERT(m_referenceCount == 0);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Find a glyph based on glyphIndex.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Font::Glyph* Font::findGlyph(unsigned int index)
+{
+    for(int i=0;i<m_glyphs.size();i++)
+    {
+        if(m_glyphs[i].m_state != Glyph::GLYPH_UNINITIALIZED && m_glyphs[i].m_index == index)
+            return &m_glyphs[i];
+    }
+    return NULL;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Find a free glyph or allocate a new one.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Font::Glyph* Font::newGlyph()
+{
+    for(int i=0;i<m_glyphs.size();i++)
+    {
+        if(m_glyphs[i].m_state == Glyph::GLYPH_UNINITIALIZED)
+            return &m_glyphs[i];
+    }
+    m_glyphs.resize(m_glyphs.size()+1);
+    return &m_glyphs[m_glyphs.size()-1];
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Free glyph and its data.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Font::clearGlyph(Glyph* g)
+{
+    RI_ASSERT(g);
+	if(g->m_path != VG_INVALID_HANDLE)
+	{
+		Path* p = (Path*)g->m_path;
+		if(!p->removeReference())
+			RI_DELETE(p);
+	}
+	if(g->m_image != VG_INVALID_HANDLE)
+	{
+		Image* p = (Image*)g->m_image;
+		p->removeInUse();
+		if(!p->removeReference())
+			RI_DELETE(p);
+	}
+	Glyph a;
+	*g = a;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Font::setGlyphToPath(unsigned int index, VGPath path, bool isHinted, const Vector2& origin, const Vector2& escapement)
+{
+    Glyph* g = findGlyph(index);
+    if(g)
+    {   //glyph exists, replace
+        clearGlyph(g);
+    }
+    else
+    {   //glyph doesn't exist, allocate a new one
+        g = newGlyph();
+    }
+
+    g->m_index = index;
+    g->m_state = Glyph::GLYPH_PATH;
+	g->m_path = path;
+    g->m_image = VG_INVALID_HANDLE;
+	g->m_isHinted = isHinted;
+	g->m_origin = origin;
+	g->m_escapement = escapement;
+
+    if(path != VG_INVALID_HANDLE)
+    {
+        Path* p = (Path*)path;
+        p->addReference();
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Font::setGlyphToImage(unsigned int index, VGImage image, const Vector2& origin, const Vector2& escapement)
+{
+    Glyph* g = findGlyph(index);
+    if(g)
+    {   //glyph exists, replace
+        clearGlyph(g);
+    }
+    else
+    {   //glyph doesn't exist, allocate a new one
+        g = newGlyph();
+    }
+
+    g->m_index = index;
+    g->m_state = Glyph::GLYPH_IMAGE;
+	g->m_path = VG_INVALID_HANDLE;
+    g->m_image = image;
+	g->m_isHinted = false;
+	g->m_origin = origin;
+	g->m_escapement = escapement;
+
+    if(image != VG_INVALID_HANDLE)
+    {
+        Image* p = (Image*)image;
+        p->addReference();
+        p->addInUse();
+    }
+}
+
+//=======================================================================
+
+}	//namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riFont.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,116 @@
+#ifndef __RIFONT_H
+#define __RIFONT_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	VGContext class. Used for storing OpenVG state.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _OPENVG_H
+#include "openvg.h"
+#endif
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIARRAY_H
+#include "riArray.h"
+#endif
+
+#ifndef __RIPATH_H
+#include "riPath.h"
+#endif
+
+#ifndef __RIIMAGE_H
+#include "riImage.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Storage and operations for VGFont.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Font
+{
+public:
+	struct Glyph
+	{
+        enum State
+        {
+            GLYPH_UNINITIALIZED     = 0,
+            GLYPH_PATH              = 1,
+            GLYPH_IMAGE             = 2
+        };
+		Glyph()				{ m_state = GLYPH_UNINITIALIZED; m_path = m_image = VG_INVALID_HANDLE; m_isHinted = false; m_origin.set(0.0f, 0.0f); m_escapement.set(0.0f, 0.0f); }
+        unsigned int m_index;
+        State        m_state;
+		VGPath		 m_path;
+		VGImage		 m_image;
+		bool		 m_isHinted;
+		Vector2		 m_origin;
+		Vector2		 m_escapement;
+	};
+
+	Font(int capacityHint);	//throws bad_alloc
+	~Font();
+
+	int				getNumGlyphs() const					{ int n=0; for(int i=0;i<m_glyphs.size();i++) { if(m_glyphs[i].m_state != Glyph::GLYPH_UNINITIALIZED) n++; } return n; }
+	void			addReference()							{ m_referenceCount++; }
+	int				removeReference()						{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+	void			setGlyphToPath(unsigned int index, VGPath path, bool isHinted, const Vector2& origin, const Vector2& escapement);    //throws bad_alloc
+	void			setGlyphToImage(unsigned int index, VGImage image, const Vector2& origin, const Vector2& escapement);    //throws bad_alloc
+    Glyph*          findGlyph(unsigned int index);
+    void            clearGlyph(Glyph* g);
+private:
+	Font(const Font&);						//!< Not allowed.
+	void operator=(const Font&);			//!< Not allowed.
+
+    Glyph*          newGlyph();    //throws bad_alloc
+
+	int				m_referenceCount;
+	Array<Glyph>	m_glyphs;
+};
+
+//=======================================================================
+
+}	//namespace OpenVGRI
+
+//=======================================================================
+
+#endif /* __RIFONT_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riImage.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,2673 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of Color and Image functions.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riImage.h"
+#include "riRasterizer.h"
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from numBits into a shifted mask
+* \param	
+* \return	
+* \note
+*//*-------------------------------------------------------------------*/
+	
+static unsigned int bitsToMask(unsigned int bits, unsigned int shift)
+{
+	return ((1<<bits)-1) << shift;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from color (RIfloat) to an int with 1.0f mapped to the
+*			given maximum with round-to-nearest semantics.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+	
+static unsigned int colorToInt(RIfloat c, int maxc)
+{
+	return RI_INT_MIN(RI_INT_MAX((int)floor(c * (RIfloat)maxc + 0.5f), 0), maxc);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from int to color (RIfloat) with the given maximum
+*			mapped to 1.0f.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static RI_INLINE RIfloat intToColor(unsigned int i, unsigned int maxi)
+{
+	return (RIfloat)(i & maxi) / (RIfloat)maxi;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from packed integer in a given format to a Color.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Color::unpack(unsigned int inputData, const Color::Descriptor& inputDesc)
+{
+	int rb = inputDesc.redBits;
+	int gb = inputDesc.greenBits;
+	int bb = inputDesc.blueBits;
+	int ab = inputDesc.alphaBits;
+	int lb = inputDesc.luminanceBits;
+	int rs = inputDesc.redShift;
+	int gs = inputDesc.greenShift;
+	int bs = inputDesc.blueShift;
+	int as = inputDesc.alphaShift;
+	int ls = inputDesc.luminanceShift;
+
+	m_format = inputDesc.internalFormat;
+	if(lb)
+	{	//luminance
+		r = g = b = intToColor(inputData >> ls, (1<<lb)-1);
+		a = 1.0f;
+	}
+	else
+	{	//rgba
+		r = rb ? intToColor(inputData >> rs, (1<<rb)-1) : (RIfloat)1.0f;
+		g = gb ? intToColor(inputData >> gs, (1<<gb)-1) : (RIfloat)1.0f;
+		b = bb ? intToColor(inputData >> bs, (1<<bb)-1) : (RIfloat)1.0f;
+		a = ab ? intToColor(inputData >> as, (1<<ab)-1) : (RIfloat)1.0f;
+
+		if(isPremultiplied())
+		{	//clamp premultiplied color to alpha to enforce consistency
+			r = RI_MIN(r, a);
+			g = RI_MIN(g, a);
+			b = RI_MIN(b, a);
+		}
+	}
+
+    assertConsistency();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from Color to a packed integer in a given format.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+unsigned int Color::pack(const Color::Descriptor& outputDesc) const
+{
+    assertConsistency();
+
+	int rb = outputDesc.redBits;
+	int gb = outputDesc.greenBits;
+	int bb = outputDesc.blueBits;
+	int ab = outputDesc.alphaBits;
+	int lb = outputDesc.luminanceBits;
+	int rs = outputDesc.redShift;
+	int gs = outputDesc.greenShift;
+	int bs = outputDesc.blueShift;
+	int as = outputDesc.alphaShift;
+	int ls = outputDesc.luminanceShift;
+
+	if(lb)
+	{	//luminance
+		RI_ASSERT(isLuminance());
+		return colorToInt(r, (1<<lb)-1) << ls;
+	}
+	else
+	{	//rgb
+		RI_ASSERT(!isLuminance());
+		unsigned int cr = rb ? colorToInt(r, (1<<rb)-1) : 0;
+		unsigned int cg = gb ? colorToInt(g, (1<<gb)-1) : 0;
+		unsigned int cb = bb ? colorToInt(b, (1<<bb)-1) : 0;
+		unsigned int ca = ab ? colorToInt(a, (1<<ab)-1) : 0;
+		return (cr << rs) | (cg << gs) | (cb << bs) | (ca << as);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from the current internal format to another.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static RIfloat gamma(RIfloat c)
+{
+	if( c <= 0.00304f )
+		c *= 12.92f;
+	else
+		c = 1.0556f * (RIfloat)pow(c, 1.0f/2.4f) - 0.0556f;
+	return c;
+}
+
+static RIfloat invgamma(RIfloat c)
+{
+	if( c <= 0.03928f )
+		c /= 12.92f;
+	else
+		c = (RIfloat)pow((c + 0.0556f)/1.0556f, 2.4f);
+	return c;
+}
+
+static RIfloat lRGBtoL(RIfloat r, RIfloat g, RIfloat b)
+{
+	return 0.2126f*r + 0.7152f*g + 0.0722f*b;
+}
+
+void Color::convert(InternalFormat outputFormat)
+{
+    assertConsistency();
+
+	if( m_format == outputFormat )
+		return;
+
+	if(isPremultiplied())
+	{	//unpremultiply
+		RIfloat ooa = (a != 0.0f) ? 1.0f / a : (RIfloat)0.0f;
+		r *= ooa;
+		g *= ooa;
+		b *= ooa;
+	}
+
+	//From Section 3.4.2 of OpenVG spec
+	//1: sRGB = gamma(lRGB)
+	//2: lRGB = invgamma(sRGB)
+	//3: lL = 0.2126 lR + 0.7152 lG + 0.0722 lB
+	//4: lRGB = lL
+	//5: sL = gamma(lL)
+	//6: lL = invgamma(sL)
+	//7: sRGB = sL
+
+	//Source/Dest lRGB sRGB   lL   sL 
+	//lRGB          -    1    3    3,5 
+	//sRGB          2    -    2,3  2,3,5 
+	//lL            4    4,1  -    5 
+	//sL            7,2  7    6    - 
+
+	const unsigned int shift = 3;
+	unsigned int conversion = (m_format & (NONLINEAR | LUMINANCE)) | ((outputFormat & (NONLINEAR | LUMINANCE)) << shift);
+
+	switch(conversion)
+	{
+	case lRGBA | (sRGBA << shift): r = gamma(r); g = gamma(g); b = gamma(b); break;							//1
+	case lRGBA | (lLA << shift)  : r = g = b = lRGBtoL(r, g, b); break;										//3
+	case lRGBA | (sLA << shift)  : r = g = b = gamma(lRGBtoL(r, g, b)); break;								//3,5
+	case sRGBA | (lRGBA << shift): r = invgamma(r); g = invgamma(g); b = invgamma(b); break;				//2
+	case sRGBA | (lLA << shift)  : r = g = b = lRGBtoL(invgamma(r), invgamma(g), invgamma(b)); break;		//2,3
+	case sRGBA | (sLA << shift)  : r = g = b = gamma(lRGBtoL(invgamma(r), invgamma(g), invgamma(b))); break;//2,3,5
+	case lLA   | (lRGBA << shift): break;																	//4
+	case lLA   | (sRGBA << shift): r = g = b = gamma(r); break;												//4,1
+	case lLA   | (sLA << shift)  : r = g = b = gamma(r); break;												//5
+	case sLA   | (lRGBA << shift): r = g = b = invgamma(r); break;											//7,2
+	case sLA   | (sRGBA << shift): break;																	//7
+	case sLA   | (lLA << shift)  : r = g = b = invgamma(r); break;											//6
+	default: RI_ASSERT((m_format & (LUMINANCE | NONLINEAR)) == (outputFormat & (LUMINANCE | NONLINEAR))); break;	//nop
+	}
+
+	if(outputFormat & PREMULTIPLIED)
+	{	//premultiply
+		r *= a;
+		g *= a;
+		b *= a;
+	}
+	m_format = outputFormat;
+
+    assertConsistency();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Creates a pixel format descriptor out of VGImageFormat
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Color::Descriptor Color::formatToDescriptor(VGImageFormat format)
+{
+	Descriptor desc;
+	memset(&desc, 0, sizeof(Descriptor));
+	RI_ASSERT(isValidImageFormat(format));
+
+	int baseFormat = (int)format & 15;
+	const int numBaseFormats = 15;
+	RI_ASSERT(baseFormat >= 0 && baseFormat < numBaseFormats);
+	int swizzleBits = ((int)format >> 6) & 3;
+
+	/* base formats
+	VG_sRGBX_8888                               =  0,
+	VG_sRGBA_8888                               =  1,
+	VG_sRGBA_8888_PRE                           =  2,
+	VG_sRGB_565                                 =  3,
+	VG_sRGBA_5551                               =  4,
+	VG_sRGBA_4444                               =  5,
+	VG_sL_8                                     =  6,
+	VG_lRGBX_8888                               =  7,
+	VG_lRGBA_8888                               =  8,
+	VG_lRGBA_8888_PRE                           =  9,
+	VG_lL_8                                     = 10,
+	VG_A_8                                      = 11,
+	VG_BW_1                                     = 12,
+	VG_A_1                                      = 13,
+	VG_A_4                                      = 14,
+	*/
+
+	static const int redBits[numBaseFormats] =       {8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+	static const int greenBits[numBaseFormats] =     {8, 8, 8, 6, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+	static const int blueBits[numBaseFormats] =      {8, 8, 8, 5, 5, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0};
+	static const int alphaBits[numBaseFormats] =     {0, 8, 8, 0, 1, 4, 0, 0, 8, 8, 0, 8, 0, 1, 4};
+	static const int luminanceBits[numBaseFormats] = {0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 8, 0, 1, 0, 0};
+
+	static const int redShifts[4*numBaseFormats] = {24, 24, 24, 11, 11, 12, 0, 24, 24, 24, 0, 0, 0, 0, 0,	//RGBA
+													16, 16, 16, 11, 10, 8,  0, 16, 16, 16, 0, 0, 0, 0, 0,	//ARGB
+													8,  8,  8,  0,  1,  4,  0, 8,  8,  8,  0, 0, 0, 0, 0,	//BGRA
+													0,  0,  0,  0,  0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0};	//ABGR
+
+	static const int greenShifts[4*numBaseFormats] = {16, 16, 16, 5,  6,  8,  0, 16, 16, 16, 0, 0, 0, 0, 0,	//RGBA
+													  8,  8,  8,  5,  5,  4,  0, 8,  8,  8,  0, 0, 0, 0, 0,	//ARGB
+													  16, 16, 16, 5,  6,  8,  0, 16, 16, 16, 0, 0, 0, 0, 0,	//BGRA
+													  8,  8,  8,  5,  5,  4,  0, 8,  8,  8,  0, 0, 0, 0, 0};//ABGR
+
+	static const int blueShifts[4*numBaseFormats] =  {8,  8,  8,  0,  1,  4,  0, 8,  8,  8,  0, 0, 0, 0, 0,	//RGBA
+													  0,  0,  0,  0,  0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0,	//ARGB
+													  24, 24, 24, 11, 11, 12, 0, 24, 24, 24, 0, 0, 0, 0, 0,	//BGRA
+													  16, 16, 16, 11, 10, 8,  0, 16, 16, 16, 0, 0, 0, 0, 0};//ABGR
+
+	static const int alphaShifts[4*numBaseFormats] = {0,  0,  0,  0,  0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0,	//RGBA
+													  0,  24, 24, 0,  15, 12, 0, 0,  24, 24, 0, 0, 0, 0, 0,	//ARGB
+													  0,  0,  0,  0,  0,  0,  0, 0,  0,  0,  0, 0, 0, 0, 0,	//BGRA
+													  0,  24, 24, 0,  15, 12, 0, 0,  24, 24, 0, 0, 0, 0, 0};//ABGR
+
+	static const int bpps[numBaseFormats] = {32, 32, 32, 16, 16, 16, 8, 32, 32, 32, 8, 8, 1, 1, 4};
+
+	static const InternalFormat internalFormats[numBaseFormats] = {sRGBA, sRGBA, sRGBA_PRE, sRGBA, sRGBA, sRGBA, sLA, lRGBA, lRGBA, lRGBA_PRE, lLA, lRGBA, lLA, lRGBA, lRGBA};
+
+	desc.redBits = redBits[baseFormat];
+	desc.greenBits = greenBits[baseFormat];
+	desc.blueBits = blueBits[baseFormat];
+	desc.alphaBits = alphaBits[baseFormat];
+	desc.luminanceBits = luminanceBits[baseFormat];
+
+	desc.redShift = redShifts[swizzleBits * numBaseFormats + baseFormat];
+	desc.greenShift = greenShifts[swizzleBits * numBaseFormats + baseFormat];
+	desc.blueShift = blueShifts[swizzleBits * numBaseFormats + baseFormat];
+	desc.alphaShift = alphaShifts[swizzleBits * numBaseFormats + baseFormat];
+	desc.luminanceShift = 0;	//always zero
+
+	desc.format = format;
+	desc.bitsPerPixel = bpps[baseFormat];
+	desc.internalFormat = internalFormats[baseFormat];
+
+	return desc;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Checks if the pixel format descriptor is valid (i.e. all the
+*           values are supported by the RI)
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Color::isValidDescriptor(const Color::Descriptor& desc)
+{
+	//A valid descriptor has 1, 2, 4, 8, 16, or 32 bits per pixel, and either luminance or rgba channels, but not both.
+	//Any of the rgba channels can be missing, and not all bits need to be used. Maximum channel bit depth is 8.
+	int rb = desc.redBits;
+	int gb = desc.greenBits;
+	int bb = desc.blueBits;
+	int ab = desc.alphaBits;
+	int lb = desc.luminanceBits;
+	int rs = desc.redShift;
+	int gs = desc.greenShift;
+	int bs = desc.blueShift;
+	int as = desc.alphaShift;
+	int ls = desc.luminanceShift;
+	int bpp = desc.bitsPerPixel;
+
+	int rgbaBits = rb + gb + bb + ab;
+	if(rb < 0 || rb > 8 || rs < 0 || rs + rb > bpp || !(rb || !rs))
+		return false;	//invalid channel description
+	if(gb < 0 || gb > 8 || gs < 0 || gs + gb > bpp || !(gb || !gs))
+		return false;	//invalid channel description
+	if(bb < 0 || bb > 8 || bs < 0 || bs + bb > bpp || !(bb || !bs))
+		return false;	//invalid channel description
+	if(ab < 0 || ab > 8 || as < 0 || as + ab > bpp || !(ab || !as))
+		return false;	//invalid channel description
+	if(lb < 0 || lb > 8 || ls < 0 || ls + lb > bpp || !(lb || !ls))
+		return false;	//invalid channel description
+
+	if(rgbaBits && lb)
+		return false;	//can't have both rgba and luminance
+	if(!rgbaBits && !lb)
+		return false;	//must have either rgba or luminance
+	if(rgbaBits)
+	{	//rgba
+		if(rb+gb+bb == 0)
+		{	//alpha only
+			if(rs || gs || bs || as || ls)
+				return false;	//wrong shifts (even alpha shift must be zero)
+			if((ab != 1 && ab != 2  && ab != 4 && ab != 8) || bpp != ab)
+				return false;	//alpha size must be 1, 2, 4, or, 8, bpp must match
+		}
+		else
+		{	//rgba
+			if(rgbaBits > bpp)
+				return false;	//bpp must be greater than or equal to the sum of rgba bits
+			if(!(bpp == 32 || bpp == 16 || bpp == 8))
+				return false;	//only 1, 2, and 4 byte formats are supported for rgba
+			
+			unsigned int rm = bitsToMask((unsigned int)rb, (unsigned int)rs);
+			unsigned int gm = bitsToMask((unsigned int)gb, (unsigned int)gs);
+			unsigned int bm = bitsToMask((unsigned int)bb, (unsigned int)bs);
+			unsigned int am = bitsToMask((unsigned int)ab, (unsigned int)as);
+			if((rm & gm) || (rm & bm) || (rm & am) || (gm & bm) || (gm & am) || (bm & am))
+				return false;	//channels overlap
+		}
+	}
+	else
+	{	//luminance
+		if(rs || gs || bs || as || ls)
+			return false;	//wrong shifts (even luminance shift must be zero)
+		if(!(lb == 1 || lb == 8) || bpp != lb)
+			return false;	//luminance size must be either 1 or 8, bpp must match
+	}
+
+	if(desc.format != -1)
+	{
+		if(!isValidImageFormat(desc.format))
+			return false;	//invalid image format
+
+		Descriptor d = formatToDescriptor(desc.format);
+		if(d.redBits != rb || d.greenBits != gb || d.blueBits != bb || d.alphaBits != ab || d.luminanceBits != lb ||
+		   d.redShift != rs || d.greenShift != gs || d.blueShift != bs || d.alphaShift != as || d.luminanceShift != ls ||
+		   d.bitsPerPixel != bpp)
+		   return false;	//if the descriptor has a VGImageFormat, it must match the bits, shifts, and bpp
+	}
+
+	if((unsigned int)desc.internalFormat & ~(Color::PREMULTIPLIED | Color::NONLINEAR | Color::LUMINANCE))
+		return false;	//invalid internal format
+
+	return true;
+}
+
+//==============================================================================================
+
+
+
+
+//==============================================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Constructs a blank image.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Image::Image(const Color::Descriptor& desc, int width, int height, VGbitfield allowedQuality) :
+	m_desc(desc),
+	m_width(width),
+	m_height(height),
+	m_allowedQuality(allowedQuality),
+	m_inUse(0),
+	m_stride(0),
+	m_data(NULL),
+	m_referenceCount(0),
+	m_ownsData(true),
+	m_parent(NULL),
+    m_storageOffsetX(0),
+    m_storageOffsetY(0),
+	m_mipmapsValid(false),
+	m_mipmaps()
+{
+	RI_ASSERT(Color::isValidDescriptor(m_desc));
+	RI_ASSERT(width > 0 && height > 0);
+	
+	m_stride = (m_width*m_desc.bitsPerPixel+7)/8;
+
+	m_data = RI_NEW_ARRAY(RIuint8, m_stride*m_height);	//throws bad_alloc
+	memset(m_data, 0, m_stride*m_height);	//clear image
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Constructs an image that uses an external array for its data
+*			storage.
+* \param	
+* \return	
+* \note		this is meant for internal use to make blitting easier
+*//*-------------------------------------------------------------------*/
+
+Image::Image(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data) :
+	m_desc(desc),
+	m_width(width),
+	m_height(height),
+	m_allowedQuality(0),
+	m_inUse(0),
+	m_stride(stride),
+	m_data(data),
+	m_referenceCount(0),
+	m_ownsData(false),
+	m_parent(NULL),
+    m_storageOffsetX(0),
+    m_storageOffsetY(0),
+	m_mipmapsValid(false),
+	m_mipmaps()
+{
+	RI_ASSERT(Color::isValidDescriptor(m_desc));
+	RI_ASSERT(width > 0 && height > 0);
+	RI_ASSERT(data);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Construcs a child image.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Image::Image(Image* parent, int x, int y, int width, int height) :
+	m_desc(Color::formatToDescriptor(VG_sRGBA_8888)),	//dummy initialization, will be overwritten below (can't read from parent->m_desc before knowing the pointer is valid)
+	m_width(width),
+	m_height(height),
+	m_allowedQuality(0),
+	m_inUse(0),
+	m_stride(0),
+	m_data(NULL),
+	m_referenceCount(0),
+	m_ownsData(false),
+	m_parent(parent),
+    m_storageOffsetX(0),
+    m_storageOffsetY(0),
+	m_mipmapsValid(false),
+	m_mipmaps()
+{
+	RI_ASSERT(parent);
+	RI_ASSERT(x >= 0 && y >= 0 && width > 0 && height > 0);
+	RI_ASSERT(RI_INT_ADDSATURATE(x,width) <= parent->m_width && RI_INT_ADDSATURATE(y,height) <= parent->m_height);	//child image must be contained in parent
+
+	m_desc = parent->m_desc;
+	RI_ASSERT(Color::isValidDescriptor(m_desc));
+	m_allowedQuality = parent->m_allowedQuality;
+	m_stride = parent->m_stride;
+	m_data = parent->m_data;
+    m_storageOffsetX = parent->m_storageOffsetX + x;
+    m_storageOffsetY = parent->m_storageOffsetY + y;
+
+	//increase the reference and use count of the parent
+	addInUse();
+	parent->addInUse();
+	parent->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Image destructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Image::~Image()
+{
+	RI_ASSERT(m_referenceCount == 0);
+
+	if(m_parent)
+	{
+		//decrease the reference and use count of the parent
+		removeInUse();
+		m_parent->removeInUse();
+		if(!m_parent->removeReference())
+			RI_DELETE(m_parent);
+	}
+	RI_ASSERT(m_inUse == 0);
+
+	for(int i=0;i<m_mipmaps.size();i++)
+	{
+		if(!m_mipmaps[i]->removeReference())
+			RI_DELETE(m_mipmaps[i]);
+		else
+		{
+			RI_ASSERT(0);	//there can't be any other references to the mipmap levels
+		}
+	}
+	m_mipmaps.clear();
+
+	if(m_ownsData)
+	{
+		RI_ASSERT(!m_parent);		//can't have parent if owns the data
+		RI_DELETE_ARRAY(m_data);	//delete image data if we own it
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns true if the two images share pixels.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Image::overlaps(const Image* src) const
+{
+	RI_ASSERT(src);
+
+	if(m_data != src->m_data)
+		return false;	//images don't share data
+
+	//check if the image storage regions overlap
+	Rectangle r(m_storageOffsetX, m_storageOffsetY, m_width, m_height);
+	r.intersect(Rectangle(src->m_storageOffsetX, src->m_storageOffsetY, src->m_width, src->m_height));
+	if(!r.width || !r.height)
+		return false;	//intersection is empty, images don't overlap	
+
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Clears a rectangular portion of an image with the given clear color.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::clear(const Color& clearColor, int x, int y, int w, int h)
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(m_referenceCount > 0);
+
+	//intersect clear region with image bounds
+	Rectangle r(0,0,m_width,m_height);
+	r.intersect(Rectangle(x,y,w,h));
+	if(!r.width || !r.height)
+		return;		//intersection is empty or one of the rectangles is invalid
+
+	Color col = clearColor;
+	col.clamp();
+	col.convert(m_desc.internalFormat);
+
+	for(int j=r.y;j<r.y + r.height;j++)
+	{
+		for(int i=r.x;i<r.x + r.width;i++)
+		{
+			writePixel(i, j, col);
+		}
+	}
+
+	m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Blits a source region to destination. Source and destination
+*			can overlap.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static RIfloat ditherChannel(RIfloat c, int bits, RIfloat m)
+{
+	RIfloat fc = c * (RIfloat)((1<<bits)-1);
+	RIfloat ic = (RIfloat)floor(fc);
+	if(fc - ic > m) ic += 1.0f;
+	return RI_MIN(ic / (RIfloat)((1<<bits)-1), 1.0f);
+}
+
+static void computeBlitRegion(int& sx, int& sy, int& dx, int& dy, int& w, int& h, int srcWidth, int srcHeight, int dstWidth, int dstHeight)
+{
+	RI_ASSERT(w > 0 && h > 0);
+	sx = RI_INT_MIN(RI_INT_MAX(sx, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+	sy = RI_INT_MIN(RI_INT_MAX(sy, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+	dx = RI_INT_MIN(RI_INT_MAX(dx, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+	dy = RI_INT_MIN(RI_INT_MAX(dy, (int)(RI_INT32_MIN>>2)), (int)(RI_INT32_MAX>>2));
+	w = RI_INT_MIN(w, (int)(RI_INT32_MAX>>2));
+	h = RI_INT_MIN(h, (int)(RI_INT32_MAX>>2));
+	int srcsx = sx, srcex = sx + w, dstsx = dx, dstex = dx + w;
+	if(srcsx < 0)
+	{
+		dstsx -= srcsx;
+		srcsx = 0;
+	}
+	if(srcex > srcWidth)
+	{
+		dstex -= srcex - srcWidth;
+		srcex = srcWidth;
+	}
+	if(dstsx < 0)
+	{
+		srcsx -= dstsx;
+		dstsx = 0;
+	}
+	if(dstex > dstWidth)
+	{
+		srcex -= dstex - dstWidth;
+		dstex = dstWidth;
+	}
+	RI_ASSERT(srcsx >= 0 && dstsx >= 0 && srcex <= srcWidth && dstex <= dstWidth);
+	w = srcex - srcsx;
+	RI_ASSERT(w == dstex - dstsx);
+
+	int srcsy = sy, srcey = sy + h, dstsy = dy, dstey = dy + h;
+	if(srcsy < 0)
+	{
+		dstsy -= srcsy;
+		srcsy = 0;
+	}
+	if(srcey > srcHeight)
+	{
+		dstey -= srcey - srcHeight;
+		srcey = srcHeight;
+	}
+	if(dstsy < 0)
+	{
+		srcsy -= dstsy;
+		dstsy = 0;
+	}
+	if(dstey > dstHeight)
+	{
+		srcey -= dstey - dstHeight;
+		dstey = dstHeight;
+	}
+	RI_ASSERT(srcsy >= 0 && dstsy >= 0 && srcey <= srcHeight && dstey <= dstHeight);
+	h = srcey - srcsy;
+	RI_ASSERT(h == dstey - dstsy);
+	sx = srcsx;
+	sy = srcsy;
+	dx = dstsx;
+	dy = dstsy;
+}
+
+void Image::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, bool dither)
+{
+	//img=>img: vgCopyImage
+	//img=>user: vgGetImageSubData
+	//user=>img: vgImageSubData
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	computeBlitRegion(sx, sy, dx, dy, w, h, src.m_width, src.m_height, m_width, m_height);
+	if(w <= 0 || h <= 0)
+		return;	//zero area
+
+	Array<Color> tmp;
+	tmp.resize(w*h);	//throws bad_alloc
+
+	//copy source region to tmp
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color c = src.readPixel(sx + i, sy + j);
+			c.convert(m_desc.internalFormat);
+			tmp[j*w+i] = c;
+		}
+	}
+
+	int rbits = m_desc.redBits, gbits = m_desc.greenBits, bbits = m_desc.blueBits, abits = m_desc.alphaBits;
+	if(m_desc.isLuminance())
+	{
+		rbits = gbits = bbits = m_desc.luminanceBits;
+		abits = 0;
+	}
+
+	//write tmp to destination region
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color col = tmp[j*w+i];
+
+			if(dither)
+			{
+				static const int matrix[16] = {
+					0,  8,  2,  10,
+					12, 4,  14, 6,
+					3,  11, 1,  9,
+					15, 7,  13, 5};
+				int x = i & 3;
+				int y = j & 3;
+				RIfloat m = matrix[y*4+x] / 16.0f;
+
+				if(rbits) col.r = ditherChannel(col.r, rbits, m);
+				if(gbits) col.g = ditherChannel(col.g, gbits, m);
+				if(bbits) col.b = ditherChannel(col.b, bbits, m);
+				if(abits) col.a = ditherChannel(col.a, abits, m);
+			}
+
+			writePixel(dx + i, dy + j, col);
+		}
+	}
+	m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts from multisampled format to display format.
+* \param	
+* \return	
+* \note
+*//*-------------------------------------------------------------------*/
+
+void Image::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h)
+{
+	//fb=>img: vgGetPixels
+	//fb=>user: vgReadPixels
+	RI_ASSERT(!src->isInUse(this));
+
+	computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), m_width, m_height);
+	if(w <= 0 || h <= 0)
+		return;	//zero area
+
+	for(int y=0;y<h;y++)
+	{
+		for(int x=0;x<w;x++)
+		{
+			Color r = src->FSAAResolve(sx + x, sy + y);
+			r.convert(getDescriptor().internalFormat);
+			writePixel(dx + x, dy + y, r);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns the color at pixel (x,y).
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Color Image::readPixel(int x, int y) const
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(x >= 0 && x < m_width);
+	RI_ASSERT(y >= 0 && y < m_height);
+	RI_ASSERT(m_referenceCount > 0);
+    x += m_storageOffsetX;
+    y += m_storageOffsetY;
+
+	unsigned int p = 0;
+	RIuint8* scanline = m_data + y * m_stride;
+	switch(m_desc.bitsPerPixel)
+	{
+	case 32:
+	{
+		RIuint32* s = (((RIuint32*)scanline) + x);
+		p = (unsigned int)*s;
+		break;
+	}
+
+	case 16:
+	{
+		RIuint16* s = ((RIuint16*)scanline) + x;
+		p = (unsigned int)*s;
+		break;
+	}
+
+    case 8:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + x;
+		p = (unsigned int)*s;
+		break;
+	}
+
+    case 4:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + (x>>1);
+		p = (unsigned int)(*s >> ((x&1)<<2)) & 0xf;
+		break;
+	}
+
+    case 2:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + (x>>2);
+		p = (unsigned int)(*s >> ((x&3)<<1)) & 0x3;
+		break;
+	}
+
+    default:
+	{
+		RI_ASSERT(m_desc.bitsPerPixel == 1);
+		RIuint8* s = ((RIuint8*)scanline) + (x>>3);
+		p = (unsigned int)(*s >> (x&7)) & 0x1;
+		break;
+	}
+	}
+	Color c;
+	c.unpack(p, m_desc);
+	return c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Writes the color to pixel (x,y). Internal color formats must
+*			match.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::writePixel(int x, int y, const Color& c)
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(x >= 0 && x < m_width);
+	RI_ASSERT(y >= 0 && y < m_height);
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(c.getInternalFormat() == m_desc.internalFormat);
+    x += m_storageOffsetX;
+    y += m_storageOffsetY;
+
+	unsigned int p = c.pack(m_desc);
+	RIuint8* scanline = m_data + y * m_stride;
+	switch(m_desc.bitsPerPixel)
+	{
+	case 32:
+	{
+		RIuint32* s = ((RIuint32*)scanline) + x;
+		*s = (RIuint32)p;
+		break;
+	}
+
+	case 16:
+	{
+		RIuint16* s = ((RIuint16*)scanline) + x;
+		*s = (RIuint16)p;
+		break;
+	}
+
+	case 8:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + x;
+		*s = (RIuint8)p;
+		break;
+	}
+    case 4:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + (x>>1);
+        *s = (RIuint8)((p << ((x&1)<<2)) | ((unsigned int)*s & ~(0xf << ((x&1)<<2))));
+		break;
+	}
+
+    case 2:
+	{
+		RIuint8* s = ((RIuint8*)scanline) + (x>>2);
+        *s = (RIuint8)((p << ((x&3)<<1)) | ((unsigned int)*s & ~(0x3 << ((x&3)<<1))));
+		break;
+	}
+
+    default:
+	{
+		RI_ASSERT(m_desc.bitsPerPixel == 1);
+		RIuint8* s = ((RIuint8*)scanline) + (x>>3);
+        *s = (RIuint8)((p << (x&7)) | ((unsigned int)*s & ~(0x1 << (x&7))));
+		break;
+	}
+	}
+	m_mipmapsValid = false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Writes a filtered color to destination surface
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::writeFilteredPixel(int i, int j, const Color& color, VGbitfield channelMask)
+{
+	//section 3.4.4: before color space conversion, premultiplied colors are
+	//clamped to alpha, and the color is converted to nonpremultiplied format
+	//section 11.2: how to deal with channel mask
+	//step 1
+	Color f = color;
+	f.clamp();			//vgColorMatrix and vgLookups can produce colors that exceed alpha or [0,1] range
+
+	//step 2: color space conversion
+	f.convert((Color::InternalFormat)(m_desc.internalFormat & (Color::NONLINEAR | Color::LUMINANCE)));
+
+	//step 3: read the destination color and convert it to nonpremultiplied
+	Color d = readPixel(i,j);
+	d.unpremultiply();
+	RI_ASSERT(d.getInternalFormat() == f.getInternalFormat());
+
+	//step 4: replace the destination channels specified by the channelMask (channelmask is ignored for luminance formats)
+    if(!m_desc.isLuminance())
+    {   //rgba format => use channelmask
+        if(channelMask & VG_RED)
+            d.r = f.r;
+        if(channelMask & VG_GREEN)
+            d.g = f.g;
+        if(channelMask & VG_BLUE)
+            d.b = f.b;
+        if(channelMask & VG_ALPHA)
+            d.a = f.a;
+    }
+    else d = f;
+
+	//step 5: if destination is premultiplied, convert to premultiplied format
+	if(m_desc.isPremultiplied())
+		d.premultiply();
+	//write the color to destination
+	writePixel(i,j,d);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Reads the pixel (x,y) and converts it into an alpha mask value.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+RIfloat Image::readMaskPixel(int x, int y) const
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(x >= 0 && x < m_width);
+	RI_ASSERT(y >= 0 && y < m_height);
+	RI_ASSERT(m_referenceCount > 0);
+
+	Color c = readPixel(x,y);
+	if(m_desc.isLuminance())
+	{
+		return c.r;
+	}
+	else
+	{	//rgba
+		if(m_desc.alphaBits)
+			return c.a;
+		return c.r;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Writes the alpha mask to pixel (x,y).
+* \param	
+* \return	
+* \note		Overwrites color.
+*//*-------------------------------------------------------------------*/
+
+void Image::writeMaskPixel(int x, int y, RIfloat m)
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(x >= 0 && x < m_width);
+	RI_ASSERT(y >= 0 && y < m_height);
+	RI_ASSERT(m_referenceCount > 0);
+
+    //if luminance or no alpha, red channel will be used, otherwise alpha channel will be used
+    writePixel(x, y, Color(m,m,m,m,m_desc.internalFormat));
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Reads a texel (u,v) at the given mipmap level. Tiling modes and
+*			color space conversion are applied. Outputs color in premultiplied
+*			format.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Color Image::readTexel(int u, int v, int level, VGTilingMode tilingMode, const Color& tileFillColor) const
+{
+	const Image* image = this;
+	if( level > 0 )
+	{
+		RI_ASSERT(level <= m_mipmaps.size());
+		image = m_mipmaps[level-1];
+	}
+	RI_ASSERT(image);
+
+	Color p;
+	if(tilingMode == VG_TILE_FILL)
+	{
+		if(u < 0 || v < 0 || u >= image->m_width || v >= image->m_height)
+			p = tileFillColor;
+		else
+			p = image->readPixel(u, v);
+	}
+	else if(tilingMode == VG_TILE_PAD)
+	{
+		u = RI_INT_MIN(RI_INT_MAX(u,0),image->m_width-1);
+		v = RI_INT_MIN(RI_INT_MAX(v,0),image->m_height-1);
+		p = image->readPixel(u, v);
+	}
+	else if(tilingMode == VG_TILE_REPEAT)
+	{
+		u = RI_INT_MOD(u, image->m_width);
+		v = RI_INT_MOD(v, image->m_height);
+		p = image->readPixel(u, v);
+	}
+	else
+	{
+		RI_ASSERT(tilingMode == VG_TILE_REFLECT);
+
+		u = RI_INT_MOD(u, image->m_width*2);
+		v = RI_INT_MOD(v, image->m_height*2);
+		if( u >= image->m_width ) u = image->m_width*2-1 - u;
+		if( v >= image->m_height ) v = image->m_height*2-1 - v;
+		p = image->readPixel(u, v);
+	}
+
+	p.premultiply();    //interpolate in premultiplied format
+	return p;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Maps point (x,y) to an image and returns a filtered,
+*			premultiplied color value.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Color Image::resample(RIfloat x, RIfloat y, const Matrix3x3& surfaceToImage, VGImageQuality quality, VGTilingMode tilingMode, const Color& tileFillColor)	//throws bad_alloc
+{
+	RI_ASSERT(m_referenceCount > 0);
+
+	VGbitfield aq = getAllowedQuality();
+	aq &= (VGbitfield)quality;
+
+	Vector3 uvw(x,y,1.0f);
+	uvw = surfaceToImage * uvw;
+	RIfloat oow = 1.0f / uvw.z;
+	uvw *= oow;
+
+	if(aq & VG_IMAGE_QUALITY_BETTER)
+	{	//EWA on mipmaps
+		makeMipMaps();	//throws bad_alloc
+
+		Color::InternalFormat procFormat = (Color::InternalFormat)(m_desc.internalFormat | Color::PREMULTIPLIED);
+
+		RIfloat m_pixelFilterRadius = 1.25f;
+		RIfloat m_resamplingFilterRadius = 1.25f;
+
+		RIfloat Ux = (surfaceToImage[0][0] - uvw.x * surfaceToImage[2][0]) * oow * m_pixelFilterRadius;
+		RIfloat Vx = (surfaceToImage[1][0] - uvw.y * surfaceToImage[2][0]) * oow * m_pixelFilterRadius;
+		RIfloat Uy = (surfaceToImage[0][1] - uvw.x * surfaceToImage[2][1]) * oow * m_pixelFilterRadius;
+		RIfloat Vy = (surfaceToImage[1][1] - uvw.y * surfaceToImage[2][1]) * oow * m_pixelFilterRadius;
+		RIfloat U0 = uvw.x;
+		RIfloat V0 = uvw.y;
+
+		//calculate mip level
+		int level = 0;
+		RIfloat axis1sq = Ux*Ux + Vx*Vx;
+		RIfloat axis2sq = Uy*Uy + Vy*Vy;
+		RIfloat minorAxissq = RI_MIN(axis1sq,axis2sq);
+		while(minorAxissq > 9.0f && level < m_mipmaps.size())	//half the minor axis must be at least three texels
+		{
+			level++;
+			minorAxissq *= 0.25f;
+		}
+
+		RIfloat sx = 1.0f;
+		RIfloat sy = 1.0f;
+		if(level > 0)
+		{
+			sx = (RIfloat)m_mipmaps[level-1]->m_width / (RIfloat)m_width;
+			sy = (RIfloat)m_mipmaps[level-1]->m_height / (RIfloat)m_height;
+		}
+		Ux *= sx;
+		Vx *= sx;
+		U0 *= sx;
+		Uy *= sy;
+		Vy *= sy;
+		V0 *= sy;
+		
+		//clamp filter size so that filtering doesn't take excessive amount of time (clamping results in aliasing)
+		RIfloat lim = 100.0f;
+		axis1sq = Ux*Ux + Vx*Vx;
+		axis2sq = Uy*Uy + Vy*Vy;
+		if( axis1sq > lim*lim )
+		{
+			RIfloat s = lim / (RIfloat)sqrt(axis1sq);
+			Ux *= s;
+			Vx *= s;
+		}
+		if( axis2sq > lim*lim )
+		{
+			RIfloat s = lim / (RIfloat)sqrt(axis2sq);
+			Uy *= s;
+			Vy *= s;
+		}
+		
+		
+		//form elliptic filter by combining texel and pixel filters
+		RIfloat A = Vx*Vx + Vy*Vy + 1.0f;
+		RIfloat B = -2.0f*(Ux*Vx + Uy*Vy);
+		RIfloat C = Ux*Ux + Uy*Uy + 1.0f;
+		//scale by the user-defined size of the kernel
+		A *= m_resamplingFilterRadius;
+		B *= m_resamplingFilterRadius;
+		C *= m_resamplingFilterRadius;
+		
+		//calculate bounding box in texture space
+		RIfloat usize = (RIfloat)sqrt(C);
+		RIfloat vsize = (RIfloat)sqrt(A);
+		int u1 = (int)floor(U0 - usize + 0.5f);
+		int u2 = (int)floor(U0 + usize + 0.5f);
+		int v1 = (int)floor(V0 - vsize + 0.5f);
+		int v2 = (int)floor(V0 + vsize + 0.5f);
+		if( u1 == u2 || v1 == v2 )
+			return Color(0,0,0,0,procFormat);
+
+		//scale the filter so that Q = 1 at the cutoff radius
+		RIfloat F = A*C - 0.25f * B*B;
+		if( F <= 0.0f )
+			return Color(0,0,0,0,procFormat);	//invalid filter shape due to numerical inaccuracies => return black
+		RIfloat ooF = 1.0f / F;
+		A *= ooF;
+		B *= ooF;
+		C *= ooF;
+		
+		//evaluate filter by using forward differences to calculate Q = A*U^2 + B*U*V + C*V^2
+		Color color(0,0,0,0,procFormat);
+		RIfloat sumweight = 0.0f;
+		RIfloat DDQ = 2.0f * A;
+		RIfloat U = (RIfloat)u1 - U0 + 0.5f;
+		for(int v=v1;v<v2;v++)
+		{
+			RIfloat V = (RIfloat)v - V0 + 0.5f;
+			RIfloat DQ = A*(2.0f*U+1.0f) + B*V;
+			RIfloat Q = (C*V+B*U)*V + A*U*U;
+			for(int u=u1;u<u2;u++)
+			{
+				if( Q >= 0.0f && Q < 1.0f )
+				{	//Q = r^2, fit gaussian to the range [0,1]
+					RIfloat weight = (RIfloat)exp(-0.5f * 10.0f * Q);	//gaussian at radius 10 equals 0.0067
+					color += weight * readTexel(u, v, level, tilingMode, tileFillColor);
+					sumweight += weight;
+				}
+				Q += DQ;
+				DQ += DDQ;
+			}
+		}
+		if( sumweight == 0.0f )
+			return Color(0,0,0,0,procFormat);
+		RI_ASSERT(sumweight > 0.0f);
+		sumweight = 1.0f / sumweight;
+		return color * sumweight;
+	}
+	else if(aq & VG_IMAGE_QUALITY_FASTER)
+	{	//bilinear
+		uvw.x -= 0.5f;
+		uvw.y -= 0.5f;
+		int u = (int)floor(uvw.x);
+		int v = (int)floor(uvw.y);
+		Color c00 = readTexel(u,v, 0, tilingMode, tileFillColor);
+		Color c10 = readTexel(u+1,v, 0, tilingMode, tileFillColor);
+		Color c01 = readTexel(u,v+1, 0, tilingMode, tileFillColor);
+		Color c11 = readTexel(u+1,v+1, 0, tilingMode, tileFillColor);
+		RIfloat fu = uvw.x - (RIfloat)u;
+		RIfloat fv = uvw.y - (RIfloat)v;
+		Color c0 = c00 * (1.0f - fu) + c10 * fu;
+		Color c1 = c01 * (1.0f - fu) + c11 * fu;
+		return c0 * (1.0f - fv) + c1 * fv;
+	}
+	else
+	{	//point sampling
+		return readTexel((int)floor(uvw.x), (int)floor(uvw.y), 0, tilingMode, tileFillColor);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Generates mip maps for an image.
+* \param	
+* \return	
+* \note		Downsampling is done in the input color space. We use a box
+*			filter for downsampling.
+*//*-------------------------------------------------------------------*/
+
+void Image::makeMipMaps()
+{
+	RI_ASSERT(m_data);
+	RI_ASSERT(m_referenceCount > 0);
+
+	if(m_mipmapsValid)
+		return;
+
+	//delete existing mipmaps
+	for(int i=0;i<m_mipmaps.size();i++)
+	{
+		if(!m_mipmaps[i]->removeReference())
+			RI_DELETE(m_mipmaps[i]);
+		else
+		{
+			RI_ASSERT(0);	//there can't be any other references to the mipmap levels
+		}
+	}
+	m_mipmaps.clear();
+
+	try
+	{
+		Color::InternalFormat procFormat = m_desc.internalFormat;
+		procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED);	//premultiplied
+
+		//generate mipmaps until width and height are one
+		Image* prev = this;
+		while( prev->m_width > 1 || prev->m_height > 1 )
+		{
+			int nextw = (int)ceil(prev->m_width*0.5f);
+			int nexth = (int)ceil(prev->m_height*0.5f);
+			RI_ASSERT(nextw >= 1 && nexth >= 1);
+			RI_ASSERT(nextw < prev->m_width || nexth < prev->m_height);
+
+			m_mipmaps.resize(m_mipmaps.size()+1);	//throws bad_alloc
+			m_mipmaps[m_mipmaps.size()-1] = NULL;
+
+			Image* next = RI_NEW(Image, (m_desc, nextw, nexth, m_allowedQuality));	//throws bad_alloc
+			next->addReference();
+			for(int j=0;j<next->m_height;j++)
+			{
+				for(int i=0;i<next->m_width;i++)
+				{
+					RIfloat u0 = (RIfloat)i / (RIfloat)next->m_width;
+					RIfloat u1 = (RIfloat)(i+1) / (RIfloat)next->m_width;
+					RIfloat v0 = (RIfloat)j / (RIfloat)next->m_height;
+					RIfloat v1 = (RIfloat)(j+1) / (RIfloat)next->m_height;
+
+					u0 *= prev->m_width;
+					u1 *= prev->m_width;
+					v0 *= prev->m_height;
+					v1 *= prev->m_height;
+
+					int su = (int)floor(u0);
+					int eu = (int)ceil(u1);
+					int sv = (int)floor(v0);
+					int ev = (int)ceil(v1);
+
+					Color c(0,0,0,0,procFormat);
+					int samples = 0;
+					for(int y=sv;y<ev;y++)
+					{
+						for(int x=su;x<eu;x++)
+						{
+							Color p = prev->readPixel(x, y);
+							p.convert(procFormat);
+							c += p;
+							samples++;
+						}
+					}
+					c *= (1.0f/samples);
+					c.convert(m_desc.internalFormat);
+					next->writePixel(i,j,c);
+				}
+			}
+			m_mipmaps[m_mipmaps.size()-1] = next;
+			prev = next;
+		}
+		RI_ASSERT(prev->m_width == 1 && prev->m_height == 1);
+		m_mipmapsValid = true;
+	}
+	catch(std::bad_alloc)
+	{
+		//delete existing mipmaps
+		for(int i=0;i<m_mipmaps.size();i++)
+		{
+			if(m_mipmaps[i])
+			{
+				if(!m_mipmaps[i]->removeReference())
+					RI_DELETE(m_mipmaps[i]);
+				else
+				{
+					RI_ASSERT(0);	//there can't be any other references to the mipmap levels
+				}
+			}
+		}
+		m_mipmaps.clear();
+		m_mipmapsValid = false;
+		throw;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies color matrix filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::colorMatrix(const Image& src, const RIfloat* matrix, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(matrix);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	Color::InternalFormat srcFormat = src.m_desc.internalFormat;
+	Color::InternalFormat procFormat = (Color::InternalFormat)(srcFormat & ~Color::LUMINANCE);	//process in RGB, not luminance
+	if(filterFormatLinear)
+		procFormat = (Color::InternalFormat)(procFormat & ~Color::NONLINEAR);
+	else
+		procFormat = (Color::InternalFormat)(procFormat | Color::NONLINEAR);
+
+	if(filterFormatPremultiplied)
+		procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED);
+	else
+		procFormat = (Color::InternalFormat)(procFormat & ~Color::PREMULTIPLIED);
+
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color s = src.readPixel(i,j);	//convert to RGBA [0,1]
+			s.convert(procFormat);
+
+			Color d(0,0,0,0,procFormat);
+			d.r = matrix[0+4*0] * s.r + matrix[0+4*1] * s.g + matrix[0+4*2] * s.b + matrix[0+4*3] * s.a + matrix[0+4*4];
+			d.g = matrix[1+4*0] * s.r + matrix[1+4*1] * s.g + matrix[1+4*2] * s.b + matrix[1+4*3] * s.a + matrix[1+4*4];
+			d.b = matrix[2+4*0] * s.r + matrix[2+4*1] * s.g + matrix[2+4*2] * s.b + matrix[2+4*3] * s.a + matrix[2+4*4];
+			d.a = matrix[3+4*0] * s.r + matrix[3+4*1] * s.g + matrix[3+4*2] * s.b + matrix[3+4*3] * s.a + matrix[3+4*4];
+
+			writeFilteredPixel(i, j, d, channelMask);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Reads a pixel from image with tiling mode applied.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static Color readTiledPixel(int x, int y, int w, int h, VGTilingMode tilingMode, const Array<Color>& image, const Color& edge)
+{
+	Color s;
+	if(x < 0 || x >= w || y < 0 || y >= h)
+	{	//apply tiling mode
+		switch(tilingMode)
+		{
+		case VG_TILE_FILL:
+			s = edge;
+			break;
+		case VG_TILE_PAD:
+			x = RI_INT_MIN(RI_INT_MAX(x, 0), w-1);
+			y = RI_INT_MIN(RI_INT_MAX(y, 0), h-1);
+			RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+			s = image[y*w+x];
+			break;
+		case VG_TILE_REPEAT:
+			x = RI_INT_MOD(x, w);
+			y = RI_INT_MOD(y, h);
+			RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+			s = image[y*w+x];
+			break;
+		default:
+			RI_ASSERT(tilingMode == VG_TILE_REFLECT);
+			x = RI_INT_MOD(x, w*2);
+			y = RI_INT_MOD(y, h*2);
+			if(x >= w) x = w*2-1-x;
+			if(y >= h) y = h*2-1-y;
+			RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+			s = image[y*w+x];
+			break;
+		}
+	}
+	else
+	{
+		RI_ASSERT(x >= 0 && x < w && y >= 0 && y < h);
+		s = image[y*w+x];
+	}
+	return s;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns processing format for filtering.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static Color::InternalFormat getProcessingFormat(Color::InternalFormat srcFormat, bool filterFormatLinear, bool filterFormatPremultiplied)
+{
+	Color::InternalFormat procFormat = (Color::InternalFormat)(srcFormat & ~Color::LUMINANCE);	//process in RGB, not luminance
+	if(filterFormatLinear)
+		procFormat = (Color::InternalFormat)(procFormat & ~Color::NONLINEAR);
+	else
+		procFormat = (Color::InternalFormat)(procFormat | Color::NONLINEAR);
+
+	if(filterFormatPremultiplied)
+		procFormat = (Color::InternalFormat)(procFormat | Color::PREMULTIPLIED);
+	else
+		procFormat = (Color::InternalFormat)(procFormat & ~Color::PREMULTIPLIED);
+	return procFormat;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies convolution filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::convolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernel, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(kernel && kernelWidth > 0 && kernelHeight > 0);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	//the area to be written is an intersection of source and destination image areas.
+	//lower-left corners of the images are aligned.
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+	Color edge = edgeFillColor;
+	edge.clamp();
+	edge.convert(procFormat);
+
+	Array<Color> tmp;
+	tmp.resize(src.m_width*src.m_height);	//throws bad_alloc
+
+	//copy source region to tmp and do conversion
+	for(int j=0;j<src.m_height;j++)
+	{
+		for(int i=0;i<src.m_width;i++)
+		{
+			Color s = src.readPixel(i, j);
+			s.convert(procFormat);
+			tmp[j*src.m_width+i] = s;
+		}
+	}
+
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color sum(0,0,0,0,procFormat);
+
+			for(int kj=0;kj<kernelHeight;kj++)
+			{
+				for(int ki=0;ki<kernelWidth;ki++)
+				{
+					int x = i+ki-shiftX;
+					int y = j+kj-shiftY;
+					Color s = readTiledPixel(x, y, src.m_width, src.m_height, tilingMode, tmp, edge);
+
+					int kx = kernelWidth-ki-1;
+					int ky = kernelHeight-kj-1;
+					RI_ASSERT(kx >= 0 && kx < kernelWidth && ky >= 0 && ky < kernelHeight);
+
+					sum += (RIfloat)kernel[kx*kernelHeight+ky] * s;
+				}
+			}
+
+			sum *= scale;
+			sum.r += bias;
+			sum.g += bias;
+			sum.b += bias;
+			sum.a += bias;
+
+			writeFilteredPixel(i, j, sum, channelMask);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies separable convolution filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::separableConvolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernelX, const RIint16* kernelY, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(kernelX && kernelY && kernelWidth > 0 && kernelHeight > 0);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	//the area to be written is an intersection of source and destination image areas.
+	//lower-left corners of the images are aligned.
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+	Color edge = edgeFillColor;
+	edge.clamp();
+	edge.convert(procFormat);
+
+	Array<Color> tmp;
+	tmp.resize(src.m_width*src.m_height);	//throws bad_alloc
+
+	//copy source region to tmp and do conversion
+	for(int j=0;j<src.m_height;j++)
+	{
+		for(int i=0;i<src.m_width;i++)
+		{
+			Color s = src.readPixel(i, j);
+			s.convert(procFormat);
+			tmp[j*src.m_width+i] = s;
+		}
+	}
+
+	Array<Color> tmp2;
+	tmp2.resize(w*src.m_height);	//throws bad_alloc
+	for(int j=0;j<src.m_height;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color sum(0,0,0,0,procFormat);
+			for(int ki=0;ki<kernelWidth;ki++)
+			{
+				int x = i+ki-shiftX;
+				Color s = readTiledPixel(x, j, src.m_width, src.m_height, tilingMode, tmp, edge);
+
+				int kx = kernelWidth-ki-1;
+				RI_ASSERT(kx >= 0 && kx < kernelWidth);
+
+				sum += (RIfloat)kernelX[kx] * s;
+			}
+			tmp2[j*w+i] = sum;
+		}
+	}
+
+	if(tilingMode == VG_TILE_FILL)
+	{	//convolve the edge color
+		Color sum(0,0,0,0,procFormat);
+		for(int ki=0;ki<kernelWidth;ki++)
+		{
+			sum += (RIfloat)kernelX[ki] * edge;
+		}
+		edge = sum;
+	}
+
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color sum(0,0,0,0,procFormat);
+			for(int kj=0;kj<kernelHeight;kj++)
+			{
+				int y = j+kj-shiftY;
+				Color s = readTiledPixel(i, y, w, src.m_height, tilingMode, tmp2, edge);
+
+				int ky = kernelHeight-kj-1;
+				RI_ASSERT(ky >= 0 && ky < kernelHeight);
+
+				sum += (RIfloat)kernelY[ky] * s;
+			}
+
+			sum *= scale;
+			sum.r += bias;
+			sum.g += bias;
+			sum.b += bias;
+			sum.a += bias;
+
+			writeFilteredPixel(i, j, sum, channelMask);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies Gaussian blur filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::gaussianBlur(const Image& src, RIfloat stdDeviationX, RIfloat stdDeviationY, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(stdDeviationX > 0.0f && stdDeviationY > 0.0f);
+	RI_ASSERT(stdDeviationX <= RI_MAX_GAUSSIAN_STD_DEVIATION && stdDeviationY <= RI_MAX_GAUSSIAN_STD_DEVIATION);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	//the area to be written is an intersection of source and destination image areas.
+	//lower-left corners of the images are aligned.
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+
+	Color edge = edgeFillColor;
+	edge.clamp();
+	edge.convert(procFormat);
+
+	Array<Color> tmp;
+	tmp.resize(src.m_width*src.m_height);	//throws bad_alloc
+
+	//copy source region to tmp and do conversion
+	for(int j=0;j<src.m_height;j++)
+	{
+		for(int i=0;i<src.m_width;i++)
+		{
+			Color s = src.readPixel(i, j);
+			s.convert(procFormat);
+			tmp[j*src.m_width+i] = s;
+		}
+	}
+
+	RIfloat expScaleX = -1.0f / (2.0f*stdDeviationX*stdDeviationX);
+	RIfloat expScaleY = -1.0f / (2.0f*stdDeviationY*stdDeviationY);
+
+	int kernelWidth = (int)(stdDeviationX * 4.0f + 1.0f);
+	int kernelHeight = (int)(stdDeviationY * 4.0f + 1.0f);
+
+	//make a separable kernel
+	Array<RIfloat> kernelX;
+	kernelX.resize(kernelWidth*2+1);
+	int shiftX = kernelWidth;
+	RIfloat scaleX = 0.0f;
+	for(int i=0;i<kernelX.size();i++)
+	{
+		int x = i-shiftX;
+		kernelX[i] = (RIfloat)exp((RIfloat)x*(RIfloat)x * expScaleX);
+		scaleX += kernelX[i];
+	}
+	scaleX = 1.0f / scaleX;	//NOTE: using the mathematical definition of the scaling term doesn't work since we cut the filter support early for performance
+
+	Array<RIfloat> kernelY;
+	kernelY.resize(kernelHeight*2+1);
+	int shiftY = kernelHeight;
+	RIfloat scaleY = 0.0f;
+	for(int i=0;i<kernelY.size();i++)
+	{
+		int y = i-shiftY;
+		kernelY[i] = (RIfloat)exp((RIfloat)y*(RIfloat)y * expScaleY);
+		scaleY += kernelY[i];
+	}
+	scaleY = 1.0f / scaleY;	//NOTE: using the mathematical definition of the scaling term doesn't work since we cut the filter support early for performance
+
+	Array<Color> tmp2;
+	tmp2.resize(w*src.m_height);	//throws bad_alloc
+	//horizontal pass
+	for(int j=0;j<src.m_height;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color sum(0,0,0,0,procFormat);
+			for(int ki=0;ki<kernelX.size();ki++)
+			{
+				int x = i+ki-shiftX;
+				sum += kernelX[ki] * readTiledPixel(x, j, src.m_width, src.m_height, tilingMode, tmp, edge);
+			}
+			tmp2[j*w+i] = sum * scaleX;
+		}
+	}
+	//vertical pass
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color sum(0,0,0,0,procFormat);
+			for(int kj=0;kj<kernelY.size();kj++)
+			{
+				int y = j+kj-shiftY;
+				sum += kernelY[kj] * readTiledPixel(i, y, w, src.m_height, tilingMode, tmp2, edge);
+			}
+			writeFilteredPixel(i, j, sum * scaleY, channelMask);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns lookup table format for lookup filters.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static Color::InternalFormat getLUTFormat(bool outputLinear, bool outputPremultiplied)
+{
+	Color::InternalFormat lutFormat = Color::lRGBA;
+	if(outputLinear && outputPremultiplied)
+		lutFormat = Color::lRGBA_PRE;
+	else if(!outputLinear && !outputPremultiplied)
+		lutFormat = Color::sRGBA;
+	else if(!outputLinear && outputPremultiplied)
+		lutFormat = Color::sRGBA_PRE;
+	return lutFormat;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies multi-channel lookup table filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::lookup(const Image& src, const RIuint8 * redLUT, const RIuint8 * greenLUT, const RIuint8 * blueLUT, const RIuint8 * alphaLUT, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(redLUT && greenLUT && blueLUT && alphaLUT);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	//the area to be written is an intersection of source and destination image areas.
+	//lower-left corners of the images are aligned.
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+	Color::InternalFormat lutFormat = getLUTFormat(outputLinear, outputPremultiplied);
+
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color s = src.readPixel(i,j);	//convert to RGBA [0,1]
+			s.convert(procFormat);
+
+			Color d(0,0,0,0,lutFormat);
+			d.r = intToColor(  redLUT[colorToInt(s.r, 255)], 255);
+			d.g = intToColor(greenLUT[colorToInt(s.g, 255)], 255);
+			d.b = intToColor( blueLUT[colorToInt(s.b, 255)], 255);
+			d.a = intToColor(alphaLUT[colorToInt(s.a, 255)], 255);
+
+			writeFilteredPixel(i, j, d, channelMask);
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Applies single channel lookup table filter.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Image::lookupSingle(const Image& src, const RIuint32 * lookupTable, VGImageChannel sourceChannel, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask)
+{
+	RI_ASSERT(src.m_data);	//source exists
+	RI_ASSERT(m_data);	//destination exists
+	RI_ASSERT(lookupTable);
+	RI_ASSERT(m_referenceCount > 0 && src.m_referenceCount > 0);
+
+	//the area to be written is an intersection of source and destination image areas.
+	//lower-left corners of the images are aligned.
+	int w = RI_INT_MIN(m_width, src.m_width);
+	int h = RI_INT_MIN(m_height, src.m_height);
+	RI_ASSERT(w > 0 && h > 0);
+
+	if(src.m_desc.isLuminance())
+		sourceChannel = VG_RED;
+	else if(src.m_desc.redBits + src.m_desc.greenBits + src.m_desc.blueBits == 0)
+	{
+		RI_ASSERT(src.m_desc.alphaBits);
+		sourceChannel = VG_ALPHA;
+	}
+
+	Color::InternalFormat procFormat = getProcessingFormat(src.m_desc.internalFormat, filterFormatLinear, filterFormatPremultiplied);
+	Color::InternalFormat lutFormat = getLUTFormat(outputLinear, outputPremultiplied);
+
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			Color s = src.readPixel(i,j);	//convert to RGBA [0,1]
+			s.convert(procFormat);
+			int e;
+			switch(sourceChannel)
+			{
+			case VG_RED:
+				e = colorToInt(s.r, 255);
+				break;
+			case VG_GREEN:
+				e = colorToInt(s.g, 255);
+				break;
+			case VG_BLUE:
+				e = colorToInt(s.b, 255);
+				break;
+			default:
+				RI_ASSERT(sourceChannel == VG_ALPHA);
+				e = colorToInt(s.a, 255);
+				break;
+			}
+
+			RIuint32 l = ((const RIuint32*)lookupTable)[e];
+			Color d(0,0,0,0,lutFormat);
+			d.r = intToColor((l>>24), 255);
+			d.g = intToColor((l>>16), 255);
+			d.b = intToColor((l>> 8), 255);
+			d.a = intToColor((l    ), 255);
+
+			writeFilteredPixel(i, j, d, channelMask);
+		}
+	}
+}
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(const Color::Descriptor& desc, int width, int height, int numSamples) :
+	m_width(width),
+	m_height(height),
+	m_numSamples(numSamples),
+	m_referenceCount(0),
+	m_image(NULL)
+{
+	RI_ASSERT(width > 0 && height > 0 && numSamples > 0 && numSamples <= 32);
+	m_image = RI_NEW(Image, (desc, width*numSamples, height, 0));	//throws bad_alloc
+	m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(Image* image) :
+	m_width(0),
+	m_height(0),
+	m_numSamples(1),
+	m_referenceCount(0),
+	m_image(image)
+{
+	RI_ASSERT(image);
+	m_width = image->getWidth();
+	m_height = image->getHeight();
+	m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Surface::Surface(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data) :
+	m_width(width),
+	m_height(height),
+	m_numSamples(1),
+	m_referenceCount(0),
+	m_image(NULL)
+{
+	RI_ASSERT(width > 0 && height > 0);
+	m_image = RI_NEW(Image, (desc, width, height, stride, data));	//throws bad_alloc
+	m_image->addReference();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Surface::~Surface()
+{
+	RI_ASSERT(m_referenceCount == 0);
+	if(!m_image->removeReference())
+		RI_DELETE(m_image);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::clear(const Color& clearColor, int x, int y, int w, int h)
+{
+	Rectangle rect;
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = getWidth();
+	rect.height = getHeight();
+	Array<Rectangle> scissors;
+	scissors.push_back(rect);
+	clear(clearColor, x, y, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::clear(const Color& clearColor, int x, int y, int w, int h, const Array<Rectangle>& scissors)
+{
+	RI_ASSERT(w > 0 && h > 0);
+
+	//intersect clear region with image bounds
+	Rectangle r(0,0,getWidth(),getHeight());
+	r.intersect(Rectangle(x,y,w,h));
+	if(!r.width || !r.height)
+		return;		//intersection is empty or one of the rectangles is invalid
+
+	Array<ScissorEdge> scissorEdges;
+	for(int i=0;i<scissors.size();i++)
+	{
+		if(scissors[i].width > 0 && scissors[i].height > 0)
+		{
+			ScissorEdge e;
+			e.miny = scissors[i].y;
+			e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+			e.x = scissors[i].x;
+			e.direction = 1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+			e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+			e.direction = -1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+		}
+	}
+	if(!scissorEdges.size())
+		return;	//there are no scissor rectangles => nothing is visible
+
+	//sort scissor edges by edge x
+    scissorEdges.sort();
+
+	//clear the image
+	Color col = clearColor;
+	col.clamp();
+	col.convert(m_image->getDescriptor().internalFormat);
+
+	Array<ScissorEdge> scissorAet;
+	for(int j=r.y;j<r.y + r.height;j++)
+	{
+		//gather scissor edges intersecting this scanline
+		scissorAet.clear();
+		for(int e=0;e<scissorEdges.size();e++)
+		{
+			const ScissorEdge& se = scissorEdges[e];
+			if(j >= se.miny && j < se.maxy)
+				scissorAet.push_back(scissorEdges[e]);	//throws bad_alloc
+		}
+		if(!scissorAet.size())
+			continue;	//scissoring is on, but there are no scissor rectangles on this scanline
+
+		//clear a scanline
+		int scissorWinding = 0;
+		int scissorIndex = 0;
+		for(int i=r.x;i<r.x + r.width;i++)
+		{
+			while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= i)
+				scissorWinding += scissorAet[scissorIndex++].direction;
+			RI_ASSERT(scissorWinding >= 0);
+
+			if(scissorWinding)
+			{
+                for(int s=0;s<m_numSamples;s++)
+                    writeSample(i, j, s, col);
+			}
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h)
+{
+	Rectangle rect;
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = getWidth();
+	rect.height = getHeight();
+	Array<Rectangle> scissors;
+	scissors.push_back(rect);
+	blit(src, sx, sy, dx, dy, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		no overlap is possible. Single sample to single or multisample (replicate)
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors)
+{
+	//img=>fb: vgSetPixels
+	//user=>fb: vgWritePixels
+	computeBlitRegion(sx, sy, dx, dy, w, h, src.getWidth(), src.getHeight(), getWidth(), getHeight());
+	if(w <= 0 || h <= 0)
+		return;	//zero area
+
+	Array<ScissorEdge> scissorEdges;
+	for(int i=0;i<scissors.size();i++)
+	{
+		if(scissors[i].width > 0 && scissors[i].height > 0)
+		{
+			ScissorEdge e;
+			e.miny = scissors[i].y;
+			e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+			e.x = scissors[i].x;
+			e.direction = 1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+			e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+			e.direction = -1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+		}
+	}
+	if(!scissorEdges.size())
+		return;	//there are no scissor rectangles => nothing is visible
+
+	//sort scissor edges by edge x
+    scissorEdges.sort();
+
+	Array<ScissorEdge> scissorAet;
+	for(int j=0;j<h;j++)
+	{
+		//gather scissor edges intersecting this scanline
+		scissorAet.clear();
+		for(int e=0;e<scissorEdges.size();e++)
+		{
+			const ScissorEdge& se = scissorEdges[e];
+			if(dy + j >= se.miny && dy + j < se.maxy)
+				scissorAet.push_back(scissorEdges[e]);	//throws bad_alloc
+		}
+		if(!scissorAet.size())
+			continue;	//scissoring is on, but there are no scissor rectangles on this scanline
+
+		//blit a scanline
+		int scissorWinding = 0;
+		int scissorIndex = 0;
+		for(int i=0;i<w;i++)
+		{
+			while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= dx + i)
+				scissorWinding += scissorAet[scissorIndex++].direction;
+			RI_ASSERT(scissorWinding >= 0);
+
+			if(scissorWinding)
+			{
+				Color c = src.readPixel(sx + i, sy + j);
+				c.convert(getDescriptor().internalFormat);
+                for(int s=0;s<m_numSamples;s++)
+                    writeSample(dx + i, dy + j, s, c);
+			}
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h)
+{
+	Rectangle rect;
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = getWidth();
+	rect.height = getHeight();
+	Array<Rectangle> scissors;
+	scissors.push_back(rect);
+	blit(src, sx, sy, dx, dy, w, h, scissors);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors)
+{
+    RI_ASSERT(m_numSamples == src->m_numSamples);
+
+	//fb=>fb: vgCopyPixels
+	computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+	if(w <= 0 || h <= 0)
+		return;	//zero area
+
+	Array<ScissorEdge> scissorEdges;
+	for(int i=0;i<scissors.size();i++)
+	{
+		if(scissors[i].width > 0 && scissors[i].height > 0)
+		{
+			ScissorEdge e;
+			e.miny = scissors[i].y;
+			e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+			e.x = scissors[i].x;
+			e.direction = 1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+			e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+			e.direction = -1;
+			scissorEdges.push_back(e);	//throws bad_alloc
+		}
+	}
+	if(!scissorEdges.size())
+		return;	//there are no scissor rectangles => nothing is visible
+
+	//sort scissor edges by edge x
+    scissorEdges.sort();
+
+	Array<Color> tmp;
+	tmp.resize(w*m_numSamples*h);	//throws bad_alloc
+
+	//copy source region to tmp
+	for(int j=0;j<h;j++)
+	{
+		for(int i=0;i<w;i++)
+		{
+			int numSamples = m_numSamples;
+			for(int s=0;s<numSamples;s++)
+			{
+				Color c = src->m_image->readPixel((sx + i)*m_numSamples+s, sy + j);
+				c.convert(m_image->getDescriptor().internalFormat);
+				tmp[(j*w+i)*m_numSamples+s] = c;
+			}
+		}
+	}
+
+	Array<ScissorEdge> scissorAet;
+	for(int j=0;j<h;j++)
+	{
+		//gather scissor edges intersecting this scanline
+		scissorAet.clear();
+		for(int e=0;e<scissorEdges.size();e++)
+		{
+			const ScissorEdge& se = scissorEdges[e];
+			if(dy + j >= se.miny && dy + j < se.maxy)
+				scissorAet.push_back(scissorEdges[e]);	//throws bad_alloc
+		}
+		if(!scissorAet.size())
+			continue;	//scissoring is on, but there are no scissor rectangles on this scanline
+
+		//blit a scanline
+		int scissorWinding = 0;
+		int scissorIndex = 0;
+		for(int i=0;i<w;i++)
+		{
+			while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= dx + i)
+				scissorWinding += scissorAet[scissorIndex++].direction;
+			RI_ASSERT(scissorWinding >= 0);
+
+			if(scissorWinding)
+			{
+				int numSamples = m_numSamples;
+				for(int s=0;s<numSamples;s++)
+				{
+					m_image->writePixel((dx + i)*m_numSamples+s, dy + j, tmp[(j*w+i)*m_numSamples+s]);
+				}
+			}
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::mask(const Image* src, VGMaskOperation operation, int x, int y, int w, int h)
+{
+	RI_ASSERT(w > 0 && h > 0);
+
+	if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+	{
+		//intersect clear region with image bounds
+		Rectangle r(0,0,getWidth(),getHeight());
+		r.intersect(Rectangle(x,y,w,h));
+		if(!r.width || !r.height)
+			return;		//intersection is empty or one of the rectangles is invalid
+
+		if(m_numSamples == 1)
+		{
+			RIfloat m = 0.0f;
+			if(operation == VG_FILL_MASK)
+				m = 1.0f;
+			for(int j=r.y;j<r.y + r.height;j++)
+			{
+				for(int i=r.x;i<r.x + r.width;i++)
+				{
+					writeMaskCoverage(i, j, m);
+				}
+			}
+		}
+		else
+		{
+			unsigned int m = 0;
+			if(operation == VG_FILL_MASK)
+				m = (1<<m_numSamples)-1;
+			for(int j=r.y;j<r.y + r.height;j++)
+			{
+				for(int i=r.x;i<r.x + r.width;i++)
+				{
+					writeMaskMSAA(i, j, m);
+				}
+			}
+		}
+	}
+	else
+	{
+		RI_ASSERT(src);
+
+		int sx = 0, sy = 0, dx = x, dy = y;
+		computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+		if(w <= 0 || h <= 0)
+			return;	//zero area
+
+		if(m_numSamples == 1)
+		{
+			for(int j=0;j<h;j++)
+			{
+				for(int i=0;i<w;i++)
+				{
+					RIfloat amask = src->readMaskPixel(sx + i, sy + j);
+					if(operation == VG_SET_MASK)
+						writeMaskCoverage(dx + i, dy + j, amask);
+					else
+					{
+						RIfloat aprev = readMaskCoverage(dx + i, dy + j);
+						RIfloat anew = 0.0f;
+						switch(operation)
+						{
+						case VG_UNION_MASK:		anew = 1.0f - (1.0f - amask)*(1.0f - aprev); break;
+						case VG_INTERSECT_MASK:	anew = amask * aprev; break;
+						default:				anew = aprev * (1.0f - amask); RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+						}
+						writeMaskCoverage(dx + i, dy + j, anew);
+					}
+				}
+			}
+		}
+		else
+		{
+			for(int j=0;j<h;j++)
+			{
+				for(int i=0;i<w;i++)
+				{
+					RIfloat fmask = src->readMaskPixel(sx + i, sy + j);
+					//TODO implement dithering?
+					unsigned int amask = fmask > 0.5f ? (1<<m_numSamples)-1 : 0;
+					if(operation == VG_SET_MASK)
+						writeMaskMSAA(dx + i, dy + j, amask);
+					else
+					{
+						unsigned int aprev = readMaskMSAA(dx + i, dy + j);
+						unsigned int anew = 0;
+						switch(operation)
+						{
+						case VG_UNION_MASK:		anew = amask | aprev; break;
+						case VG_INTERSECT_MASK:	anew = amask & aprev; break;
+						default:				anew = ~amask & aprev; RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+						}
+						writeMaskMSAA(dx + i, dy + j, anew);
+					}
+				}
+			}
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Surface::mask(const Surface* src, VGMaskOperation operation, int x, int y, int w, int h)
+{
+	RI_ASSERT(w > 0 && h > 0);
+
+	if(operation == VG_CLEAR_MASK || operation == VG_FILL_MASK)
+	{
+		//intersect clear region with image bounds
+		Rectangle r(0,0,getWidth(),getHeight());
+		r.intersect(Rectangle(x,y,w,h));
+		if(!r.width || !r.height)
+			return;		//intersection is empty or one of the rectangles is invalid
+
+		if(m_numSamples == 1)
+		{
+			RIfloat m = 0.0f;
+			if(operation == VG_FILL_MASK)
+				m = 1.0f;
+			for(int j=r.y;j<r.y + r.height;j++)
+			{
+				for(int i=r.x;i<r.x + r.width;i++)
+				{
+					writeMaskCoverage(i, j, m);
+				}
+			}
+		}
+		else
+		{
+			unsigned int m = 0;
+			if(operation == VG_FILL_MASK)
+				m = (1<<m_numSamples)-1;
+			for(int j=r.y;j<r.y + r.height;j++)
+			{
+				for(int i=r.x;i<r.x + r.width;i++)
+				{
+					writeMaskMSAA(i, j, m);
+				}
+			}
+		}
+	}
+	else
+	{
+		RI_ASSERT(src);
+        RI_ASSERT(m_numSamples == src->m_numSamples);
+
+		int sx = 0, sy = 0, dx = x, dy = y;
+		computeBlitRegion(sx, sy, dx, dy, w, h, src->getWidth(), src->getHeight(), getWidth(), getHeight());
+		if(w <= 0 || h <= 0)
+			return;	//zero area
+
+		if(m_numSamples == 1)
+		{
+			for(int j=0;j<h;j++)
+			{
+				for(int i=0;i<w;i++)
+				{
+					RIfloat amask = src->readMaskCoverage(sx + i, sy + j);
+					if(operation == VG_SET_MASK)
+						writeMaskCoverage(dx + i, dy + j, amask);
+					else
+					{
+						RIfloat aprev = readMaskCoverage(dx + i, dy + j);
+						RIfloat anew = 0.0f;
+						switch(operation)
+						{
+						case VG_UNION_MASK:		anew = 1.0f - (1.0f - amask)*(1.0f - aprev); break;
+						case VG_INTERSECT_MASK:	anew = amask * aprev; break;
+						default:				anew = aprev * (1.0f - amask); RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+						}
+						writeMaskCoverage(dx + i, dy + j, anew);
+					}
+				}
+			}
+		}
+		else
+		{
+			for(int j=0;j<h;j++)
+			{
+				for(int i=0;i<w;i++)
+				{
+					unsigned int amask = src->readMaskMSAA(sx + i, sy + j);
+					if(operation == VG_SET_MASK)
+						writeMaskMSAA(dx + i, dy + j, amask);
+					else
+					{
+						unsigned int aprev = readMaskMSAA(dx + i, dy + j);
+						unsigned int anew = 0;
+						switch(operation)
+						{
+						case VG_UNION_MASK:		anew = amask | aprev; break;
+						case VG_INTERSECT_MASK:	anew = amask & aprev; break;
+						default:				anew = ~amask & aprev; RI_ASSERT(operation == VG_SUBTRACT_MASK); break;
+						}
+						writeMaskMSAA(dx + i, dy + j, anew);
+					}
+				}
+			}
+		}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+RIfloat Surface::readMaskCoverage(int x, int y) const
+{
+	RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+    RI_ASSERT(m_numSamples == 1);
+	return m_image->readMaskPixel(x, y);
+}
+
+void Surface::writeMaskCoverage(int x, int y, RIfloat m)
+{
+	RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+    RI_ASSERT(m_numSamples == 1);
+    m_image->writeMaskPixel(x, y, m);    //TODO support other than alpha formats but don't write to color channels?
+}
+
+unsigned int Surface::readMaskMSAA(int x, int y) const
+{
+	RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+    RI_ASSERT(m_numSamples > 1);
+    unsigned int m = 0;
+    for(int i=0;i<m_numSamples;i++)
+    {
+        if(m_image->readMaskPixel(x*m_numSamples+i, y) > 0.5f)   //TODO is this the right formula for converting alpha to bit mask? does it matter?
+            m |= 1<<i;
+    }
+    return m;
+}
+
+void Surface::writeMaskMSAA(int x, int y, unsigned int m)
+{
+	RI_ASSERT(x >= 0 && x < m_width && y >= 0 && y < m_height);
+    RI_ASSERT(m_numSamples > 1);
+    for(int i=0;i<m_numSamples;i++)
+    {
+        RIfloat a = 0.0f;
+        if(m & (1<<i))
+            a = 1.0f;
+        m_image->writeMaskPixel(x*m_numSamples+i, y, a);    //TODO support other than alpha formats but don't write to color channels?
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Color Surface::FSAAResolve(int x, int y) const
+{
+	if(m_numSamples == 1)
+		return readSample(x, y, 0);
+
+	Color::InternalFormat aaFormat = getDescriptor().isLuminance() ? Color::lLA_PRE : Color::lRGBA_PRE;	//antialias in linear color space
+	Color r(0.0f, 0.0f, 0.0f, 0.0f, aaFormat);
+	for(int i=0;i<m_numSamples;i++)
+	{
+		Color d = readSample(x, y, i);
+		d.convert(aaFormat);
+		r += d;
+	}
+	r *= 1.0f/m_numSamples;
+	return r;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(const Color::Descriptor& desc, int width, int height, int numSamples, int maskBits) :
+	m_referenceCount(0),
+	m_color(NULL),
+	m_mask(NULL)
+{
+	RI_ASSERT(width > 0 && height > 0 && numSamples > 0 && numSamples <= 32);
+	RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+    m_color = RI_NEW(Surface, (desc, width, height, numSamples));	//throws bad_alloc
+	m_color->addReference();
+    if(maskBits)
+    {
+        VGImageFormat mf = VG_A_1;
+        if(maskBits == 4)
+            mf = VG_A_4;
+        else if(maskBits == 8)
+            mf = VG_A_8;
+        m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), width, height, numSamples));
+        m_mask->addReference();
+        m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(Image* image, int maskBits) :
+	m_referenceCount(0),
+	m_color(NULL),
+	m_mask(NULL)
+{
+	RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+	RI_ASSERT(image);
+    m_color = RI_NEW(Surface, (image));
+	m_color->addReference();
+    if(maskBits)
+    {
+        VGImageFormat mf = VG_A_1;
+        if(maskBits == 4)
+            mf = VG_A_4;
+        else if(maskBits == 8)
+            mf = VG_A_8;
+        m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), image->getWidth(), image->getHeight(), 1));
+        m_mask->addReference();
+        m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, image->getWidth(), image->getHeight());
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Drawable::Drawable(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data, int maskBits) :
+	m_referenceCount(0),
+	m_color(NULL),
+	m_mask(NULL)
+{
+	RI_ASSERT(width > 0 && height > 0);
+	RI_ASSERT(maskBits == 0 || maskBits == 1 || maskBits == 4 || maskBits == 8);
+	m_color = RI_NEW(Surface, (desc, width, height, stride, data));	//throws bad_alloc
+	m_color->addReference();
+    if(maskBits)
+    {
+        VGImageFormat mf = VG_A_1;
+        if(maskBits == 4)
+            mf = VG_A_4;
+        else if(maskBits == 8)
+            mf = VG_A_8;
+        m_mask = RI_NEW(Surface, (Color::formatToDescriptor(mf), width, height, 1));
+        m_mask->addReference();
+        m_mask->clear(Color(1,1,1,1,Color::sRGBA), 0, 0, width, height);
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Drawable::~Drawable()
+{
+	RI_ASSERT(m_referenceCount == 0);
+	if(!m_color->removeReference())
+		RI_DELETE(m_color);
+    if(m_mask)
+        if(!m_mask->removeReference())
+            RI_DELETE(m_mask);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Drawable::resize(int newWidth, int newHeight)
+{
+	Surface* oldcolor = m_color;
+	Surface* oldmask = m_mask;
+	int oldWidth = m_color->getWidth();
+	int oldHeight = m_color->getHeight();
+
+	//TODO check that image is not a proxy
+	m_color = RI_NEW(Surface, (m_color->getDescriptor(), newWidth, newHeight, m_color->getNumSamples()));
+	m_color->addReference();
+    if(m_mask)
+    {
+        m_mask = RI_NEW(Surface, (m_mask->getDescriptor(), newWidth, newHeight, m_mask->getNumSamples()));
+        m_mask->addReference();
+    }
+
+	int wmin = RI_INT_MIN(newWidth,oldWidth);
+	int hmin = RI_INT_MIN(newHeight,oldHeight);
+	m_color->clear(Color(0.0f, 0.0f, 0.0f, 0.0f, getDescriptor().internalFormat), 0, 0, m_color->getWidth(), m_color->getHeight());
+    m_color->blit(oldcolor, 0, 0, 0, 0, wmin, hmin);
+    if(m_mask)
+    {
+        m_mask->clear(Color(1.0f, 1.0f, 1.0f, 1.0f, getDescriptor().internalFormat), 0, 0, m_mask->getWidth(), m_mask->getHeight());
+        m_mask->blit(oldmask, 0, 0, 0, 0, wmin, hmin);
+    }
+
+	if(!oldcolor->removeReference())
+		RI_DELETE(oldcolor);
+    if(oldmask)
+        if(!oldmask->removeReference())
+            RI_DELETE(oldmask);
+}
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+//==============================================================================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riImage.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,379 @@
+#ifndef __RIIMAGE_H
+#define __RIIMAGE_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Color and Image classes.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef OPENVG_H
+#include "openvg.h"
+#endif
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIARRAY_H
+#include "riArray.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	A class representing rectangles.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Rectangle
+{
+public:
+	Rectangle() : x(0), y(0), width(0), height(0) {}
+	Rectangle(int rx, int ry, int rw, int rh) : x(rx), y(ry), width(rw), height(rh) {}
+	void		intersect(const Rectangle& r)
+	{
+		if(width >= 0 && r.width >= 0 && height >= 0 && r.height >= 0)
+		{
+			int x1 = RI_INT_MIN(RI_INT_ADDSATURATE(x, width), RI_INT_ADDSATURATE(r.x, r.width));
+			x = RI_INT_MAX(x, r.x);
+			width = RI_INT_MAX(x1 - x, 0);
+
+			int y1 = RI_INT_MIN(RI_INT_ADDSATURATE(y, height), RI_INT_ADDSATURATE(r.y, r.height));
+			y = RI_INT_MAX(y, r.y);
+			height = RI_INT_MAX(y1 - y, 0);
+		}
+		else
+		{
+			x = 0;
+			y = 0;
+			width = 0;
+			height = 0;
+		}
+	}
+
+	int			x;
+	int			y;
+	int			width;
+	int			height;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	A class representing color for processing and converting it
+*			to and from various surface formats.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Color
+{
+public:
+	enum InternalFormat
+	{
+		lRGBA			= 0,
+		sRGBA			= 1,
+		lRGBA_PRE		= 2,
+		sRGBA_PRE		= 3,
+		lLA				= 4,
+		sLA				= 5,
+		lLA_PRE			= 6,
+		sLA_PRE			= 7
+	};
+	enum FormatBits
+	{
+		NONLINEAR		= (1<<0),
+		PREMULTIPLIED	= (1<<1),
+		LUMINANCE		= (1<<2)
+	};
+	class Descriptor
+	{
+    public:
+        bool                        isNonlinear() const                                 { return (internalFormat & NONLINEAR) ? true : false; }
+        bool                        isPremultiplied() const                             { return (internalFormat & PREMULTIPLIED) ? true : false; }
+        bool                        isLuminance() const                                 { return (internalFormat & LUMINANCE) ? true : false; }
+        bool                        isAlphaOnly() const                                 { return (alphaBits && (redBits+greenBits+blueBits+luminanceBits) == 0) ? true : false; }
+
+		int				redBits;
+		int				redShift;
+		int				greenBits;
+		int				greenShift;
+		int				blueBits;
+		int				blueShift;
+		int				alphaBits;
+		int				alphaShift;
+		int				luminanceBits;
+		int				luminanceShift;
+		VGImageFormat	format;
+		InternalFormat	internalFormat;
+		int				bitsPerPixel;
+	};
+
+	RI_INLINE Color() : r(0.0f), g(0.0f), b(0.0f), a(0.0f), m_format(lRGBA)													{}
+	RI_INLINE Color(RIfloat cl, RIfloat ca, InternalFormat cs) : r(cl), g(cl), b(cl), a(ca), m_format(cs)							{ RI_ASSERT(cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); }
+	RI_INLINE Color(RIfloat cr, RIfloat cg, RIfloat cb, RIfloat ca, InternalFormat cs) : r(cr), g(cg), b(cb), a(ca), m_format(cs)	{ RI_ASSERT(cs == lRGBA || cs == sRGBA || cs == lRGBA_PRE || cs == sRGBA_PRE || cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); }
+	RI_INLINE Color(const Color& c) : r(c.r), g(c.g), b(c.b), a(c.a), m_format(c.m_format)									{}
+	RI_INLINE Color& operator=(const Color&c)										{ r = c.r; g = c.g; b = c.b; a = c.a; m_format = c.m_format; return *this; }
+	RI_INLINE void operator*=(RIfloat f)											{ r *= f; g *= f; b *= f; a*= f; }
+	RI_INLINE void operator+=(const Color& c1)										{ RI_ASSERT(m_format == c1.getInternalFormat()); r += c1.r; g += c1.g; b += c1.b; a += c1.a; }
+	RI_INLINE void operator-=(const Color& c1)										{ RI_ASSERT(m_format == c1.getInternalFormat()); r -= c1.r; g -= c1.g; b -= c1.b; a -= c1.a; }
+
+	void						set(RIfloat cl, RIfloat ca, InternalFormat cs)							{ RI_ASSERT(cs == lLA || cs == sLA || cs == lLA_PRE || cs == sLA_PRE); r = cl; g = cl; b = cl; a = ca; m_format = cs; }
+	void						set(RIfloat cr, RIfloat cg, RIfloat cb, RIfloat ca, InternalFormat cs)	{ RI_ASSERT(cs == lRGBA || cs == sRGBA || cs == lRGBA_PRE || cs == sRGBA_PRE); r = cr; g = cg; b = cb; a = ca; m_format = cs; }
+	void						unpack(unsigned int inputData, const Descriptor& inputDesc);
+	unsigned int				pack(const Descriptor& outputDesc) const;
+	RI_INLINE InternalFormat	getInternalFormat() const							{ return m_format; }
+
+	//clamps nonpremultiplied colors and alpha to [0,1] range, and premultiplied alpha to [0,1], colors to [0,a]
+	void						clamp()												{ a = RI_CLAMP(a,0.0f,1.0f); RIfloat u = (m_format & PREMULTIPLIED) ? a : (RIfloat)1.0f; r = RI_CLAMP(r,0.0f,u); g = RI_CLAMP(g,0.0f,u); b = RI_CLAMP(b,0.0f,u); }
+	void						convert(InternalFormat outputFormat);
+	void						premultiply()										{ if(!(m_format & PREMULTIPLIED)) { r *= a; g *= a; b *= a; m_format = (InternalFormat)(m_format | PREMULTIPLIED); } }
+	void						unpremultiply()										{ if(m_format & PREMULTIPLIED) { RIfloat ooa = (a != 0.0f) ? 1.0f/a : (RIfloat)0.0f; r *= ooa; g *= ooa; b *= ooa; m_format = (InternalFormat)(m_format & ~PREMULTIPLIED); } }
+    void                        luminanceToRGB()                                    { if(m_format & LUMINANCE) { RI_ASSERT(r == g && g == b); m_format = (InternalFormat)(m_format & ~LUMINANCE); } }
+
+    bool                        isNonlinear() const                                 { return (m_format & NONLINEAR) ? true : false; }
+    bool                        isPremultiplied() const                             { return (m_format & PREMULTIPLIED) ? true : false; }
+    bool                        isLuminance() const                                 { return (m_format & LUMINANCE) ? true : false; }
+
+    RI_INLINE void              assertConsistency() const;
+
+	static Descriptor			formatToDescriptor(VGImageFormat format);
+	static bool					isValidDescriptor(const Descriptor& desc);
+
+	RIfloat		r;
+	RIfloat		g;
+	RIfloat		b;
+	RIfloat		a;
+private:
+	InternalFormat	m_format;
+};
+
+RI_INLINE Color operator*(const Color& c, RIfloat f)			{ return Color(c.r*f, c.g*f, c.b*f, c.a*f, c.getInternalFormat()); }
+RI_INLINE Color operator*(RIfloat f, const Color& c)			{ return Color(c.r*f, c.g*f, c.b*f, c.a*f, c.getInternalFormat()); }
+RI_INLINE Color operator+(const Color& c0, const Color& c1)		{ RI_ASSERT(c0.getInternalFormat() == c1.getInternalFormat()); return Color(c0.r+c1.r, c0.g+c1.g, c0.b+c1.b, c0.a+c1.a, c0.getInternalFormat()); }
+RI_INLINE Color operator-(const Color& c0, const Color& c1)		{ RI_ASSERT(c0.getInternalFormat() == c1.getInternalFormat()); return Color(c0.r-c1.r, c0.g-c1.g, c0.b-c1.b, c0.a-c1.a, c0.getInternalFormat()); }
+RI_INLINE void  Color::assertConsistency() const
+{
+	RI_ASSERT(r >= 0.0f && r <= 1.0f);
+	RI_ASSERT(g >= 0.0f && g <= 1.0f);
+	RI_ASSERT(b >= 0.0f && b <= 1.0f);
+	RI_ASSERT(a >= 0.0f && a <= 1.0f);
+	RI_ASSERT(!isPremultiplied() || (r <= a && g <= a && b <= a));	//premultiplied colors must have color channels less than or equal to alpha
+	RI_ASSERT((isLuminance() && r == g && r == b) || !isLuminance());	//if luminance, r=g=b
+}
+
+//==============================================================================================
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Storage and operations for VGImage.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Surface;
+class Image
+{
+public:
+	Image(const Color::Descriptor& desc, int width, int height, VGbitfield allowedQuality);	//throws bad_alloc
+	//use data from a memory buffer. NOTE: data is not copied, so it is user's responsibility to make sure the data remains valid while the Image is in use.
+	Image(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data);	//throws bad_alloc
+	//child image constructor
+	Image(Image* parent, int x, int y, int width, int height);	//throws bad_alloc
+	~Image();
+
+	const Color::Descriptor&	getDescriptor() const		{ return m_desc; }
+	int					getWidth() const					{ return m_width; }
+	int					getHeight() const					{ return m_height; }
+	int					getStride() const					{ return m_stride; }
+	Image*				getParent() const					{ return m_parent; }
+	VGbitfield			getAllowedQuality() const			{ return m_allowedQuality; }
+	void				addInUse()							{ m_inUse++; }
+	void				removeInUse()						{ RI_ASSERT(m_inUse > 0); m_inUse--; }
+	int					isInUse() const						{ return m_inUse; }
+	RIuint8*			getData() const						{ return m_data; }
+	void				addReference()						{ m_referenceCount++; }
+	int					removeReference()					{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+	bool				overlaps(const Image* src) const;
+
+	void				clear(const Color& clearColor, int x, int y, int w, int h);
+	void				blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, bool dither);	//throws bad_alloc
+	void				blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h);	//throws bad_alloc
+
+	Color				readPixel(int x, int y) const;
+	void				writePixel(int x, int y, const Color& c);
+	void				writeFilteredPixel(int x, int y, const Color& c, VGbitfield channelMask);
+
+	RIfloat				readMaskPixel(int x, int y) const;		//can read any image format
+	void				writeMaskPixel(int x, int y, RIfloat m);	//can write only to VG_A_x
+
+	Color				resample(RIfloat x, RIfloat y, const Matrix3x3& surfaceToImage, VGImageQuality quality, VGTilingMode tilingMode, const Color& tileFillColor);	//throws bad_alloc
+	void				makeMipMaps();	//throws bad_alloc
+
+	void				colorMatrix(const Image& src, const RIfloat* matrix, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+	void				convolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernel, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+	void				separableConvolve(const Image& src, int kernelWidth, int kernelHeight, int shiftX, int shiftY, const RIint16* kernelX, const RIint16* kernelY, RIfloat scale, RIfloat bias, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+	void				gaussianBlur(const Image& src, RIfloat stdDeviationX, RIfloat stdDeviationY, VGTilingMode tilingMode, const Color& edgeFillColor, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+	void				lookup(const Image& src, const RIuint8 * redLUT, const RIuint8 * greenLUT, const RIuint8 * blueLUT, const RIuint8 * alphaLUT, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+	void				lookupSingle(const Image& src, const RIuint32 * lookupTable, VGImageChannel sourceChannel, bool outputLinear, bool outputPremultiplied, bool filterFormatLinear, bool filterFormatPremultiplied, VGbitfield channelMask);
+private:
+	Image(const Image&);					//!< Not allowed.
+	void operator=(const Image&);			//!< Not allowed.
+
+	Color				readTexel(int u, int v, int level, VGTilingMode tilingMode, const Color& tileFillColor) const;
+
+	Color::Descriptor	m_desc;
+	int					m_width;
+	int					m_height;
+	VGbitfield			m_allowedQuality;
+	int					m_inUse;
+	int					m_stride;
+	RIuint8*			m_data;
+	int					m_referenceCount;
+	bool				m_ownsData;
+	Image*				m_parent;
+	int					m_storageOffsetX;
+	int					m_storageOffsetY;
+
+	bool				m_mipmapsValid;
+	Array<Image*>		m_mipmaps;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Surface class abstracting multisampled rendering surface.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Surface
+{
+public:
+	Surface(const Color::Descriptor& desc, int width, int height, int numSamples);	//throws bad_alloc
+	Surface(Image* image);	//throws bad_alloc
+	Surface(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data);	//throws bad_alloc
+	~Surface();
+
+	RI_INLINE const Color::Descriptor&	getDescriptor() const		{ return m_image->getDescriptor(); }
+	RI_INLINE int		getWidth() const							{ return m_width; }
+	RI_INLINE int		getHeight() const							{ return m_height; }
+	RI_INLINE int		getNumSamples() const						{ return m_numSamples; }
+	RI_INLINE void		addReference()								{ m_referenceCount++; }
+	RI_INLINE int		removeReference()							{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+	RI_INLINE int		isInUse() const								{ return m_image->isInUse(); }
+	RI_INLINE bool		isInUse(Image* image) const					{ return image == m_image ? true : false; }
+
+	void				clear(const Color& clearColor, int x, int y, int w, int h);
+	void				clear(const Color& clearColor, int x, int y, int w, int h, const Array<Rectangle>& scissors);
+	void				blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h);	//throws bad_alloc
+	void				blit(const Image& src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors);	//throws bad_alloc
+	void				blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h);	//throws bad_alloc
+	void				blit(const Surface* src, int sx, int sy, int dx, int dy, int w, int h, const Array<Rectangle>& scissors);	//throws bad_alloc
+	void				mask(const Image* src, VGMaskOperation operation, int x, int y, int w, int h);
+	void				mask(const Surface* src, VGMaskOperation operation, int x, int y, int w, int h);
+
+	RI_INLINE Color		readSample(int x, int y, int sample) const                   { return m_image->readPixel(x*m_numSamples+sample, y); }
+	RI_INLINE void		writeSample(int x, int y, int sample, const Color& c)        { m_image->writePixel(x*m_numSamples+sample, y, c); }
+
+	RIfloat				readMaskCoverage(int x, int y) const;
+	void				writeMaskCoverage(int x, int y, RIfloat m);
+	unsigned int		readMaskMSAA(int x, int y) const;
+	void				writeMaskMSAA(int x, int y, unsigned int m);
+
+	Color				FSAAResolve(int x, int y) const;	//for fb=>img: vgGetPixels, vgReadPixels
+private:
+	Surface(const Surface&);			//!< Not allowed.
+	void operator=(const Surface&);			//!< Not allowed.
+
+	struct ScissorEdge
+	{
+		ScissorEdge() : x(0), miny(0), maxy(0), direction(0) {}
+		bool operator<(const ScissorEdge& e) const	{ return x < e.x; }
+		int			x;
+		int			miny;
+		int			maxy;
+		int			direction;		//1 start, -1 end
+	};
+
+	int				m_width;
+	int				m_height;
+	int				m_numSamples;
+	int				m_referenceCount;
+	Image*			m_image;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Drawable class for encapsulating color and mask buffers.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Drawable
+{
+public:
+	Drawable(const Color::Descriptor& desc, int width, int height, int numSamples, int maskBits);	//throws bad_alloc
+	Drawable(Image* image, int maskBits);	//throws bad_alloc
+	Drawable(const Color::Descriptor& desc, int width, int height, int stride, RIuint8* data, int maskBits);	//throws bad_alloc
+	~Drawable();
+
+	RI_INLINE const Color::Descriptor&	getDescriptor() const		{ return m_color->getDescriptor(); }
+    RI_INLINE int       getNumMaskBits() const                      { if(!m_mask) return 0; return m_mask->getDescriptor().alphaBits; }
+	RI_INLINE int		getWidth() const							{ return m_color->getWidth(); }
+	RI_INLINE int		getHeight() const							{ return m_color->getHeight(); }
+	RI_INLINE int		getNumSamples() const						{ return m_color->getNumSamples(); }
+	RI_INLINE void		addReference()								{ m_referenceCount++; }
+	RI_INLINE int		removeReference()							{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+	RI_INLINE int		isInUse() const								{ return m_color->isInUse() || (m_mask && m_mask->isInUse()); }
+	RI_INLINE bool		isInUse(Image* image) const					{ return m_color->isInUse(image) || (m_mask && m_mask->isInUse(image)); }
+    RI_INLINE Surface*  getColorBuffer() const                      { return m_color; }
+    RI_INLINE Surface*  getMaskBuffer() const                       { return m_mask; }
+
+	void				resize(int newWidth, int newHeight);	//throws bad_alloc
+private:
+    Drawable(const Drawable&);			//!< Not allowed.
+    void operator=(const Drawable&);	//!< Not allowed.
+
+	int                 m_referenceCount;
+	Surface*			m_color;
+	Surface*            m_mask;
+};
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+//==============================================================================================
+
+#endif /* __RIIMAGE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMath.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,75 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of non-inline matrix functions.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riDefs.h"
+#include "riMath.h"
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Inverts a 3x3 matrix. Returns false if the matrix is singular.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Matrix3x3::invert()
+{
+	bool affine = isAffine();
+	RIfloat det00 = matrix[1][1]*matrix[2][2] - matrix[2][1]*matrix[1][2];
+	RIfloat det01 = matrix[2][0]*matrix[1][2] - matrix[1][0]*matrix[2][2];
+	RIfloat det02 = matrix[1][0]*matrix[2][1] - matrix[2][0]*matrix[1][1];
+
+	RIfloat d = matrix[0][0]*det00 + matrix[0][1]*det01 + matrix[0][2]*det02;
+	if( d == 0.0f ) return false;	//singular, leave the matrix unmodified and return false
+	d = 1.0f / d;
+
+	Matrix3x3 t;
+	t[0][0] = d * det00;
+	t[1][0] = d * det01;
+	t[2][0] = d * det02;
+	t[0][1] = d * (matrix[2][1]*matrix[0][2] - matrix[0][1]*matrix[2][2]);
+	t[1][1] = d * (matrix[0][0]*matrix[2][2] - matrix[2][0]*matrix[0][2]);
+	t[2][1] = d * (matrix[2][0]*matrix[0][1] - matrix[0][0]*matrix[2][1]);
+	t[0][2] = d * (matrix[0][1]*matrix[1][2] - matrix[1][1]*matrix[0][2]);
+	t[1][2] = d * (matrix[1][0]*matrix[0][2] - matrix[0][0]*matrix[1][2]);
+	t[2][2] = d * (matrix[0][0]*matrix[1][1] - matrix[1][0]*matrix[0][1]);
+	if(affine)
+		t[2].set(0,0,1);	//affine matrix stays affine
+	*this = t;
+	return true;
+}
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMath.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,382 @@
+#ifndef __RIMATH_H
+#define __RIMATH_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Math functions, Vector and Matrix classes.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef __RIDEFS_H
+#include "riDefs.h"
+#endif
+
+#include <math.h>
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+RI_INLINE int		RI_ISNAN(float a)
+{
+	RIfloatInt p;
+	p.f = a;
+	unsigned int exponent = (p.i>>23) & 0xff;
+	unsigned int mantissa = p.i & 0x7fffff;
+	if(exponent == 255 && mantissa)
+		return 1;
+	return 0;
+}
+
+#if (RI_MANTISSA_BITS > 23)
+#error RI_MANTISSA_BITS is greater than 23
+#elif (RI_EXPONENT_BITS > 8)
+#error RI_EXPONENT_BITS is greater than 8
+#elif (RI_MANTISSA_BITS != 23) || (RI_EXPONENT_BITS != 8)
+
+class RIfloat
+{
+public:
+	RIfloat() : v(0.0f)						{ removeBits(); }
+	RIfloat(float a) : v(a)					{ removeBits(); }
+	RIfloat(double a) : v((float)a)			{ removeBits(); }
+	RIfloat(int a) : v((float)a)			{ removeBits(); }
+	RIfloat(unsigned int a) : v((float)a)	{ removeBits(); }
+	RIfloat&	operator=(const RIfloat &a)	{ v = a.v; removeBits(); return *this; }
+	RIfloat&	operator+=(const RIfloat &a){ v += a.v; removeBits(); return *this; }
+	RIfloat&	operator-=(const RIfloat &a){ v -= a.v; removeBits(); return *this; }
+	RIfloat&	operator*=(const RIfloat &a){ v *= a.v; removeBits(); return *this; }
+	RIfloat&	operator/=(const RIfloat &a){ v /= a.v; removeBits(); return *this; }
+	RIfloat		operator-() const			{ return -v; }
+	operator float() const					{ return v; }
+	operator double() const					{ return (double)v; }
+	operator int() const					{ return (int)v; }
+
+	friend RIfloat	operator+(const RIfloat &a, const RIfloat &b);
+	friend RIfloat	operator+(float a, const RIfloat &b);
+	friend RIfloat	operator+(const RIfloat &a, float b);
+	friend RIfloat	operator-(const RIfloat &a, const RIfloat &b);
+	friend RIfloat	operator-(float a, const RIfloat &b);
+	friend RIfloat	operator-(const RIfloat &a, float b);
+	friend RIfloat	operator*(const RIfloat &a, const RIfloat &b);
+	friend RIfloat	operator*(float a, const RIfloat &b);
+	friend RIfloat	operator*(const RIfloat &a, float b);
+	friend RIfloat	operator/(const RIfloat &a, const RIfloat &b);
+	friend RIfloat	operator/(float a, const RIfloat &b);
+	friend RIfloat	operator/(const RIfloat &a, float b);
+
+	friend bool		operator<(const RIfloat &a, const RIfloat &b);
+	friend bool		operator<(float a, const RIfloat &b);
+	friend bool		operator<(const RIfloat &a, float b);
+	friend bool		operator>(const RIfloat &a, const RIfloat &b);
+	friend bool		operator>(float a, const RIfloat &b);
+	friend bool		operator>(const RIfloat &a, float b);
+	friend bool		operator<=(const RIfloat &a, const RIfloat &b);
+	friend bool		operator<=(float a, const RIfloat &b);
+	friend bool		operator<=(const RIfloat &a, float b);
+	friend bool		operator>=(const RIfloat &a, const RIfloat &b);
+	friend bool		operator>=(float a, const RIfloat &b);
+	friend bool		operator>=(const RIfloat &a, float b);
+	friend bool		operator==(const RIfloat &a, const RIfloat &b);
+	friend bool		operator==(float a, const RIfloat &b);
+	friend bool		operator==(const RIfloat &a, float b);
+	friend bool		operator!=(const RIfloat &a, const RIfloat &b);
+	friend bool		operator!=(float a, const RIfloat &b);
+	friend bool		operator!=(const RIfloat &a, float b);
+private:
+	void	removeBits()
+	{
+		RIfloatInt p;
+		p.f = v;
+		unsigned int exponent = (p.i>>23) & 0xff;
+		if(exponent == 0 || exponent == 255)
+			return;	//zero, denormal, infinite, or NaN
+
+		p.i &= ~((1<<(23-RI_MANTISSA_BITS))-1);
+
+#if (RI_EXPONENT_BITS != 8)
+		if (exponent > 127 + (1 << (RI_EXPONENT_BITS-1)))
+			exponent = 127 + (1 << (RI_EXPONENT_BITS-1));
+
+		if (exponent < 127 + 1 - (1 << (RI_EXPONENT_BITS-1)))
+			exponent = 127 + 1 - (1 << (RI_EXPONENT_BITS-1));
+
+		p.i &= ~(0xff<<23);
+		p.i |= exponent<<23;
+#endif
+		v = p.f;
+	}
+
+	float		v;
+};
+
+RI_INLINE RIfloat operator+(const RIfloat &a, const RIfloat &b)	{ return RIfloat(a.v+b.v); }
+RI_INLINE RIfloat operator+(float a, const RIfloat &b)			{ return RIfloat(a+b.v); }
+RI_INLINE RIfloat operator+(const RIfloat &a, float b)			{ return RIfloat(a.v+b); }
+RI_INLINE RIfloat operator-(const RIfloat &a, const RIfloat &b)	{ return RIfloat(a.v-b.v); }
+RI_INLINE RIfloat operator-(float a, const RIfloat &b)			{ return RIfloat(a-b.v); }
+RI_INLINE RIfloat operator-(const RIfloat &a, float b)			{ return RIfloat(a.v-b); }
+RI_INLINE RIfloat operator*(const RIfloat &a, const RIfloat &b)	{ return RIfloat(a.v*b.v); }
+RI_INLINE RIfloat operator*(float a, const RIfloat &b)			{ return RIfloat(a*b.v); }
+RI_INLINE RIfloat operator*(const RIfloat &a, float b)			{ return RIfloat(a.v*b); }
+RI_INLINE RIfloat operator/(const RIfloat &a, const RIfloat &b)	{ return RIfloat(a.v/b.v); }
+RI_INLINE RIfloat operator/(float a, const RIfloat &b)			{ return RIfloat(a/b.v); }
+RI_INLINE RIfloat operator/(const RIfloat &a, float b)			{ return RIfloat(a.v/b); }
+
+RI_INLINE bool operator<(const RIfloat &a, const RIfloat &b)	{ return a.v < b.v ? true : false; }
+RI_INLINE bool operator<(float a, const RIfloat &b)				{ return a < b.v ? true : false; }
+RI_INLINE bool operator<(const RIfloat &a, float b)				{ return a.v < b ? true : false; }
+RI_INLINE bool operator>(const RIfloat &a, const RIfloat &b)	{ return a.v > b.v ? true : false; }
+RI_INLINE bool operator>(float a, const RIfloat &b)				{ return a > b.v ? true : false; }
+RI_INLINE bool operator>(const RIfloat &a, float b)				{ return a.v > b ? true : false; }
+RI_INLINE bool operator<=(const RIfloat &a, const RIfloat &b)	{ return a.v <= b.v ? true : false; }
+RI_INLINE bool operator<=(float a, const RIfloat &b)			{ return a <= b.v ? true : false; }
+RI_INLINE bool operator<=(const RIfloat &a, float b)			{ return a.v <= b ? true : false; }
+RI_INLINE bool operator>=(const RIfloat &a, const RIfloat &b)	{ return a.v >= b.v ? true : false; }
+RI_INLINE bool operator>=(float a, const RIfloat &b)			{ return a >= b.v ? true : false; }
+RI_INLINE bool operator>=(const RIfloat &a, float b)			{ return a.v >= b ? true : false; }
+RI_INLINE bool operator==(const RIfloat &a, const RIfloat &b)	{ return a.v == b.v ? true : false; }
+RI_INLINE bool operator==(float a, const RIfloat &b)			{ return a == b.v ? true : false; }
+RI_INLINE bool operator==(const RIfloat &a, float b)			{ return a.v == b ? true : false; }
+RI_INLINE bool operator!=(const RIfloat &a, const RIfloat &b)	{ return a.v != b.v ? true : false; }
+RI_INLINE bool operator!=(float a, const RIfloat &b)			{ return a != b.v ? true : false; }
+RI_INLINE bool operator!=(const RIfloat &a, float b)			{ return a.v != b ? true : false; }
+
+#else
+typedef float RIfloat;
+#endif
+
+#define	PI						3.141592654f
+
+RI_INLINE RIfloat	RI_MAX(RIfloat a, RIfloat b)				{ return (a > b) ? a : b; }
+RI_INLINE RIfloat	RI_MIN(RIfloat a, RIfloat b)				{ return (a < b) ? a : b; }
+RI_INLINE RIfloat	RI_CLAMP(RIfloat a, RIfloat l, RIfloat h)	{ if(RI_ISNAN(a)) return l; RI_ASSERT(l <= h); return (a < l) ? l : (a > h) ? h : a; }
+RI_INLINE void		RI_SWAP(RIfloat &a, RIfloat &b)				{ RIfloat tmp = a; a = b; b = tmp; }
+RI_INLINE RIfloat	RI_ABS(RIfloat a)							{ return (a < 0.0f) ? -a : a; }
+RI_INLINE RIfloat	RI_SQR(RIfloat a)							{ return a * a; }
+RI_INLINE RIfloat	RI_DEG_TO_RAD(RIfloat a)					{ return a * PI / 180.0f; }
+RI_INLINE RIfloat	RI_RAD_TO_DEG(RIfloat a)					{ return a * 180.0f/ PI; }
+RI_INLINE RIfloat	RI_MOD(RIfloat a, RIfloat b)				{ if(RI_ISNAN(a) || RI_ISNAN(b)) return 0.0f; RI_ASSERT(b >= 0.0f); if(b == 0.0f) return 0.0f; RIfloat f = (RIfloat)fmod(a, b); if(f < 0.0f) f += b; RI_ASSERT(f >= 0.0f && f <= b); return f; }
+
+RI_INLINE int		RI_INT_MAX(int a, int b)			{ return (a > b) ? a : b; }
+RI_INLINE int		RI_INT_MIN(int a, int b)			{ return (a < b) ? a : b; }
+RI_INLINE void		RI_INT_SWAP(int &a, int &b)			{ int tmp = a; a = b; b = tmp; }
+RI_INLINE int		RI_INT_MOD(int a, int b)			{ RI_ASSERT(b >= 0); if(!b) return 0; int i = a % b; if(i < 0) i += b; RI_ASSERT(i >= 0 && i < b); return i; }
+RI_INLINE int		RI_INT_ADDSATURATE(int a, int b)	{ RI_ASSERT(b >= 0); int r = a + b; return (r >= a) ? r : RI_INT32_MAX; }
+
+class Matrix3x3;
+class Vector2;
+class Vector3;
+
+//==============================================================================================
+
+//MatrixRxC, R = number of rows, C = number of columns
+//indexing: matrix[row][column]
+//Matrix3x3 inline functions cannot be inside the class because Vector3 is not defined yet when Matrix3x3 is defined
+
+class Matrix3x3
+{
+public:
+	RI_INLINE					Matrix3x3		();						//initialized to identity
+	RI_INLINE					Matrix3x3		( const Matrix3x3& m );
+	RI_INLINE					Matrix3x3		( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 );
+	RI_INLINE					~Matrix3x3		();
+	RI_INLINE Matrix3x3&		operator=		( const Matrix3x3& m );
+	RI_INLINE Vector3&			operator[]		( int i );				//returns a row vector
+	RI_INLINE const Vector3&	operator[]		( int i ) const;
+	RI_INLINE void				set				( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 );
+	RI_INLINE const Vector3		getRow			( int i ) const;
+	RI_INLINE const Vector3		getColumn		( int i ) const;
+	RI_INLINE void				setRow			( int i, const Vector3& v );
+	RI_INLINE void				setColumn		( int i, const Vector3& v );
+	RI_INLINE void				operator*=		( const Matrix3x3& m );
+	RI_INLINE void				operator*=		( RIfloat f );
+	RI_INLINE void				operator+=		( const Matrix3x3& m );
+	RI_INLINE void				operator-=		( const Matrix3x3& m );
+	RI_INLINE const Matrix3x3	operator-		() const;
+	RI_INLINE void				identity		();
+	RI_INLINE void				transpose		();
+	bool						invert			();	//if the matrix is singular, returns false and leaves it unmodified
+	RI_INLINE RIfloat				det				() const;
+	RI_INLINE bool				isAffine		() const;
+
+private:
+	RIfloat						matrix[3][3];
+};
+
+//==============================================================================================
+
+class Vector2
+{
+public:
+	RI_INLINE					Vector2			() : x(0.0f), y(0.0f)					{}
+	RI_INLINE					Vector2			( const Vector2& v ) : x(v.x), y(v.y)	{}
+	RI_INLINE					Vector2			( RIfloat fx, RIfloat fy ) : x(fx), y(fy)	{}
+	RI_INLINE					~Vector2		()								{}
+	RI_INLINE Vector2&			operator=		( const Vector2& v )			{ x = v.x; y = v.y; return *this; }
+	RI_INLINE RIfloat&			operator[]		( int i )						{ RI_ASSERT(i>=0&&i<2); return (&x)[i]; }
+	RI_INLINE const RIfloat&	operator[]		( int i ) const					{ RI_ASSERT(i>=0&&i<2); return (&x)[i]; }
+	RI_INLINE void				set				( RIfloat fx, RIfloat fy )			{ x = fx; y = fy; }
+	RI_INLINE void				operator*=		( RIfloat f )						{ x *= f; y *= f; }
+	RI_INLINE void				operator+=		( const Vector2& v )			{ x += v.x; y += v.y; }
+	RI_INLINE void				operator-=		( const Vector2& v )			{ x -= v.x; y -= v.y; }
+	RI_INLINE const Vector2		operator-		() const						{ return Vector2(-x,-y); }
+	//if the vector is zero, returns false and leaves it unmodified
+	RI_INLINE bool				normalize		()								{ double l = (double)x*(double)x+(double)y*(double)y; if( l == 0.0 ) return false; l = 1.0 / sqrt(l); x = (RIfloat)((double)x * l); y = (RIfloat)((double)y * l); return true; }
+	RI_INLINE RIfloat			length			() const						{ return (RIfloat)sqrt((double)x*(double)x+(double)y*(double)y); }
+	RI_INLINE void				scale			( const Vector2& v )			{ x *= v.x; y *= v.y; }	//component-wise scale
+	RI_INLINE void				negate			()								{ x = -x; y = -y; }
+
+	RIfloat						x,y;
+};
+
+//==============================================================================================
+
+class Vector3
+{
+public:
+	RI_INLINE					Vector3			() : x(0.0f), y(0.0f), z(0.0f)							{}
+	RI_INLINE					Vector3			( const Vector3& v ) : x(v.x), y(v.y), z(v.z)			{}
+	RI_INLINE					Vector3			( RIfloat fx, RIfloat fy, RIfloat fz ) : x(fx), y(fy), z(fz)	{}
+	RI_INLINE					~Vector3		()								{}
+	RI_INLINE Vector3&			operator=		( const Vector3& v )			{ x = v.x; y = v.y; z = v.z; return *this; }
+	RI_INLINE RIfloat&			operator[]		( int i )						{ RI_ASSERT(i>=0&&i<3); return (&x)[i]; }
+	RI_INLINE const RIfloat&	operator[]		( int i ) const					{ RI_ASSERT(i>=0&&i<3); return (&x)[i]; }
+	RI_INLINE void				set				( RIfloat fx, RIfloat fy, RIfloat fz ){ x = fx; y = fy; z = fz; }
+	RI_INLINE void				operator*=		( RIfloat f )						{ x *= f; y *= f; z *= f; }
+	RI_INLINE void				operator+=		( const Vector3& v )			{ x += v.x; y += v.y; z += v.z; }
+	RI_INLINE void				operator-=		( const Vector3& v )			{ x -= v.x; y -= v.y; z -= v.z; }
+	RI_INLINE const Vector3		operator-		() const						{ return Vector3(-x,-y,-z); }
+	//if the vector is zero, returns false and leaves it unmodified
+	RI_INLINE bool				normalize		()								{ double l = (double)x*(double)x+(double)y*(double)y+(double)z*(double)z; if( l == 0.0 ) return false; l = 1.0 / sqrt(l); x = (RIfloat)((double)x * l); y = (RIfloat)((double)y * l); z = (RIfloat)((double)z * l); return true; }
+	RI_INLINE RIfloat			length			() const						{ return (RIfloat)sqrt((double)x*(double)x+(double)y*(double)y+(double)z*(double)z); }
+	RI_INLINE void				scale			( const Vector3& v )			{ x *= v.x; y *= v.y; z *= v.z; }	//component-wise scale
+	RI_INLINE void				negate			()								{ x = -x; y = -y; z = -z; }
+
+	RIfloat						x,y,z;
+};
+
+//==============================================================================================
+
+//Vector2 global functions
+RI_INLINE bool			operator==	( const Vector2& v1, const Vector2& v2 )	{ return (v1.x == v2.x) && (v1.y == v2.y); }
+RI_INLINE bool			operator!=	( const Vector2& v1, const Vector2& v2 )	{ return (v1.x != v2.x) || (v1.y != v2.y); }
+RI_INLINE bool			isEqual		( const Vector2& v1, const Vector2& v2, RIfloat epsilon )	{ return RI_SQR(v2.x-v1.x) + RI_SQR(v2.y-v1.y) <= epsilon*epsilon; }
+RI_INLINE bool			isZero		( const Vector2& v )						{ return (v.x == 0.0f) && (v.y == 0.0f); }
+RI_INLINE const Vector2	operator*	( RIfloat f, const Vector2& v )				{ return Vector2(v.x*f,v.y*f); }
+RI_INLINE const Vector2	operator*	( const Vector2& v, RIfloat f )				{ return Vector2(v.x*f,v.y*f); }
+RI_INLINE const Vector2	operator+	( const Vector2& v1, const Vector2& v2 )	{ return Vector2(v1.x+v2.x, v1.y+v2.y); }
+RI_INLINE const Vector2	operator-	( const Vector2& v1, const Vector2& v2 )	{ return Vector2(v1.x-v2.x, v1.y-v2.y); }
+RI_INLINE RIfloat		dot			( const Vector2& v1, const Vector2& v2 )	{ return v1.x*v2.x+v1.y*v2.y; }
+//if v is a zero vector, returns a zero vector
+RI_INLINE const Vector2	normalize	( const Vector2& v )						{ double l = (double)v.x*(double)v.x+(double)v.y*(double)v.y; if( l != 0.0 ) l = 1.0 / sqrt(l); return Vector2((RIfloat)((double)v.x * l), (RIfloat)((double)v.y * l)); }
+//if onThis is a zero vector, returns a zero vector
+RI_INLINE const Vector2	project		( const Vector2& v, const Vector2& onThis ) { RIfloat l = dot(onThis,onThis); if( l != 0.0f ) l = dot(v, onThis)/l; return onThis * l; }
+RI_INLINE const Vector2	lerp		( const Vector2& v1, const Vector2& v2, RIfloat ratio )	{ return v1 + ratio * (v2 - v1); }
+RI_INLINE const Vector2	scale		( const Vector2& v1, const Vector2& v2 )	{ return Vector2(v1.x*v2.x, v1.y*v2.y); }
+//matrix * column vector. The input vector2 is implicitly expanded to (x,y,1)
+RI_INLINE const Vector2 affineTransform( const Matrix3x3& m, const Vector2& v )	{ RI_ASSERT(m.isAffine()); return Vector2(v.x * m[0][0] + v.y * m[0][1] + m[0][2], v.x * m[1][0] + v.y * m[1][1] + m[1][2]); }
+//matrix * column vector. The input vector2 is implicitly expanded to (x,y,0)
+RI_INLINE const Vector2 affineTangentTransform(const Matrix3x3& m, const Vector2& v)	{ RI_ASSERT(m.isAffine()); return Vector2(v.x * m[0][0] + v.y * m[0][1], v.x * m[1][0] + v.y * m[1][1]); }
+RI_INLINE const Vector2 perpendicularCW(const Vector2& v)						{ return Vector2(v.y, -v.x); }
+RI_INLINE const Vector2 perpendicularCCW(const Vector2& v)						{ return Vector2(-v.y, v.x); }
+RI_INLINE const Vector2 perpendicular(const Vector2& v, bool cw)				{ if(cw) return Vector2(v.y, -v.x); return Vector2(-v.y, v.x); }
+
+//==============================================================================================
+
+//Vector3 global functions
+RI_INLINE bool			operator==	( const Vector3& v1, const Vector3& v2 )	{ return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); }
+RI_INLINE bool			operator!=	( const Vector3& v1, const Vector3& v2 )	{ return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); }
+RI_INLINE bool			isEqual		( const Vector3& v1, const Vector3& v2, RIfloat epsilon )	{ return RI_SQR(v2.x-v1.x) + RI_SQR(v2.y-v1.y) + RI_SQR(v2.z-v1.z) <= epsilon*epsilon; }
+RI_INLINE const Vector3	operator*	( RIfloat f, const Vector3& v )				{ return Vector3(v.x*f,v.y*f,v.z*f); }
+RI_INLINE const Vector3	operator*	( const Vector3& v, RIfloat f )				{ return Vector3(v.x*f,v.y*f,v.z*f); }
+RI_INLINE const Vector3	operator+	( const Vector3& v1, const Vector3& v2 )	{ return Vector3(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); }
+RI_INLINE const Vector3	operator-	( const Vector3& v1, const Vector3& v2 )	{ return Vector3(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); }
+RI_INLINE RIfloat		dot			( const Vector3& v1, const Vector3& v2 )	{ return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z; }
+RI_INLINE const Vector3	cross		( const Vector3& v1, const Vector3& v2 )	{ return Vector3( v1.y*v2.z-v1.z*v2.y, v1.z*v2.x-v1.x*v2.z, v1.x*v2.y-v1.y*v2.x ); }
+//if v is a zero vector, returns a zero vector
+RI_INLINE const Vector3	normalize	( const Vector3& v )						{ double l = (double)v.x*(double)v.x+(double)v.y*(double)v.y+(double)v.z*(double)v.z; if( l != 0.0 ) l = 1.0 / sqrt(l); return Vector3((RIfloat)((double)v.x * l), (RIfloat)((double)v.y * l), (RIfloat)((double)v.z * l)); }
+RI_INLINE const Vector3	lerp		( const Vector3& v1, const Vector3& v2, RIfloat ratio )	{ return v1 + ratio * (v2 - v1); }
+RI_INLINE const Vector3	scale		( const Vector3& v1, const Vector3& v2 )	{ return Vector3(v1.x*v2.x, v1.y*v2.y, v1.z*v2.z); }
+
+//==============================================================================================
+
+//matrix * column vector
+RI_INLINE const Vector3	operator*	( const Matrix3x3& m, const Vector3& v)		{ return Vector3( v.x*m[0][0]+v.y*m[0][1]+v.z*m[0][2], v.x*m[1][0]+v.y*m[1][1]+v.z*m[1][2], v.x*m[2][0]+v.y*m[2][1]+v.z*m[2][2] ); }
+
+//==============================================================================================
+
+//Matrix3x3 global functions
+RI_INLINE bool				operator==	( const Matrix3x3& m1, const Matrix3x3& m2 )	{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) if( m1[i][j] != m2[i][j] ) return false; return true; }
+RI_INLINE bool				operator!=	( const Matrix3x3& m1, const Matrix3x3& m2 )	{ return !(m1 == m2); }
+RI_INLINE const Matrix3x3	operator*	( const Matrix3x3& m1, const Matrix3x3& m2 )	{ Matrix3x3 t; for(int i=0;i<3;i++) for(int j=0;j<3;j++) t[i][j] = m1[i][0] * m2[0][j] + m1[i][1] * m2[1][j] + m1[i][2] * m2[2][j]; return t; }
+RI_INLINE const Matrix3x3	operator*	( RIfloat f, const Matrix3x3& m )					{ Matrix3x3 t(m); t *= f; return t; }
+RI_INLINE const Matrix3x3	operator*	( const Matrix3x3& m, RIfloat f )					{ Matrix3x3 t(m); t *= f; return t; }
+RI_INLINE const Matrix3x3	operator+	( const Matrix3x3& m1, const Matrix3x3& m2 )	{ Matrix3x3 t(m1); t += m2; return t; }
+RI_INLINE const Matrix3x3	operator-	( const Matrix3x3& m1, const Matrix3x3& m2 )	{ Matrix3x3 t(m1); t -= m2; return t; }
+RI_INLINE const Matrix3x3	transpose	( const Matrix3x3& m )							{ Matrix3x3 t(m); t.transpose(); return t; }
+// if the matrix is singular, returns it unmodified
+RI_INLINE const Matrix3x3	invert		( const Matrix3x3& m )							{ Matrix3x3 t(m); t.invert(); return t; }
+
+//==============================================================================================
+
+//Matrix3x3 inline functions (cannot be inside the class because Vector3 is not defined yet when Matrix3x3 is defined)
+RI_INLINE					Matrix3x3::Matrix3x3	()									{ identity(); }
+RI_INLINE					Matrix3x3::Matrix3x3	( const Matrix3x3& m )				{ *this = m; }
+RI_INLINE					Matrix3x3::Matrix3x3	( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 )	{ set(m00,m01,m02,m10,m11,m12,m20,m21,m22); }
+RI_INLINE					Matrix3x3::~Matrix3x3	()									{}
+RI_INLINE Matrix3x3&		Matrix3x3::operator=	( const Matrix3x3& m )				{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] = m.matrix[i][j]; return *this; }
+RI_INLINE Vector3&			Matrix3x3::operator[]	( int i )							{ RI_ASSERT(i>=0&&i<3); return (Vector3&)matrix[i][0]; }
+RI_INLINE const Vector3&	Matrix3x3::operator[]	( int i ) const						{ RI_ASSERT(i>=0&&i<3); return (const Vector3&)matrix[i][0]; }
+RI_INLINE void				Matrix3x3::set			( RIfloat m00, RIfloat m01, RIfloat m02, RIfloat m10, RIfloat m11, RIfloat m12, RIfloat m20, RIfloat m21, RIfloat m22 ) { matrix[0][0] = m00; matrix[0][1] = m01; matrix[0][2] = m02; matrix[1][0] = m10; matrix[1][1] = m11; matrix[1][2] = m12; matrix[2][0] = m20; matrix[2][1] = m21; matrix[2][2] = m22; }
+RI_INLINE const Vector3		Matrix3x3::getRow		( int i ) const						{ RI_ASSERT(i>=0&&i<3); return Vector3(matrix[i][0], matrix[i][1], matrix[i][2]); }
+RI_INLINE const Vector3		Matrix3x3::getColumn	( int i ) const						{ RI_ASSERT(i>=0&&i<3); return Vector3(matrix[0][i], matrix[1][i], matrix[2][i]); }
+RI_INLINE void				Matrix3x3::setRow		( int i, const Vector3& v )			{ RI_ASSERT(i>=0&&i<3); matrix[i][0] = v.x; matrix[i][1] = v.y; matrix[i][2] = v.z; }
+RI_INLINE void				Matrix3x3::setColumn	( int i, const Vector3& v )			{ RI_ASSERT(i>=0&&i<3); matrix[0][i] = v.x; matrix[1][i] = v.y; matrix[2][i] = v.z; }
+RI_INLINE void				Matrix3x3::operator*=	( const Matrix3x3& m )				{ *this = *this * m; }
+RI_INLINE void				Matrix3x3::operator*=	( RIfloat f )							{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] *= f; }
+RI_INLINE void				Matrix3x3::operator+=	( const Matrix3x3& m )				{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] += m.matrix[i][j]; }
+RI_INLINE void				Matrix3x3::operator-=	( const Matrix3x3& m )				{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] -= m.matrix[i][j]; }
+RI_INLINE const Matrix3x3	Matrix3x3::operator-	() const							{ return Matrix3x3( -matrix[0][0],-matrix[0][1],-matrix[0][2], -matrix[1][0],-matrix[1][1],-matrix[1][2], -matrix[2][0],-matrix[2][1],-matrix[2][2]); }
+RI_INLINE void				Matrix3x3::identity		()									{ for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i][j] = (i == j) ? 1.0f : 0.0f; }
+RI_INLINE void				Matrix3x3::transpose	()									{ RI_SWAP(matrix[1][0], matrix[0][1]); RI_SWAP(matrix[2][0], matrix[0][2]); RI_SWAP(matrix[2][1], matrix[1][2]); }
+RI_INLINE RIfloat			Matrix3x3::det			() const							{ return matrix[0][0] * (matrix[1][1]*matrix[2][2] - matrix[2][1]*matrix[1][2]) + matrix[0][1] * (matrix[2][0]*matrix[1][2] - matrix[1][0]*matrix[2][2]) + matrix[0][2] * (matrix[1][0]*matrix[2][1] - matrix[2][0]*matrix[1][1]); }
+RI_INLINE bool				Matrix3x3::isAffine		() const							{ if(matrix[2][0] == 0.0f && matrix[2][1] == 0.0f && matrix[2][2] == 1.0f) return true; return false; }
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+#endif /* __RIMATH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,2396 @@
+/*------------------------------------------------------------------------
+ *
+ * EGL 1.3
+ * -------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Simple implementation of EGL 1.3
+ * \note	caveats:
+			- always renders into the backbuffer and blits it to window (no single buffered rendering)
+			- no native Windows or Mac OS X pixmap support
+			- no power management events
+			- no support for swap interval
+ * \todo	what happens in egl functions when eglTerminate has been called but the context and surface are still in use?
+ * \todo	OSDeinitMutex should be called in case getEGL fails.
+ *//*-------------------------------------------------------------------*/
+
+#include "egl.h"
+#include "openvg.h"
+#include "riArray.h"
+#include "riMath.h"
+#include "riContext.h"
+#include "riImage.h"
+
+#ifdef BUILD_WITH_PRIVATE_EGL 
+#include "eglinternal.h"
+#endif
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+#include "openvginternal.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+void* OSGetCurrentThreadID(void);
+void OSAcquireMutex(void);
+void OSReleaseMutex(void);
+void OSDeinitMutex(void);
+
+EGLDisplay OSGetDisplay(EGLNativeDisplayType display_id);
+void* OSCreateWindowContext(EGLNativeWindowType window);
+void OSDestroyWindowContext(void* context);
+bool OSIsWindow(const void* context);
+void OSGetWindowSize(const void* context, int& width, int& height);
+void OSBlitToWindow(void* context, const Drawable* drawable);
+EGLBoolean OSGetNativePixmapInfo(NativePixmapType pixmap, int* width, int* height, int* stride, VGImageFormat* format, int** data);
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class RIEGLConfig
+{
+public:
+	RIEGLConfig() : m_desc(Color::formatToDescriptor(VG_sRGBA_8888)), m_configID(0)	{}
+	~RIEGLConfig()							{}
+	void		set(int r, int g, int b, int a, int l, int bpp, int samples, int maskBits, int ID)
+	{
+		m_desc.redBits = r;
+		m_desc.greenBits = g;
+		m_desc.blueBits = b;
+		m_desc.alphaBits = a;
+		m_desc.luminanceBits = l;
+		m_desc.alphaShift = 0;
+		m_desc.luminanceShift = 0;
+		m_desc.blueShift = b ? a : 0;
+		m_desc.greenShift = g ? a + b : 0;
+		m_desc.redShift = r ? a + b + g : 0;
+		m_desc.format = (VGImageFormat)-1;
+		m_desc.internalFormat = l ? Color::sLA : Color::sRGBA;
+		m_desc.bitsPerPixel = bpp;
+		RI_ASSERT(Color::isValidDescriptor(m_desc));
+		m_samples = samples;
+        m_maskBits = maskBits;
+		m_configID = ID;
+        m_config = (EGLConfig)ID;
+	}
+
+    Color::Descriptor configToDescriptor(bool sRGB, bool premultiplied) const
+    {
+        Color::Descriptor desc = m_desc;
+        unsigned int f = m_desc.luminanceBits ? Color::LUMINANCE : 0;
+        f |= sRGB ? Color::NONLINEAR : 0;
+        f |= premultiplied ? Color::PREMULTIPLIED : 0;
+        desc.internalFormat = (Color::InternalFormat)f;
+        return desc;
+    }
+
+	//EGL RED SIZE bits of Red in the color buffer
+	//EGL GREEN SIZE bits of Green in the color buffer
+	//EGL BLUE SIZE bits of Blue in the color buffer
+	//EGL ALPHA SIZE bits of Alpha in the color buffer
+	//EGL LUMINANCE SIZE bits of Luminance in the color buffer
+	Color::Descriptor	m_desc;
+	int					m_samples;
+    int                 m_maskBits;
+	EGLint				m_configID;			//EGL CONFIG ID unique EGLConfig identifier
+    EGLConfig           m_config;
+	//EGL BUFFER SIZE depth of the color buffer (sum of channel bits)
+	//EGL ALPHA MASK SIZE number alpha mask bits (always 8)
+	//EGL BIND TO TEXTURE RGB boolean True if bindable to RGB textures. (always EGL_FALSE)
+	//EGL BIND TO TEXTURE RGBA boolean True if bindable to RGBA textures. (always EGL_FALSE)
+	//EGL COLOR BUFFER TYPE enum color buffer type (EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER)
+	//EGL CONFIG CAVEAT enum any caveats for the configuration (always EGL_NONE)
+	//EGL DEPTH SIZE integer bits of Z in the depth buffer (always 0)
+	//EGL LEVEL integer frame buffer level (always 0)
+	//EGL MAX PBUFFER WIDTH integer maximum width of pbuffer (always INT_MAX)
+	//EGL MAX PBUFFER HEIGHT integer maximum height of pbuffer (always INT_MAX)
+	//EGL MAX PBUFFER PIXELS integer maximum size of pbuffer (always INT_MAX)
+	//EGL MAX SWAP INTERVAL integer maximum swap interval (always 1)
+	//EGL MIN SWAP INTERVAL integer minimum swap interval (always 1)
+	//EGL NATIVE RENDERABLE boolean EGL TRUE if native rendering APIs can render to surface (always EGL_FALSE)
+	//EGL NATIVE VISUAL ID integer handle of corresponding native visual (always 0)
+	//EGL NATIVE VISUAL TYPE integer native visual type of the associated visual (always EGL_NONE)
+	//EGL RENDERABLE TYPE bitmask which client rendering APIs are supported. (always EGL_OPENVG_BIT)
+	//EGL SAMPLE BUFFERS integer number of multisample buffers (always 0)
+	//EGL SAMPLES integer number of samples per pixel (always 0)
+	//EGL STENCIL SIZE integer bits of Stencil in the stencil buffer (always 0)
+	//EGL SURFACE TYPE bitmask which types of EGL surfaces are supported. (always EGL WINDOW BIT | EGL PIXMAP BIT | EGL PBUFFER BIT)
+	//EGL TRANSPARENT TYPE enum type of transparency supported (always EGL_NONE)
+	//EGL TRANSPARENT RED VALUE integer transparent red value (undefined)
+	//EGL TRANSPARENT GREEN VALUE integer transparent green value (undefined)
+	//EGL TRANSPARENT BLUE VALUE integer transparent blue value (undefined)
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class RIEGLContext
+{
+public:
+	RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config);
+	~RIEGLContext();
+	void	addReference()				{ m_referenceCount++; }
+	int		removeReference()			{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+    VGContext*      getVGContext() const      { return m_vgContext; }
+    EGLConfig getConfig() const         { return m_config; }
+private:
+	RIEGLContext(const RIEGLContext&);
+	RIEGLContext& operator=(const RIEGLContext&);
+	VGContext*		m_vgContext;
+	const EGLConfig	m_config;
+	int				m_referenceCount;
+};
+
+RIEGLContext* CastToRIEGLContext(EGLContext aCtxId);
+EGLContext CastFromRIEGLContext(RIEGLContext* aCtx);
+
+RIEGLContext::RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config) :
+	m_vgContext(vgctx),
+	m_config(config),
+	m_referenceCount(0)
+{
+}
+RIEGLContext::~RIEGLContext()
+{
+	RI_ASSERT(m_referenceCount == 0);
+	RI_DELETE(m_vgContext);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class RIEGLSurface
+{
+public:
+    RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer);
+	~RIEGLSurface();
+	void	addReference()				{ m_referenceCount++; }
+	int		removeReference()			{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+    void*           getOSWindowContext() const { return m_OSWindowContext; }
+    EGLConfig       getConfig() const          { return m_config; }
+    Drawable*       getDrawable() const        { return m_drawable; }
+    bool            isLargestPbuffer() const   { return m_largestPbuffer; }
+    int             getRenderBuffer() const    { return m_renderBuffer; }
+
+private:
+	RIEGLSurface(const RIEGLSurface&);
+	RIEGLSurface& operator=(const RIEGLSurface&);
+    void*            m_OSWindowContext;
+	const EGLConfig	 m_config;
+	Drawable*        m_drawable;
+	bool			 m_largestPbuffer;
+	int				 m_renderBuffer;		//EGL_BACK_BUFFER or EGL_SINGLE_BUFFER
+	int				 m_referenceCount;
+};
+
+RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId);
+EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface);
+
+RIEGLSurface::RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer) :
+    m_OSWindowContext(OSWindowContext),
+	m_config(config),
+	m_drawable(drawable),
+	m_largestPbuffer(largestPbuffer),
+	m_renderBuffer(renderBuffer),
+	m_referenceCount(0)
+{
+    RI_ASSERT(m_renderBuffer == EGL_BACK_BUFFER);   //only back buffer rendering is supported
+    m_drawable->addReference();
+}
+
+RIEGLSurface::~RIEGLSurface()
+{
+	RI_ASSERT(m_referenceCount == 0);
+    OSDestroyWindowContext(m_OSWindowContext);
+	if(m_drawable)
+	{
+		if(!m_drawable->removeReference())
+			RI_DELETE(m_drawable);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#define EGL_NUMCONFIGS		60
+
+class RIEGLDisplay
+{
+public:
+	RIEGLDisplay(EGLDisplay id);
+	~RIEGLDisplay();
+
+	int                getNumConfigs() const              { return EGL_NUMCONFIGS; }
+    const RIEGLConfig& getConfigByIdx(int i) const             { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; }
+    const RIEGLConfig& getConfig(const EGLConfig config) const        { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; }
+
+    EGLDisplay        getID() const                       { return m_id; }
+
+    void              addContext(RIEGLContext* ctx)       { RI_ASSERT(ctx); m_contexts.push_back(ctx); }  //throws bad_alloc
+    void              removeContext(RIEGLContext* ctx)    { RI_ASSERT(ctx); bool res = m_contexts.remove(ctx); RI_ASSERT(res); RI_UNREF(res); }
+
+    void              addSurface(RIEGLSurface* srf)       { RI_ASSERT(srf); m_surfaces.push_back(srf); }  //throws bad_alloc
+    void              removeSurface(RIEGLSurface* srf)    { RI_ASSERT(srf); bool res = m_surfaces.remove(srf); RI_ASSERT(res); RI_UNREF(res); }
+
+    EGLBoolean        contextExists(const EGLContext ctx) const;
+    EGLBoolean        surfaceExists(const EGLSurface srf) const;
+    EGLBoolean        configExists(const EGLConfig cfg) const;
+
+private:
+	RIEGLDisplay(const RIEGLDisplay& t);
+	RIEGLDisplay& operator=(const RIEGLDisplay&t);
+
+	EGLDisplay              m_id;
+
+	Array<RIEGLContext*>	m_contexts;
+	Array<RIEGLSurface*>	m_surfaces;
+
+	RIEGLConfig             m_configs[EGL_NUMCONFIGS];
+};
+
+RIEGLDisplay::RIEGLDisplay(EGLDisplay id) :
+	m_id(id),
+	m_contexts(),
+	m_surfaces()
+{
+	RI_ASSERT(EGL_NUMCONFIGS == 60);
+
+	//sorted by RGB/LUMINANCE (exact), larger total number of color bits (at least), buffer size (at least), config ID (exact)
+	//NOTE: 16 bit configs need to be sorted on the fly if the request ignores some channels
+	//NOTE: config IDs start from 1
+	//               R  B  G  A  L  bpp samples maskBits ID
+	m_configs[0].set(8, 8, 8, 8, 0, 32, 1, 8, 1);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[1].set(8, 8, 8, 0, 0, 32, 1, 8, 2);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[2].set(5, 5, 5, 1, 0, 16, 1, 4, 3);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[3].set(5, 6, 5, 0, 0, 16, 1, 4, 4);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[4].set(4, 4, 4, 4, 0, 16, 1, 4, 5);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[5].set(0, 0, 0, 8, 0, 8,  1, 8, 6);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[6].set(0, 0, 0, 4, 0, 4,  1, 4, 7);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[7].set(0, 0, 0, 1, 0, 1,  1, 1, 8);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[8].set(0, 0, 0, 0, 8, 8,  1, 8, 9);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[9].set(0, 0, 0, 0, 1, 1,  1, 1, 10);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+
+	m_configs[10].set(8, 8, 8, 8, 0, 32, 4, 1, 11);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[11].set(8, 8, 8, 0, 0, 32, 4, 1, 12);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[12].set(5, 5, 5, 1, 0, 16, 4, 1, 13);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[13].set(5, 6, 5, 0, 0, 16, 4, 1, 14);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[14].set(4, 4, 4, 4, 0, 16, 4, 1, 15);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[15].set(0, 0, 0, 8, 0, 8,  4, 1, 16);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[16].set(0, 0, 0, 4, 0, 4,  4, 1, 17);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[17].set(0, 0, 0, 1, 0, 1,  4, 1, 18);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[18].set(0, 0, 0, 0, 8, 8,  4, 1, 19);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[19].set(0, 0, 0, 0, 1, 1,  4, 1, 20);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+
+	m_configs[20].set(8, 8, 8, 8, 0, 32, 32, 1, 21);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[21].set(8, 8, 8, 0, 0, 32, 32, 1, 22);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[22].set(5, 5, 5, 1, 0, 16, 32, 1, 23);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[23].set(5, 6, 5, 0, 0, 16, 32, 1, 24);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[24].set(4, 4, 4, 4, 0, 16, 32, 1, 25);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[25].set(0, 0, 0, 8, 0, 8,  32, 1, 26);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[26].set(0, 0, 0, 4, 0, 4,  32, 1, 27);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[27].set(0, 0, 0, 1, 0, 1,  32, 1, 28);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[28].set(0, 0, 0, 0, 8, 8,  32, 1, 29);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[29].set(0, 0, 0, 0, 1, 1,  32, 1, 30);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+
+    //configs without mask
+	m_configs[30].set(8, 8, 8, 8, 0, 32, 1, 0, 31);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[31].set(8, 8, 8, 0, 0, 32, 1, 0, 32);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[32].set(5, 5, 5, 1, 0, 16, 1, 0, 33);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[33].set(5, 6, 5, 0, 0, 16, 1, 0, 34);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[34].set(4, 4, 4, 4, 0, 16, 1, 0, 35);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[35].set(0, 0, 0, 8, 0, 8,  1, 0, 36);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[36].set(0, 0, 0, 4, 0, 4,  1, 0, 37);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[37].set(0, 0, 0, 1, 0, 1,  1, 0, 38);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[38].set(0, 0, 0, 0, 8, 8,  1, 0, 39);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[39].set(0, 0, 0, 0, 1, 1,  1, 0, 40);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+
+	m_configs[40].set(8, 8, 8, 8, 0, 32, 4, 0, 41);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[41].set(8, 8, 8, 0, 0, 32, 4, 0, 42);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[42].set(5, 5, 5, 1, 0, 16, 4, 0, 43);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[43].set(5, 6, 5, 0, 0, 16, 4, 0, 44);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[44].set(4, 4, 4, 4, 0, 16, 4, 0, 45);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[45].set(0, 0, 0, 8, 0, 8,  4, 0, 46);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[46].set(0, 0, 0, 4, 0, 4,  4, 0, 47);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[47].set(0, 0, 0, 1, 0, 1,  4, 0, 48);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[48].set(0, 0, 0, 0, 8, 8,  4, 0, 49);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[49].set(0, 0, 0, 0, 1, 1,  4, 0, 50);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+
+	m_configs[50].set(8, 8, 8, 8, 0, 32, 32, 0, 51);	//EGL_RGB_BUFFER, buffer size = 32
+	m_configs[51].set(8, 8, 8, 0, 0, 32, 32, 0, 52);	//EGL_RGB_BUFFER, buffer size = 24
+	m_configs[52].set(5, 5, 5, 1, 0, 16, 32, 0, 53);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[53].set(5, 6, 5, 0, 0, 16, 32, 0, 54);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[54].set(4, 4, 4, 4, 0, 16, 32, 0, 55);	//EGL_RGB_BUFFER, buffer size = 16
+	m_configs[55].set(0, 0, 0, 8, 0, 8,  32, 0, 56);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[56].set(0, 0, 0, 4, 0, 4,  32, 0, 57);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[57].set(0, 0, 0, 1, 0, 1,  32, 0, 58);	//EGL_RGB_BUFFER, buffer size = 8
+	m_configs[58].set(0, 0, 0, 0, 8, 8,  32, 0, 59);	//EGL_LUMINANCE_BUFFER, buffer size = 8
+	m_configs[59].set(0, 0, 0, 0, 1, 1,  32, 0, 60);	//EGL_LUMINANCE_BUFFER, buffer size = 1
+/*
+attrib                default        criteria order   priority
+--------------------------------------------------------------
+EGL_COLOR_BUFFER_TYPE EGL_RGB_BUFFER Exact    None    2 
+EGL_RED_SIZE          0              AtLeast  Special 3 
+EGL_GREEN_SIZE        0              AtLeast  Special 3 
+EGL_BLUE_SIZE         0              AtLeast  Special 3 
+EGL_LUMINANCE_SIZE    0              AtLeast  Special 3 
+EGL_ALPHA_SIZE        0              AtLeast  Special 3 
+EGL_BUFFER_SIZE       0              AtLeast  Smaller 4 
+EGL_CONFIG_ID         EGL_DONT_CARE  Exact    Smaller 11
+*/
+}
+
+RIEGLDisplay::~RIEGLDisplay()
+{
+	//mark everything for deletion, but don't delete the current context and surface
+	for(int i=0;i<m_contexts.size();i++)
+	{
+		if(!m_contexts[i]->removeReference())
+			RI_DELETE(m_contexts[i]);
+	}
+	m_contexts.clear();	//remove all contexts from the list (makes further references to the current contexts invalid)
+
+	for(int i=0;i<m_surfaces.size();i++)
+	{
+		if(!m_surfaces[i]->removeReference())
+			RI_DELETE(m_surfaces[i]);
+	}
+	m_surfaces.clear();	//remove all surfaces from the list (makes further references to the current surfaces invalid)
+}
+
+EGLBoolean RIEGLDisplay::contextExists(const EGLContext ctx) const
+{
+	for(int i=0;i<m_contexts.size();i++)
+	{
+		if(m_contexts[i] == CastToRIEGLContext(ctx))
+			return EGL_TRUE;
+	}
+	return EGL_FALSE;
+}
+
+EGLBoolean RIEGLDisplay::surfaceExists(const EGLSurface surf) const
+{
+	for(int i=0;i<m_surfaces.size();i++)
+	{
+		if(m_surfaces[i] == CastToRIEGLSurface(surf))
+			return EGL_TRUE;
+	}
+	return EGL_FALSE;
+}
+
+EGLBoolean RIEGLDisplay::configExists(const EGLConfig config) const
+{
+    for(int i=0;i<EGL_NUMCONFIGS;i++)
+    {
+        if(m_configs[i].m_config == config)
+		return EGL_TRUE;
+    }
+	return EGL_FALSE;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class RIEGLThread
+{
+public:
+	RIEGLThread(void* currentThreadID);
+	~RIEGLThread();
+
+    void*           getThreadID() const       { return m_threadID; }
+
+    void            makeCurrent(RIEGLContext* c, RIEGLSurface* s)       { m_context = c; m_surface = s; }
+	RIEGLContext*	getCurrentContext() const   { return m_context; }
+	RIEGLSurface*	getCurrentSurface() const   { return m_surface; }
+
+    void            setError(EGLint error)      { m_error = error; }
+    EGLint          getError() const            { return m_error; }
+
+    void            bindAPI(EGLint api)         { m_boundAPI = api; }
+    EGLint          getBoundAPI() const         { return m_boundAPI; }
+
+private:
+	RIEGLThread(const RIEGLThread&);
+	RIEGLThread operator=(const RIEGLThread&);
+
+	RIEGLContext*		m_context;
+	RIEGLSurface*		m_surface;
+	EGLint              m_error;
+	void*               m_threadID;
+	EGLint              m_boundAPI;
+};
+
+RIEGLThread::RIEGLThread(void* currentThreadID) :
+	m_context(NULL),
+	m_surface(NULL),
+	m_error(EGL_SUCCESS),
+	m_threadID(currentThreadID),
+	m_boundAPI(EGL_NONE)
+{
+}
+
+RIEGLThread::~RIEGLThread()
+{
+}
+
+
+
+
+
+Image* CastToImage(EGLClientBuffer aBufferId);
+EGLClientBuffer CastFromImage(Image* aBUffer);
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class EGL
+{
+public:
+	EGL();
+	~EGL();
+
+	void	addReference()				{ m_referenceCount++; }
+	int		removeReference()			{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+    void                addDisplay(RIEGLDisplay* display)           { RI_ASSERT(display); m_displays.push_back(display); }  //throws bad alloc
+    void                removeDisplay(RIEGLDisplay* display)        { RI_ASSERT(display); bool res = m_displays.remove(display); RI_ASSERT(res); RI_UNREF(res); }
+    RIEGLDisplay*       getDisplay(const EGLDisplay displayID) const;
+    EGLDisplay          findDisplay(const EGLContext ctx) const;
+
+    void                addCurrentThread(RIEGLThread* thread)       { RI_ASSERT(thread); m_currentThreads.push_back(thread); }  //throws bad alloc
+    void                removeCurrentThread(RIEGLThread* thread)    { RI_ASSERT(thread); bool res = m_currentThreads.remove(thread); RI_ASSERT(res); RI_UNREF(res); }
+    RIEGLThread*        getCurrentThread() const;
+
+    RIEGLThread*        getThread();
+    void                destroyThread();
+
+    bool                isInUse(const void* image) const;
+
+private:
+	EGL(const EGL&);						// Not allowed.
+	const EGL& operator=(const EGL&);		// Not allowed.
+
+	Array<RIEGLThread*>		m_threads;			//threads that have called EGL
+	Array<RIEGLThread*>		m_currentThreads;	//threads that have a bound context
+	Array<RIEGLDisplay*>	m_displays;
+
+	int                     m_referenceCount;
+};
+
+EGL::EGL() :
+	m_threads(),
+	m_currentThreads(),
+	m_displays(),
+	m_referenceCount(0)
+{
+}
+EGL::~EGL()
+{
+	for(int i=0;i<m_displays.size();i++)
+	{
+		RI_DELETE(m_displays[i]);
+	}
+	for(int i=0;i<m_threads.size();i++)
+	{
+		RI_DELETE(m_threads[i]);
+	}
+	//currentThreads contain just pointers to threads we just deleted
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+//static EGL* g_egl = NULL;	//never use this directly
+EGL* getEGL()
+{
+	/*if(!g_egl)
+	{
+		try
+		{
+			g_egl = RI_NEW(EGL, ());				//throws bad_alloc
+			g_egl->addReference();
+		}
+		catch(std::bad_alloc)
+		{
+			g_egl = NULL;
+		}
+	}
+	return g_egl;
+	*/
+
+
+	//use TLS to store static global g_egl
+	EGL* pEgl=NULL; 
+	if((pEgl = static_cast<EGL*>(Dll::Tls()))==NULL)
+		{
+		//create TLS instance
+		pEgl = RI_NEW(EGL, ());
+		Dll::SetTls(pEgl);
+		}
+	return pEgl;
+
+	
+}
+static void releaseEGL()
+{
+/*
+	if(g_egl)
+	{
+		if(!g_egl->removeReference())
+		{
+			RI_DELETE(g_egl);
+			g_egl = NULL;
+		}
+	}
+	*/
+	EGL* pEgl = static_cast<EGL*>(Dll::Tls());
+	if (pEgl)
+		delete pEgl; 
+	Dll::SetTls(NULL);
+
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Given a display ID, return the corresponding object, or NULL
+*			if the ID hasn't been initialized.
+* \param	
+* \return	
+* \note		if egl has been initialized for this display, the display ID can
+*			be found from egl->m_displays
+*//*-------------------------------------------------------------------*/
+
+RIEGLDisplay* EGL::getDisplay(EGLDisplay displayID) const
+{
+	for(int i=0;i<m_displays.size();i++)
+	{
+		if(displayID == m_displays[i]->getID())
+			return m_displays[i];
+	}
+	return NULL;		//error: the display hasn't been eglInitialized
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	return EGLDisplay for the current context
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+EGLDisplay EGL::findDisplay(EGLContext ctx) const
+{
+	for(int i=0;i<m_displays.size();i++)
+	{
+        if(m_displays[i]->contextExists(ctx))
+            return m_displays[i]->getID();
+	}
+    return EGL_NO_DISPLAY;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	return an EGL thread struct for the thread made current, or
+*            NULL if there's no current context.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+RIEGLThread* EGL::getCurrentThread() const
+{
+	void* currentThreadID = OSGetCurrentThreadID();
+	for(int i=0;i<m_currentThreads.size();i++)
+	{
+		if(currentThreadID == m_currentThreads[i]->getThreadID())
+			return m_currentThreads[i];
+	}
+	return NULL;		//thread is not current
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	return an EGL thread struct corresponding to current OS thread.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+RIEGLThread* EGL::getThread()
+{
+	void* currentThreadID = OSGetCurrentThreadID();
+	for(int i=0;i<m_threads.size();i++)
+	{
+		if(currentThreadID == m_threads[i]->getThreadID())
+			return m_threads[i];
+	}
+
+	//EGL doesn't have a struct for the thread yet, add it to EGL's list
+	RIEGLThread* newThread = NULL;
+	try
+	{
+		newThread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID()));	//throws bad_alloc
+		m_threads.push_back(newThread);	//throws bad_alloc
+		return newThread;
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(newThread);
+		return NULL;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	destroy an EGL thread struct
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void EGL::destroyThread()
+{
+	void* currentThreadID = OSGetCurrentThreadID();
+	for(int i=0;i<m_threads.size();i++)
+	{
+		if(currentThreadID == m_threads[i]->getThreadID())
+        {
+            RIEGLThread* thread = m_threads[i];
+            bool res = m_threads.remove(thread);
+            RI_ASSERT(res);
+            RI_UNREF(res);
+            RI_DELETE(thread);
+            break;
+        }
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool EGL::isInUse(const void* image) const
+{
+    for(int i=0;i<m_currentThreads.size();i++)
+    {
+        RIEGLSurface* s = m_currentThreads[i]->getCurrentSurface();
+        if(s && s->getDrawable() && s->getDrawable()->isInUse((Image*)image))
+            return true;
+    }
+    return false;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#define EGL_GET_DISPLAY(DISPLAY, RETVAL) \
+	OSAcquireMutex(); \
+	EGL* egl = getEGL(); \
+    if(!egl) \
+    { \
+		OSReleaseMutex(); \
+		return RETVAL; \
+    } \
+	RIEGLDisplay* display = egl->getDisplay(DISPLAY); \
+
+#define EGL_GET_EGL(RETVAL) \
+	OSAcquireMutex(); \
+	EGL* egl = getEGL(); \
+    if(!egl) \
+    { \
+		OSReleaseMutex(); \
+		return RETVAL; \
+    } \
+
+#define EGL_IF_ERROR(COND, ERRORCODE, RETVAL) \
+	if(COND) { eglSetError(egl, ERRORCODE); OSReleaseMutex(); return RETVAL; } \
+
+#define EGL_RETURN(ERRORCODE, RETVAL) \
+	{ \
+		eglSetError(egl, ERRORCODE); \
+		OSReleaseMutex(); \
+		return RETVAL; \
+	}
+
+// Note: egl error handling model differs from OpenVG. The latest error is stored instead of the oldest one.
+static void eglSetError(EGL* egl, EGLint error)
+{
+	RIEGLThread* thread = egl->getThread();
+	if(thread)
+		thread->setError(error);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns the OpenVG context current to the calling thread.
+* \param	
+* \return	
+* \note		This function is always called from a mutexed API function
+*//*-------------------------------------------------------------------*/
+
+void* eglvgGetCurrentVGContext(void)
+{
+	EGL* egl = getEGL();
+    if(egl)
+    {
+        RIEGLThread* thread = egl->getCurrentThread();
+        if(thread)
+        {
+            RI_ASSERT(thread->getCurrentContext() && thread->getCurrentSurface());
+            return thread->getCurrentContext()->getVGContext();
+        }
+    }
+	return NULL;	//not initialized or made current
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Check if the image is current in any of the displays
+* \param	
+* \return	
+* \note		This function is always called from a mutexed API function
+*//*-------------------------------------------------------------------*/
+
+bool eglvgIsInUse(void* image)
+{
+	EGL* egl = getEGL();
+    if(egl)
+    {
+        return egl->isInUse(image);
+    }
+	return false;
+}
+
+//helper functions
+RIEGLContext* CastToRIEGLContext(EGLContext aCtxId)
+  {
+  return (RIEGLContext*)(aCtxId);
+  }
+EGLContext CastFromRIEGLContext(RIEGLContext* aCtx)
+  {
+  return (EGLContext)(aCtx);
+  }
+
+RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId)
+  {
+  return (RIEGLSurface*)(aSurfaceId);
+  }
+EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface)
+  {
+  return (EGLSurface)(aSurface);
+  }
+
+Image* CastToImage(EGLClientBuffer aBufferId)
+  {
+  return (Image*)(aBufferId);
+  }
+
+EGLClientBuffer CastFromImage(Image* aBUffer)
+  {
+  return (EGLClientBuffer)(aBUffer);
+  }
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+using namespace OpenVGRI;
+
+
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLint do_eglGetError()
+#else
+EGLint eglGetError()
+#endif
+{
+    OSAcquireMutex();
+    EGLint ret = EGL_SUCCESS;
+	EGL* egl = getEGL();
+    if(egl)
+    {
+        RIEGLThread* thread = egl->getThread();
+        if(thread)
+            ret = thread->getError();	//initialized, return error code
+    }
+    else ret = EGL_NOT_INITIALIZED;
+    OSReleaseMutex();
+    return ret;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLDisplay do_eglGetDisplay(EGLNativeDisplayType display_id)
+#else
+EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
+#endif
+{
+    return OSGetDisplay(display_id);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+#else
+EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(display, EGL_SUCCESS, EGL_TRUE);	//already initialized
+
+	//create the current display
+	//if a context and a surface are bound by the time of eglTerminate, they remain bound until eglMakeCurrent is called
+	RIEGLDisplay* newDisplay = NULL;
+	try
+	{
+		newDisplay = RI_NEW(RIEGLDisplay, (dpy));	//throws bad_alloc
+		egl->addDisplay(newDisplay);	//throws bad_alloc
+		display = newDisplay;
+		RI_ASSERT(display);
+	}
+	catch(std::bad_alloc)
+	{
+		RI_DELETE(newDisplay);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE);
+	}
+
+	if(major) *major = 1;
+	if(minor) *minor = 2;
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglTerminate(EGLDisplay dpy)
+#else
+EGLBoolean eglTerminate(EGLDisplay dpy)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_SUCCESS, EGL_TRUE);
+    egl->removeDisplay(display);
+    RI_DELETE(display);
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY const char *do_eglQueryString(EGLDisplay dpy, EGLint name)
+#else
+const char *eglQueryString(EGLDisplay dpy, EGLint name)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, NULL);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, NULL);
+
+	static const char apis[] = "OpenVG";
+	static const char extensions[] = "";
+	static const char vendor[] = "Khronos Group";
+	static const char version[] = "1.3";
+
+	const char* ret = NULL;
+	switch(name)
+	{
+	case EGL_CLIENT_APIS:
+		ret = apis;
+		break;
+
+	case EGL_EXTENSIONS:
+		ret = extensions;
+		break;
+
+	case EGL_VENDOR:
+		ret = vendor;
+		break;
+
+	case EGL_VERSION:
+		ret = version;
+		break;
+
+	default:
+		EGL_RETURN(EGL_BAD_PARAMETER, NULL);
+	}
+	EGL_RETURN(EGL_SUCCESS, ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+#else
+EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE);
+	if(!configs)
+	{
+		*num_config = display->getNumConfigs();
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	}
+	*num_config = RI_INT_MIN(config_size, display->getNumConfigs());
+	for(int i=0;i<*num_config;i++)
+		configs[i] = display->getConfigByIdx(i).m_config;
+
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static bool smaller(EGLint c, EGLint filter)
+{
+	return (filter != EGL_DONT_CARE) && (c < filter);
+}
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+#else
+EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE);
+
+	if(!configs)
+	{
+		*num_config = display->getNumConfigs();
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	}
+	*num_config = 0;
+	if(!config_size)
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+
+	int bufferSize = 0;
+	int redSize = 0;
+	int greenSize = 0;
+	int blueSize = 0;
+	int luminanceSize = 0;
+	int alphaSize = 0;
+	int colorBufferType = EGL_RGB_BUFFER;
+	int configID = EGL_DONT_CARE;
+	int sampleBuffers = 0;
+	int samples = 0;
+	if(attrib_list)
+	{
+		for(int i=0;attrib_list[i] != EGL_NONE;i+=2)
+		{
+			switch(attrib_list[i])
+			{
+			case EGL_BUFFER_SIZE:				//depth of the color buffer
+				bufferSize = attrib_list[i+1];
+				break;
+			case EGL_RED_SIZE:					//bits of Red in the color buffer
+				redSize = attrib_list[i+1];
+				break;
+			case EGL_GREEN_SIZE:				//bits of Green in the color buffer
+				greenSize = attrib_list[i+1];
+				break;
+			case EGL_BLUE_SIZE:					//bits of Blue in the color buffer
+				blueSize = attrib_list[i+1];
+				break;
+			case EGL_LUMINANCE_SIZE:			//bits of Luminance in the color buffer
+				luminanceSize = attrib_list[i+1];
+				break;
+			case EGL_ALPHA_SIZE:				//bits of Alpha in the color buffer
+				alphaSize = attrib_list[i+1];
+				break;
+			case EGL_ALPHA_MASK_SIZE:			//bits of Alpha in the alpha mask buffer
+				if(attrib_list[i+1] > 8)
+					EGL_RETURN(EGL_SUCCESS, EGL_TRUE);	//not supported
+				break;
+			case EGL_COLOR_BUFFER_TYPE:			//enum color buffer type (EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER)
+				EGL_IF_ERROR(attrib_list[i+1] != EGL_RGB_BUFFER && attrib_list[i+1] != EGL_LUMINANCE_BUFFER && attrib_list[i+1] != EGL_DONT_CARE, EGL_BAD_ATTRIBUTE, EGL_FALSE);
+				colorBufferType = attrib_list[i+1];
+				break;
+			case EGL_CONFIG_ID:					//unique EGLConfig identifier
+				configID = attrib_list[i+1];
+				break;
+
+			case EGL_SAMPLE_BUFFERS:			//integer number of multisample buffers
+				sampleBuffers = attrib_list[i+1];
+				break;
+			case EGL_SAMPLES:					//integer number of samples per pixel
+				samples = attrib_list[i+1];
+				break;
+
+			case EGL_BIND_TO_TEXTURE_RGB:		//boolean True if bindable to RGB textures. (always EGL_FALSE)
+			case EGL_BIND_TO_TEXTURE_RGBA:		//boolean True if bindable to RGBA textures. (always EGL_FALSE)
+			case EGL_DEPTH_SIZE:				//integer bits of Z in the depth buffer (always 0)
+			case EGL_LEVEL:						//integer frame buffer level (always 0)
+			case EGL_NATIVE_RENDERABLE:			//boolean EGL TRUE if native rendering APIs can render to surface (always EGL_FALSE)
+			case EGL_STENCIL_SIZE:				//integer bits of Stencil in the stencil buffer (always 0)
+				if(attrib_list[i+1])
+					EGL_RETURN(EGL_SUCCESS, EGL_TRUE);	//not supported
+				break;
+
+			case EGL_CONFIG_CAVEAT:				//enum any caveats for the configuration (always EGL_NONE)
+			case EGL_NATIVE_VISUAL_TYPE:		//integer native visual type of the associated visual (always EGL_NONE)
+				if(attrib_list[i+1] != EGL_NONE)
+					EGL_RETURN(EGL_SUCCESS, EGL_TRUE);	//not supported
+				break;
+
+			case EGL_MAX_SWAP_INTERVAL:			//integer maximum swap interval (always 1)
+			case EGL_MIN_SWAP_INTERVAL:			//integer minimum swap interval (always 1)
+				if(attrib_list[i+1] != 1)
+					EGL_RETURN(EGL_SUCCESS, EGL_TRUE);	//not supported
+				break;
+
+			case EGL_RENDERABLE_TYPE:			//bitmask which client rendering APIs are supported. (always EGL_OPENVG_BIT)
+				if(!(attrib_list[i+1] & EGL_OPENVG_BIT))
+					EGL_RETURN(EGL_SUCCESS, EGL_TRUE);	//not supported
+				break;
+
+			case EGL_SURFACE_TYPE:				//bitmask which types of EGL surfaces are supported. (always EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT)
+				break;	//all types are always supported
+
+			case EGL_TRANSPARENT_TYPE:			//enum type of transparency supported (always EGL_NONE)
+			case EGL_NATIVE_VISUAL_ID:			//integer handle of corresponding native visual (always 0)
+			case EGL_MAX_PBUFFER_WIDTH:			//integer maximum width of pbuffer (always INT_MAX)
+			case EGL_MAX_PBUFFER_HEIGHT:		//integer maximum height of pbuffer (always INT_MAX)
+			case EGL_MAX_PBUFFER_PIXELS:		//integer maximum size of pbuffer (always INT_MAX)
+			case EGL_TRANSPARENT_RED_VALUE:		//integer transparent red value (undefined)
+			case EGL_TRANSPARENT_GREEN_VALUE:	//integer transparent green value (undefined)
+			case EGL_TRANSPARENT_BLUE_VALUE:	//integer transparent blue value (undefined)
+				break;	//ignored
+
+			default:
+				EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE);	//unknown attribute
+			}
+		}
+	}
+
+	if(configID && configID != EGL_DONT_CARE)
+	{	//if CONFIG_ID is defined, ignore the rest of the attribs
+        for(int i=0;i<EGL_NUMCONFIGS;i++)
+        {
+            if(display->getConfigByIdx(i).m_configID == configID)
+            {
+                *num_config = 1;
+                *configs = display->getConfigByIdx(i).m_config;
+            }
+        }
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	}
+
+	//go through all configs, add passed configs to return list
+    //TODO take alpha mask size into account
+	EGLConfig found[EGL_NUMCONFIGS];
+    int keys[EGL_NUMCONFIGS];
+	int numFound = 0;
+	for(int i=0;i<display->getNumConfigs();i++)
+	{
+		const RIEGLConfig& c = display->getConfigByIdx(i);
+
+		int colorBits = c.m_desc.redBits + c.m_desc.greenBits + c.m_desc.blueBits;
+		int luminanceBits = c.m_desc.luminanceBits;
+		int configBufferSize;
+		if(colorBits)
+		{
+			RI_ASSERT(!luminanceBits);
+			colorBits += c.m_desc.alphaBits;
+			configBufferSize = colorBits;
+		}
+		else if(luminanceBits)
+		{
+			luminanceBits += c.m_desc.alphaBits;
+			configBufferSize = luminanceBits;
+		}
+		else
+		{	//alpha only surface
+			colorBits = c.m_desc.alphaBits;
+			luminanceBits = c.m_desc.alphaBits;
+			configBufferSize = colorBits;
+		}
+
+		if (smaller(configBufferSize, bufferSize))
+			continue;
+
+		int configSampleBuffers = c.m_samples == 1 ? 0 : 1;
+		if (smaller(configSampleBuffers, sampleBuffers))
+			continue;
+		if (smaller(c.m_samples, samples))
+			continue;
+
+		if (smaller(c.m_desc.redBits, redSize)
+			|| smaller(c.m_desc.greenBits, greenSize)
+			|| smaller(c.m_desc.blueBits, blueSize) 
+			|| smaller(c.m_desc.alphaBits, alphaSize) )
+			continue;
+
+		if (smaller(c.m_desc.luminanceBits, luminanceSize))
+			continue;
+
+		if ((colorBufferType == EGL_RGB_BUFFER && !colorBits) ||
+			(colorBufferType == EGL_LUMINANCE_BUFFER && !luminanceBits))
+			continue;
+
+		int sortKey = c.m_configID;	//sort from smaller to larger
+		int sortBits = 0;
+		if(redSize != 0 && redSize != EGL_DONT_CARE)
+			sortBits += c.m_desc.redBits;
+		if(greenSize != 0 && greenSize != EGL_DONT_CARE)
+			sortBits += c.m_desc.greenBits;
+		if(blueSize != 0 && blueSize != EGL_DONT_CARE)
+			sortBits += c.m_desc.blueBits;
+		if(alphaSize != 0 && alphaSize != EGL_DONT_CARE)
+			sortBits += c.m_desc.alphaBits;
+		if(luminanceSize != 0 && luminanceSize != EGL_DONT_CARE)
+			sortBits += c.m_desc.luminanceBits;
+		RI_ASSERT(c.m_configID <= EGL_NUMCONFIGS);	//if there are more configs, increase the shift value
+		RI_ASSERT(sortBits <= 32);
+		sortKey += (32-sortBits) << 4;	//sort from larger to smaller
+
+		found[numFound] = c.m_config;
+		keys[numFound++] = sortKey;
+	}
+	if(!numFound)
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+
+	//sort return list into increasing order
+	for(int e=0;e<numFound-1;e++)
+	{
+		for(int f=e+1;f<numFound;f++)
+		{
+			if(keys[e] > keys[f])
+			{
+                EGLConfig tmp = found[e];
+                found[e] = found[f];
+                found[f] = tmp;
+				RI_INT_SWAP(keys[e], keys[f]);
+			}
+		}
+	}
+
+	//write configs into return array
+	numFound = RI_INT_MIN(numFound, config_size);
+	for(int i=0;i<numFound;i++)
+	{
+		configs[i] = found[i];
+	}
+	*num_config = numFound;
+
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+#else
+EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_FALSE);
+	const RIEGLConfig& c = display->getConfig(config);
+	switch(attribute)
+	{
+	case EGL_BUFFER_SIZE:
+		*value = RI_INT_MAX(c.m_desc.redBits + c.m_desc.greenBits + c.m_desc.blueBits + c.m_desc.alphaBits, c.m_desc.luminanceBits + c.m_desc.alphaBits);
+		break;
+
+	case EGL_RED_SIZE:
+		*value = c.m_desc.redBits;
+		break;
+
+	case EGL_GREEN_SIZE:
+		*value = c.m_desc.greenBits;
+		break;
+
+	case EGL_BLUE_SIZE:
+		*value = c.m_desc.blueBits;
+		break;
+
+	case EGL_LUMINANCE_SIZE:
+		*value = c.m_desc.luminanceBits;
+		break;
+
+	case EGL_ALPHA_SIZE:
+		*value = c.m_desc.alphaBits;
+		break;
+
+	case EGL_ALPHA_MASK_SIZE:
+		*value = c.m_maskBits;
+		break;
+
+	case EGL_BIND_TO_TEXTURE_RGB:
+	case EGL_BIND_TO_TEXTURE_RGBA:
+		*value = EGL_FALSE;
+		break;
+
+	case EGL_COLOR_BUFFER_TYPE:
+		if(c.m_desc.redBits)
+			*value = EGL_RGB_BUFFER;
+		else
+			*value = EGL_LUMINANCE_BUFFER;
+		break;
+
+	case EGL_CONFIG_CAVEAT:
+		*value = EGL_NONE;
+		break;
+
+	case EGL_CONFIG_ID:
+		*value = c.m_configID;
+		break;
+
+	case EGL_DEPTH_SIZE:
+		*value = 0;
+		break;
+
+	case EGL_LEVEL:
+		*value = 0;
+		break;
+
+	case EGL_MAX_PBUFFER_WIDTH:
+	case EGL_MAX_PBUFFER_HEIGHT:
+		*value = 16384;			//NOTE arbitrary maximum
+		break;
+		
+	case EGL_MAX_PBUFFER_PIXELS:
+		*value = 16384*16384;	//NOTE arbitrary maximum
+		break;
+
+	case EGL_MAX_SWAP_INTERVAL:
+	case EGL_MIN_SWAP_INTERVAL:
+		*value = 1;
+		break;
+
+	case EGL_NATIVE_RENDERABLE:
+		*value = EGL_FALSE;
+		break;
+
+	case EGL_NATIVE_VISUAL_ID:
+		*value = 0;
+		break;
+
+	case EGL_NATIVE_VISUAL_TYPE:
+		*value = EGL_NONE;
+		break;
+
+	case EGL_RENDERABLE_TYPE:
+		*value = EGL_OPENVG_BIT;
+		break;
+
+	case EGL_SAMPLE_BUFFERS:
+		*value = c.m_samples > 1 ? 1 : 0;
+		break;
+
+	case EGL_SAMPLES:
+		*value = c.m_samples > 1 ? c.m_samples : 0;
+		break;
+
+	case EGL_STENCIL_SIZE:
+		*value = 0;
+		break;
+
+	case EGL_SURFACE_TYPE:
+		*value = EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT;
+		break;
+
+	case EGL_TRANSPARENT_TYPE:
+		*value = EGL_NONE;
+		break;
+
+	case EGL_TRANSPARENT_RED_VALUE:
+	case EGL_TRANSPARENT_GREEN_VALUE:
+	case EGL_TRANSPARENT_BLUE_VALUE:
+		*value = 0;
+		break;
+
+    case EGL_CONFORMANT:
+        *value = EGL_OPENVG_BIT;  //TODO return proper value
+        break;
+
+	default:
+		EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+	}
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLSurface do_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+#else
+EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
+
+	int renderBuffer = EGL_BACK_BUFFER;
+	int colorSpace = EGL_VG_COLORSPACE_sRGB;
+	int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
+	if(attrib_list)
+	{
+		for(int i=0;attrib_list[i] != EGL_NONE;i+=2)
+		{
+			switch(attrib_list[i])
+			{
+			case EGL_RENDER_BUFFER:
+				renderBuffer = attrib_list[i+1];
+				break;
+
+			case EGL_VG_COLORSPACE:
+				colorSpace = attrib_list[i+1];
+				break;
+
+			case EGL_VG_ALPHA_FORMAT:
+				alphaFormat = attrib_list[i+1];
+				break;
+
+			default:
+				EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
+			}
+		}
+	}
+	//we ignore the renderBuffer parameter since we can only render to double buffered surfaces
+
+	//TODO If the attributes of win do not correspond to config, then an EGL BAD MATCH error is generated.
+	//TODO If there is already an EGLConfig associated with win (as a result of a previous eglCreateWindowSurface call), then an EGL BAD ALLOC error is generated
+
+    void* wc = NULL;
+    Drawable* d = NULL;
+	RIEGLSurface* s = NULL;
+	try
+	{
+        wc = OSCreateWindowContext(win);
+		RI_ASSERT(wc);
+		//TODO what should happen if window width or height is zero?
+		int windowWidth = 0, windowHeight = 0;
+		OSGetWindowSize(wc, windowWidth, windowHeight);
+        bool isWindow = OSIsWindow(wc);
+		if(windowWidth <= 0 || windowHeight <= 0 || !isWindow)
+		{
+            OSDestroyWindowContext(wc);
+            EGL_IF_ERROR(!isWindow, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+			EGL_IF_ERROR(windowWidth <= 0 || windowHeight <= 0, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
+		}
+		d = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), windowWidth, windowHeight, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits));	//throws bad_alloc
+		RI_ASSERT(d);
+		s = RI_NEW(RIEGLSurface,(wc, config, d, false, renderBuffer));	//throws bad_alloc
+		RI_ASSERT(s);
+		s->addReference();
+		display->addSurface(s);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+        OSDestroyWindowContext(wc);
+        RI_DELETE(d);
+        RI_DELETE(s);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+	}
+	EGL_RETURN(EGL_SUCCESS, (EGLSurface)s);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLSurface do_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+#else
+EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
+
+	int width = 0, height = 0;
+	bool largestPbuffer = false;
+	int colorSpace = EGL_VG_COLORSPACE_sRGB;
+	int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
+	if(attrib_list)
+	{
+		for(int i=0;attrib_list[i] != EGL_NONE;i+=2)
+		{
+			switch(attrib_list[i])
+			{
+			case EGL_WIDTH:
+				width = attrib_list[i+1];
+				break;
+
+			case EGL_HEIGHT:
+				height = attrib_list[i+1];
+				break;
+
+			case EGL_LARGEST_PBUFFER:
+				largestPbuffer = attrib_list[i+1] ? true : false;
+				break;
+
+			case EGL_VG_COLORSPACE:
+				colorSpace = attrib_list[i+1];
+				break;
+
+			case EGL_VG_ALPHA_FORMAT:
+				alphaFormat = attrib_list[i+1];
+				break;
+
+			case EGL_TEXTURE_FORMAT:	//config doesn't support OpenGL ES
+			case EGL_TEXTURE_TARGET:	//config doesn't support OpenGL ES
+			case EGL_MIPMAP_TEXTURE:	//config doesn't support OpenGL ES
+			default:
+				EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
+			}
+		}
+	}
+	EGL_IF_ERROR(width <= 0 || height <= 0, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
+
+    Drawable* d = NULL;
+	RIEGLSurface* s = NULL;
+	try
+	{
+		d = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), width, height, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits));	//throws bad_alloc
+		RI_ASSERT(d);
+		s = RI_NEW(RIEGLSurface,(NULL, config, d, largestPbuffer, EGL_BACK_BUFFER));	//throws bad_alloc
+		RI_ASSERT(s);
+		s->addReference();
+		display->addSurface(s);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+        RI_DELETE(d);
+        RI_DELETE(s);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+	}
+	EGL_RETURN(EGL_SUCCESS, (EGLSurface)s);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLSurface do_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+#else
+EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
+	EGL_IF_ERROR(buftype != EGL_OPENVG_IMAGE, EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!buffer, EGL_BAD_PARAMETER, EGL_NO_SURFACE);	//TODO should also check if buffer really is a valid VGImage object (needs VG context for that)
+    Image* image = (Image*)buffer;
+	EGL_IF_ERROR(image->isInUse(), EGL_BAD_ACCESS, EGL_NO_SURFACE);	//buffer is in use by OpenVG
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
+	EGL_IF_ERROR(attrib_list && attrib_list[0] != EGL_NONE, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);	//there are no valid attribs for OpenVG
+	const Color::Descriptor& bc = ((Image*)buffer)->getDescriptor();
+	const Color::Descriptor& cc = display->getConfig(config).m_desc;
+	EGL_IF_ERROR(bc.redBits != cc.redBits || bc.greenBits != cc.greenBits || bc.blueBits != cc.blueBits ||
+				 bc.alphaBits != cc.alphaBits || bc.luminanceBits != cc.luminanceBits, EGL_BAD_MATCH, EGL_NO_SURFACE);
+
+	//TODO If buffer is already bound to another pbuffer, an EGL BAD ACCESS error is generated.
+
+    Drawable* d = NULL;
+	RIEGLSurface* s = NULL;
+	try
+	{
+		d = RI_NEW(Drawable, (image, display->getConfig(config).m_maskBits));
+		RI_ASSERT(d);
+		s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER));	//throws bad_alloc
+		RI_ASSERT(s);
+		s->addReference();
+		display->addSurface(s);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+        RI_DELETE(d);
+        RI_DELETE(s);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+	}
+	EGL_RETURN(EGL_SUCCESS, (EGLSurface)s);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLSurface do_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+#else
+EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
+#endif
+{
+    EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
+	//EGL_IF_ERROR(!pixmap || !isValidImageFormat(pixmap->format) || !pixmap->data || pixmap->width <= 0 || pixmap->height <= 0, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE);
+
+	RI_UNREF(attrib_list);
+	EGL_IF_ERROR(display->getConfig(config).m_samples != 1, EGL_BAD_MATCH, EGL_NO_SURFACE);
+
+	//TODO If there is already an EGLSurface associated with pixmap (as a result of a previous eglCreatePixmapSurface call), then a EGL BAD ALLOC error is generated.
+	
+	
+	EGLint  width  = -1;
+	EGLint  height = -1;
+	EGLint  stride = -1;
+	VGImageFormat format;
+	int* data = NULL;
+	EGLBoolean err = OSGetNativePixmapInfo(pixmap, &width, &height, &stride,&format, &data);
+	
+    Drawable* d = NULL;
+	RIEGLSurface* s = NULL;
+	try
+	{
+		d = RI_NEW(Drawable, (Color::formatToDescriptor(format), width, height, stride, (RIuint8*)data, display->getConfig(config).m_maskBits));	//throws bad_alloc
+		RI_ASSERT(d);
+		s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER));	//throws bad_alloc
+		RI_ASSERT(s);
+		s->addReference();
+		display->addSurface(s);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+        RI_DELETE(d);
+        RI_DELETE(s);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+	}
+	EGL_RETURN(EGL_SUCCESS, (EGLSurface)s);
+	
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+#else
+EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
+
+    display->removeSurface((RIEGLSurface*)surface);
+	if(!((RIEGLSurface*)surface)->removeReference())
+		RI_DELETE((RIEGLSurface*)surface);
+
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+#else
+EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
+	RI_UNREF(attribute);
+	RI_UNREF(value);
+	//do nothing
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+#else
+EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
+	//TODO give an error if value is NULL?
+
+	RIEGLSurface* s = (RIEGLSurface*)surface;
+	switch(attribute)
+	{
+	case EGL_VG_ALPHA_FORMAT:
+		*value = (s->getDrawable()->getDescriptor().isPremultiplied()) ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE;
+		break;
+
+	case EGL_VG_COLORSPACE:
+		*value = (s->getDrawable()->getDescriptor().isNonlinear()) ? EGL_VG_COLORSPACE_sRGB : EGL_VG_COLORSPACE_LINEAR;
+		break;
+
+	case EGL_CONFIG_ID:
+		*value = display->getConfig(s->getConfig()).m_configID;
+		break;
+
+	case EGL_HEIGHT:
+		*value = s->getDrawable()->getHeight();
+		break;
+
+	case EGL_HORIZONTAL_RESOLUTION:
+		*value = EGL_UNKNOWN;			//TODO Horizontal dot pitch
+		break;
+
+	case EGL_LARGEST_PBUFFER:
+		if(!s->getOSWindowContext())
+			*value = s->isLargestPbuffer() ? EGL_TRUE : EGL_FALSE;
+		break;
+
+	case EGL_MIPMAP_TEXTURE:
+		if(!s->getOSWindowContext())
+			*value = EGL_FALSE;
+		break;
+
+	case EGL_MIPMAP_LEVEL:
+		if(!s->getOSWindowContext())
+			*value = 0;
+		break;
+
+	case EGL_PIXEL_ASPECT_RATIO:
+		*value = EGL_UNKNOWN;			//TODO Display aspect ratio
+		break;
+
+	case EGL_RENDER_BUFFER:
+		*value = s->getRenderBuffer();
+		break;
+
+	case EGL_SWAP_BEHAVIOR:
+		*value = EGL_BUFFER_PRESERVED;
+		break;
+
+	case EGL_TEXTURE_FORMAT:
+		if(!s->getOSWindowContext())
+			*value = EGL_NO_TEXTURE;
+		break;
+
+	case EGL_TEXTURE_TARGET:
+		if(!s->getOSWindowContext())
+			*value = EGL_NO_TEXTURE;
+		break;
+
+	case EGL_VERTICAL_RESOLUTION:
+		*value = EGL_UNKNOWN;			//TODO Vertical dot pitch
+		break;
+
+	case EGL_WIDTH:
+		*value = s->getDrawable()->getWidth();
+		break;
+
+	default:
+		EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+	}
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLContext do_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+#else
+EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_NO_CONTEXT);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_CONTEXT);
+	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_CONTEXT);
+	RI_UNREF(attrib_list);
+
+	RIEGLThread* thread = egl->getThread();
+	if(!thread)
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+
+	//creation of OpenGL ES contexts is not allowed in this implementation
+	if(thread->getBoundAPI() != EGL_OPENVG_API)
+		EGL_RETURN(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+
+    OpenVGRI::VGContext* vgctx = NULL;
+	RIEGLContext* c = NULL;
+	try
+	{
+		vgctx = RI_NEW(OpenVGRI::VGContext, (share_context ? ((RIEGLContext*)share_context)->getVGContext() : NULL));	//throws bad_alloc
+		c = RI_NEW(RIEGLContext, (vgctx, config));	//throws bad_alloc
+		c->addReference();
+		display->addContext(c);	//throws bad_alloc
+	}
+	catch(std::bad_alloc)
+	{
+        RI_DELETE(vgctx);
+        RI_DELETE(c);
+		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+	}
+
+	EGL_RETURN(EGL_SUCCESS, (EGLContext)c);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+#else
+EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE);
+
+	RIEGLContext* context = (RIEGLContext*)ctx;
+    display->removeContext(context);
+	if(!context->removeReference() )
+		RI_DELETE(context);
+
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+#else
+EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(ctx != EGL_NO_CONTEXT && !display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE);
+	EGL_IF_ERROR(draw != EGL_NO_SURFACE && !display->surfaceExists(draw), EGL_BAD_SURFACE, EGL_FALSE);
+	EGL_IF_ERROR(read != EGL_NO_SURFACE && !display->surfaceExists(read), EGL_BAD_SURFACE, EGL_FALSE);
+	EGL_IF_ERROR(draw != read, EGL_BAD_MATCH, EGL_FALSE);	//TODO what's the proper error code?
+	EGL_IF_ERROR((draw != EGL_NO_SURFACE && ctx == EGL_NO_CONTEXT) || (draw == EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT), EGL_BAD_MATCH, EGL_FALSE);
+
+	RIEGLSurface* s = NULL;
+	RIEGLContext* c = NULL;
+	if(draw != EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT)
+	{
+		EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+
+		s = (RIEGLSurface*)draw;
+		c = (RIEGLContext*)ctx;
+
+        //If either draw or read are pbuffers created with eglCreatePbufferFromClientBuffer, and the underlying bound client API buffers
+        //are in use by the client API that created them, an EGL BAD ACCESS error is generated.
+		EGL_IF_ERROR(s->getDrawable()->isInUse(), EGL_BAD_ACCESS, EGL_FALSE);
+
+
+		//TODO properly check compatibility of surface and context:
+		//-both have RGB or LUMINANCE configs
+		//-buffer bit depths match
+		//-configs support OpenVG
+		//-both have the same display
+		EGL_IF_ERROR(s->getConfig() != c->getConfig(), EGL_BAD_MATCH, EGL_FALSE);
+		//TODO check if context or surfaces are already bound to another thread
+
+		//If a native window underlying either draw or read is no longer valid, an EGL BAD NATIVE WINDOW error is generated.
+        EGL_IF_ERROR(s->getOSWindowContext() && !OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
+
+		//TODO If the previous context of the calling display has unflushed commands, and the previous surface is no longer valid, an EGL BAD CURRENT SURFACE error is generated. (can this happen?)
+		//TODO If the ancillary buffers for draw and read cannot be allocated, an EGL BAD ALLOC error is generated. (mask buffer?)
+	}
+
+	//check if the thread is current
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(thread)
+	{	//thread is current, release the old bindinds and remove the thread from the current thread list
+		RIEGLContext* pc = thread->getCurrentContext();
+		RIEGLSurface* ps = thread->getCurrentSurface();
+		if(pc)
+		{
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+			/*do_vg*/vgFlush();
+#else
+			vgFlush();
+#endif
+			pc->getVGContext()->setDefaultDrawable(NULL);
+			if(!pc->removeReference())
+				RI_DELETE(pc);
+		}
+		if(ps)
+		{
+			if(!ps->removeReference())
+				RI_DELETE(ps);
+		}
+
+        egl->removeCurrentThread(thread);
+	}
+
+	if( c && s )
+	{
+		//bind context and surface to the current display
+		RIEGLThread* newThread = egl->getThread();
+		if(!newThread)
+			EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE);
+        newThread->makeCurrent(c, s);
+		c->getVGContext()->setDefaultDrawable(s->getDrawable());
+
+		try
+		{
+			egl->addCurrentThread(newThread);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+			EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE);
+		}
+
+		c->addReference();
+		s->addReference();
+	}
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLContext do_eglGetCurrentContext()
+#else
+EGLContext eglGetCurrentContext()
+#endif
+{
+    EGL_GET_EGL(EGL_NO_CONTEXT);
+	EGLContext ret = EGL_NO_CONTEXT;
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(thread && thread->getBoundAPI() == EGL_OPENVG_API)
+    {
+        ret = CastFromRIEGLContext(thread->getCurrentContext());
+        RI_ASSERT(ret);
+    }
+	EGL_RETURN(EGL_SUCCESS, ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLSurface do_eglGetCurrentSurface(EGLint readdraw)
+#else
+EGLSurface eglGetCurrentSurface(EGLint readdraw)
+#endif
+{
+    EGL_GET_EGL(EGL_NO_SURFACE);
+	EGL_IF_ERROR(readdraw != EGL_READ && readdraw != EGL_DRAW, EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+	EGLContext ret = EGL_NO_SURFACE;
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(thread && thread->getBoundAPI() == EGL_OPENVG_API)
+    {
+        ret = CastFromRIEGLSurface(thread->getCurrentSurface());
+        RI_ASSERT(ret);
+    }
+	EGL_RETURN(EGL_SUCCESS, ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns the current display
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLDisplay do_eglGetCurrentDisplay(void)
+#else
+EGLDisplay eglGetCurrentDisplay(void)
+#endif
+{
+    EGL_GET_EGL(EGL_NO_DISPLAY);
+
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(!thread || thread->getBoundAPI() != EGL_OPENVG_API)
+		EGL_RETURN(EGL_SUCCESS, EGL_NO_DISPLAY);
+
+	RIEGLContext* ctx = thread->getCurrentContext();
+    RI_ASSERT(ctx);
+    EGLDisplay ret = egl->findDisplay(CastFromRIEGLContext(ctx));
+	EGL_RETURN(EGL_SUCCESS, ret);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value)
+#else
+EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE);
+	EGL_IF_ERROR(attribute != EGL_CONFIG_ID && attribute != EGL_CONTEXT_CLIENT_TYPE, EGL_BAD_ATTRIBUTE, EGL_FALSE);
+	if(attribute == EGL_CONFIG_ID)
+		*value = display->getConfig(((RIEGLContext*)ctx)->getConfig()).m_configID;
+	if(attribute == EGL_CONTEXT_CLIENT_TYPE)
+		*value = EGL_OPENVG_API;
+	// \todo [kalle 05/Jul/05] Handling of EGL_RENDER_BUFFER attribute is missing.
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglBindAPI(EGLenum api)
+#else
+EGLBoolean eglBindAPI(EGLenum api)
+#endif
+{
+    EGL_GET_EGL(EGL_FALSE);
+	EGL_IF_ERROR(api != EGL_OPENVG_API && api != EGL_OPENGL_ES_API, EGL_BAD_PARAMETER, EGL_FALSE);
+	RIEGLThread* thread = egl->getThread();
+	if(thread)
+		thread->bindAPI(api);
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLenum do_eglQueryAPI(void)
+#else
+EGLenum eglQueryAPI(void)
+#endif
+{
+    EGL_GET_EGL(EGL_NONE);
+	RIEGLThread* thread = egl->getThread();
+	if(thread)
+		EGL_RETURN(EGL_SUCCESS, thread->getBoundAPI());
+	EGL_RETURN(EGL_SUCCESS, EGL_NONE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglWaitClient()
+#else
+EGLBoolean eglWaitClient()
+#endif
+{
+    EGL_GET_EGL(EGL_FALSE);
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(thread && thread->getBoundAPI() == EGL_OPENVG_API)
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+		/*do_vg*/vgFinish();
+#else
+		vgFinish();
+#endif
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Waits for OpenGL ES
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglWaitGL(void)
+#else
+EGLBoolean eglWaitGL(void)
+#endif
+{
+	return EGL_TRUE;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		We don't support native rendering
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglWaitNative(EGLint engine)
+#else
+EGLBoolean eglWaitNative(EGLint engine)
+#endif
+{
+	RI_UNREF(engine);
+	return EGL_TRUE;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+#else
+EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
+
+	RIEGLSurface* s = (RIEGLSurface*)surface;
+
+	RIEGLThread* currentThread = egl->getCurrentThread();
+	EGL_IF_ERROR(!currentThread || currentThread->getCurrentSurface() != s, EGL_BAD_SURFACE, EGL_FALSE);
+	EGL_IF_ERROR(!OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+	/*do_vg*/vgFlush();
+#else
+	vgFlush();
+#endif
+
+	if(!s->getOSWindowContext())
+	{	//do nothing for other than window surfaces (NOTE: single-buffered window surfaces should return immediately as well)
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	}
+
+	int windowWidth = 0, windowHeight = 0;
+    OSGetWindowSize(s->getOSWindowContext(), windowWidth, windowHeight);
+
+	if(windowWidth != s->getDrawable()->getWidth() || windowHeight != s->getDrawable()->getHeight())
+	{	//resize the back buffer
+		RIEGLContext* c = currentThread->getCurrentContext();
+		RI_ASSERT(c);
+		try
+		{
+			s->getDrawable()->resize(windowWidth, windowHeight);	//throws bad_alloc
+		}
+		catch(std::bad_alloc)
+		{
+			c->getVGContext()->setDefaultDrawable(NULL);
+			EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE);
+		}
+	}
+
+    OSBlitToWindow(s->getOSWindowContext(), s->getDrawable());
+
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+#else
+EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
+	//EGL_IF_ERROR(!target || !isValidImageFormat(target->format) || !target->data || target->width <= 0 || target->height <= 0, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE);
+	EGLint  width  = -1;
+	EGLint  height = -1;
+	EGLint  stride = -1;
+	VGImageFormat format;
+	int* data = NULL;
+	EGLBoolean err = OSGetNativePixmapInfo(target, &width, &height, &stride,&format, &data);
+	
+	TUint* fdata = (TUint*)((TUint)data + ( stride * ( height - 1  ) ) );	
+	try
+	{
+		Image output(Color::formatToDescriptor(format), width, height, -stride, (RIuint8*)fdata);
+        output.addReference();
+		output.blit(((RIEGLSurface*)surface)->getDrawable()->getColorBuffer(), 0, 0, 0, 0, width, height);	//throws bad_alloc
+        output.removeReference();
+	}
+	catch(std::bad_alloc)
+	{
+	}
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		We support only swap interval one
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglSwapInterval(EGLDisplay dpy, EGLint interval)
+#else
+EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
+#endif
+{
+	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
+	RI_UNREF(interval);
+	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+typedef void RI_Proc();
+
+//EGLAPI void (* EGLAPIENTRY      eglGetProcAddress(const char *procname))(void);
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY void (*do_eglGetProcAddress(const char *procname))(...)
+#else
+void (*eglGetProcAddress(const char *procname))(...)
+#endif
+{
+	if(!procname)
+		return NULL;
+	return NULL;
+}
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglReleaseThread(void)
+#else
+EGLBoolean eglReleaseThread(void)
+#endif
+{
+    EGL_GET_EGL(EGL_FALSE);
+
+	//check if the thread is current
+	RIEGLThread* thread = egl->getCurrentThread();
+	if(thread)
+	{	//thread is current, release the old bindings and remove the thread from the current thread list
+		RIEGLContext* pc = thread->getCurrentContext();
+		RIEGLSurface* ps = thread->getCurrentSurface();
+		if(pc)
+		{
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+			/*do_vg*/vgFlush();
+#else
+			vgFlush();
+#endif
+			pc->getVGContext()->setDefaultDrawable(NULL);
+			if(!pc->removeReference())
+				RI_DELETE(pc);
+		}
+		if(ps)
+		{
+			if(!ps->removeReference())
+				RI_DELETE(ps);
+		}
+
+        egl->removeCurrentThread(thread);
+	}
+
+    //destroy EGL's thread struct
+    egl->destroyThread();
+
+	//destroy the EGL instance
+	releaseEGL();
+
+	OSReleaseMutex();
+    OSDeinitMutex();
+
+	return EGL_SUCCESS;
+}
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+#else
+EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+#endif
+	{
+	//not implemented
+	RI_ASSERT(0);
+	return false;
+	}
+
+#ifdef BUILD_WITH_PRIVATE_EGL
+RI_APIENTRY EGLBoolean do_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+#else 
+EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
+#endif
+	{
+	//not implemented
+	RI_ASSERT(0);
+	return false;
+	}
+#undef EGL_NUMCONFIGS
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riPath.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,2579 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of Path functions.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riPath.h"
+
+//==============================================================================================
+
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+RIfloat inputFloat(VGfloat f);	//defined in riApi.cpp
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Form a reliable normalized average of the two unit input vectors.
+*           The average always lies to the given direction from the first
+*			vector.
+* \param	u0, u1 Unit input vectors.
+* \param	cw True if the average should be clockwise from u0, false if
+*              counterclockwise.
+* \return	Average of the two input vectors.
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1, bool cw)
+{
+	Vector2 u = 0.5f * (u0 + u1);
+	Vector2 n0 = perpendicularCCW(u0);
+
+	if( dot(u, u) > 0.25f )
+	{	//the average is long enough and thus reliable
+		if( dot(n0, u1) < 0.0f )
+			u = -u;	//choose the larger angle
+	}
+	else
+	{	// the average is too short, use the average of the normals to the vectors instead
+		Vector2 n1 = perpendicularCW(u1);
+		u = 0.5f * (n0 + n1);
+	}
+	if( cw )
+		u = -u;
+
+	return normalize(u);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Form a reliable normalized average of the two unit input vectors.
+*			The average lies on the side where the angle between the input
+*			vectors is less than 180 degrees.
+* \param	u0, u1 Unit input vectors.
+* \return	Average of the two input vectors.
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 unitAverage(const Vector2& u0, const Vector2& u1)
+{
+	Vector2 u = 0.5f * (u0 + u1);
+
+	if( dot(u, u) < 0.25f )
+	{	// the average is unreliable, use the average of the normals to the vectors instead
+		Vector2 n0 = perpendicularCCW(u0);
+		Vector2 n1 = perpendicularCW(u1);
+		u = 0.5f * (n0 + n1);
+		if( dot(n1, u0) < 0.0f )
+			u = -u;
+	}
+
+	return normalize(u);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Interpolate the given unit tangent vectors to the given
+*			direction on a unit circle.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 circularLerp(const Vector2& t0, const Vector2& t1, RIfloat ratio, bool cw)
+{
+	Vector2 u0 = t0, u1 = t1;
+	RIfloat l0 = 0.0f, l1 = 1.0f;
+	for(int i=0;i<18;i++)
+	{
+		Vector2 n = unitAverage(u0, u1, cw);
+		RIfloat l = 0.5f * (l0 + l1);
+		if( ratio < l )
+		{
+			u1 = n;
+			l1 = l;
+		}
+		else
+		{
+			u0 = n;
+			l0 = l;
+		}
+	}
+	return u0;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Interpolate the given unit tangent vectors on a unit circle.
+*			Smaller angle between the vectors is used.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static const Vector2 circularLerp(const Vector2& t0, const Vector2& t1, RIfloat ratio)
+{
+	Vector2 u0 = t0, u1 = t1;
+	RIfloat l0 = 0.0f, l1 = 1.0f;
+	for(int i=0;i<18;i++)
+	{
+		Vector2 n = unitAverage(u0, u1);
+		RIfloat l = 0.5f * (l0 + l1);
+		if( ratio < l )
+		{
+			u1 = n;
+			l1 = l;
+		}
+		else
+		{
+			u0 = n;
+			l0 = l;
+		}
+	}
+	return u0;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Path constructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Path::Path(VGint format, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int segmentCapacityHint, int coordCapacityHint, VGbitfield caps) :
+	m_format(format),
+	m_datatype(datatype),
+	m_scale(scale),
+	m_bias(bias),
+	m_capabilities(caps),
+	m_referenceCount(0),
+	m_segments(),
+	m_data(),
+	m_vertices(),
+	m_segmentToVertex(),
+	m_userMinx(0.0f),
+	m_userMiny(0.0f),
+	m_userMaxx(0.0f),
+	m_userMaxy(0.0f)
+{
+	RI_ASSERT(format == VG_PATH_FORMAT_STANDARD);
+	RI_ASSERT(datatype >= VG_PATH_DATATYPE_S_8 && datatype <= VG_PATH_DATATYPE_F);
+	if(segmentCapacityHint > 0)
+		m_segments.reserve(RI_INT_MIN(segmentCapacityHint, 65536));
+	if(coordCapacityHint > 0)
+		m_data.reserve(RI_INT_MIN(coordCapacityHint, 65536) * getBytesPerCoordinate(datatype));
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Path destructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Path::~Path()
+{
+	RI_ASSERT(m_referenceCount == 0);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Reads a coordinate and applies scale and bias.
+* \param	
+* \return	
+*//*-------------------------------------------------------------------*/
+
+RIfloat Path::getCoordinate(int i) const
+{
+	RI_ASSERT(i >= 0 && i < m_data.size() / getBytesPerCoordinate(m_datatype));
+	RI_ASSERT(m_scale != 0.0f);
+
+	const RIuint8* ptr = &m_data[0];
+	switch(m_datatype)
+	{
+	case VG_PATH_DATATYPE_S_8:
+		return (RIfloat)(((const RIint8*)ptr)[i]) * m_scale + m_bias;
+
+	case VG_PATH_DATATYPE_S_16:
+		return (RIfloat)(((const RIint16*)ptr)[i]) * m_scale + m_bias;
+
+	case VG_PATH_DATATYPE_S_32:
+		return (RIfloat)(((const RIint32*)ptr)[i]) * m_scale + m_bias;
+
+	default:
+		RI_ASSERT(m_datatype == VG_PATH_DATATYPE_F);
+		return (RIfloat)(((const RIfloat32*)ptr)[i]) * m_scale + m_bias;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Writes a coordinate, subtracting bias and dividing out scale.
+* \param	
+* \return	
+* \note		If the coordinates do not fit into path datatype range, they
+*			will overflow silently.
+*//*-------------------------------------------------------------------*/
+
+void Path::setCoordinate(Array<RIuint8>& data, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int i, RIfloat c)
+{
+	RI_ASSERT(i >= 0 && i < data.size()/getBytesPerCoordinate(datatype));
+	RI_ASSERT(scale != 0.0f);
+
+	c -= bias;
+	c /= scale;
+
+	RIuint8* ptr = &data[0];
+	switch(datatype)
+	{
+	case VG_PATH_DATATYPE_S_8:
+		((RIint8*)ptr)[i] = (RIint8)floor(c + 0.5f);	//add 0.5 for correct rounding
+		break;
+
+	case VG_PATH_DATATYPE_S_16:
+		((RIint16*)ptr)[i] = (RIint16)floor(c + 0.5f);	//add 0.5 for correct rounding
+		break;
+
+	case VG_PATH_DATATYPE_S_32:
+		((RIint32*)ptr)[i] = (RIint32)floor(c + 0.5f);	//add 0.5 for correct rounding
+		break;
+
+	default:
+		RI_ASSERT(datatype == VG_PATH_DATATYPE_F);
+		((RIfloat32*)ptr)[i] = (RIfloat32)c;
+		break;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Given a datatype, returns the number of bytes per coordinate.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+int Path::getBytesPerCoordinate(VGPathDatatype datatype)
+{
+	if(datatype == VG_PATH_DATATYPE_S_8)
+		return 1;
+	if(datatype == VG_PATH_DATATYPE_S_16)
+		return 2;
+	RI_ASSERT(datatype == VG_PATH_DATATYPE_S_32 || datatype == VG_PATH_DATATYPE_F);
+	return 4;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Given a path segment type, returns the number of coordinates
+*			it uses.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+int Path::segmentToNumCoordinates(VGPathSegment segment)
+{
+	RI_ASSERT(((int)segment >> 1) >= 0 && ((int)segment >> 1) <= 12);
+	static const int coords[13] = {0,2,2,1,1,4,6,2,4,5,5,5,5};
+	return coords[(int)segment >> 1];
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Computes the number of coordinates a segment sequence uses.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+int Path::countNumCoordinates(const RIuint8* segments, int numSegments)
+{
+	RI_ASSERT(segments);
+	RI_ASSERT(numSegments >= 0);
+
+	int coordinates = 0;
+	for(int i=0;i<numSegments;i++)
+		coordinates += segmentToNumCoordinates(getPathSegment(segments[i]));
+	return coordinates;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Clears path segments and data, and resets capabilities.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::clear(VGbitfield capabilities)
+{
+	m_segments.clear();
+	m_data.clear();
+	m_capabilities = capabilities;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Appends user segments and data.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::appendData(const RIuint8* segments, int numSegments, const RIuint8* data)
+{
+	RI_ASSERT(numSegments > 0);
+	RI_ASSERT(segments && data);
+	RI_ASSERT(m_referenceCount > 0);
+
+	//allocate new arrays
+	int oldSegmentsSize = m_segments.size();
+	int newSegmentsSize = oldSegmentsSize + numSegments;
+	Array<RIuint8> newSegments;
+	newSegments.resize(newSegmentsSize);	//throws bad_alloc
+
+	int newCoords = countNumCoordinates(segments, numSegments);
+	int bytesPerCoordinate = getBytesPerCoordinate(m_datatype);
+	int newDataSize = m_data.size() + newCoords * bytesPerCoordinate;
+	Array<RIuint8> newData;
+	newData.resize(newDataSize);	//throws bad_alloc
+	//if we get here, the memory allocations have succeeded
+
+	//copy old segments and append new ones
+	if(m_segments.size())
+		memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+	memcpy(&newSegments[0] + m_segments.size(), segments, numSegments);
+
+	//copy old data and append new ones
+	if(newData.size())
+	{
+		if(m_data.size())
+			memcpy(&newData[0], &m_data[0], m_data.size());
+		if(m_datatype == VG_PATH_DATATYPE_F)
+		{
+			RIfloat32* d = (RIfloat32*)(&newData[0] + m_data.size());
+			const RIfloat32* s = (const RIfloat32*)data;
+			for(int i=0;i<newCoords;i++)
+				*d++ = (RIfloat32)inputFloat(*s++);
+		}
+		else
+		{
+			memcpy(&newData[0] + m_data.size(), data, newCoords * bytesPerCoordinate);
+		}
+	}
+
+	RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+	//replace old arrays
+	m_segments.swap(newSegments);
+	m_data.swap(newData);
+
+	int c = 0;
+	for(int i=0;i<m_segments.size();i++)
+	{
+		VGPathSegment segment = getPathSegment(m_segments[i]);
+		int coords = segmentToNumCoordinates(segment);
+		c += coords;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Appends a path.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::append(const Path* srcPath)
+{
+	RI_ASSERT(srcPath);
+	RI_ASSERT(m_referenceCount > 0 && srcPath->m_referenceCount > 0);
+
+	if(srcPath->m_segments.size())
+	{
+		//allocate new arrays
+		int newSegmentsSize = m_segments.size() + srcPath->m_segments.size();
+		Array<RIuint8> newSegments;
+		newSegments.resize(newSegmentsSize);	//throws bad_alloc
+
+		int newDataSize = m_data.size() + srcPath->getNumCoordinates() * getBytesPerCoordinate(m_datatype);
+		Array<RIuint8> newData;
+		newData.resize(newDataSize);	//throws bad_alloc
+		//if we get here, the memory allocations have succeeded
+
+		//copy old segments and append new ones
+		if(m_segments.size())
+			memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+		if(srcPath->m_segments.size())
+			memcpy(&newSegments[0] + m_segments.size(), &srcPath->m_segments[0], srcPath->m_segments.size());
+
+		//copy old data and append new ones
+		if(m_data.size())
+			memcpy(&newData[0], &m_data[0], m_data.size());
+		for(int i=0;i<srcPath->getNumCoordinates();i++)
+			setCoordinate(newData, m_datatype, m_scale, m_bias, i + getNumCoordinates(), srcPath->getCoordinate(i));
+
+		RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+		//replace old arrays
+		m_segments.swap(newSegments);
+		m_data.swap(newData);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Modifies existing coordinate data.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::modifyCoords(int startIndex, int numSegments, const RIuint8* data)
+{
+	RI_ASSERT(numSegments > 0);
+	RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size());
+	RI_ASSERT(data);
+	RI_ASSERT(m_referenceCount > 0);
+
+	int startCoord = countNumCoordinates(&m_segments[0], startIndex);
+	int numCoords = countNumCoordinates(&m_segments[startIndex], numSegments);
+	if(!numCoords)
+		return;
+	int bytesPerCoordinate = getBytesPerCoordinate(m_datatype);
+	RIuint8* dst = &m_data[startCoord * bytesPerCoordinate];
+	if(m_datatype == VG_PATH_DATATYPE_F)
+	{
+		RIfloat32* d = (RIfloat32*)dst;
+		const RIfloat32* s = (const RIfloat32*)data;
+		for(int i=0;i<numCoords;i++)
+			*d++ = (RIfloat32)inputFloat(*s++);
+	}
+	else
+	{
+		memcpy(dst, data, numCoords*bytesPerCoordinate);
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Appends a transformed copy of the source path.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::transform(const Path* srcPath, const Matrix3x3& matrix)
+{
+	RI_ASSERT(srcPath);
+	RI_ASSERT(m_referenceCount > 0 && srcPath->m_referenceCount > 0);
+	RI_ASSERT(matrix.isAffine());
+
+	if(!srcPath->m_segments.size())
+		return;
+
+	//count the number of resulting coordinates
+	int numSrcCoords = 0;
+	int numDstCoords = 0;
+	for(int i=0;i<srcPath->m_segments.size();i++)
+	{
+		VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+		int coords = segmentToNumCoordinates(segment);
+		numSrcCoords += coords;
+		if(segment == VG_HLINE_TO || segment == VG_VLINE_TO)
+			coords = 2;	//convert hline and vline to lines
+		numDstCoords += coords;
+	}
+
+	//allocate new arrays
+	Array<RIuint8> newSegments;
+	newSegments.resize(m_segments.size() + srcPath->m_segments.size());	//throws bad_alloc
+	Array<RIuint8> newData;
+	newData.resize(m_data.size() + numDstCoords * getBytesPerCoordinate(m_datatype));	//throws bad_alloc
+	//if we get here, the memory allocations have succeeded
+
+	//copy old segments
+	if(m_segments.size())
+		memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+
+	//copy old data
+	if(m_data.size())
+		memcpy(&newData[0], &m_data[0], m_data.size());
+
+	int srcCoord = 0;
+	int dstCoord = getNumCoordinates();
+	Vector2 s(0,0);		//the beginning of the current subpath
+	Vector2 o(0,0);		//the last point of the previous segment
+	for(int i=0;i<srcPath->m_segments.size();i++)
+	{
+		VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+		VGPathAbsRel absRel = getPathAbsRel(srcPath->m_segments[i]);
+		int coords = segmentToNumCoordinates(segment);
+
+		switch(segment)
+		{
+		case VG_CLOSE_PATH:
+		{
+			RI_ASSERT(coords == 0);
+			o = s;
+			break;
+		}
+
+		case VG_MOVE_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+            Vector2 tc;
+
+			if (absRel == VG_ABSOLUTE)
+                tc = affineTransform(matrix, c);
+            else
+            {
+                tc = affineTangentTransform(matrix, c);
+				c += o;
+            }
+			
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+			s = c;
+			o = c;
+			break;
+		}
+
+		case VG_LINE_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+            Vector2 tc;
+
+			if (absRel == VG_ABSOLUTE)
+                tc = affineTransform(matrix, c);
+            else
+            {
+                tc = affineTangentTransform(matrix, c);
+				c += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+			o = c;
+			break;
+		}
+
+		case VG_HLINE_TO:
+		{
+			RI_ASSERT(coords == 1);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), 0);
+            Vector2 tc;
+
+			if (absRel == VG_ABSOLUTE)
+            {
+                c.y = o.y;
+                tc = affineTransform(matrix, c);
+            }
+            else
+            {
+                tc = affineTangentTransform(matrix, c);
+				c += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+			o = c;
+			segment = VG_LINE_TO;
+			break;
+		}
+
+		case VG_VLINE_TO:
+		{
+			RI_ASSERT(coords == 1);
+			Vector2 c(0, srcPath->getCoordinate(srcCoord+0));
+            Vector2 tc;
+
+			if (absRel == VG_ABSOLUTE)
+            {
+                c.x = o.x;
+                tc = affineTransform(matrix, c);
+            }
+            else
+            {
+                tc = affineTangentTransform(matrix, c);
+				c += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+			o = c;
+			segment = VG_LINE_TO;
+			break;
+		}
+
+		case VG_QUAD_TO:
+		{
+			RI_ASSERT(coords == 4);
+			Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+            Vector2 tc0, tc1;
+
+			if (absRel == VG_ABSOLUTE)
+            {
+                tc0 = affineTransform(matrix, c0);
+                tc1 = affineTransform(matrix, c1);
+            }
+            else
+            {
+                tc0 = affineTangentTransform(matrix, c0);
+                tc1 = affineTangentTransform(matrix, c1);
+                c1 += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+			o = c1;
+			break;
+		}
+
+		case VG_CUBIC_TO:
+		{
+			RI_ASSERT(coords == 6);
+			Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+			Vector2 c2(srcPath->getCoordinate(srcCoord+4), srcPath->getCoordinate(srcCoord+5));
+            Vector2 tc0, tc1, tc2;
+
+			if (absRel == VG_ABSOLUTE)
+            {
+                tc0 = affineTransform(matrix, c0);
+                tc1 = affineTransform(matrix, c1);
+                tc2 = affineTransform(matrix, c2);
+            }
+            else
+            {
+                tc0 = affineTangentTransform(matrix, c0);
+                tc1 = affineTangentTransform(matrix, c1);
+                tc2 = affineTangentTransform(matrix, c2);
+                c2 += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc0.y);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y);
+			o = c2;
+			break;
+		}
+
+		case VG_SQUAD_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+            Vector2 tc1;
+
+			if (absRel == VG_ABSOLUTE)
+                tc1 = affineTransform(matrix, c1);
+            else
+            {
+                tc1 = affineTangentTransform(matrix, c1);
+                c1 += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+			o = c1;
+			break;
+		}
+
+		case VG_SCUBIC_TO:
+		{
+			RI_ASSERT(coords == 4);
+			Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c2(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+            Vector2 tc1, tc2;
+
+			if (absRel == VG_ABSOLUTE)
+            {
+                tc1 = affineTransform(matrix, c1);
+                tc2 = affineTransform(matrix, c2);
+            }
+            else
+            {
+                tc1 = affineTangentTransform(matrix, c1);
+                tc2 = affineTangentTransform(matrix, c2);
+                c2 += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc1.y);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc2.y);
+			o = c2;
+			break;
+		}
+
+		default:
+		{
+			RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+					  segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+			RI_ASSERT(coords == 5);
+			RIfloat rh = srcPath->getCoordinate(srcCoord+0);
+			RIfloat rv = srcPath->getCoordinate(srcCoord+1);
+			RIfloat rot = srcPath->getCoordinate(srcCoord+2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+3), srcPath->getCoordinate(srcCoord+4));
+
+			rot = RI_DEG_TO_RAD(rot);
+			Matrix3x3 u((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv,  0,
+						(RIfloat)sin(rot)*rh,  (RIfloat)cos(rot)*rv,  0,
+						0,                   0,                   1);
+			u = matrix * u;
+			u[2].set(0,0,1);		//force affinity
+			//u maps from the unit circle to transformed ellipse
+
+			//compute new rh, rv and rot
+			Vector2	p(u[0][0], u[1][0]);
+			Vector2	q(u[1][1], -u[0][1]);
+			bool swapped = false;
+			if(dot(p,p) < dot(q,q))
+			{
+				RI_SWAP(p.x,q.x);
+				RI_SWAP(p.y,q.y);
+				swapped = true;
+			}
+			Vector2 h = (p+q) * 0.5f;
+			Vector2 hp = (p-q) * 0.5f;
+			RIfloat hlen = h.length();
+			RIfloat hplen = hp.length();
+			rh = hlen + hplen;
+			rv = hlen - hplen;
+			h = hplen * h + hlen * hp;
+			hlen = dot(h,h);
+			if(hlen == 0.0f)
+				rot = 0.0f;
+			else
+			{
+				h.normalize();
+				rot = (RIfloat)acos(h.x);
+				if(h.y < 0.0f)
+					rot = 2.0f*PI - rot;
+			}
+			if(swapped)
+				rot += PI*0.5f;
+
+            Vector2 tc;
+			if (absRel == VG_ABSOLUTE)
+                tc = affineTransform(matrix, c);
+            else
+            {
+                tc = affineTangentTransform(matrix, c);
+                c += o;
+            }
+
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rh);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, rv);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, RI_RAD_TO_DEG(rot));
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.x);
+			setCoordinate(newData, m_datatype, m_scale, m_bias, dstCoord++, tc.y);
+			o = c;
+
+            //flip winding if the determinant is negative
+            if (matrix.det() < 0)
+            {
+                switch (segment)
+                {
+                case VG_SCCWARC_TO: segment = VG_SCWARC_TO;     break;
+                case VG_SCWARC_TO:  segment = VG_SCCWARC_TO;    break;
+                case VG_LCCWARC_TO: segment = VG_LCWARC_TO;     break;
+                case VG_LCWARC_TO:  segment = VG_LCCWARC_TO;    break;
+                default:                                        break;
+                }
+            }
+            break;
+		}
+		}
+
+		newSegments[m_segments.size() + i] = (RIuint8)(segment | absRel);
+		srcCoord += coords;
+	}
+	RI_ASSERT(srcCoord == numSrcCoords);
+	RI_ASSERT(dstCoord == getNumCoordinates() + numDstCoords);
+
+	RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+	//replace old arrays
+	m_segments.swap(newSegments);
+	m_data.swap(newData);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Normalizes a path for interpolation.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::normalizeForInterpolation(const Path* srcPath)
+{
+	RI_ASSERT(srcPath);
+	RI_ASSERT(srcPath != this);
+	RI_ASSERT(srcPath->m_referenceCount > 0);
+
+	//count the number of resulting coordinates
+	int numSrcCoords = 0;
+	int numDstCoords = 0;
+	for(int i=0;i<srcPath->m_segments.size();i++)
+	{
+		VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+		int coords = segmentToNumCoordinates(segment);
+		numSrcCoords += coords;
+		switch(segment)
+		{
+		case VG_CLOSE_PATH:
+		case VG_MOVE_TO:
+		case VG_LINE_TO:
+			break;
+
+		case VG_HLINE_TO:
+		case VG_VLINE_TO:
+			coords = 2;
+			break;
+
+		case VG_QUAD_TO:
+		case VG_CUBIC_TO:
+		case VG_SQUAD_TO:
+		case VG_SCUBIC_TO:
+			coords = 6;
+			break;
+
+		default:
+			RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+					  segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+			break;
+		}
+		numDstCoords += coords;
+	}
+
+	m_segments.resize(srcPath->m_segments.size());	//throws bad_alloc
+	m_data.resize(numDstCoords * getBytesPerCoordinate(VG_PATH_DATATYPE_F));	//throws bad_alloc
+
+	int srcCoord = 0;
+	int dstCoord = 0;
+	Vector2 s(0,0);		//the beginning of the current subpath
+	Vector2 o(0,0);		//the last point of the previous segment
+
+	// the last internal control point of the previous segment, if the
+	//segment was a (regular or smooth) quadratic or cubic
+	//Bezier, or else the last point of the previous segment
+	Vector2 p(0,0);		
+	for(int i=0;i<srcPath->m_segments.size();i++)
+	{
+		VGPathSegment segment = getPathSegment(srcPath->m_segments[i]);
+		VGPathAbsRel absRel = getPathAbsRel(srcPath->m_segments[i]);
+		int coords = segmentToNumCoordinates(segment);
+
+		switch(segment)
+		{
+		case VG_CLOSE_PATH:
+		{
+			RI_ASSERT(coords == 0);
+			p = s;
+			o = s;
+			break;
+		}
+
+		case VG_MOVE_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			if(absRel == VG_RELATIVE)
+				c += o;
+			setCoordinate(dstCoord++, c.x);
+			setCoordinate(dstCoord++, c.y);
+			s = c;
+			p = c;
+			o = c;
+			break;
+		}
+
+		case VG_LINE_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			if(absRel == VG_RELATIVE)
+				c += o;
+			setCoordinate(dstCoord++, c.x);
+			setCoordinate(dstCoord++, c.y);
+			p = c;
+			o = c;
+			break;
+		}
+
+		case VG_HLINE_TO:
+		{
+			RI_ASSERT(coords == 1);
+			Vector2 c(srcPath->getCoordinate(srcCoord+0), o.y);
+			if(absRel == VG_RELATIVE)
+				c.x += o.x;
+			setCoordinate(dstCoord++, c.x);
+			setCoordinate(dstCoord++, c.y);
+			p = c;
+			o = c;
+			segment = VG_LINE_TO;
+			break;
+		}
+
+		case VG_VLINE_TO:
+		{
+			RI_ASSERT(coords == 1);
+			Vector2 c(o.x, srcPath->getCoordinate(srcCoord+0));
+			if(absRel == VG_RELATIVE)
+				c.y += o.y;
+			setCoordinate(dstCoord++, c.x);
+			setCoordinate(dstCoord++, c.y);
+			p = c;
+			o = c;
+			segment = VG_LINE_TO;
+			break;
+		}
+
+		case VG_QUAD_TO:
+		{
+			RI_ASSERT(coords == 4);
+			Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+			if(absRel == VG_RELATIVE)
+			{
+				c0 += o;
+				c1 += o;
+			}
+			Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0);
+			Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0);
+			setCoordinate(dstCoord++, d0.x);
+			setCoordinate(dstCoord++, d0.y);
+			setCoordinate(dstCoord++, d1.x);
+			setCoordinate(dstCoord++, d1.y);
+			setCoordinate(dstCoord++, c1.x);
+			setCoordinate(dstCoord++, c1.y);
+			p = c0;
+			o = c1;
+			segment = VG_CUBIC_TO;
+			break;
+		}
+
+		case VG_CUBIC_TO:
+		{
+			RI_ASSERT(coords == 6);
+			Vector2 c0(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c1(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+			Vector2 c2(srcPath->getCoordinate(srcCoord+4), srcPath->getCoordinate(srcCoord+5));
+			if(absRel == VG_RELATIVE)
+			{
+				c0 += o;
+				c1 += o;
+				c2 += o;
+			}
+			setCoordinate(dstCoord++, c0.x);
+			setCoordinate(dstCoord++, c0.y);
+			setCoordinate(dstCoord++, c1.x);
+			setCoordinate(dstCoord++, c1.y);
+			setCoordinate(dstCoord++, c2.x);
+			setCoordinate(dstCoord++, c2.y);
+			p = c1;
+			o = c2;
+			break;
+		}
+
+		case VG_SQUAD_TO:
+		{
+			RI_ASSERT(coords == 2);
+			Vector2 c0 = 2.0f * o - p;
+			Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			if(absRel == VG_RELATIVE)
+				c1 += o;
+			Vector2 d0 = (1.0f/3.0f) * (o + 2.0f * c0);
+			Vector2 d1 = (1.0f/3.0f) * (c1 + 2.0f * c0);
+			setCoordinate(dstCoord++, d0.x);
+			setCoordinate(dstCoord++, d0.y);
+			setCoordinate(dstCoord++, d1.x);
+			setCoordinate(dstCoord++, d1.y);
+			setCoordinate(dstCoord++, c1.x);
+			setCoordinate(dstCoord++, c1.y);
+			p = c0;
+			o = c1;
+			segment = VG_CUBIC_TO;
+			break;
+		}
+
+		case VG_SCUBIC_TO:
+		{
+			RI_ASSERT(coords == 4);
+			Vector2 c0 = 2.0f * o - p;
+			Vector2 c1(srcPath->getCoordinate(srcCoord+0), srcPath->getCoordinate(srcCoord+1));
+			Vector2 c2(srcPath->getCoordinate(srcCoord+2), srcPath->getCoordinate(srcCoord+3));
+			if(absRel == VG_RELATIVE)
+			{
+				c1 += o;
+				c2 += o;
+			}
+			setCoordinate(dstCoord++, c0.x);
+			setCoordinate(dstCoord++, c0.y);
+			setCoordinate(dstCoord++, c1.x);
+			setCoordinate(dstCoord++, c1.y);
+			setCoordinate(dstCoord++, c2.x);
+			setCoordinate(dstCoord++, c2.y);
+			p = c1;
+			o = c2;
+			segment = VG_CUBIC_TO;
+			break;
+		}
+
+		default:
+		{
+			RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+					  segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+			RI_ASSERT(coords == 5);
+			RIfloat rh = srcPath->getCoordinate(srcCoord+0);
+			RIfloat rv = srcPath->getCoordinate(srcCoord+1);
+			RIfloat rot = srcPath->getCoordinate(srcCoord+2);
+			Vector2 c(srcPath->getCoordinate(srcCoord+3), srcPath->getCoordinate(srcCoord+4));
+			if(absRel == VG_RELATIVE)
+				c += o;
+			setCoordinate(dstCoord++, rh);
+			setCoordinate(dstCoord++, rv);
+			setCoordinate(dstCoord++, rot);
+			setCoordinate(dstCoord++, c.x);
+			setCoordinate(dstCoord++, c.y);
+			p = c;
+			o = c;
+			break;
+		}
+		}
+
+		m_segments[i] = (RIuint8)(segment | VG_ABSOLUTE);
+		srcCoord += coords;
+	}
+	RI_ASSERT(srcCoord == numSrcCoords);
+	RI_ASSERT(dstCoord == numDstCoords);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Appends a linearly interpolated copy of the two source paths.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+bool Path::interpolate(const Path* startPath, const Path* endPath, RIfloat amount)
+{
+	RI_ASSERT(startPath && endPath);
+	RI_ASSERT(m_referenceCount > 0 && startPath->m_referenceCount > 0 && endPath->m_referenceCount > 0);
+
+	if(!startPath->m_segments.size() || startPath->m_segments.size() != endPath->m_segments.size())
+		return false;	//start and end paths are incompatible or zero length
+
+	Path start(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, 0);
+	start.normalizeForInterpolation(startPath);	//throws bad_alloc
+
+	Path end(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, 0);
+	end.normalizeForInterpolation(endPath);	//throws bad_alloc
+
+	//check that start and end paths are compatible
+	if(start.m_data.size() != end.m_data.size() || start.m_segments.size() != end.m_segments.size())
+		return false;	//start and end paths are incompatible
+
+	//allocate new arrays
+	Array<RIuint8> newSegments;
+	newSegments.resize(m_segments.size() + start.m_segments.size());	//throws bad_alloc
+	Array<RIuint8> newData;
+	newData.resize(m_data.size() + start.m_data.size() * getBytesPerCoordinate(m_datatype) / getBytesPerCoordinate(start.m_datatype));	//throws bad_alloc
+	//if we get here, the memory allocations have succeeded
+
+	//copy old segments
+	if(m_segments.size())
+		memcpy(&newSegments[0], &m_segments[0], m_segments.size());
+
+	//copy old data
+	if(m_data.size())
+		memcpy(&newData[0], &m_data[0], m_data.size());
+
+	//copy segments
+	for(int i=0;i<start.m_segments.size();i++)
+	{
+		VGPathSegment s = getPathSegment(start.m_segments[i]);
+		VGPathSegment e = getPathSegment(end.m_segments[i]);
+
+		if(s == VG_SCCWARC_TO || s == VG_SCWARC_TO || s == VG_LCCWARC_TO || s == VG_LCWARC_TO)
+		{
+			if(e != VG_SCCWARC_TO && e != VG_SCWARC_TO && e != VG_LCCWARC_TO && e != VG_LCWARC_TO)
+				return false;	//start and end paths are incompatible
+			if(amount < 0.5f)
+				newSegments[m_segments.size() + i] = start.m_segments[i];
+			else
+				newSegments[m_segments.size() + i] = end.m_segments[i];
+		}
+		else
+		{
+			if(s != e)
+				return false;	//start and end paths are incompatible
+			newSegments[m_segments.size() + i] = start.m_segments[i];
+		}
+	}
+
+	//interpolate data
+	int oldNumCoords = getNumCoordinates();
+	for(int i=0;i<start.getNumCoordinates();i++)
+		setCoordinate(newData, m_datatype, m_scale, m_bias, oldNumCoords + i, start.getCoordinate(i) * (1.0f - amount) + end.getCoordinate(i) * amount);
+
+	RI_ASSERT(newData.size() == countNumCoordinates(&newSegments[0],newSegments.size()) * getBytesPerCoordinate(m_datatype));
+
+	//replace old arrays
+	m_segments.swap(newSegments);
+	m_data.swap(newData);
+
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path for filling and appends resulting edges
+*			to a rasterizer.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::fill(const Matrix3x3& pathToSurface, Rasterizer& rasterizer)
+{
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(pathToSurface.isAffine());
+
+	tessellate(pathToSurface, 0.0f);	//throws bad_alloc
+
+	try
+	{
+		Vector2 p0(0,0), p1(0,0);
+		for(int i=0;i<m_vertices.size();i++)
+		{
+			p1 = affineTransform(pathToSurface, m_vertices[i].userPosition);
+
+			if(!(m_vertices[i].flags & START_SEGMENT))
+			{	//in the middle of a segment
+				rasterizer.addEdge(p0, p1);	//throws bad_alloc
+			}
+
+			p0 = p1;
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		rasterizer.clear();	//remove the unfinished path
+		throw;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Smoothly interpolates between two StrokeVertices. Positions
+*			are interpolated linearly, while tangents are interpolated
+*			on a unit circle. Stroking is implemented so that overlapping
+*			geometry doesnt cancel itself when filled with nonzero rule.
+*			The resulting polygons are closed.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::interpolateStroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth) const
+{
+	Vector2 pccw = affineTransform(pathToSurface, v0.ccw);
+	Vector2 pcw = affineTransform(pathToSurface, v0.cw);
+	Vector2 p = affineTransform(pathToSurface, v0.p);
+	Vector2 endccw = affineTransform(pathToSurface, v1.ccw);
+	Vector2 endcw = affineTransform(pathToSurface, v1.cw);
+	Vector2 endp = affineTransform(pathToSurface, v1.p);
+
+	const RIfloat tessellationAngle = 5.0f;
+
+	RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(v0.t, v1.t), -1.0f, 1.0f))) / tessellationAngle;
+	int samples = RI_INT_MAX((int)ceil(angle), 1);
+
+	for(int j=0;j<samples-1;j++)
+	{
+		RIfloat t = (RIfloat)(j+1) / (RIfloat)samples;
+		Vector2 position = v0.p * (1.0f - t) + v1.p * t;
+		Vector2 tangent = circularLerp(v0.t, v1.t, t);
+		Vector2 normal = normalize(perpendicularCCW(tangent)) * strokeWidth * 0.5f;
+
+		Vector2 nccw = affineTransform(pathToSurface, position + normal);
+		Vector2 ncw = affineTransform(pathToSurface, position - normal);
+		Vector2 n = affineTransform(pathToSurface, position);
+
+        rasterizer.clear();
+		rasterizer.addEdge(p, pccw);	//throws bad_alloc
+		rasterizer.addEdge(pccw, nccw);	//throws bad_alloc
+		rasterizer.addEdge(nccw, n);	//throws bad_alloc
+		rasterizer.addEdge(n, ncw);     //throws bad_alloc
+		rasterizer.addEdge(ncw, pcw);	//throws bad_alloc
+		rasterizer.addEdge(pcw, p);	    //throws bad_alloc
+        rasterizer.fill();
+
+		pccw = nccw;
+		pcw = ncw;
+        p = n;
+	}
+
+	//connect the last segment to the end coordinates
+    rasterizer.clear();
+	rasterizer.addEdge(p, pccw);	    //throws bad_alloc
+	rasterizer.addEdge(pccw, endccw);	//throws bad_alloc
+	rasterizer.addEdge(endccw, endp);	//throws bad_alloc
+	rasterizer.addEdge(endp, endcw);	//throws bad_alloc
+	rasterizer.addEdge(endcw, pcw);     //throws bad_alloc
+	rasterizer.addEdge(pcw, p);         //throws bad_alloc
+    rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Generate edges for stroke caps. Resulting polygons are closed.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::doCap(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v, RIfloat strokeWidth, VGCapStyle capStyle) const
+{
+	Vector2 ccwt = affineTransform(pathToSurface, v.ccw);
+	Vector2 cwt = affineTransform(pathToSurface, v.cw);
+	Vector2 p = affineTransform(pathToSurface, v.p);
+
+    rasterizer.clear();
+	switch(capStyle)
+	{
+	case VG_CAP_BUTT:
+		break;
+
+	case VG_CAP_ROUND:
+	{
+        const RIfloat tessellationAngle = 5.0f;
+
+		RIfloat angle = 180.0f / tessellationAngle;
+
+		int samples = (int)ceil(angle);
+		RIfloat step = 1.0f / samples;
+		RIfloat t = step;
+		Vector2 u0 = normalize(v.ccw - v.p);
+		Vector2 u1 = normalize(v.cw - v.p);
+		Vector2 prev = ccwt;
+		rasterizer.addEdge(p, ccwt);	//throws bad_alloc
+		for(int j=1;j<samples;j++)
+		{
+			Vector2 next = v.p + circularLerp(u0, u1, t, true) * strokeWidth * 0.5f;
+			next = affineTransform(pathToSurface, next);
+
+			rasterizer.addEdge(prev, next);	//throws bad_alloc
+			prev = next;
+			t += step;
+		}
+		rasterizer.addEdge(prev, cwt);	//throws bad_alloc
+		rasterizer.addEdge(cwt, p);     //throws bad_alloc
+		break;
+	}
+
+	default:
+	{
+		RI_ASSERT(capStyle == VG_CAP_SQUARE);
+		Vector2 t = v.t;
+		t.normalize();
+		Vector2 ccws = affineTransform(pathToSurface, v.ccw + t * strokeWidth * 0.5f);
+		Vector2 cws = affineTransform(pathToSurface, v.cw + t * strokeWidth * 0.5f);
+		rasterizer.addEdge(p, ccwt);	//throws bad_alloc
+		rasterizer.addEdge(ccwt, ccws);	//throws bad_alloc
+		rasterizer.addEdge(ccws, cws);	//throws bad_alloc
+		rasterizer.addEdge(cws, cwt);	//throws bad_alloc
+		rasterizer.addEdge(cwt, p);     //throws bad_alloc
+		break;
+	}
+	}
+    rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Generate edges for stroke joins. Resulting polygons are closed.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth, VGJoinStyle joinStyle, RIfloat miterLimit) const
+{
+	Vector2 ccw0t = affineTransform(pathToSurface, v0.ccw);
+	Vector2 cw0t = affineTransform(pathToSurface, v0.cw);
+	Vector2 m0t = affineTransform(pathToSurface, v0.p);
+	Vector2 ccw1t = affineTransform(pathToSurface, v1.ccw);
+	Vector2 cw1t = affineTransform(pathToSurface, v1.cw);
+	Vector2 m1t = affineTransform(pathToSurface, v1.p);
+
+	Vector2 tccw = v1.ccw - v0.ccw;
+	Vector2 s, e, m, st, et;
+	bool cw;
+
+    rasterizer.clear();
+
+	if( dot(tccw, v0.t) > 0.0f )
+	{	//draw ccw miter (draw from point 0 to 1)
+		s = ccw0t;
+		e = ccw1t;
+		st = v0.t;
+		et = v1.t;
+		m = v0.ccw;
+		cw = false;
+		rasterizer.addEdge(m0t, ccw0t);	//throws bad_alloc
+		rasterizer.addEdge(ccw1t, m1t);	//throws bad_alloc
+		rasterizer.addEdge(m1t, m0t);	//throws bad_alloc
+	}
+	else
+	{	//draw cw miter (draw from point 1 to 0)
+		s = cw1t;
+		e = cw0t;
+		st = v1.t;
+		et = v0.t;
+		m = v0.cw;
+		cw = true;
+		rasterizer.addEdge(cw0t, m0t);	//throws bad_alloc
+		rasterizer.addEdge(m1t, cw1t);	//throws bad_alloc
+		rasterizer.addEdge(m0t, m1t);	//throws bad_alloc
+	}
+
+	switch(joinStyle)
+	{
+	case VG_JOIN_MITER:
+	{
+		RIfloat theta = (RIfloat)acos(RI_CLAMP(dot(v0.t, -v1.t), -1.0f, 1.0f));
+		RIfloat miterLengthPerStrokeWidth = 1.0f / (RIfloat)sin(theta*0.5f);
+		if( miterLengthPerStrokeWidth < miterLimit )
+		{	//miter
+			RIfloat l = (RIfloat)cos(theta*0.5f) * miterLengthPerStrokeWidth * (strokeWidth * 0.5f);
+			l = RI_MIN(l, RI_FLOAT_MAX);	//force finite
+			Vector2 c = m + v0.t * l;
+			c = affineTransform(pathToSurface, c);
+			rasterizer.addEdge(s, c);	//throws bad_alloc
+			rasterizer.addEdge(c, e);	//throws bad_alloc
+		}
+		else
+		{	//bevel
+			rasterizer.addEdge(s, e);	//throws bad_alloc
+		}
+		break;
+	}
+
+	case VG_JOIN_ROUND:
+	{
+		const RIfloat tessellationAngle = 5.0f;
+
+		Vector2 prev = s;
+		RIfloat angle = RI_RAD_TO_DEG((RIfloat)acos(RI_CLAMP(dot(st, et), -1.0f, 1.0f))) / tessellationAngle;
+		int samples = (int)ceil(angle);
+		if( samples )
+		{
+			RIfloat step = 1.0f / samples;
+			RIfloat t = step;
+			for(int j=1;j<samples;j++)
+			{
+				Vector2 position = v0.p * (1.0f - t) + v1.p * t;
+				Vector2 tangent = circularLerp(st, et, t, true);
+
+				Vector2 next = position + normalize(perpendicular(tangent, cw)) * strokeWidth * 0.5f;
+				next = affineTransform(pathToSurface, next);
+
+				rasterizer.addEdge(prev, next);	//throws bad_alloc
+				prev = next;
+				t += step;
+			}
+		}
+		rasterizer.addEdge(prev, e);	//throws bad_alloc
+		break;
+	}
+
+	default:
+		RI_ASSERT(joinStyle == VG_JOIN_BEVEL);
+		if(!cw)
+			rasterizer.addEdge(ccw0t, ccw1t);	//throws bad_alloc
+		else
+			rasterizer.addEdge(cw1t, cw0t);		//throws bad_alloc
+		break;
+	}
+    rasterizer.fill();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellate a path, apply stroking, dashing, caps and joins, and
+*			append resulting edges to a rasterizer.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const Array<RIfloat>& dashPattern, RIfloat dashPhase, bool dashPhaseReset, RIfloat strokeWidth, VGCapStyle capStyle, VGJoinStyle joinStyle, RIfloat miterLimit)
+{
+	RI_ASSERT(pathToSurface.isAffine());
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(strokeWidth >= 0.0f);
+	RI_ASSERT(miterLimit >= 1.0f);
+
+	tessellate(pathToSurface, strokeWidth);	//throws bad_alloc
+
+	if(!m_vertices.size())
+		return;
+
+	bool dashing = true;
+	int dashPatternSize = dashPattern.size();
+	if( dashPattern.size() & 1 )
+		dashPatternSize--;	//odd number of dash pattern entries, discard the last one
+	RIfloat dashPatternLength = 0.0f;
+	for(int i=0;i<dashPatternSize;i++)
+		dashPatternLength += RI_MAX(dashPattern[i], 0.0f);
+	if(!dashPatternSize || dashPatternLength == 0.0f )
+		dashing = false;
+	dashPatternLength = RI_MIN(dashPatternLength, RI_FLOAT_MAX);
+
+	//walk along the path
+	//stop at the next event which is either:
+	//-path vertex
+	//-dash stop
+	//for robustness, decisions based on geometry are done only once.
+	//inDash keeps track whether the last point was in dash or not
+
+	//loop vertex events
+	try
+	{
+		RIfloat nextDash = 0.0f;
+		int d = 0;
+		bool inDash = true;
+		StrokeVertex v0, v1, vs;
+		for(int i=0;i<m_vertices.size();i++)
+		{
+			//read the next vertex
+			Vertex& v = m_vertices[i];
+			v1.p = v.userPosition;
+			v1.t = v.userTangent;
+			RI_ASSERT(!isZero(v1.t));	//don't allow zero tangents
+			v1.ccw = v1.p + normalize(perpendicularCCW(v1.t)) * strokeWidth * 0.5f;
+			v1.cw = v1.p + normalize(perpendicularCW(v1.t)) * strokeWidth * 0.5f;
+			v1.pathLength = v.pathLength;
+			v1.flags = v.flags;
+			v1.inDash = dashing ? inDash : true;	//NOTE: for other than START_SEGMENT vertices inDash will be updated after dashing
+
+			//process the vertex event
+			if(v.flags & START_SEGMENT)
+			{
+				if(v.flags & START_SUBPATH)
+				{
+					if( dashing )
+					{	//initialize dashing by finding which dash or gap the first point of the path lies in
+						if(dashPhaseReset || i == 0)
+						{
+							d = 0;
+							inDash = true;
+							nextDash = v1.pathLength - RI_MOD(dashPhase, dashPatternLength);
+							for(;;)
+							{
+								RIfloat prevDash = nextDash;
+								nextDash = prevDash + RI_MAX(dashPattern[d], 0.0f);
+								if(nextDash >= v1.pathLength)
+									break;
+
+								if( d & 1 )
+									inDash = true;
+								else
+									inDash = false;
+								d = (d+1) % dashPatternSize;
+							}
+							v1.inDash = inDash;
+							//the first point of the path lies between prevDash and nextDash
+							//d in the index of the next dash stop
+							//inDash is true if the first point is in a dash
+						}
+					}
+					vs = v1;	//save the subpath start point
+				}
+				else
+				{
+					if( v.flags & IMPLICIT_CLOSE_SUBPATH )
+					{	//do caps for the start and end of the current subpath
+						if( v0.inDash )
+							doCap(pathToSurface, rasterizer, v0, strokeWidth, capStyle);	//end cap	//throws bad_alloc
+						if( vs.inDash )
+						{
+							StrokeVertex vi = vs;
+							vi.t = -vi.t;
+							RI_SWAP(vi.ccw.x, vi.cw.x);
+							RI_SWAP(vi.ccw.y, vi.cw.y);
+							doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle);	//start cap	//throws bad_alloc
+						}
+					}
+					else
+					{	//join two segments
+						RI_ASSERT(v0.inDash == v1.inDash);
+						if( v0.inDash )
+							doJoin(pathToSurface, rasterizer, v0, v1, strokeWidth, joinStyle, miterLimit);	//throws bad_alloc
+					}
+				}
+			}
+			else
+			{	//in the middle of a segment
+				if( !(v.flags & IMPLICIT_CLOSE_SUBPATH) )
+				{	//normal segment, do stroking
+					if( dashing )
+					{
+						StrokeVertex prevDashVertex = v0;	//dashing of the segment starts from the previous vertex
+
+						if(nextDash + 10000.0f * dashPatternLength < v1.pathLength)
+							throw std::bad_alloc();		//too many dashes, throw bad_alloc
+
+						//loop dash events until the next vertex event
+						//zero length dashes are handled as a special case since if they hit the vertex,
+						//we want to include their starting point to this segment already in order to generate a join
+						int numDashStops = 0;
+						while(nextDash < v1.pathLength || (nextDash <= v1.pathLength && dashPattern[(d+1) % dashPatternSize] == 0.0f))
+						{
+							RIfloat edgeLength = v1.pathLength - v0.pathLength;
+							RIfloat ratio = 0.0f;
+							if(edgeLength > 0.0f)
+								ratio = (nextDash - v0.pathLength) / edgeLength;
+							StrokeVertex nextDashVertex;
+							nextDashVertex.p = v0.p * (1.0f - ratio) + v1.p * ratio;
+							nextDashVertex.t = circularLerp(v0.t, v1.t, ratio);
+							nextDashVertex.ccw = nextDashVertex.p + normalize(perpendicularCCW(nextDashVertex.t)) * strokeWidth * 0.5f;
+							nextDashVertex.cw = nextDashVertex.p + normalize(perpendicularCW(nextDashVertex.t)) * strokeWidth * 0.5f;
+
+							if( inDash )
+							{	//stroke from prevDashVertex -> nextDashVertex
+								if( numDashStops )
+								{	//prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped)
+									StrokeVertex vi = prevDashVertex;
+									vi.t = -vi.t;
+									RI_SWAP(vi.ccw.x, vi.cw.x);
+									RI_SWAP(vi.ccw.y, vi.cw.y);
+									doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle);	//throws bad_alloc
+								}
+								interpolateStroke(pathToSurface, rasterizer, prevDashVertex, nextDashVertex, strokeWidth);	//throws bad_alloc
+								doCap(pathToSurface, rasterizer, nextDashVertex, strokeWidth, capStyle);	//end cap	//throws bad_alloc
+							}
+							prevDashVertex = nextDashVertex;
+
+							if( d & 1 )
+							{	//dash starts
+								RI_ASSERT(!inDash);
+								inDash = true;
+							}
+							else
+							{	//dash ends
+								RI_ASSERT(inDash);
+								inDash = false;
+							}
+							d = (d+1) % dashPatternSize;
+							nextDash += RI_MAX(dashPattern[d], 0.0f);
+							numDashStops++;
+						}
+						
+						if( inDash )
+						{	//stroke prevDashVertex -> v1
+							if( numDashStops )
+							{	//prevDashVertex is not the start vertex of the segment, cap it (start vertex has already been joined or capped)
+								StrokeVertex vi = prevDashVertex;
+								vi.t = -vi.t;
+								RI_SWAP(vi.ccw.x, vi.cw.x);
+								RI_SWAP(vi.ccw.y, vi.cw.y);
+								doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle);	//throws bad_alloc
+							}
+							interpolateStroke(pathToSurface, rasterizer, prevDashVertex, v1, strokeWidth);	//throws bad_alloc
+							//no cap, leave path open
+						}
+
+						v1.inDash = inDash;	//update inDash status of the segment end point
+					}
+					else	//no dashing, just interpolate segment end points
+						interpolateStroke(pathToSurface, rasterizer, v0, v1, strokeWidth);	//throws bad_alloc
+				}
+			}
+
+			if((v.flags & END_SEGMENT) && (v.flags & CLOSE_SUBPATH))
+			{	//join start and end of the current subpath
+				if( v1.inDash && vs.inDash )
+					doJoin(pathToSurface, rasterizer, v1, vs, strokeWidth, joinStyle, miterLimit);	//throws bad_alloc
+				else
+				{	//both start and end are not in dash, cap them
+					if( v1.inDash )
+						doCap(pathToSurface, rasterizer, v1, strokeWidth, capStyle);	//end cap	//throws bad_alloc
+					if( vs.inDash )
+					{
+						StrokeVertex vi = vs;
+						vi.t = -vi.t;
+						RI_SWAP(vi.ccw.x, vi.cw.x);
+						RI_SWAP(vi.ccw.y, vi.cw.y);
+						doCap(pathToSurface, rasterizer, vi, strokeWidth, capStyle);	//start cap	//throws bad_alloc
+					}
+				}
+			}
+
+			v0 = v1;
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		rasterizer.clear();	//remove the unfinished path
+		throw;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path, and returns a position and a tangent on the path
+*			given a distance along the path.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPointAlong(int startIndex, int numSegments, RIfloat distance, Vector2& p, Vector2& t)
+{
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size() && numSegments > 0);
+
+	Matrix3x3 identity;
+	identity.identity();
+	tessellate(identity, 0.0f);	//throws bad_alloc
+
+	RI_ASSERT(startIndex >= 0 && startIndex < m_segmentToVertex.size());
+	RI_ASSERT(startIndex + numSegments >= 0 && startIndex + numSegments <= m_segmentToVertex.size());
+
+    // ignore move segments at the start of the path
+    while (numSegments && (m_segments[startIndex] & ~VG_RELATIVE) == VG_MOVE_TO)
+    {
+        startIndex++;
+        numSegments--;
+    }
+
+    // ignore move segments at the end of the path
+    while (numSegments && (m_segments[startIndex + numSegments - 1] & ~VG_RELATIVE) == VG_MOVE_TO)
+        numSegments--;
+
+    // empty path?
+    if (!m_vertices.size() || !numSegments)
+    {
+		p.set(0,0);
+		t.set(1,0);
+		return;
+    }
+
+	int startVertex = m_segmentToVertex[startIndex].start;
+	int endVertex = m_segmentToVertex[startIndex + numSegments - 1].end;
+
+	if(startVertex == -1)
+		startVertex = 0;
+
+    // zero length?
+    if (startVertex >= endVertex)
+    {
+		p = m_vertices[startVertex].userPosition;
+		t.set(1,0);
+		return;
+    }
+
+	RI_ASSERT(startVertex >= 0 && startVertex < m_vertices.size());
+	RI_ASSERT(endVertex >= 0 && endVertex < m_vertices.size());
+
+	distance += m_vertices[startVertex].pathLength;	//map distance to the range of the whole path
+
+	if(distance <= m_vertices[startVertex].pathLength)
+	{	//return the first point of the path
+		p = m_vertices[startVertex].userPosition;
+		t = m_vertices[startVertex].userTangent;
+		return;
+	}
+
+	if(distance >= m_vertices[endVertex].pathLength)
+	{	//return the last point of the path
+		p = m_vertices[endVertex].userPosition;
+		t = m_vertices[endVertex].userTangent;
+		return;
+	}
+
+	//search for the segment containing the distance
+	for(int s=startIndex;s<startIndex+numSegments;s++)
+	{
+		int start = m_segmentToVertex[s].start;
+		int end = m_segmentToVertex[s].end;
+		if(start < 0)
+			start = 0;
+		if(end < 0)
+			end = 0;
+		RI_ASSERT(start >= 0 && start < m_vertices.size());
+		RI_ASSERT(end >= 0 && end < m_vertices.size());
+
+		if(distance >= m_vertices[start].pathLength && distance < m_vertices[end].pathLength)
+		{	//segment contains the queried distance
+			for(int i=start;i<end;i++)
+			{
+				const Vertex& v0 = m_vertices[i];
+				const Vertex& v1 = m_vertices[i+1];
+				if(distance >= v0.pathLength && distance < v1.pathLength)
+				{	//segment found, interpolate linearly between its end points
+					RIfloat edgeLength = v1.pathLength - v0.pathLength;
+					RI_ASSERT(edgeLength > 0.0f);
+					RIfloat r = (distance - v0.pathLength) / edgeLength;
+					p = (1.0f - r) * v0.userPosition + r * v1.userPosition;
+					t = (1.0f - r) * v0.userTangent + r * v1.userTangent;
+					return;
+				}
+			}
+		}
+	}
+
+	RI_ASSERT(0);	//point not found (should never get here)
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path, and computes its length.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+RIfloat Path::getPathLength(int startIndex, int numSegments)
+{
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(startIndex >= 0 && startIndex + numSegments <= m_segments.size() && numSegments > 0);
+
+	Matrix3x3 identity;
+	identity.identity();
+	tessellate(identity, 0.0f);	//throws bad_alloc
+
+	RI_ASSERT(startIndex >= 0 && startIndex < m_segmentToVertex.size());
+	RI_ASSERT(startIndex + numSegments >= 0 && startIndex + numSegments <= m_segmentToVertex.size());
+
+	int startVertex = m_segmentToVertex[startIndex].start;
+	int endVertex = m_segmentToVertex[startIndex + numSegments - 1].end;
+
+	if(!m_vertices.size())
+		return 0.0f;
+
+	RIfloat startPathLength = 0.0f;
+	if(startVertex >= 0)
+	{
+		RI_ASSERT(startVertex >= 0 && startVertex < m_vertices.size());
+		startPathLength = m_vertices[startVertex].pathLength;
+	}
+	RIfloat endPathLength = 0.0f;
+	if(endVertex >= 0)
+	{
+		RI_ASSERT(endVertex >= 0 && endVertex < m_vertices.size());
+		endPathLength = m_vertices[endVertex].pathLength;
+	}
+
+	return endPathLength - startPathLength;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path, and computes its bounding box in user space.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPathBounds(RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy)
+{
+	RI_ASSERT(m_referenceCount > 0);
+
+	Matrix3x3 identity;
+	identity.identity();
+	tessellate(identity, 0.0f);	//throws bad_alloc
+
+	if(m_vertices.size())
+	{
+		minx = m_userMinx;
+		miny = m_userMiny;
+		maxx = m_userMaxx;
+		maxy = m_userMaxy;
+	}
+	else
+	{
+		minx = miny = 0;
+		maxx = maxy = -1;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path, and computes its bounding box in surface space.
+* \param	
+* \return	
+* \note		if runs out of memory, throws bad_alloc and leaves the path as it was
+*//*-------------------------------------------------------------------*/
+
+void Path::getPathTransformedBounds(const Matrix3x3& pathToSurface, RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy)
+{
+	RI_ASSERT(m_referenceCount > 0);
+	RI_ASSERT(pathToSurface.isAffine());
+
+	Matrix3x3 identity;
+	identity.identity();
+	tessellate(identity, 0.0f);	//throws bad_alloc
+
+	if(m_vertices.size())
+	{
+		Vector3 p0(m_userMinx, m_userMiny, 1.0f);
+		Vector3 p1(m_userMinx, m_userMaxy, 1.0f);
+		Vector3 p2(m_userMaxx, m_userMaxy, 1.0f);
+		Vector3 p3(m_userMaxx, m_userMiny, 1.0f);
+		p0 = pathToSurface * p0;
+		p1 = pathToSurface * p1;
+		p2 = pathToSurface * p2;
+		p3 = pathToSurface * p3;
+
+		minx = RI_MIN(RI_MIN(RI_MIN(p0.x, p1.x), p2.x), p3.x);
+		miny = RI_MIN(RI_MIN(RI_MIN(p0.y, p1.y), p2.y), p3.y);
+		maxx = RI_MAX(RI_MAX(RI_MAX(p0.x, p1.x), p2.x), p3.x);
+		maxy = RI_MAX(RI_MAX(RI_MAX(p0.y, p1.y), p2.y), p3.y);
+	}
+	else
+	{
+		minx = miny = 0;
+		maxx = maxy = -1;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Adds a vertex to a tessellated path.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::addVertex(const Vector2& p, const Vector2& t, RIfloat pathLength, unsigned int flags)
+{
+	RI_ASSERT(!isZero(t));
+
+	Vertex v;
+	v.pathLength = pathLength;
+	v.userPosition = p;
+	v.userTangent = t;
+	v.flags = flags;
+	m_vertices.push_back(v);	//throws bad_alloc
+    m_numTessVertices++;
+
+	m_userMinx = RI_MIN(m_userMinx, v.userPosition.x);
+	m_userMiny = RI_MIN(m_userMiny, v.userPosition.y);
+	m_userMaxx = RI_MAX(m_userMaxx, v.userPosition.x);
+	m_userMaxy = RI_MAX(m_userMaxy, v.userPosition.y);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Adds an edge to a tessellated path.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::addEdge(const Vector2& p0, const Vector2& p1, const Vector2& t0, const Vector2& t1, unsigned int startFlags, unsigned int endFlags)
+{
+	Vertex v;
+	RIfloat pathLength = 0.0f;
+
+	RI_ASSERT(!isZero(t0) && !isZero(t1));
+
+	//segment midpoints are shared between edges
+	if(!m_numTessVertices)
+	{
+		if(m_vertices.size() > 0)
+			pathLength = m_vertices[m_vertices.size()-1].pathLength;
+
+		addVertex(p0, t0, pathLength, startFlags);	//throws bad_alloc
+	}
+
+	//other than implicit close paths (caused by a MOVE_TO) add to path length
+	if( !(endFlags & IMPLICIT_CLOSE_SUBPATH) )
+	{
+		//NOTE: with extremely large coordinates the floating point path length is infinite
+		RIfloat l = (p1 - p0).length();
+		pathLength = m_vertices[m_vertices.size()-1].pathLength + l;
+		pathLength = RI_MIN(pathLength, RI_FLOAT_MAX);
+	}
+
+	addVertex(p1, t1, pathLength, endFlags);	//throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a close-path segment.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Path::addEndPath(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry, unsigned int flags)
+{
+	RI_UNREF(pathToSurface);
+    m_numTessVertices = 0;
+	if(!subpathHasGeometry)
+	{	//single vertex
+		Vector2 t(1.0f,0.0f);
+		addEdge(p0, p1, t, t, START_SEGMENT | START_SUBPATH, END_SEGMENT | END_SUBPATH);	//throws bad_alloc
+        m_numTessVertices = 0;
+		addEdge(p0, p1, -t, -t, IMPLICIT_CLOSE_SUBPATH | START_SEGMENT, IMPLICIT_CLOSE_SUBPATH | END_SEGMENT);	//throws bad_alloc
+		return;
+	}
+	//the subpath contains segment commands that have generated geometry
+
+	//add a close path segment to the start point of the subpath
+	RI_ASSERT(m_vertices.size() > 0);
+	m_vertices[m_vertices.size()-1].flags |= END_SUBPATH;
+
+	Vector2 t = normalize(p1 - p0);
+	if(isZero(t))
+		t = m_vertices[m_vertices.size()-1].userTangent;	//if the segment is zero-length, use the tangent of the last segment end point so that proper join will be generated
+	RI_ASSERT(!isZero(t));
+
+	addEdge(p0, p1, t, t, flags | START_SEGMENT, flags | END_SEGMENT);	//throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a line-to segment.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Path::addLineTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry)
+{
+	RI_UNREF(pathToSurface);
+	if(p0 == p1)
+		return false;	//discard zero-length segments
+
+	//compute end point tangents
+	Vector2 t = normalize(p1 - p0);
+	RI_ASSERT(!isZero(t));
+
+    m_numTessVertices = 0;
+	unsigned int startFlags = START_SEGMENT;
+	if(!subpathHasGeometry)
+		startFlags |= START_SUBPATH;
+	addEdge(p0, p1, t, t, startFlags, END_SEGMENT);	//throws bad_alloc
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a quad-to segment.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Path::addQuadTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, bool subpathHasGeometry, float strokeWidth)
+{
+	RI_UNREF(pathToSurface);
+	RI_UNREF(strokeWidth);
+	if(p0 == p1 && p0 == p2)
+	{
+		RI_ASSERT(p1 == p2);
+		return false;	//discard zero-length segments
+	}
+
+	//compute end point tangents
+
+	Vector2 incomingTangent = normalize(p1 - p0);
+	Vector2 outgoingTangent = normalize(p2 - p1);
+	if(p0 == p1)
+		incomingTangent = normalize(p2 - p0);
+	if(p1 == p2)
+		outgoingTangent = normalize(p2 - p0);
+	RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+    m_numTessVertices = 0;
+	unsigned int startFlags = START_SEGMENT;
+	if(!subpathHasGeometry)
+		startFlags |= START_SUBPATH;
+
+	const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+	Vector2 pp = p0;
+	Vector2 tp = incomingTangent;
+	unsigned int prevFlags = startFlags;
+	for(int i=1;i<segments;i++)
+	{
+		RIfloat t = (RIfloat)i / (RIfloat)segments;
+		RIfloat u = 1.0f-t;
+		Vector2 pn = u*u * p0 + 2.0f*t*u * p1 + t*t * p2;
+		Vector2 tn = (-1.0f+t) * p0 + (1.0f-2.0f*t) * p1 + t * p2;
+		tn = normalize(tn);
+		if(isZero(tn))
+			tn = tp;
+
+		addEdge(pp, pn, tp, tn, prevFlags, 0);	//throws bad_alloc
+
+		pp = pn;
+		tp = tn;
+		prevFlags = 0;
+	}
+	addEdge(pp, p2, tp, outgoingTangent, prevFlags, END_SEGMENT);	//throws bad_alloc
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a cubic-to segment.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Path::addCubicTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, bool subpathHasGeometry, float strokeWidth)
+{
+	RI_UNREF(pathToSurface);
+	RI_UNREF(strokeWidth);
+
+	if(p0 == p1 && p0 == p2 && p0 == p3)
+	{
+		RI_ASSERT(p1 == p2 && p1 == p3 && p2 == p3);
+		return false;	//discard zero-length segments
+	}
+
+	//compute end point tangents
+	Vector2 incomingTangent = normalize(p1 - p0);
+	Vector2 outgoingTangent = normalize(p3 - p2);
+	if(p0 == p1)
+	{
+		incomingTangent = normalize(p2 - p0);
+		if(p1 == p2)
+			incomingTangent = normalize(p3 - p0);
+	}
+	if(p2 == p3)
+	{
+		outgoingTangent = normalize(p3 - p1);
+		if(p1 == p2)
+			outgoingTangent = normalize(p3 - p0);
+	}
+	RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+    m_numTessVertices = 0;
+	unsigned int startFlags = START_SEGMENT;
+	if(!subpathHasGeometry)
+		startFlags |= START_SUBPATH;
+
+	const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+	Vector2 pp = p0;
+	Vector2 tp = incomingTangent;
+	unsigned int prevFlags = startFlags;
+	for(int i=1;i<segments;i++)
+	{
+		RIfloat t = (RIfloat)i / (RIfloat)segments;
+		Vector2 pn = (1.0f - 3.0f*t + 3.0f*t*t - t*t*t) * p0 + (3.0f*t - 6.0f*t*t + 3.0f*t*t*t) * p1 + (3.0f*t*t - 3.0f*t*t*t) * p2 + t*t*t * p3;
+		Vector2 tn = (-3.0f + 6.0f*t - 3.0f*t*t) * p0 + (3.0f - 12.0f*t + 9.0f*t*t) * p1 + (6.0f*t - 9.0f*t*t) * p2 + 3.0f*t*t * p3;
+
+		tn = normalize(tn);
+		if(isZero(tn))
+			tn = tp;
+
+		addEdge(pp, pn, tp, tn, prevFlags, 0);	//throws bad_alloc
+
+		pp = pn;
+		tp = tn;
+		prevFlags = 0;
+	}
+	addEdge(pp, p3, tp, outgoingTangent, prevFlags, END_SEGMENT);	//throws bad_alloc
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Finds an ellipse center and transformation from the unit circle to
+*			that ellipse.
+* \param	rh Length of the horizontal axis
+*			rv Length of the vertical axis
+*			rot Rotation angle
+*			p0,p1 User space end points of the arc
+*			c0,c1 (Return value) Unit circle space center points of the two ellipses
+*			u0,u1 (Return value) Unit circle space end points of the arc
+*			unitCircleToEllipse (Return value) A matrix mapping from unit circle space to user space
+* \return	true if ellipse exists, false if doesn't
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static bool findEllipses(RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p0, const Vector2& p1, VGPathSegment segment, Vector2& c0, Vector2& c1, Vector2& u0, Vector2& u1, Matrix3x3& unitCircleToEllipse, bool& cw)
+{
+	rh = RI_ABS(rh);
+	rv = RI_ABS(rv);
+	if(rh == 0.0f || rv == 0.0f || p0 == p1)
+		return false;	//degenerate ellipse
+
+	rot = RI_DEG_TO_RAD(rot);
+	unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv,  0,
+							(RIfloat)sin(rot)*rh,  (RIfloat)cos(rot)*rv,  0,
+							0,                   0,                   1);
+	Matrix3x3 ellipseToUnitCircle = invert(unitCircleToEllipse);
+	//force affinity
+	ellipseToUnitCircle[2][0] = 0.0f;
+	ellipseToUnitCircle[2][1] = 0.0f;
+	ellipseToUnitCircle[2][2] = 1.0f;
+
+	// Transform p0 and p1 into unit space
+	u0 = affineTransform(ellipseToUnitCircle, p0);
+	u1 = affineTransform(ellipseToUnitCircle, p1);
+
+	Vector2 m = 0.5f * (u0 + u1);
+	Vector2 d = u0 - u1;
+
+	RIfloat lsq = (RIfloat)dot(d,d);
+	if(lsq <= 0.0f)
+		return false;	//the points are coincident
+
+	RIfloat disc = (1.0f / lsq) - 0.25f;
+	if(disc < 0.0f)
+	{	//the points are too far apart for a solution to exist, scale the axes so that there is a solution
+		RIfloat l = (RIfloat)sqrt(lsq);
+		rh *= 0.5f * l;
+		rv *= 0.5f * l;
+
+		//redo the computation with scaled axes
+		unitCircleToEllipse.set((RIfloat)cos(rot)*rh, -(RIfloat)sin(rot)*rv,  0,
+								(RIfloat)sin(rot)*rh,  (RIfloat)cos(rot)*rv,  0,
+								0,                   0,                   1);
+		ellipseToUnitCircle = invert(unitCircleToEllipse);
+		//force affinity
+		ellipseToUnitCircle[2][0] = 0.0f;
+		ellipseToUnitCircle[2][1] = 0.0f;
+		ellipseToUnitCircle[2][2] = 1.0f;
+
+		// Transform p0 and p1 into unit space
+		u0 = affineTransform(ellipseToUnitCircle, p0);
+		u1 = affineTransform(ellipseToUnitCircle, p1);
+
+		// Solve for intersecting unit circles
+		d = u0 - u1;
+		m = 0.5f * (u0 + u1);
+
+		lsq = dot(d,d);
+		if(lsq <= 0.0f)
+			return false;	//the points are coincident
+
+		disc = RI_MAX(0.0f, 1.0f / lsq - 0.25f);
+	}
+
+	if(u0 == u1)
+		return false;
+
+	Vector2 sd = d * (RIfloat)sqrt(disc);
+	Vector2 sp = perpendicularCW(sd);
+	c0 = m + sp;
+	c1 = m - sp;
+
+	//choose the center point and direction
+	Vector2 cp = c0;
+	if(segment == VG_SCWARC_TO || segment == VG_LCCWARC_TO)
+		cp = c1;
+	cw = false;
+	if(segment == VG_SCWARC_TO || segment == VG_LCWARC_TO)
+		cw = true;
+
+	//move the unit circle origin to the chosen center point
+	u0 -= cp;
+	u1 -= cp;
+
+	if(u0 == u1 || isZero(u0) || isZero(u1))
+		return false;
+
+	//transform back to the original coordinate space
+	cp = affineTransform(unitCircleToEllipse, cp);
+	unitCircleToEllipse[0][2] = cp.x;
+	unitCircleToEllipse[1][2] = cp.y;
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates an arc-to segment.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+bool Path::addArcTo(const Matrix3x3& pathToSurface, const Vector2& p0, RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p1, const Vector2& p1r, VGPathSegment segment, bool subpathHasGeometry, float strokeWidth)
+{
+	RI_UNREF(pathToSurface);
+	RI_UNREF(strokeWidth);
+	if(p0 == p1)
+		return false;	//discard zero-length segments
+
+	Vector2 c0, c1, u0, u1;
+	Matrix3x3 unitCircleToEllipse;
+	bool cw;
+
+    m_numTessVertices = 0;
+	unsigned int startFlags = START_SEGMENT;
+	if(!subpathHasGeometry)
+		startFlags |= START_SUBPATH;
+
+	if(!findEllipses(rh, rv, rot, Vector2(), p1r, segment, c0, c1, u0, u1, unitCircleToEllipse, cw))
+	{	//ellipses don't exist, add line instead
+		Vector2 t = normalize(p1r);
+		RI_ASSERT(!isZero(t));
+		addEdge(p0, p1, t, t, startFlags, END_SEGMENT);	//throws bad_alloc
+		return true;
+	}
+
+	//compute end point tangents
+	Vector2 incomingTangent = perpendicular(u0, cw);
+	incomingTangent = affineTangentTransform(unitCircleToEllipse, incomingTangent);
+	incomingTangent = normalize(incomingTangent);
+	Vector2 outgoingTangent = perpendicular(u1, cw);
+	outgoingTangent = affineTangentTransform(unitCircleToEllipse, outgoingTangent);
+	outgoingTangent = normalize(outgoingTangent);
+	RI_ASSERT(!isZero(incomingTangent) && !isZero(outgoingTangent));
+
+	const int segments = RI_NUM_TESSELLATED_SEGMENTS;
+	Vector2 pp = p0;
+	Vector2 tp = incomingTangent;
+	unsigned int prevFlags = startFlags;
+	for(int i=1;i<segments;i++)
+	{
+		RIfloat t = (RIfloat)i / (RIfloat)segments;
+		Vector2 pn = circularLerp(u0, u1, t, cw);
+		Vector2 tn = perpendicular(pn, cw);
+		tn = affineTangentTransform(unitCircleToEllipse, tn);
+		pn = affineTransform(unitCircleToEllipse, pn) + p0;
+		tn = normalize(tn);
+		if(isZero(tn))
+			tn = tp;
+
+		addEdge(pp, pn, tp, tn, prevFlags, 0);	//throws bad_alloc
+
+		pp = pn;
+		tp = tn;
+		prevFlags = 0;
+	}
+	addEdge(pp, p1, tp, outgoingTangent, prevFlags, END_SEGMENT);	//throws bad_alloc
+	return true;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Tessellates a path.
+* \param	
+* \return	
+* \note		tessellation output format: A list of vertices describing the
+*			path tessellated into line segments and relevant aspects of the
+*			input data. Each path segment has a start vertex, a number of
+*			internal vertices (possibly zero), and an end vertex. The start
+*			and end of segments and subpaths have been flagged, as well as
+*			implicit and explicit close subpath segments.
+*//*-------------------------------------------------------------------*/
+
+void Path::tessellate(const Matrix3x3& pathToSurface, float strokeWidth)
+{
+	m_vertices.clear();
+
+	m_userMinx = RI_FLOAT_MAX;
+	m_userMiny = RI_FLOAT_MAX;
+	m_userMaxx = -RI_FLOAT_MAX;
+	m_userMaxy = -RI_FLOAT_MAX;
+
+	try
+	{
+		m_segmentToVertex.resize(m_segments.size());
+
+		int coordIndex = 0;
+		Vector2 s(0,0);		//the beginning of the current subpath
+		Vector2 o(0,0);		//the last point of the previous segment
+		Vector2 p(0,0);		//the last internal control point of the previous segment, if the segment was a (regular or smooth) quadratic or cubic Bezier, or else the last point of the previous segment
+
+		//tessellate the path segments
+		coordIndex = 0;
+		s.set(0,0);
+		o.set(0,0);
+		p.set(0,0);
+		bool subpathHasGeometry = false;
+		VGPathSegment prevSegment = VG_MOVE_TO;
+		for(int i=0;i<m_segments.size();i++)
+		{
+			VGPathSegment segment = getPathSegment(m_segments[i]);
+			VGPathAbsRel absRel = getPathAbsRel(m_segments[i]);
+			int coords = segmentToNumCoordinates(segment);
+			m_segmentToVertex[i].start = m_vertices.size();
+
+			switch(segment)
+			{
+			case VG_CLOSE_PATH:
+			{
+				RI_ASSERT(coords == 0);
+				addEndPath(pathToSurface, o, s, subpathHasGeometry, CLOSE_SUBPATH);
+				p = s;
+				o = s;
+				subpathHasGeometry = false;
+				break;
+			}
+
+			case VG_MOVE_TO:
+			{
+				RI_ASSERT(coords == 2);
+				Vector2 c(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				if(absRel == VG_RELATIVE)
+					c += o;
+				if(prevSegment != VG_MOVE_TO && prevSegment != VG_CLOSE_PATH)
+					addEndPath(pathToSurface, o, s, subpathHasGeometry, IMPLICIT_CLOSE_SUBPATH);
+				s = c;
+				p = c;
+				o = c;
+				subpathHasGeometry = false;
+				break;
+			}
+
+			case VG_LINE_TO:
+			{
+				RI_ASSERT(coords == 2);
+				Vector2 c(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				if(absRel == VG_RELATIVE)
+					c += o;
+				if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+					subpathHasGeometry = true;
+				p = c;
+				o = c;
+				break;
+			}
+
+			case VG_HLINE_TO:
+			{
+				RI_ASSERT(coords == 1);
+				Vector2 c(getCoordinate(coordIndex+0), o.y);
+				if(absRel == VG_RELATIVE)
+					c.x += o.x;
+				if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+					subpathHasGeometry = true;
+				p = c;
+				o = c;
+				break;
+			}
+
+			case VG_VLINE_TO:
+			{
+				RI_ASSERT(coords == 1);
+				Vector2 c(o.x, getCoordinate(coordIndex+0));
+				if(absRel == VG_RELATIVE)
+					c.y += o.y;
+				if(addLineTo(pathToSurface, o, c, subpathHasGeometry))
+					subpathHasGeometry = true;
+				p = c;
+				o = c;
+				break;
+			}
+
+			case VG_QUAD_TO:
+			{
+				RI_ASSERT(coords == 4);
+				Vector2 c0(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				Vector2 c1(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+				if(absRel == VG_RELATIVE)
+				{
+					c0 += o;
+					c1 += o;
+				}
+				if(addQuadTo(pathToSurface, o, c0, c1, subpathHasGeometry, strokeWidth))
+					subpathHasGeometry = true;
+				p = c0;
+				o = c1;
+				break;
+			}
+
+			case VG_SQUAD_TO:
+			{
+				RI_ASSERT(coords == 2);
+				Vector2 c0 = 2.0f * o - p;
+				Vector2 c1(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				if(absRel == VG_RELATIVE)
+					c1 += o;
+				if(addQuadTo(pathToSurface, o, c0, c1, subpathHasGeometry, strokeWidth))
+					subpathHasGeometry = true;
+				p = c0;
+				o = c1;
+				break;
+			}
+
+			case VG_CUBIC_TO:
+			{
+				RI_ASSERT(coords == 6);
+				Vector2 c0(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				Vector2 c1(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+				Vector2 c2(getCoordinate(coordIndex+4), getCoordinate(coordIndex+5));
+				if(absRel == VG_RELATIVE)
+				{
+					c0 += o;
+					c1 += o;
+					c2 += o;
+				}
+				if(addCubicTo(pathToSurface, o, c0, c1, c2, subpathHasGeometry, strokeWidth))
+					subpathHasGeometry = true;
+				p = c1;
+				o = c2;
+				break;
+			}
+
+			case VG_SCUBIC_TO:
+			{
+				RI_ASSERT(coords == 4);
+				Vector2 c0 = 2.0f * o - p;
+				Vector2 c1(getCoordinate(coordIndex+0), getCoordinate(coordIndex+1));
+				Vector2 c2(getCoordinate(coordIndex+2), getCoordinate(coordIndex+3));
+				if(absRel == VG_RELATIVE)
+				{
+					c1 += o;
+					c2 += o;
+				}
+				if(addCubicTo(pathToSurface, o, c0, c1, c2, subpathHasGeometry, strokeWidth))
+					subpathHasGeometry = true;
+				p = c1;
+				o = c2;
+				break;
+			}
+
+			default:
+			{
+				RI_ASSERT(segment == VG_SCCWARC_TO || segment == VG_SCWARC_TO ||
+						  segment == VG_LCCWARC_TO || segment == VG_LCWARC_TO);
+				RI_ASSERT(coords == 5);
+				RIfloat rh = getCoordinate(coordIndex+0);
+				RIfloat rv = getCoordinate(coordIndex+1);
+				RIfloat rot = getCoordinate(coordIndex+2);
+				Vector2 c(getCoordinate(coordIndex+3), getCoordinate(coordIndex+4));
+
+                Vector2 cr = c;
+				if(absRel == VG_ABSOLUTE)
+                    cr -= o;
+                else
+					c += o;
+
+				if(addArcTo(pathToSurface, o, rh, rv, rot, c, cr, segment, subpathHasGeometry, strokeWidth))
+					subpathHasGeometry = true;
+				p = c;
+				o = c;
+				break;
+			}
+			}
+
+			if(m_vertices.size() > m_segmentToVertex[i].start)
+			{	//segment produced vertices
+				m_segmentToVertex[i].end = m_vertices.size() - 1;
+			}
+			else
+			{	//segment didn't produce vertices (zero-length segment). Ignore it.
+				m_segmentToVertex[i].start = m_segmentToVertex[i].end = m_vertices.size()-1;
+			}
+			prevSegment = segment;
+			coordIndex += coords;
+		}
+
+		//add an implicit MOVE_TO to the end to close the last subpath.
+		//if the subpath contained only zero-length segments, this produces the necessary geometry to get it stroked
+		// and included in path bounds. The geometry won't be included in the pointAlongPath query.
+		if(prevSegment != VG_MOVE_TO && prevSegment != VG_CLOSE_PATH)
+			addEndPath(pathToSurface, o, s, subpathHasGeometry, IMPLICIT_CLOSE_SUBPATH);
+
+		//check that the flags are correct
+#ifdef RI_DEBUG
+		int prev = -1;
+		bool subpathStarted = false;
+		bool segmentStarted = false;
+		for(int i=0;i<m_vertices.size();i++)
+		{
+			Vertex& v = m_vertices[i];
+
+			if(v.flags & START_SUBPATH)
+			{
+				RI_ASSERT(!subpathStarted);
+				RI_ASSERT(v.flags & START_SEGMENT);
+				RI_ASSERT(!(v.flags & END_SUBPATH));
+				RI_ASSERT(!(v.flags & END_SEGMENT));
+				RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+				RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+				subpathStarted = true;
+			}
+			
+			if(v.flags & START_SEGMENT)
+			{
+				RI_ASSERT(subpathStarted || (v.flags & CLOSE_SUBPATH) || (v.flags & IMPLICIT_CLOSE_SUBPATH));
+				RI_ASSERT(!segmentStarted);
+				RI_ASSERT(!(v.flags & END_SUBPATH));
+				RI_ASSERT(!(v.flags & END_SEGMENT));
+				segmentStarted = true;
+			}
+			
+			if( v.flags & CLOSE_SUBPATH )
+			{
+				RI_ASSERT(segmentStarted);
+				RI_ASSERT(!subpathStarted);
+				RI_ASSERT((v.flags & START_SEGMENT) || (v.flags & END_SEGMENT));
+				RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+				RI_ASSERT(!(v.flags & START_SUBPATH));
+				RI_ASSERT(!(v.flags & END_SUBPATH));
+			}
+			if( v.flags & IMPLICIT_CLOSE_SUBPATH )
+			{
+				RI_ASSERT(segmentStarted);
+				RI_ASSERT(!subpathStarted);
+				RI_ASSERT((v.flags & START_SEGMENT) || (v.flags & END_SEGMENT));
+				RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+				RI_ASSERT(!(v.flags & START_SUBPATH));
+				RI_ASSERT(!(v.flags & END_SUBPATH));
+			}
+			
+			if( prev >= 0 )
+			{
+				RI_ASSERT(segmentStarted);
+				RI_ASSERT(subpathStarted || ((m_vertices[prev].flags & CLOSE_SUBPATH) && (m_vertices[i].flags & CLOSE_SUBPATH)) ||
+						  ((m_vertices[prev].flags & IMPLICIT_CLOSE_SUBPATH) && (m_vertices[i].flags & IMPLICIT_CLOSE_SUBPATH)));
+			}
+
+			prev = i;
+			if(v.flags & END_SEGMENT)
+			{
+				RI_ASSERT(subpathStarted || (v.flags & CLOSE_SUBPATH) || (v.flags & IMPLICIT_CLOSE_SUBPATH));
+				RI_ASSERT(segmentStarted);
+				RI_ASSERT(!(v.flags & START_SUBPATH));
+				RI_ASSERT(!(v.flags & START_SEGMENT));
+				segmentStarted = false;
+				prev = -1;
+			}
+			
+			if(v.flags & END_SUBPATH)
+			{
+				RI_ASSERT(subpathStarted);
+				RI_ASSERT(v.flags & END_SEGMENT);
+				RI_ASSERT(!(v.flags & START_SUBPATH));
+				RI_ASSERT(!(v.flags & START_SEGMENT));
+				RI_ASSERT(!(v.flags & CLOSE_SUBPATH));
+				RI_ASSERT(!(v.flags & IMPLICIT_CLOSE_SUBPATH));
+				subpathStarted = false;
+			}
+		}
+#endif	//RI_DEBUG
+	}
+	catch(std::bad_alloc)
+	{
+		m_vertices.clear();
+		throw;
+	}
+}
+
+//==============================================================================================
+
+}		//namespace OpenVGRI
+
+//==============================================================================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riPath.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,188 @@
+#ifndef __RIPATH_H
+#define __RIPATH_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Path class.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef _OPENVG_H
+#include "openvg.h"
+#endif
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIARRAY_H
+#include "riArray.h"
+#endif
+
+#ifndef __RIRASTERIZER_H
+#include "riRasterizer.h"
+#endif
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Storage and operations for VGPath.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Path
+{
+public:
+	Path(VGint format, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int segmentCapacityHint, int coordCapacityHint, VGbitfield caps);	//throws bad_alloc
+	~Path();
+
+	VGint				getFormat() const						{ return m_format; }
+	VGPathDatatype		getDatatype() const						{ return m_datatype; }
+	RIfloat				getScale() const						{ return m_scale; }
+	RIfloat				getBias() const							{ return m_bias; }
+	VGbitfield			getCapabilities() const					{ return m_capabilities; }
+	void				setCapabilities(VGbitfield caps)		{ m_capabilities = caps; }
+	int					getNumSegments() const					{ return m_segments.size(); }
+	int					getNumCoordinates() const				{ return m_data.size() / getBytesPerCoordinate(m_datatype); }
+	void				addReference()							{ m_referenceCount++; }
+	int					removeReference()						{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+	void				clear(VGbitfield capabilities);
+	void				appendData(const RIuint8* segments, int numSegments, const RIuint8* data);	//throws bad_alloc
+	void				append(const Path* srcPath);	//throws bad_alloc
+	void				modifyCoords(int startIndex, int numSegments, const RIuint8* data);
+	void				transform(const Path* srcPath, const Matrix3x3& matrix);	//throws bad_alloc
+	//returns true if interpolation succeeds, false if start and end paths are not compatible
+	bool				interpolate(const Path* startPath, const Path* endPath, RIfloat amount);	//throws bad_alloc
+	void				fill(const Matrix3x3& pathToSurface, Rasterizer& rasterizer);	//throws bad_alloc
+	void				stroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const Array<RIfloat>& dashPattern, RIfloat dashPhase, bool dashPhaseReset, RIfloat strokeWidth, VGCapStyle capStyle, VGJoinStyle joinStyle, RIfloat miterLimit);	//throws bad_alloc
+
+	void				getPointAlong(int startIndex, int numSegments, RIfloat distance, Vector2& p, Vector2& t);	//throws bad_alloc
+	RIfloat				getPathLength(int startIndex, int numSegments);	//throws bad_alloc
+	void				getPathBounds(RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy);	//throws bad_alloc
+	void				getPathTransformedBounds(const Matrix3x3& pathToSurface, RIfloat& minx, RIfloat& miny, RIfloat& maxx, RIfloat& maxy);	//throws bad_alloc
+
+private:
+	enum VertexFlags
+	{
+		START_SUBPATH			= (1<<0),
+		END_SUBPATH				= (1<<1),
+		START_SEGMENT			= (1<<2),
+		END_SEGMENT				= (1<<3),
+		CLOSE_SUBPATH			= (1<<4),
+		IMPLICIT_CLOSE_SUBPATH	= (1<<5)
+	};
+	struct Vertex
+	{
+		Vertex() : userPosition(), userTangent(), pathLength(0.0f), flags(0) {}
+		Vector2			userPosition;
+		Vector2			userTangent;
+		RIfloat			pathLength;
+		unsigned int	flags;
+	};
+	struct StrokeVertex
+	{
+		StrokeVertex() : p(), t(), ccw(), cw(), pathLength(0.0f), flags(0), inDash(false) {}
+		Vector2			p;
+		Vector2			t;
+		Vector2			ccw;
+		Vector2			cw;
+		RIfloat			pathLength;
+		unsigned int	flags;
+		bool			inDash;
+	};
+
+	Path(const Path&);						//!< Not allowed.
+	const Path& operator=(const Path&);		//!< Not allowed.
+
+	static VGPathSegment getPathSegment(RIuint8 data)				{ return (VGPathSegment)(data & 0x1e); }
+	static VGPathAbsRel	getPathAbsRel(RIuint8 data)					{ return (VGPathAbsRel)(data & 0x1); }
+	static int			segmentToNumCoordinates(VGPathSegment segment);
+	static int			countNumCoordinates(const RIuint8* segments, int numSegments);
+	static int			getBytesPerCoordinate(VGPathDatatype datatype);
+
+	static void			setCoordinate(Array<RIuint8>& data, VGPathDatatype datatype, RIfloat scale, RIfloat bias, int i, RIfloat c);
+
+	RIfloat				getCoordinate(int i) const;
+	void				setCoordinate(int i, RIfloat c)				{ setCoordinate(m_data, m_datatype, m_scale, m_bias, i, c); }
+
+	void				addVertex(const Vector2& p, const Vector2& t, RIfloat pathLength, unsigned int flags);	//throws bad_alloc
+	void				addEdge(const Vector2& p0, const Vector2& p1, const Vector2& t0, const Vector2& t1, unsigned int startFlags, unsigned int endFlags);	//throws bad_alloc
+
+	void				addEndPath(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry, unsigned int flags);	//throws bad_alloc
+	bool				addLineTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, bool subpathHasGeometry);	//throws bad_alloc
+	bool				addQuadTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, bool subpathHasGeometry, float strokeWidth);	//throws bad_alloc
+	bool				addCubicTo(const Matrix3x3& pathToSurface, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, bool subpathHasGeometry, float strokeWidth);	//throws bad_alloc
+	bool				addArcTo(const Matrix3x3& pathToSurface, const Vector2& p0, RIfloat rh, RIfloat rv, RIfloat rot, const Vector2& p1, const Vector2& p1r, VGPathSegment segment, bool subpathHasGeometry, float strokeWidth);	//throws bad_alloc
+
+	void				tessellate(const Matrix3x3& pathToSurface, float strokeWidth);	//throws bad_alloc
+
+	void				normalizeForInterpolation(const Path* srcPath);	//throws bad_alloc
+
+	void				interpolateStroke(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth) const;	//throws bad_alloc
+	void				doCap(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v, RIfloat strokeWidth, VGCapStyle capStyle) const;	//throws bad_alloc
+	void				doJoin(const Matrix3x3& pathToSurface, Rasterizer& rasterizer, const StrokeVertex& v0, const StrokeVertex& v1, RIfloat strokeWidth, VGJoinStyle joinStyle, RIfloat miterLimit) const;	//throws bad_alloc
+
+	//input data
+	VGint				m_format;
+	VGPathDatatype		m_datatype;
+	RIfloat				m_scale;
+	RIfloat				m_bias;
+	VGbitfield			m_capabilities;
+	int					m_referenceCount;
+	Array<RIuint8>		m_segments;
+	Array<RIuint8>		m_data;
+
+	//data produced by tessellation
+	struct VertexIndex
+	{
+		int		start;
+		int		end;
+	};
+	Array<Vertex>		m_vertices;
+    int                 m_numTessVertices;
+	Array<VertexIndex>	m_segmentToVertex;
+	RIfloat				m_userMinx;
+	RIfloat				m_userMiny;
+	RIfloat				m_userMaxx;
+	RIfloat				m_userMaxy;
+};
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+//==============================================================================================
+
+#endif /* __RIPATH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riPixelPipe.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,894 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief   Implementation of Paint and pixel pipe functionality.
+ * \note    
+ *//*-------------------------------------------------------------------*/
+
+#include "riPixelPipe.h"
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Paint constructor.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+Paint::Paint() :
+    m_paintType(VG_PAINT_TYPE_COLOR),
+    m_paintColor(0,0,0,1,Color::sRGBA_PRE),
+    m_inputPaintColor(0,0,0,1,Color::sRGBA),
+    m_colorRampSpreadMode(VG_COLOR_RAMP_SPREAD_PAD),
+    m_colorRampStops(),
+    m_inputColorRampStops(),
+    m_colorRampPremultiplied(VG_TRUE),
+    m_inputLinearGradientPoint0(0,0),
+    m_inputLinearGradientPoint1(1,0),
+    m_inputRadialGradientCenter(0,0),
+    m_inputRadialGradientFocalPoint(0,0),
+    m_inputRadialGradientRadius(1.0f),
+    m_linearGradientPoint0(0,0),
+    m_linearGradientPoint1(1,0),
+    m_radialGradientCenter(0,0),
+    m_radialGradientFocalPoint(0,0),
+    m_radialGradientRadius(1.0f),
+    m_patternTilingMode(VG_TILE_FILL),
+    m_pattern(NULL),
+    m_referenceCount(0)
+{
+    Paint::GradientStop gs;
+    gs.offset = 0.0f;
+    gs.color.set(0,0,0,1,Color::sRGBA);
+    m_colorRampStops.push_back(gs); //throws bad_alloc
+    gs.offset = 1.0f;
+    gs.color.set(1,1,1,1,Color::sRGBA);
+    m_colorRampStops.push_back(gs); //throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Paint destructor.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+Paint::~Paint()
+{
+    RI_ASSERT(m_referenceCount == 0);
+    if(m_pattern)
+    {
+        m_pattern->removeInUse();
+        if(!m_pattern->removeReference())
+            RI_DELETE(m_pattern);
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    PixelPipe constructor.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+PixelPipe::PixelPipe() :
+    m_drawable(NULL),
+    m_image(NULL),
+    m_paint(NULL),
+    m_defaultPaint(),
+    m_blendMode(VG_BLEND_SRC_OVER),
+    m_imageMode(VG_DRAW_IMAGE_NORMAL),
+    m_imageQuality(VG_IMAGE_QUALITY_FASTER),
+    m_tileFillColor(0,0,0,0,Color::sRGBA),
+    m_colorTransform(false),
+    m_colorTransformValues(),
+    m_surfaceToPaintMatrix(),
+    m_surfaceToImageMatrix()
+{
+    for(int i=0;i<8;i++)
+        m_colorTransformValues[i] = (i < 4) ? 1.0f : 0.0f;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    PixelPipe destructor.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+PixelPipe::~PixelPipe()
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the rendering surface.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setDrawable(Drawable* drawable)
+{
+    RI_ASSERT(drawable);
+    m_drawable = drawable;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the blend mode.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setBlendMode(VGBlendMode blendMode)
+{
+    RI_ASSERT(blendMode >= VG_BLEND_SRC && blendMode <= VG_BLEND_ADDITIVE);
+    m_blendMode = blendMode;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the mask image. NULL disables masking.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setMask(bool masking)
+{
+    m_masking = masking;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the image to be drawn. NULL disables image drawing.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setImage(Image* image, VGImageMode imageMode)
+{
+    RI_ASSERT(imageMode == VG_DRAW_IMAGE_NORMAL || imageMode == VG_DRAW_IMAGE_MULTIPLY || imageMode == VG_DRAW_IMAGE_STENCIL);
+    m_image = image;
+    m_imageMode = imageMode;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the surface-to-paint matrix.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setSurfaceToPaintMatrix(const Matrix3x3& surfaceToPaintMatrix)
+{
+    m_surfaceToPaintMatrix = surfaceToPaintMatrix;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets the surface-to-image matrix.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setSurfaceToImageMatrix(const Matrix3x3& surfaceToImageMatrix)
+{
+    m_surfaceToImageMatrix = surfaceToImageMatrix;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets image quality.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setImageQuality(VGImageQuality imageQuality)
+{
+    RI_ASSERT(imageQuality == VG_IMAGE_QUALITY_NONANTIALIASED || imageQuality == VG_IMAGE_QUALITY_FASTER || imageQuality == VG_IMAGE_QUALITY_BETTER);
+    m_imageQuality = imageQuality;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets fill color for VG_TILE_FILL tiling mode (pattern only).
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setTileFillColor(const Color& c)
+{
+    m_tileFillColor = c;
+    m_tileFillColor.clamp();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Sets paint.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setPaint(const Paint* paint)
+{
+    m_paint = paint;
+    if(!m_paint)
+        m_paint = &m_defaultPaint;
+    if(m_paint->m_pattern)
+        m_tileFillColor.convert(m_paint->m_pattern->getDescriptor().internalFormat);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Color transform.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::setColorTransform(bool enable, RIfloat values[8])
+{
+    m_colorTransform = enable;
+    for(int i=0;i<4;i++)
+    {
+        m_colorTransformValues[i] = RI_CLAMP(values[i], -127.0f, 127.0f);
+        m_colorTransformValues[i+4] = RI_CLAMP(values[i+4], -1.0f, 1.0f);
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Computes the linear gradient function at (x,y).
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::linearGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const
+{
+    RI_ASSERT(m_paint);
+    Vector2 u = m_paint->m_linearGradientPoint1 - m_paint->m_linearGradientPoint0;
+    RIfloat usq = dot(u,u);
+    if( usq <= 0.0f )
+    {   //points are equal, gradient is always 1.0f
+        g = 1.0f;
+        rho = 0.0f;
+        return;
+    }
+    RIfloat oou = 1.0f / usq;
+
+    Vector2 p(x, y);
+    p = affineTransform(m_surfaceToPaintMatrix, p);
+    p -= m_paint->m_linearGradientPoint0;
+    RI_ASSERT(usq >= 0.0f);
+    g = dot(p, u) * oou;
+    RIfloat dgdx = oou * u.x * m_surfaceToPaintMatrix[0][0] + oou * u.y * m_surfaceToPaintMatrix[1][0];
+    RIfloat dgdy = oou * u.x * m_surfaceToPaintMatrix[0][1] + oou * u.y * m_surfaceToPaintMatrix[1][1];
+    rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy);
+    RI_ASSERT(rho >= 0.0f);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Computes the radial gradient function at (x,y).
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::radialGradient(RIfloat &g, RIfloat &rho, RIfloat x, RIfloat y) const
+{
+    RI_ASSERT(m_paint);
+    if( m_paint->m_radialGradientRadius <= 0.0f )
+    {
+        g = 1.0f;
+        rho = 0.0f;
+        return;
+    }
+
+    RIfloat r = m_paint->m_radialGradientRadius;
+    Vector2 c = m_paint->m_radialGradientCenter;
+    Vector2 f = m_paint->m_radialGradientFocalPoint;
+    Vector2 gx(m_surfaceToPaintMatrix[0][0], m_surfaceToPaintMatrix[1][0]);
+    Vector2 gy(m_surfaceToPaintMatrix[0][1], m_surfaceToPaintMatrix[1][1]);
+
+    Vector2 fp = f - c;
+
+    //clamp the focal point inside the gradient circle
+    RIfloat fpLen = fp.length();
+    if( fpLen > 0.999f * r )
+        fp *= 0.999f * r / fpLen;
+
+    RIfloat D = -1.0f / (dot(fp,fp) - r*r);
+    Vector2 p(x, y);
+    p = affineTransform(m_surfaceToPaintMatrix, p) - c;
+    Vector2 d = p - fp;
+    RIfloat s = (RIfloat)sqrt(r*r*dot(d,d) - RI_SQR(p.x*fp.y - p.y*fp.x));
+    g = (dot(fp,d) + s) * D;
+    if(RI_ISNAN(g))
+        g = 0.0f;
+    RIfloat dgdx = D*dot(fp,gx) + (r*r*dot(d,gx) - (gx.x*fp.y - gx.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s);
+    RIfloat dgdy = D*dot(fp,gy) + (r*r*dot(d,gy) - (gy.x*fp.y - gy.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s);
+    rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy);
+    if(RI_ISNAN(rho))
+        rho = 0.0f;
+    RI_ASSERT(rho >= 0.0f);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Returns the average color within an offset range in the color ramp.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+static Color readStopColor(const Array<Paint::GradientStop>& colorRampStops, int i, VGboolean colorRampPremultiplied)
+{
+    RI_ASSERT(i >= 0 && i < colorRampStops.size());
+    Color c = colorRampStops[i].color;
+    RI_ASSERT(c.getInternalFormat() == Color::sRGBA);
+    if(colorRampPremultiplied)
+        c.premultiply();
+    return c;
+}
+
+Color PixelPipe::integrateColorRamp(RIfloat gmin, RIfloat gmax) const
+{
+    RI_ASSERT(gmin <= gmax);
+    RI_ASSERT(gmin >= 0.0f && gmin <= 1.0f);
+    RI_ASSERT(gmax >= 0.0f && gmax <= 1.0f);
+    RI_ASSERT(m_paint->m_colorRampStops.size() >= 2);   //there are at least two stops
+
+    Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA);
+    if(gmin == 1.0f || gmax == 0.0f)
+        return c;
+
+    int i=0;
+    for(;i<m_paint->m_colorRampStops.size()-1;i++)
+    {
+        if(gmin >= m_paint->m_colorRampStops[i].offset && gmin < m_paint->m_colorRampStops[i+1].offset)
+        {
+            RIfloat s = m_paint->m_colorRampStops[i].offset;
+            RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+            RI_ASSERT(s < e);
+            RIfloat g = (gmin - s) / (e - s);
+
+            Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+            Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+            Color rc = (1.0f-g) * sc + g * ec;
+
+            //subtract the average color from the start of the stop to gmin
+            c -= 0.5f*(gmin - s)*(sc + rc);
+            break;
+        }
+    }
+
+    for(;i<m_paint->m_colorRampStops.size()-1;i++)
+    {
+        RIfloat s = m_paint->m_colorRampStops[i].offset;
+        RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+        RI_ASSERT(s <= e);
+
+        Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+        Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+
+        //average of the stop
+        c += 0.5f*(e-s)*(sc + ec);
+
+        if(gmax >= m_paint->m_colorRampStops[i].offset && gmax < m_paint->m_colorRampStops[i+1].offset)
+        {
+            RIfloat g = (gmax - s) / (e - s);
+            Color rc = (1.0f-g) * sc + g * ec;
+
+            //subtract the average color from gmax to the end of the stop
+            c -= 0.5f*(e - gmax)*(rc + ec);
+            break;
+        }
+    }
+    return c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Maps a gradient function value to a color.
+* \param    
+* \return   
+* \note     
+*//*-------------------------------------------------------------------*/
+
+Color PixelPipe::colorRamp(RIfloat gradient, RIfloat rho) const
+{
+    RI_ASSERT(m_paint);
+    RI_ASSERT(rho >= 0.0f);
+
+    Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA);
+    Color avg;
+
+    if(rho == 0.0f)
+    {   //filter size is zero or gradient is degenerate
+        switch(m_paint->m_colorRampSpreadMode)
+        {
+        case VG_COLOR_RAMP_SPREAD_PAD:
+            gradient = RI_CLAMP(gradient, 0.0f, 1.0f);
+            break;
+        case VG_COLOR_RAMP_SPREAD_REFLECT:
+        {
+            RIfloat g = RI_MOD(gradient, 2.0f);
+            gradient = (g < 1.0f) ? g : 2.0f - g;
+            break;
+        }
+        default:
+            RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT);
+            gradient = gradient - (RIfloat)floor(gradient);
+            break;
+        }
+        RI_ASSERT(gradient >= 0.0f && gradient <= 1.0f);
+
+        for(int i=0;i<m_paint->m_colorRampStops.size()-1;i++)
+        {
+            if(gradient >= m_paint->m_colorRampStops[i].offset && gradient < m_paint->m_colorRampStops[i+1].offset)
+            {
+                RIfloat s = m_paint->m_colorRampStops[i].offset;
+                RIfloat e = m_paint->m_colorRampStops[i+1].offset;
+                RI_ASSERT(s < e);
+                RIfloat g = RI_CLAMP((gradient - s) / (e - s), 0.0f, 1.0f); //clamp needed due to numerical inaccuracies
+
+                Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied);
+                Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied);
+                return (1.0f-g) * sc + g * ec;  //return interpolated value
+            }
+        }
+        return readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied);
+    }
+
+    RIfloat gmin = gradient - rho*0.5f;         //filter starting from the gradient point (if starts earlier, radial gradient center will be an average of the first and the last stop, which doesn't look good)
+    RIfloat gmax = gradient + rho*0.5f;
+
+    switch(m_paint->m_colorRampSpreadMode)
+    {
+    case VG_COLOR_RAMP_SPREAD_PAD:
+    {
+        if(gmin < 0.0f)
+            c += (RI_MIN(gmax, 0.0f) - gmin) * readStopColor(m_paint->m_colorRampStops, 0, m_paint->m_colorRampPremultiplied);
+        if(gmax > 1.0f)
+            c += (gmax - RI_MAX(gmin, 1.0f)) * readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied);
+        gmin = RI_CLAMP(gmin, 0.0f, 1.0f);
+        gmax = RI_CLAMP(gmax, 0.0f, 1.0f);
+        c += integrateColorRamp(gmin, gmax);
+        c *= 1.0f/rho;
+        c.clamp();  //clamp needed due to numerical inaccuracies
+        return c;
+    }
+
+    case VG_COLOR_RAMP_SPREAD_REFLECT:
+    {
+        avg = integrateColorRamp(0.0f, 1.0f);
+        RIfloat gmini = (RIfloat)floor(gmin);
+        RIfloat gmaxi = (RIfloat)floor(gmax);
+        c = (gmaxi + 1.0f - gmini) * avg;       //full ramps
+
+        //subtract beginning
+        if(((int)gmini) & 1)
+            c -= integrateColorRamp(RI_CLAMP(1.0f - (gmin - gmini), 0.0f, 1.0f), 1.0f);
+        else
+            c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f));
+
+        //subtract end
+        if(((int)gmaxi) & 1)
+            c -= integrateColorRamp(0.0f, RI_CLAMP(1.0f - (gmax - gmaxi), 0.0f, 1.0f));
+        else
+            c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f);
+        break;
+    }
+
+    default:
+    {
+        RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT);
+        avg = integrateColorRamp(0.0f, 1.0f);
+        RIfloat gmini = (RIfloat)floor(gmin);
+        RIfloat gmaxi = (RIfloat)floor(gmax);
+        c = (gmaxi + 1.0f - gmini) * avg;       //full ramps
+        c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f));  //subtract beginning
+        c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f);  //subtract end
+        break;
+    }
+    }
+
+    //divide color by the length of the range
+    c *= 1.0f / rho;
+    c.clamp();  //clamp needed due to numerical inaccuracies
+
+    //hide aliasing by fading to the average color
+    const RIfloat fadeStart = 0.5f;
+    const RIfloat fadeMultiplier = 2.0f;    //the larger, the earlier fade to average is done
+
+    if(rho < fadeStart)
+        return c;
+
+    RIfloat ratio = RI_MIN((rho - fadeStart) * fadeMultiplier, 1.0f);
+    return ratio * avg + (1.0f - ratio) * c;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Computes blend.
+* \param    
+* \return   
+* \note     premultiplied blending formulas
+            //src
+            a = asrc
+            r = rsrc
+            //src over
+            a = asrc + adst * (1-asrc)
+            r = rsrc + rdst * (1-asrc)
+            //dst over
+            a = asrc * (1-adst) + adst
+            r = rsrc * (1-adst) + adst
+            //src in
+            a = asrc * adst
+            r = rsrc * adst
+            //dst in
+            a = adst * asrc
+            r = rdst * asrc
+            //multiply
+            a = asrc + adst * (1-asrc)
+            r = rsrc * (1-adst) + rdst * (1-asrc) + rsrc * rdst
+            //screen
+            a = asrc + adst * (1-asrc)
+            r = rsrc + rdst - rsrc * rdst
+            //darken
+            a = asrc + adst * (1-asrc)
+            r = MIN(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst))
+            //lighten
+            a = asrc + adst * (1-asrc)
+            r = MAX(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst))
+            //additive
+            a = MIN(asrc+adst,1)
+            r = rsrc + rdst
+*//*-------------------------------------------------------------------*/
+
+Color PixelPipe::blend(const Color& s, RIfloat ar, RIfloat ag, RIfloat ab, const Color& d, VGBlendMode blendMode) const
+{
+    //apply blending in the premultiplied format
+    Color r(0,0,0,0,d.getInternalFormat());
+    RI_ASSERT(s.a >= 0.0f && s.a <= 1.0f);
+    RI_ASSERT(s.r >= 0.0f && s.r <= s.a && s.r <= ar);
+    RI_ASSERT(s.g >= 0.0f && s.g <= s.a && s.g <= ag);
+    RI_ASSERT(s.b >= 0.0f && s.b <= s.a && s.b <= ab);
+    RI_ASSERT(d.a >= 0.0f && d.a <= 1.0f);
+    RI_ASSERT(d.r >= 0.0f && d.r <= d.a);
+    RI_ASSERT(d.g >= 0.0f && d.g <= d.a);
+    RI_ASSERT(d.b >= 0.0f && d.b <= d.a);
+    switch(blendMode)
+    {
+    case VG_BLEND_SRC:
+        r = s;
+        break;
+
+    case VG_BLEND_SRC_OVER:
+        r.r = s.r + d.r * (1.0f - ar);
+        r.g = s.g + d.g * (1.0f - ag);
+        r.b = s.b + d.b * (1.0f - ab);
+        r.a = s.a + d.a * (1.0f - s.a);
+        break;
+
+    case VG_BLEND_DST_OVER:
+        r.r = s.r * (1.0f - d.a) + d.r;
+        r.g = s.g * (1.0f - d.a) + d.g;
+        r.b = s.b * (1.0f - d.a) + d.b;
+        r.a = s.a * (1.0f - d.a) + d.a;
+        break;
+
+    case VG_BLEND_SRC_IN:
+        r.r = s.r * d.a;
+        r.g = s.g * d.a;
+        r.b = s.b * d.a;
+        r.a = s.a * d.a;
+        break;
+
+    case VG_BLEND_DST_IN:
+        r.r = d.r * ar;
+        r.g = d.g * ag;
+        r.b = d.b * ab;
+        r.a = d.a * s.a;
+        break;
+
+    case VG_BLEND_MULTIPLY:
+        r.r = s.r * (1.0f - d.a + d.r) + d.r * (1.0f - ar);
+        r.g = s.g * (1.0f - d.a + d.g) + d.g * (1.0f - ag);
+        r.b = s.b * (1.0f - d.a + d.b) + d.b * (1.0f - ab);
+        r.a = s.a + d.a * (1.0f - s.a);
+        break;
+
+    case VG_BLEND_SCREEN:
+        r.r = s.r + d.r * (1.0f - s.r);
+        r.g = s.g + d.g * (1.0f - s.g);
+        r.b = s.b + d.b * (1.0f - s.b);
+        r.a = s.a + d.a * (1.0f - s.a);
+        break;
+
+    case VG_BLEND_DARKEN:
+        r.r = RI_MIN(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a));
+        r.g = RI_MIN(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a));
+        r.b = RI_MIN(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a));
+        r.a = s.a + d.a * (1.0f - s.a);
+        break;
+
+    case VG_BLEND_LIGHTEN:
+        r.r = RI_MAX(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a));
+        r.g = RI_MAX(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a));
+        r.b = RI_MAX(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a));
+        //although the statement below is equivalent to r.a = s.a + d.a * (1.0f - s.a)
+        //in practice there can be a very slight difference because
+        //of the max operation in the blending formula that may cause color to exceed alpha.
+        //Because of this, we compute the result both ways and return the maximum.
+        r.a = RI_MAX(s.a + d.a * (1.0f - s.a), d.a + s.a * (1.0f - d.a));
+        break;
+
+    default:
+        RI_ASSERT(blendMode == VG_BLEND_ADDITIVE);
+        r.r = RI_MIN(s.r + d.r, 1.0f);
+        r.g = RI_MIN(s.g + d.g, 1.0f);
+        r.b = RI_MIN(s.b + d.b, 1.0f);
+        r.a = RI_MIN(s.a + d.a, 1.0f);
+        break;
+    }
+    return r;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Applies color transform.
+* \param    
+* \return   
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::colorTransform(Color& c) const
+{
+    if(m_colorTransform)
+    {
+        c.unpremultiply();
+        c.luminanceToRGB();
+        c.r = c.r * m_colorTransformValues[0] + m_colorTransformValues[4];
+        c.g = c.g * m_colorTransformValues[1] + m_colorTransformValues[5];
+        c.b = c.b * m_colorTransformValues[2] + m_colorTransformValues[6];
+        c.a = c.a * m_colorTransformValues[3] + m_colorTransformValues[7];
+        c.clamp();
+        c.premultiply();
+    }
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief    Applies paint, image drawing, masking and blending at pixel (x,y).
+* \param    
+* \return   
+* \note
+*//*-------------------------------------------------------------------*/
+
+void PixelPipe::pixelPipe(int x, int y, RIfloat coverage, unsigned int sampleMask) const
+{
+    RI_ASSERT(m_drawable);
+    RI_ASSERT(sampleMask);
+    RI_ASSERT(coverage > 0.0f);
+    Color::InternalFormat dstFormat = (Color::InternalFormat)(m_drawable->getDescriptor().internalFormat | Color::PREMULTIPLIED);
+
+    //evaluate paint
+    RI_ASSERT(m_paint);
+    Color s;
+    switch(m_paint->m_paintType)
+    {
+    case VG_PAINT_TYPE_COLOR:
+        s = m_paint->m_paintColor;
+        break;
+
+    case VG_PAINT_TYPE_LINEAR_GRADIENT:
+    {
+        RIfloat g, rho;
+        linearGradient(g, rho, x+0.5f, y+0.5f);
+        s = colorRamp(g, rho);
+        RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied));
+        s.premultiply();
+        break;
+    }
+
+    case VG_PAINT_TYPE_RADIAL_GRADIENT:
+    {
+        RIfloat g, rho;
+        radialGradient(g, rho, x+0.5f, y+0.5f);
+        s = colorRamp(g, rho);
+        RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied));
+        s.premultiply();
+        break;
+    }
+
+    default:
+        RI_ASSERT(m_paint->m_paintType == VG_PAINT_TYPE_PATTERN);
+        if(m_paint->m_pattern)
+            s = m_paint->m_pattern->resample(x+0.5f, y+0.5f, m_surfaceToPaintMatrix, m_imageQuality, m_paint->m_patternTilingMode, m_tileFillColor);
+        else
+            s = m_paint->m_paintColor;
+        break;
+    }
+    s.assertConsistency();
+
+    //apply image (vgDrawImage only)
+    //1. paint: convert paint to dst space
+    //2. image: convert image to dst space
+    //3. paint MULTIPLY image: convert paint to image number of channels, multiply with image, and convert to dst
+    //4. paint STENCIL image: convert paint to dst, convert image to dst number of channels, multiply
+
+    //color transform:
+    //paint => transform paint color
+    //image normal => transform image color
+    //image multiply => transform paint*image color
+    //image stencil => transform paint color
+
+    RIfloat ar = 0.0f, ag = 0.0f, ab = 0.0f;
+    if(m_image)
+    {
+        Color im = m_image->resample(x+0.5f, y+0.5f, m_surfaceToImageMatrix, m_imageQuality, VG_TILE_PAD, Color(0,0,0,0,m_image->getDescriptor().internalFormat));
+        im.assertConsistency();
+
+        switch(m_imageMode)
+        {
+        case VG_DRAW_IMAGE_NORMAL:
+            s = im;
+            colorTransform(s);
+            ar = s.a;
+            ag = s.a;
+            ab = s.a;
+            s.convert(dstFormat);   //convert image color to destination color space
+            break;
+        case VG_DRAW_IMAGE_MULTIPLY:
+            //the result will be in image color space, except when paint is RGB and image is L the result will be RGB.
+            //paint == RGB && image == RGB: RGB*RGB
+            //paint == RGB && image == L  : RGB*LLL
+            //paint == L   && image == RGB: LLL*RGB
+            //paint == L   && image == L  : L*L
+            RI_ASSERT(m_surfaceToPaintMatrix.isAffine());
+            if(!s.isLuminance() && im.isLuminance())
+                im.convert((Color::InternalFormat)(im.getInternalFormat() & ~Color::LUMINANCE));
+            im.r *= s.r;
+            im.g *= s.g;
+            im.b *= s.b;
+            im.a *= s.a;
+            s = im;     //use image color space
+            colorTransform(s);
+            ar = s.a;
+            ag = s.a;
+            ab = s.a;
+            s.convert(dstFormat);   //convert resulting color to destination color space
+            break;
+        default:
+            //the result will be in paint color space.
+            //dst == RGB && image == RGB: RGB*RGB
+            //dst == RGB && image == L  : RGB*LLL
+            //dst == L   && image == RGB: L*(0.2126 R + 0.7152 G + 0.0722 B)
+            //dst == L   && image == L  : L*L
+            RI_ASSERT(m_imageMode == VG_DRAW_IMAGE_STENCIL);
+            if(dstFormat & Color::LUMINANCE && !im.isLuminance())
+            {
+                im.r = im.g = im.b = RI_MIN(0.2126f*im.r + 0.7152f*im.g + 0.0722f*im.b, im.a);
+            }
+            RI_ASSERT(m_surfaceToPaintMatrix.isAffine());
+            //s and im are both in premultiplied format. Each image channel acts as an alpha channel.
+            colorTransform(s);
+            s.convert(dstFormat);   //convert paint color to destination space already here, since convert cannot deal with per channel alphas used in this mode.
+            //compute per channel alphas
+            ar = s.a * im.r;
+            ag = s.a * im.g;
+            ab = s.a * im.b;
+            //premultiply each channel by per channel alphas from the image
+            s.r *= im.r;
+            s.g *= im.g;
+            s.b *= im.b;
+            s.a *= im.a;
+            //in nonpremultiplied form the result is
+            // s.rgb = paint.a * paint.rgb * image.a * image.rgb
+            // s.a = paint.a * image.a
+            // argb = paint.a * image.a * image.rgb
+            break;
+        }
+    }
+    else
+    {    //paint only
+        colorTransform(s);
+        ar = s.a;
+        ag = s.a;
+        ab = s.a;
+        s.convert(dstFormat);   //convert paint color to destination color space
+    }
+    RI_ASSERT(s.getInternalFormat() == Color::lRGBA_PRE || s.getInternalFormat() == Color::sRGBA_PRE || s.getInternalFormat() == Color::lLA_PRE || s.getInternalFormat() == Color::sLA_PRE);
+    s.assertConsistency();
+
+    Surface* colorBuffer = m_drawable->getColorBuffer();
+    Surface* maskBuffer = m_drawable->getMaskBuffer();
+    RI_ASSERT(colorBuffer);
+
+    if(m_drawable->getNumSamples() == 1)
+    {   //coverage-based antialiasing
+        RIfloat cov = coverage;
+        if(m_masking && maskBuffer)
+        {
+            cov *= maskBuffer->readMaskCoverage(x, y);
+            if(cov == 0.0f)
+                return;
+        }
+
+        //read destination color
+        Color d = colorBuffer->readSample(x, y, 0);
+        d.premultiply();
+        RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE);
+
+        //blend
+        Color r = blend(s, ar, ag, ab, d, m_blendMode);
+
+        //apply antialiasing in linear color space
+        Color::InternalFormat aaFormat = (dstFormat & Color::LUMINANCE) ? Color::lLA_PRE : Color::lRGBA_PRE;
+        r.convert(aaFormat);
+        d.convert(aaFormat);
+        r = r * cov + d * (1.0f - cov);
+
+        //write result to the destination surface
+        r.convert(colorBuffer->getDescriptor().internalFormat);
+        colorBuffer->writeSample(x, y, 0, r);
+    }
+    else
+    {   //multisampling FSAA
+        if(m_masking && maskBuffer)
+        {
+            sampleMask &= maskBuffer->readMaskMSAA(x, y);
+            if(!sampleMask)
+                return;
+        }
+
+        {
+            for(int i=0;i<m_drawable->getNumSamples();i++)
+            {
+                if(sampleMask & (1<<i)) //1-bit coverage
+                {
+                    //read destination color
+                    Color d = colorBuffer->readSample(x, y, i);
+
+                    d.premultiply();
+                    RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE);
+
+                    //blend
+                    Color r = blend(s, ar, ag, ab, d, m_blendMode);
+
+                    //write result to the destination surface
+                    r.convert(colorBuffer->getDescriptor().internalFormat);
+                    colorBuffer->writeSample(x, y, i, r);
+                }
+            }
+        }
+    }
+}
+
+//=======================================================================
+    
+}   //namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riPixelPipe.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,155 @@
+#ifndef __RIPIXELPIPE_H
+#define __RIPIXELPIPE_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Paint and PixelPipe classes.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIIMAGE_H
+#include "riImage.h"
+#endif
+
+//=======================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Storage and operations for VGPaint.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Paint
+{
+public:
+	Paint();
+	~Paint();
+	void					addReference()							{ m_referenceCount++; }
+	int						removeReference()						{ m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; }
+
+	struct GradientStop
+	{
+		GradientStop() : offset(0.0f), color(0.0f, 0.0f, 0.0f, 0.0f, Color::sRGBA) {}
+		RIfloat		offset;
+		Color		color;
+	};
+
+	VGPaintType				m_paintType;
+	Color					m_paintColor;
+	Color					m_inputPaintColor;
+	VGColorRampSpreadMode	m_colorRampSpreadMode;
+	Array<GradientStop>		m_colorRampStops;
+	Array<GradientStop>		m_inputColorRampStops;
+	VGboolean				m_colorRampPremultiplied;
+	Vector2					m_inputLinearGradientPoint0;
+	Vector2					m_inputLinearGradientPoint1;
+	Vector2					m_inputRadialGradientCenter;
+	Vector2					m_inputRadialGradientFocalPoint;
+	RIfloat					m_inputRadialGradientRadius;
+	Vector2					m_linearGradientPoint0;
+	Vector2					m_linearGradientPoint1;
+	Vector2					m_radialGradientCenter;
+	Vector2					m_radialGradientFocalPoint;
+	RIfloat					m_radialGradientRadius;
+	VGTilingMode			m_patternTilingMode;
+	Image*					m_pattern;
+private:
+	Paint(const Paint&);						//!< Not allowed.
+	const Paint& operator=(const Paint&);		//!< Not allowed.
+
+	int						m_referenceCount;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Encapsulates all information needed for painting a pixel.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+	
+class PixelPipe
+{
+public:
+	PixelPipe();	//throws bad_alloc
+	~PixelPipe();
+
+	void	pixelPipe(int x, int y, RIfloat coverage, unsigned int sampleMask) const;	//rasterizer calls this function for each pixel
+
+	void	setDrawable(Drawable* drawable);
+	void	setBlendMode(VGBlendMode blendMode);
+	void	setMask(bool masking);
+	void	setImage(Image* image, VGImageMode imageMode);	//image = NULL disables drawImage functionality
+	void	setSurfaceToPaintMatrix(const Matrix3x3& surfaceToPaintMatrix);
+	void	setSurfaceToImageMatrix(const Matrix3x3& surfaceToImageMatrix);
+	void	setImageQuality(VGImageQuality imageQuality);
+	void	setTileFillColor(const Color& c);
+	void	setPaint(const Paint* paint);
+    void    setColorTransform(bool enable, RIfloat values[8]);
+
+private:
+	void	linearGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const;
+	void	radialGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const;
+	Color	integrateColorRamp(RIfloat gmin, RIfloat gmax) const;
+	Color	colorRamp(RIfloat gradient, RIfloat rho) const;
+	Color	blend(const Color& s, RIfloat ar, RIfloat ag, RIfloat ab, const Color& d, VGBlendMode blendMode) const;
+    void    colorTransform(Color& c) const;
+
+	PixelPipe(const PixelPipe&);						//!< Not allowed.
+	const PixelPipe& operator=(const PixelPipe&);		//!< Not allowed.
+
+	Drawable*               m_drawable;
+	bool					m_masking;
+	Image*					m_image;
+	const Paint*			m_paint;
+	Paint					m_defaultPaint;
+	VGBlendMode				m_blendMode;
+	VGImageMode				m_imageMode;
+	VGImageQuality			m_imageQuality;
+	Color					m_tileFillColor;
+    bool                    m_colorTransform;
+    RIfloat                 m_colorTransformValues[8];
+	Matrix3x3				m_surfaceToPaintMatrix;
+	Matrix3x3				m_surfaceToImageMatrix;
+};
+
+//=======================================================================
+
+}	//namespace OpenVGRI
+
+//=======================================================================
+
+#endif /* __RIPIXELPIPE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riRasterizer.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,499 @@
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of polygon rasterizer.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#include "riRasterizer.h"
+
+//==============================================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Rasterizer constructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Rasterizer::Rasterizer() :
+	m_edges(),
+	m_scissorEdges(),
+	m_scissor(false),
+	m_samples(),
+	m_numSamples(0),
+	m_numFSAASamples(0),
+	m_sumWeights(0.0f),
+	m_sampleRadius(0.0f),
+    m_vpx(0),
+    m_vpy(0),
+    m_vpwidth(0),
+    m_vpheight(0),
+    m_fillRule(VG_EVEN_ODD),
+    m_pixelPipe(NULL),
+    m_covBuffer(NULL)
+{}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Rasterizer destructor.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+Rasterizer::~Rasterizer()
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Removes all appended edges.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::clear()
+{
+	m_edges.clear();
+    m_edgeMin.set(RI_FLOAT_MAX, RI_FLOAT_MAX);
+    m_edgeMax.set(-RI_FLOAT_MAX, -RI_FLOAT_MAX);
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Appends an edge to the rasterizer.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::addBBox(const Vector2& v)
+{
+    if(v.x < m_edgeMin.x) m_edgeMin.x = v.x;
+    if(v.y < m_edgeMin.y) m_edgeMin.y = v.y;
+    if(v.x > m_edgeMax.x) m_edgeMax.x = v.x;
+    if(v.y > m_edgeMax.y) m_edgeMax.y = v.y;
+}
+
+void Rasterizer::addEdge(const Vector2& v0, const Vector2& v1)
+{
+	if( m_edges.size() >= RI_MAX_EDGES )
+		throw std::bad_alloc();	//throw an out of memory error if there are too many edges
+
+	if(v0.y == v1.y)
+		return;	//skip horizontal edges (they don't affect rasterization since we scan horizontally)
+
+	Edge e;
+	if(v0.y < v1.y)
+	{	//edge is going upward
+		e.v0 = v0;
+		e.v1 = v1;
+		e.direction = 1;
+	}
+	else
+	{	//edge is going downward
+		e.v0 = v1;
+		e.v1 = v0;
+		e.direction = -1;
+	}
+
+    addBBox(v0);
+    addBBox(v1);
+
+	m_edges.push_back(e);	//throws bad_alloc
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Set up rasterizer
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::setup(int vpx, int vpy, int vpwidth, int vpheight, VGFillRule fillRule, const PixelPipe* pixelPipe, unsigned int* covBuffer)
+{
+	RI_ASSERT(vpwidth >= 0 && vpheight >= 0);
+	RI_ASSERT(vpx + vpwidth >= vpx && vpy + vpheight >= vpy);
+	RI_ASSERT(fillRule == VG_EVEN_ODD || fillRule == VG_NON_ZERO);
+    RI_ASSERT(pixelPipe || covBuffer);
+    m_vpx = vpx;
+    m_vpy = vpy;
+    m_vpwidth = vpwidth;
+    m_vpheight = vpheight;
+    m_fillRule = fillRule;
+    m_pixelPipe = pixelPipe;
+    m_covBuffer = covBuffer;
+    m_covMinx = vpx+vpwidth;
+    m_covMiny = vpy+vpheight;
+    m_covMaxx = vpx;
+    m_covMaxy = vpy;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Sets scissor rectangles.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::setScissor(const Array<Rectangle>& scissors)
+{
+	m_scissor = true;
+	try
+	{
+		m_scissorEdges.clear();
+		for(int i=0;i<scissors.size();i++)
+		{
+			if(scissors[i].width > 0 && scissors[i].height > 0)
+			{
+				ScissorEdge e;
+				e.miny = scissors[i].y;
+				e.maxy = RI_INT_ADDSATURATE(scissors[i].y, scissors[i].height);
+
+				e.x = scissors[i].x;
+				e.direction = 1;
+				m_scissorEdges.push_back(e);	//throws bad_alloc
+				e.x = RI_INT_ADDSATURATE(scissors[i].x, scissors[i].width);
+				e.direction = -1;
+				m_scissorEdges.push_back(e);	//throws bad_alloc
+			}
+		}
+	}
+	catch(std::bad_alloc)
+	{
+		m_scissorEdges.clear();
+		throw;
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Returns a radical inverse of a given integer for Hammersley
+*			point set.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static double radicalInverseBase2(unsigned int i)
+{
+	if( i == 0 )
+		return 0.0;
+	double p = 0.0;
+	double f = 0.5;
+	double ff = f;
+	for(unsigned int j=0;j<32;j++)
+	{
+		if( i & (1<<j) )
+			p += f;
+		f *= ff;
+	}
+	return p;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Calls PixelPipe::pixelPipe for each pixel with coverage greater
+*			than zero.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+int Rasterizer::setupSamplingPattern(VGRenderingQuality renderingQuality, int numFSAASamples)
+{
+	RI_ASSERT(renderingQuality == VG_RENDERING_QUALITY_NONANTIALIASED ||
+			  renderingQuality == VG_RENDERING_QUALITY_FASTER ||
+			  renderingQuality == VG_RENDERING_QUALITY_BETTER);
+	RI_ASSERT(numFSAASamples > 0 && numFSAASamples <= RI_MAX_SAMPLES);
+
+	//make a sampling pattern
+	m_sumWeights = 0.0f;
+	m_sampleRadius = 0.0f;		//max offset of the sampling points from a pixel center
+	m_numFSAASamples = numFSAASamples;
+	if(numFSAASamples == 1)
+	{
+		if(renderingQuality == VG_RENDERING_QUALITY_NONANTIALIASED)
+		{
+			m_numSamples = 1;
+			m_samples[0].x = 0.0f;
+			m_samples[0].y = 0.0f;
+			m_samples[0].weight = 1.0f;
+			m_sampleRadius = 0.0f;
+			m_sumWeights = 1.0f;
+		}
+		else if(renderingQuality == VG_RENDERING_QUALITY_FASTER)
+		{	//box filter of diameter 1.0f, 8-queen sampling pattern
+			m_numSamples = 8;
+			m_samples[0].x = 3;
+			m_samples[1].x = 7;
+			m_samples[2].x = 0;
+			m_samples[3].x = 2;
+			m_samples[4].x = 5;
+			m_samples[5].x = 1;
+			m_samples[6].x = 6;
+			m_samples[7].x = 4;
+			for(int i=0;i<m_numSamples;i++)
+			{
+				m_samples[i].x = (m_samples[i].x + 0.5f) / (RScalar)m_numSamples - 0.5f;
+				m_samples[i].y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples - 0.5f;
+				m_samples[i].weight = 1.0f / (RScalar)m_numSamples;
+				m_sumWeights += m_samples[i].weight;
+			}
+			m_sampleRadius = 0.5f;
+		}
+		else
+		{
+			RI_ASSERT(renderingQuality == VG_RENDERING_QUALITY_BETTER);
+			m_numSamples = RI_MAX_SAMPLES;
+			m_sampleRadius = 0.75f;
+			for(int i=0;i<m_numSamples;i++)
+			{	//Gaussian filter, implemented using Hammersley point set for sample point locations
+				RScalar x = (RScalar)radicalInverseBase2(i);
+				RScalar y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples;
+				RI_ASSERT(x >= 0.0f && x < 1.0f);
+				RI_ASSERT(y >= 0.0f && y < 1.0f);
+
+				//map unit square to unit circle
+				RScalar r = (RScalar)sqrt(x) * m_sampleRadius;
+				x = r * (RScalar)sin(y*2.0f*PI);
+				y = r * (RScalar)cos(y*2.0f*PI);
+				m_samples[i].weight = (RScalar)exp(-0.5f * RI_SQR(r/m_sampleRadius));
+
+				RI_ASSERT(x >= -1.5f && x <= 1.5f && y >= -1.5f && y <= 1.5f);	//the specification restricts the filter radius to be less than or equal to 1.5
+				
+				m_samples[i].x = x;
+				m_samples[i].y = y;
+				m_sumWeights += m_samples[i].weight;
+			}
+		}
+	}
+	else
+	{	//box filter
+        m_numSamples = numFSAASamples;
+        RI_ASSERT(numFSAASamples >= 1 && numFSAASamples <= 32);	//sample mask is a 32-bit uint => can't support more than 32 samples
+		//use Hammersley point set as a sampling pattern
+        for(int i=0;i<m_numSamples;i++)
+        {
+            m_samples[i].x = (RScalar)radicalInverseBase2(i) + 1.0f / (RScalar)(m_numSamples<<1) - 0.5f;
+            m_samples[i].y = ((RScalar)i + 0.5f) / (RScalar)m_numSamples - 0.5f;
+            m_samples[i].weight = 1.0f;
+			RI_ASSERT(m_samples[i].x > -0.5f && m_samples[i].x < 0.5f);
+			RI_ASSERT(m_samples[i].y > -0.5f && m_samples[i].y < 0.5f);
+        }
+        m_sumWeights = (RScalar)m_numSamples;
+        m_sampleRadius = 0.5f;
+	}
+    return m_numSamples;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Calls PixelPipe::pixelPipe for each pixel with coverage greater
+*			than zero.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void Rasterizer::fill()
+{
+	if(m_scissor && !m_scissorEdges.size())
+		return;	//scissoring is on, but there are no scissor rectangles => nothing is visible
+
+	//proceed scanline by scanline
+	//keep track of edges that can intersect the pixel filters of the current scanline (Active Edge Table)
+	//until all pixels of the scanline have been processed
+	//  for all sampling points of the current pixel
+	//    determine the winding number using edge functions
+	//    add filter weight to coverage
+	//  divide coverage by the number of samples
+	//  determine a run of pixels with constant coverage
+	//  call fill callback for each pixel of the run
+
+	int fillRuleMask = 1;
+	if(m_fillRule == VG_NON_ZERO)
+		fillRuleMask = -1;
+
+    int bbminx = (int)floor(m_edgeMin.x);
+    int bbminy = (int)floor(m_edgeMin.y);
+    int bbmaxx = (int)floor(m_edgeMax.x)+1;
+    int bbmaxy = (int)floor(m_edgeMax.y)+1;
+    int sx = RI_INT_MAX(m_vpx, bbminx);
+    int ex = RI_INT_MIN(m_vpx+m_vpwidth, bbmaxx);
+    int sy = RI_INT_MAX(m_vpy, bbminy);
+    int ey = RI_INT_MIN(m_vpy+m_vpheight, bbmaxy);
+    if(sx < m_covMinx) m_covMinx = sx;
+    if(sy < m_covMiny) m_covMiny = sy;
+    if(ex > m_covMaxx) m_covMaxx = ex;
+    if(ey > m_covMaxy) m_covMaxy = ey;
+
+	//fill the screen
+	Array<ActiveEdge> aet;
+	Array<ScissorEdge> scissorAet;
+	for(int j=sy;j<ey;j++)
+	{
+		//gather scissor edges intersecting this scanline
+		scissorAet.clear();
+		if( m_scissor )
+		{
+			for(int e=0;e<m_scissorEdges.size();e++)
+			{
+				const ScissorEdge& se = m_scissorEdges[e];
+				if(j >= se.miny && j < se.maxy)
+					scissorAet.push_back(m_scissorEdges[e]);	//throws bad_alloc
+			}
+			if(!scissorAet.size())
+				continue;	//scissoring is on, but there are no scissor rectangles on this scanline
+		}
+
+		//simple AET: scan through all the edges and pick the ones intersecting this scanline
+		aet.clear();
+		for(int e=0;e<m_edges.size();e++)
+		{
+			RScalar cminy = (RScalar)j - m_sampleRadius + 0.5f;
+			RScalar cmaxy = (RScalar)j + m_sampleRadius + 0.5f;
+			const Edge& ed = m_edges[e];
+			RI_ASSERT(ed.v0.y <= ed.v1.y);	//horizontal edges should have been dropped already
+
+			ActiveEdge ae;
+			ae.v0 = ed.v0;
+			ae.v1 = ed.v1;
+			ae.direction = ed.direction;
+
+			if(cmaxy >= ae.v0.y && cminy < ae.v1.y)
+			{
+				ae.n.set(ae.v0.y - ae.v1.y, ae.v1.x - ae.v0.x);	//edge normal
+				ae.cnst = ae.v0.x * ae.n.x + ae.v0.y * ae.n.y;	//distance of v0 from the origin along the edge normal
+				
+				//compute edge min and max x-coordinates for this scanline
+				Vector2 vd(ae.v1.x - ae.v0.x, ae.v1.y - ae.v0.y);
+				RScalar wl = 1.0f / vd.y;
+				RScalar sx = ae.v0.x + vd.x * (cminy - ae.v0.y) * wl;
+				RScalar ex = ae.v0.x + vd.x * (cmaxy - ae.v0.y) * wl;
+				RScalar bminx = RI_MIN(ae.v0.x, ae.v1.x);
+				RScalar bmaxx = RI_MAX(ae.v0.x, ae.v1.x);
+				sx = RI_CLAMP(sx, bminx, bmaxx);
+				ex = RI_CLAMP(ex, bminx, bmaxx);
+				ae.minx = RI_MIN(sx,ex);
+				ae.maxx = RI_MAX(sx,ex);
+				aet.push_back(ae);	//throws bad_alloc
+			}
+		}
+		if(!aet.size())
+			continue;	//no edges on the whole scanline, skip it
+
+		//sort AET by edge minx
+		aet.sort();
+		
+		//sort scissor AET by edge x
+		scissorAet.sort();
+
+		//fill the scanline
+		int scissorWinding = m_scissor ? 0 : 1;	//if scissoring is off, winding is always 1
+		int scissorIndex = 0;
+		int aes = 0;
+		int aen = 0;
+		for(int i=sx;i<ex;)
+		{
+			Vector2 pc(i + 0.5f, j + 0.5f);		//pixel center
+			
+			//find edges that intersect or are to the left of the pixel antialiasing filter
+			while(aes < aet.size() && pc.x + m_sampleRadius >= aet[aes].minx)
+				aes++;
+			//edges [0,aes[ may have an effect on winding, and need to be evaluated while sampling
+
+			//compute coverage
+			RScalar coverage = 0.0f;
+			unsigned int sampleMask = 0;
+			for(int s=0;s<m_numSamples;s++)
+			{
+				Vector2 sp = pc;	//sampling point
+				sp.x += m_samples[s].x;
+				sp.y += m_samples[s].y;
+
+				//compute winding number by evaluating the edge functions of edges to the left of the sampling point
+				int winding = 0;
+				for(int e=0;e<aes;e++)
+				{
+					if(sp.y >= aet[e].v0.y && sp.y < aet[e].v1.y)
+					{	//evaluate edge function to determine on which side of the edge the sampling point lies
+						RScalar side = sp.x * aet[e].n.x + sp.y * aet[e].n.y - aet[e].cnst;
+						if(side <= 0.0f)	//implicit tie breaking: a sampling point on an opening edge is in, on a closing edge it's out
+						{
+                            winding += aet[e].direction;
+						}
+					}
+				}
+                if(winding & fillRuleMask)
+				{
+					coverage += m_samples[s].weight;
+					sampleMask |= (unsigned int)(1<<s);
+				}
+			}
+
+			//constant coverage optimization:
+			//scan AET from left to right and skip all the edges that are completely to the left of the pixel filter.
+			//since AET is sorted by minx, the edge we stop at is the leftmost of the edges we haven't passed yet.
+			//if that edge is to the right of this pixel, coverage is constant between this pixel and the start of the edge.
+			while(aen < aet.size() && aet[aen].maxx < pc.x - m_sampleRadius - 0.01f)	//0.01 is a safety region to prevent too aggressive optimization due to numerical inaccuracy
+				aen++;
+
+			int endSpan = m_vpx + m_vpwidth;	//endSpan is the first pixel NOT part of the span
+			if(aen < aet.size())
+				endSpan = RI_INT_MAX(i+1, RI_INT_MIN(endSpan, (int)ceil(aet[aen].minx - m_sampleRadius - 0.5f)));
+
+			coverage /= m_sumWeights;
+			RI_ASSERT(coverage >= 0.0f && coverage <= 1.0f);
+
+			//fill a run of pixels with constant coverage
+			if(sampleMask)
+			{
+				for(;i<endSpan;i++)
+				{
+					//update scissor winding number
+					while(scissorIndex < scissorAet.size() && scissorAet[scissorIndex].x <= i)
+						scissorWinding += scissorAet[scissorIndex++].direction;
+					RI_ASSERT(scissorWinding >= 0);
+
+					if(scissorWinding)
+                    {
+                        if(m_covBuffer)
+                            m_covBuffer[j*m_vpwidth+i] |= (RIuint32)sampleMask;
+                        else
+                            m_pixelPipe->pixelPipe(i, j, coverage, sampleMask);
+                    }
+				}
+			}
+			i = endSpan;
+		}
+	}
+}
+
+//=======================================================================
+
+}	//namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riRasterizer.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,173 @@
+#ifndef __RIRASTERIZER_H
+#define __RIRASTERIZER_H
+
+/*------------------------------------------------------------------------
+ *
+ * OpenVG 1.1 Reference Implementation
+ * -----------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Rasterizer class.
+ * \note	
+ *//*-------------------------------------------------------------------*/
+
+#ifndef __RIMATH_H
+#include "riMath.h"
+#endif
+
+#ifndef __RIARRAY_H
+#include "riArray.h"
+#endif
+
+#ifndef __RIPIXELPIPE_H
+#include "riPixelPipe.h"
+#endif
+
+//=======================================================================
+
+namespace OpenVGRI
+{
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Scalar and vector data types used by the rasterizer.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+typedef RIfloat RScalar;	//change this if you want to have different precision for rasterizer scalars and RIfloat
+
+struct RVector2
+{
+	RI_INLINE RVector2()							{ }
+	RI_INLINE RVector2(const Vector2& v)			{ x = v.x; y = v.y; }
+	RI_INLINE RVector2(RIfloat vx, RIfloat vy)		{ x = vx; y = vy; }
+	RI_INLINE void set(RIfloat vx, RIfloat vy)		{ x = vx; y = vy; }
+	RScalar		x;
+	RScalar		y;
+};
+
+/*-------------------------------------------------------------------*//*!
+* \brief	Converts a set of edges to coverage values for each pixel and
+*			calls PixelPipe::pixelPipe for painting a pixel.
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+class Rasterizer
+{
+public:
+	Rasterizer();	//throws bad_alloc
+	~Rasterizer();
+
+    void        setup(int vpx, int vpy, int vpwidth, int vpheight, VGFillRule fillRule, const PixelPipe* pixelPipe, RIuint32* covBuffer);
+	void		setScissor(const Array<Rectangle>& scissors);	//throws bad_alloc
+
+	void		clear();
+	void		addEdge(const Vector2& v0, const Vector2& v1);	//throws bad_alloc
+
+	int         setupSamplingPattern(VGRenderingQuality renderingQuality, int numFSAASamples);
+	void		fill();	//throws bad_alloc
+
+    void        getBBox(int& sx, int& sy, int& ex, int& ey) const       { sx = m_covMinx; sy = m_covMiny; ex = m_covMaxx; ey = m_covMaxy; }
+private:
+	Rasterizer(const Rasterizer&);						//!< Not allowed.
+	const Rasterizer& operator=(const Rasterizer&);		//!< Not allowed.
+
+	struct ScissorEdge
+	{
+		ScissorEdge() : x(0), miny(0), maxy(0), direction(0) {}
+		bool operator<(const ScissorEdge& e) const	{ return x < e.x; }
+		int			x;
+		int			miny;
+		int			maxy;
+		int			direction;		//1 start, -1 end
+	};
+
+	struct Edge
+	{
+		Edge() : v0(), v1(), direction(1) {}
+		bool operator<(const Edge& e) const	{ return v0.y < e.v0.y; }
+		RVector2	v0;
+		RVector2	v1;
+		int			direction;
+	};
+
+	struct ActiveEdge
+	{
+		ActiveEdge() : v0(), v1(), direction(0), minx(0.0f), maxx(0.0f), n(), cnst(0.0f) {}
+		bool operator<(const ActiveEdge& e) const	{ return minx < e.minx; }
+		RVector2	v0;
+		RVector2	v1;
+		int			direction;		//-1 down, 1 up
+		RScalar		minx;			//for the current scanline
+		RScalar		maxx;			//for the current scanline
+		RVector2	n;
+		RScalar		cnst;
+	};
+
+	struct Sample
+	{
+		Sample() : x(0.0f), y(0.0f), weight(0.0f) {}
+		RScalar		x;
+		RScalar		y;
+		RScalar		weight;
+	};
+
+    void                addBBox(const Vector2& v);
+
+	Array<Edge>				m_edges;
+	Array<ScissorEdge>		m_scissorEdges;
+	bool					m_scissor;
+
+	Sample				m_samples[RI_MAX_SAMPLES];
+	int					m_numSamples;
+	int					m_numFSAASamples;
+	RScalar				m_sumWeights;
+	RScalar				m_sampleRadius;
+
+    Vector2             m_edgeMin;
+    Vector2             m_edgeMax;
+    int                 m_covMinx;
+    int                 m_covMiny;
+    int                 m_covMaxx;
+    int                 m_covMaxy;
+    int                 m_vpx;
+    int                 m_vpy;
+    int                 m_vpwidth;
+    int                 m_vpheight;
+    VGFillRule          m_fillRule;
+    const PixelPipe*    m_pixelPipe;
+    RIuint32*           m_covBuffer;
+};
+
+//=======================================================================
+
+}	//namespace OpenVGRI
+
+//=======================================================================
+
+#endif /* __RIRASTERIZER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riVGU.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,543 @@
+/*------------------------------------------------------------------------
+ *
+ * VGU library for OpenVG 1.1 Reference Implementation
+ * ---------------------------------------------------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Implementation of the VGU utility library for OpenVG
+ *//*-------------------------------------------------------------------*/
+
+#include "vgu.h"
+#include "openvg.h"
+#include "riMath.h"
+
+#ifdef BUILD_WITH_PRIVATE_VGU
+#include "vguinternal.h"
+#endif
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+#include "openvginternal.h"
+#endif
+
+using namespace OpenVGRI;
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+static void append(VGPath path, int numSegments, const VGubyte* segments, int numCoordinates, const VGfloat* coordinates)
+{
+	RI_ASSERT(numCoordinates <= 26);
+
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+	VGPathDatatype datatype = (VGPathDatatype)/*do_vg*/vgGetParameteri(path, VG_PATH_DATATYPE);
+	VGfloat scale = /*do_vg*/vgGetParameterf(path, VG_PATH_SCALE);
+	VGfloat bias = /*do_vg*/vgGetParameterf(path, VG_PATH_BIAS);
+#else
+	VGPathDatatype datatype = (VGPathDatatype)vgGetParameteri(path, VG_PATH_DATATYPE);
+	VGfloat scale = vgGetParameterf(path, VG_PATH_SCALE);
+	VGfloat bias = vgGetParameterf(path, VG_PATH_BIAS);
+#endif
+
+	switch(datatype)
+	{
+	case VG_PATH_DATATYPE_S_8:
+	{
+		RIint8 data[26];
+		for(int i=0;i<numCoordinates;i++)
+			data[i] = (RIint8)floor((coordinates[i] - bias) / scale + 0.5f);	//add 0.5 for correct rounding
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+		/*do_vg*/vgAppendPathData(path, numSegments, segments, data);
+#else
+		vgAppendPathData(path, numSegments, segments, data);
+#endif
+		break;
+	}
+
+	case VG_PATH_DATATYPE_S_16:
+	{
+		RIint16 data[26];
+		for(int i=0;i<numCoordinates;i++)
+			data[i] = (RIint16)floor((coordinates[i] - bias) / scale + 0.5f);	//add 0.5 for correct rounding
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+		/*do_vg*/vgAppendPathData(path, numSegments, segments, data);
+#else
+		vgAppendPathData(path, numSegments, segments, data);
+#endif
+		break;
+	}
+
+	case VG_PATH_DATATYPE_S_32:
+	{
+		RIint32 data[26];
+		for(int i=0;i<numCoordinates;i++)
+			data[i] = (RIint32)floor((coordinates[i] - bias) / scale + 0.5f);	//add 0.5 for correct rounding
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+		/*do_vg*/vgAppendPathData(path, numSegments, segments, data);
+#else
+		vgAppendPathData(path, numSegments, segments, data);
+#endif
+		break;
+	}
+
+	default:
+	{
+		RI_ASSERT(datatype == VG_PATH_DATATYPE_F);
+		RIfloat32 data[26];
+		for(int i=0;i<numCoordinates;i++)
+			data[i] = (RIfloat32)((coordinates[i] - bias) / scale);
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+		/*do_vg*/vgAppendPathData(path, numSegments, segments, data);
+#else
+		vgAppendPathData(path, numSegments, segments, data);
+#endif
+		break;
+	}
+	}
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguLine(VGPath path, VGfloat x0, VGfloat y0, VGfloat x1, VGfloat y1)
+#else
+VGUErrorCode RI_APIENTRY vguLine(VGPath path, VGfloat x0, VGfloat y0, VGfloat x1, VGfloat y1)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	static const VGubyte segments[2] = {VG_MOVE_TO | VG_ABSOLUTE, VG_LINE_TO | VG_ABSOLUTE};
+	const VGfloat data[4] = {x0, y0, x1, y1};
+	append(path, 2, segments, 4, data);
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguPolygon(VGPath path, const VGfloat * points, VGint count, VGboolean closed)
+#else
+VGUErrorCode RI_APIENTRY vguPolygon(VGPath path, const VGfloat * points, VGint count, VGboolean closed)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	if(!points || (((RIuintptr)points) & 3) || count <= 0)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	VGubyte segments[1] = {VG_MOVE_TO | VG_ABSOLUTE};
+	VGfloat data[2];
+	for(int i=0;i<count;i++)
+	{
+		data[0] = points[i*2+0];
+		data[1] = points[i*2+1];
+		append(path, 1, segments, 2, data);
+		segments[0] = VG_LINE_TO | VG_ABSOLUTE;
+	}
+	if(closed)
+	{
+		segments[0] = VG_CLOSE_PATH;
+		append(path, 1, segments, 0, data);
+	}
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height)
+#else
+VGUErrorCode RI_APIENTRY vguRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	if(width <= 0 || height <= 0)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	static const VGubyte segments[5] = {VG_MOVE_TO | VG_ABSOLUTE,
+										VG_HLINE_TO | VG_ABSOLUTE,
+										VG_VLINE_TO | VG_ABSOLUTE,
+										VG_HLINE_TO | VG_ABSOLUTE,
+										VG_CLOSE_PATH};
+	const VGfloat data[5] = {x, y, x + width, y + height, x};
+	append(path, 5, segments, 5, data);
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguRoundRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat arcWidth, VGfloat arcHeight)
+#else
+VGUErrorCode RI_APIENTRY vguRoundRect(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat arcWidth, VGfloat arcHeight)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	if(width <= 0 || height <= 0)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	arcWidth = RI_CLAMP(arcWidth, 0.0f, width);
+	arcHeight = RI_CLAMP(arcHeight, 0.0f, height);
+
+	static const VGubyte segments[10] = {VG_MOVE_TO | VG_ABSOLUTE,
+										 VG_HLINE_TO | VG_ABSOLUTE,
+										 VG_SCCWARC_TO | VG_ABSOLUTE,
+										 VG_VLINE_TO | VG_ABSOLUTE,
+										 VG_SCCWARC_TO | VG_ABSOLUTE,
+										 VG_HLINE_TO | VG_ABSOLUTE,
+										 VG_SCCWARC_TO | VG_ABSOLUTE,
+										 VG_VLINE_TO | VG_ABSOLUTE,
+										 VG_SCCWARC_TO | VG_ABSOLUTE,
+										 VG_CLOSE_PATH};
+	const VGfloat data[26] = {x + arcWidth/2, y,
+							  x + width - arcWidth/2,
+							  arcWidth/2, arcHeight/2, 0, x + width, y + arcHeight/2,
+							  y + height - arcHeight/2,
+							  arcWidth/2, arcHeight/2, 0, x + width - arcWidth/2, y + height,
+							  x + arcWidth/2,
+							  arcWidth/2, arcHeight/2, 0, x, y + height - arcHeight/2,
+							  y + arcHeight/2,
+							  arcWidth/2, arcHeight/2, 0, x + arcWidth/2, y};
+	append(path, 10, segments, 26, data);
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguEllipse(VGPath path, VGfloat cx, VGfloat cy, VGfloat width, VGfloat height)
+#else
+VGUErrorCode RI_APIENTRY vguEllipse(VGPath path, VGfloat cx, VGfloat cy, VGfloat width, VGfloat height)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	if(width <= 0 || height <= 0)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	static const VGubyte segments[4] = {VG_MOVE_TO | VG_ABSOLUTE,
+										VG_SCCWARC_TO | VG_ABSOLUTE,
+										VG_SCCWARC_TO | VG_ABSOLUTE,
+										VG_CLOSE_PATH};
+	const VGfloat data[12] = {cx + width/2, cy,
+							  width/2, height/2, 0, cx - width/2, cy,
+							  width/2, height/2, 0, cx + width/2, cy};
+	append(path, 4, segments, 12, data);
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguArc(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, VGUArcType arcType)
+#else
+VGUErrorCode RI_APIENTRY vguArc(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height, VGfloat startAngle, VGfloat angleExtent, VGUArcType arcType)
+#endif
+{
+	VGErrorCode error = vgGetError();	//clear the error state
+	if((arcType != VGU_ARC_OPEN && arcType != VGU_ARC_CHORD && arcType != VGU_ARC_PIE) || width <= 0.0f || height <= 0.0f)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	startAngle = RI_DEG_TO_RAD(startAngle);
+	angleExtent = RI_DEG_TO_RAD(angleExtent);
+
+	VGfloat w = width/2.0f;
+	VGfloat h = height/2.0f;
+
+	VGubyte segments[1];
+	VGfloat data[5];
+
+	segments[0] = VG_MOVE_TO | VG_ABSOLUTE;
+	data[0] = x + w * (VGfloat)cos(startAngle);
+	data[1] = y + h * (VGfloat)sin(startAngle);
+	append(path, 1, segments, 2, data);
+
+	data[0] = w;
+	data[1] = h;
+	data[2] = 0.0f;
+	VGfloat endAngle = startAngle + angleExtent;
+	if(angleExtent >= 0.0f)
+	{
+		segments[0] = VG_SCCWARC_TO | VG_ABSOLUTE;
+		for(VGfloat a = startAngle + PI;a < endAngle; a += PI)
+		{
+			data[3] = x + w * (VGfloat)cos(a);
+			data[4] = y + h * (VGfloat)sin(a);
+			append(path, 1, segments, 5, data);
+		}
+	}
+	else
+	{
+		segments[0] = VG_SCWARC_TO | VG_ABSOLUTE;
+		for(VGfloat a = startAngle - PI;a > endAngle; a -= PI)
+		{
+			data[3] = x + w * (VGfloat)cos(a);
+			data[4] = y + h * (VGfloat)sin(a);
+			append(path, 1, segments, 5, data);
+		}
+	}
+	data[3] = x + w * (VGfloat)cos(endAngle);
+	data[4] = y + h * (VGfloat)sin(endAngle);
+	append(path, 1, segments, 5, data);
+
+	if(arcType == VGU_ARC_CHORD)
+	{
+		segments[0] = VG_CLOSE_PATH;
+		append(path, 1, segments, 0, data);
+	}
+	else if(arcType == VGU_ARC_PIE)
+	{
+		segments[0] = VG_LINE_TO | VG_ABSOLUTE;
+		data[0] = x;
+		data[1] = y;
+		append(path, 1, segments, 2, data);
+		segments[0] = VG_CLOSE_PATH;
+		append(path, 1, segments, 0, data);
+	}
+
+	error = vgGetError();
+	if(error == VG_BAD_HANDLE_ERROR)
+		return VGU_BAD_HANDLE_ERROR;
+	else if(error == VG_PATH_CAPABILITY_ERROR)
+		return VGU_PATH_CAPABILITY_ERROR;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+#else
+VGUErrorCode RI_APIENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+#endif
+{
+	if(!matrix || ((RIuintptr)matrix) & 3)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	VGfloat mat[9];
+#ifdef BUILD_WITH_PRIVATE_VGU
+	VGUErrorCode ret = do_vguComputeWarpSquareToQuad(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, mat);
+#else
+	VGUErrorCode ret = vguComputeWarpSquareToQuad(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, mat);
+#endif
+	if(ret == VGU_BAD_WARP_ERROR)
+		return VGU_BAD_WARP_ERROR;
+	Matrix3x3 m(mat[0], mat[3], mat[6],
+				mat[1], mat[4], mat[7],
+				mat[2], mat[5], mat[8]);
+	bool nonsingular = m.invert();
+	if(!nonsingular)
+		return VGU_BAD_WARP_ERROR;
+	matrix[0] = m[0][0];
+	matrix[1] = m[1][0];
+	matrix[2] = m[2][0];
+	matrix[3] = m[0][1];
+	matrix[4] = m[1][1];
+	matrix[5] = m[2][1];
+	matrix[6] = m[0][2];
+	matrix[7] = m[1][2];
+	matrix[8] = m[2][2];
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat * matrix)
+#else
+VGUErrorCode RI_APIENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat * matrix)
+#endif
+{
+	if(!matrix || ((RIuintptr)matrix) & 3)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	//from Heckbert:Fundamentals of Texture Mapping and Image Warping
+	//Note that his mapping of vertices is different from OpenVG's
+	//(0,0) => (dx0,dy0)
+	//(1,0) => (dx1,dy1)
+	//(0,1) => (dx2,dy2)
+	//(1,1) => (dx3,dy3)
+
+	VGfloat diffx1 = dx1 - dx3;
+	VGfloat diffy1 = dy1 - dy3;
+	VGfloat diffx2 = dx2 - dx3;
+	VGfloat diffy2 = dy2 - dy3;
+
+	VGfloat det = diffx1*diffy2 - diffx2*diffy1;
+	if(det == 0.0f)
+		return VGU_BAD_WARP_ERROR;
+
+	VGfloat sumx = dx0 - dx1 + dx3 - dx2;
+	VGfloat sumy = dy0 - dy1 + dy3 - dy2;
+
+	if(sumx == 0.0f && sumy == 0.0f)
+	{	//affine mapping
+		matrix[0] = dx1 - dx0;
+		matrix[1] = dy1 - dy0;
+		matrix[2] = 0.0f;
+		matrix[3] = dx3 - dx1;
+		matrix[4] = dy3 - dy1;
+		matrix[5] = 0.0f;
+		matrix[6] = dx0;
+		matrix[7] = dy0;
+		matrix[8] = 1.0f;
+		return VGU_NO_ERROR;
+	}
+
+	VGfloat oodet = 1.0f / det;
+	VGfloat g = (sumx*diffy2 - diffx2*sumy) * oodet;
+	VGfloat h = (diffx1*sumy - sumx*diffy1) * oodet;
+
+	matrix[0] = dx1-dx0+g*dx1;
+	matrix[1] = dy1-dy0+g*dy1;
+	matrix[2] = g;
+	matrix[3] = dx2-dx0+h*dx2;
+	matrix[4] = dy2-dy0+h*dy2;
+	matrix[5] = h;
+	matrix[6] = dx0;
+	matrix[7] = dy0;
+	matrix[8] = 1.0f;
+	return VGU_NO_ERROR;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#ifdef BUILD_WITH_PRIVATE_VGU
+VGUErrorCode RI_APIENTRY do_vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+#else
+VGUErrorCode RI_APIENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, VGfloat dx1, VGfloat dy1, VGfloat dx2, VGfloat dy2, VGfloat dx3, VGfloat dy3, VGfloat sx0, VGfloat sy0, VGfloat sx1, VGfloat sy1, VGfloat sx2, VGfloat sy2, VGfloat sx3, VGfloat sy3, VGfloat * matrix)
+#endif
+{
+	if(!matrix || ((RIuintptr)matrix) & 3)
+		return VGU_ILLEGAL_ARGUMENT_ERROR;
+
+	VGfloat qtos[9];
+#ifdef BUILD_WITH_PRIVATE_VGU
+	VGUErrorCode ret1 = do_vguComputeWarpQuadToSquare(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, qtos);
+#else
+	VGUErrorCode ret1 = vguComputeWarpQuadToSquare(sx0, sy0, sx1, sy1, sx2, sy2, sx3, sy3, qtos);
+#endif
+	if(ret1 == VGU_BAD_WARP_ERROR)
+		return VGU_BAD_WARP_ERROR;
+
+	VGfloat stoq[9];
+#ifdef BUILD_WITH_PRIVATE_VGU
+	VGUErrorCode ret2 = do_vguComputeWarpSquareToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, stoq);
+#else
+	VGUErrorCode ret2 = vguComputeWarpSquareToQuad(dx0, dy0, dx1, dy1, dx2, dy2, dx3, dy3, stoq);
+#endif
+	if(ret2 == VGU_BAD_WARP_ERROR)
+		return VGU_BAD_WARP_ERROR;
+
+	Matrix3x3 m1(qtos[0], qtos[3], qtos[6],
+				 qtos[1], qtos[4], qtos[7],
+				 qtos[2], qtos[5], qtos[8]);
+	Matrix3x3 m2(stoq[0], stoq[3], stoq[6],
+				 stoq[1], stoq[4], stoq[7],
+				 stoq[2], stoq[5], stoq[8]);
+	Matrix3x3 r = m2 * m1;
+
+	matrix[0] = r[0][0];
+	matrix[1] = r[1][0];
+	matrix[2] = r[2][0];
+	matrix[3] = r[0][1];
+	matrix[4] = r[1][1];
+	matrix[5] = r[2][1];
+	matrix[6] = r[0][2];
+	matrix[7] = r[1][2];
+	matrix[8] = r[2][2];
+	return VGU_NO_ERROR;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/eglosnativewindowtype.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Declaration of native window type structure
+*/
+
+#include <e32std.h>
+#include <w32std.h>
+
+#ifndef EGLOSNATVIEWINDOWTYPE_H
+#define EGLOSNATVIEWINDOWTYPE_H
+
+struct TNativeWindowType
+	{
+public:
+	TNativeWindowType() :
+	iSize(0,0),
+	iBitmap(NULL)
+	{};
+	TSize				iSize; //to keep
+	CFbsBitmap* 		iBitmap; //to keep
+	};
+
+#endif //EGLOSCALLBACK_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/riEGLOS.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,242 @@
+/*------------------------------------------------------------------------
+ *
+ * EGL 1.3
+ * -------
+ *
+ * Copyright (c) 2007 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and /or associated documentation files
+ * (the "Materials "), to deal in the Materials without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Materials,
+ * and to permit persons to whom the Materials are furnished to do so,
+ * subject to the following conditions: 
+ *
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Materials. 
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
+ * THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//**
+ * \file
+ * \brief	Generic OS EGL functionality (not thread safe, no window rendering)
+ * \note
+  *//*-------------------------------------------------------------------*/
+
+#include "egl.h"
+#include "riImage.h"
+#include "riDefs.h"
+
+#include <e32std.h>
+#include <w32std.h>
+#include <eglosnativewindowtype.h>
+
+namespace OpenVGRI
+{
+//internal fucntions
+VGImageFormat MapSymbianDisplayModeToVG(TDisplayMode aMode);
+void ReadPixelsToCFbsBitmap(CFbsBitmap& aBitmap, TUint aW, TUint aH);
+
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void* OSGetCurrentThreadID(void)
+{
+	int g_threadid = RThread().Id();
+	return (void*)g_threadid;
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+void OSDeinitMutex(void)
+{
+}
+
+void OSAcquireMutex(void)
+{
+}
+
+void OSReleaseMutex(void)
+{
+}
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+struct OSWindowContext
+{
+	TNativeWindowType*  iNativeWindowType;   
+};
+
+void* OSCreateWindowContext(EGLNativeWindowType window)
+{
+    OSWindowContext* ctx = NULL;
+    try
+    {
+        ctx = RI_NEW(OSWindowContext, ());
+    }
+	catch(std::bad_alloc)
+	{
+		return NULL;
+	}
+    ctx->iNativeWindowType = (TNativeWindowType*)window;
+    return ctx;
+}
+
+void OSDestroyWindowContext(void* context)
+{
+    OSWindowContext* ctx = (OSWindowContext*)context;
+    if(ctx)
+    {
+        RI_DELETE(ctx);
+    }
+}
+
+bool OSIsWindow(const void* context)
+{
+    OSWindowContext* ctx = (OSWindowContext*)context;
+    if(ctx)
+    {
+        return true;
+    }
+    return false;
+}
+
+void OSGetWindowSize(const void* context, int& width, int& height)
+{
+    OSWindowContext* ctx = (OSWindowContext*)context;
+    if(ctx)
+    {
+    	width=ctx->iNativeWindowType->iSize.iWidth;
+		height=ctx->iNativeWindowType->iSize.iHeight; 
+    }
+    else
+    {
+        width = 0;
+        height = 0;
+    }
+}
+
+
+EGLDisplay OSGetDisplay(EGLNativeDisplayType display_id)
+{
+    RI_UNREF(display_id);
+    return (EGLDisplay)1;    //support only a single display
+}
+
+
+void OSBlitToWindow(void* context, const Drawable* drawable)
+{
+    OSWindowContext* ctx = (OSWindowContext*)context;
+    //blit if either of iBitmap or iMaskBitmap exist
+    if(ctx && ctx->iNativeWindowType->iBitmap)
+    {
+        TUint w = drawable->getWidth();
+        TUint h = drawable->getHeight();
+        
+        //these should be same as bitmap
+        if(ctx->iNativeWindowType->iBitmap)
+        	{
+        	CFbsBitmap* bitmap = ctx->iNativeWindowType->iBitmap;        	
+        	ReadPixelsToCFbsBitmap(*bitmap, w, h);        	
+        	}
+    }
+}
+
+void ReadPixelsToCFbsBitmap(CFbsBitmap& aBitmap, TUint aW, TUint aH)
+	{
+	TSize sz = aBitmap.SizeInPixels();
+	RI_ASSERT(aW==sz.iWidth);
+	RI_ASSERT(aH==sz.iHeight);
+	
+	VGImageFormat f = MapSymbianDisplayModeToVG(aBitmap.DisplayMode());
+	
+	TInt bitmapDataStride = aBitmap.DataStride();
+	
+	//copy from source OpenVG model to target(CFbsBitmap) buffer			
+	aBitmap.BeginDataAccess();
+	//openvg returns pixels in cartesian coordinates (y+) where as CFbsBitmap
+	//wants screen coordinates (y-) so we read pixels out starting at top left corner 
+	TUint8* ptarget = (TUint8*)aBitmap.DataAddress()+(aH-1)*bitmapDataStride;
+	vgReadPixels(ptarget, -bitmapDataStride, f, 0, 0, aW, aH);
+	aBitmap.EndDataAccess(EFalse);
+	}
+
+VGImageFormat MapSymbianDisplayModeToVG(TDisplayMode aMode)
+	{
+	VGImageFormat f;
+	switch(aMode)
+		{
+		case EColor16MA:
+			f = VG_sARGB_8888;
+			break;
+		case EColor16MU:
+			f = VG_sRGBX_8888;
+			break;
+		case EColor64K:
+			f = VG_sRGB_565;
+			break;
+		case EGray256:
+			f = VG_A_8;
+			break;
+		case EGray2:
+			f = VG_BW_1;
+			break;
+		default:
+			RI_ASSERT(0);
+		}
+	return f;
+	}
+EGLBoolean OSGetNativePixmapInfo(NativePixmapType pixmap, int* width, int* height, int* stride, VGImageFormat* format, int** data)
+{
+	TSize size = ((CFbsBitmap*)pixmap)->SizeInPixels();
+    *width  = size.iWidth;
+    *height = size.iHeight;
+    *stride = ((CFbsBitmap*)pixmap)->DataStride();    
+    
+    *data = (int*)(((CFbsBitmap*)pixmap)->DataAddress());
+    TDisplayMode mode = ((CFbsBitmap*)pixmap)->DisplayMode(); 
+	switch(mode)
+	{
+	case EColor16MA:
+		*format = VG_sRGBA_8888;
+		break;
+	case EColor16MU:
+		*format = VG_sRGBX_8888;
+		break;
+	case EColor64K:
+		*format = VG_sRGB_565;
+		break;
+	case EGray256:
+		*format = VG_A_8;
+		break;
+	case EGray2:
+		*format = VG_BW_1;
+		break;
+	default:
+		RI_ASSERT(0);
+	}
+    return EGL_TRUE;
+}
+}   //namespace OpenVGRI
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/data/tiger.rss	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app resource
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    AWIZ // 4 letter ID
+
+//  INCLUDES
+#include <eikon.rh>
+#include "tiger.hrh"
+#include "tiger.rls"
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <appinfo.rh>
+
+//  RESOURCE DEFINITIONS
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="Tiger"; }
+
+RESOURCE EIK_APP_INFO
+    {
+    menubar = r_tiger_menubar;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+    }
+
+//----------------------------------------------------
+//
+//    r_tiger_menubar
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_tiger_menubar
+{
+    titles =
+        {
+            MENU_TITLE
+            {
+                menu_pane = r_tiger_exit;
+            }
+        };
+}
+
+//----------------------------------------------------
+//
+//    r_tiger_exit
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_tiger_exit
+{
+    items =
+        {
+            MENU_ITEM
+            {
+                command = EAknCmdExit;
+                txt = STRING_r_tiger_exit;
+            }
+        };
+}
+
+
+
+
+
+
+//----------------------------------------------------
+//
+//    r_tiger_localisable_app_info
+//
+//----------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_tiger_localisable_app_info
+    {
+    short_caption = STRING_r_app_short_caption_string;
+    caption_and_icon =
+    CAPTION_AND_ICON_INFO
+        {
+        caption         = STRING_r_app_caption_string;
+        number_of_icons = 1;
+        icon_file       = "\\resource\\apps\\tiger_icon.mif";
+        };
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/data/tiger_reg.rss	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app resource
+*/
+
+
+
+#include <appinfo.rh>
+#include <tiger.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+
+// Application UID
+UID3 0xA000024A
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file                  = "Tiger";
+    localisable_resource_file = "\\resource\\apps\\tiger";
+    localisable_resource_id   = R_TIGER_LOCALISABLE_APP_INFO;
+    embeddability             = KAppNotEmbeddable;
+    newfile                   = KAppDoesNotSupportNewFile;
+
+//    group_name                = "OpenVG";
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/gfx/qgn_menu_tiger.svg	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!-- Generator: eNetzwerk JPG2SVG 0.1 http://www.enetzwerk.de/svg -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"   "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [
+	<!ENTITY st0 "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;">
+]>
+<svg  width="130" height="130" viewBox="0 0 130 130" xml:space="preserve">
+	<g id="Ebene_x0020_1" style="&st0;">
+		<image width="130" height="130" xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCACCAIIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD30dKWkHSloATFKOKKQnFFgFLAdaTeP8Ky9a17T9Ds2uL2YrtBYRoNzvj0Uc/j09TivAPGnxJ13X7rFjqc+jaeGKxR2cv7xz2Z5QyqforED3xUOcVoXGnJnv2seJtE8Pxh9W1S0s8jKrNKAzfRep/CsOz+K3ga/uhbQeIrTzDwPNDRKf8AgTgD9a+WL2wltN9x4gsryVp3yt6twGJJGeeobj3qhFq1zFBJYQustrL8qi4jU7fcZztP40cza90ORJ+8fXmofE3wXpj7LjxHY7gcEQv5pH12ZxUNl8V/A+oSbIfENsnOMzq8K/8AfTqB+tfMUFrcaZZg3ek30C7QwuVt45EAPc5Tkf8AAqnW8sImW6i1VUOP3gtITbyH3MfMbfQEfjUOrrojWNC61Z9iQzw3EKTQSJLE4yrowYMPUEdafkV8maZ8SL7wbfsul+TcxEBwVRoElBGfni+7n3UA+9eo/D/4i+MviFe3CW1po1jZ2oBnuJI5ZDls4VVDjJ4J64x74q4O6u0ZTiouyPYcg0oryo6rq9j8c9K0R9aub2G40+Wa8hOFiRsOVCoPugbVxklsNyTXqo61ZAtAooFAC0UUUANHSlpB0paAEJwOapatqdvpWmzXtw4VIgTycZPp9aut0ryn4q6i9zZX1ra38dvLYWrXAjEBkeQn5RhuFQAggdTnPA4JibfK7FwSclc8q8W+KH1nVJZtRu2WESfLHCNzsAeNqnge244AxgE/MeWF6bzUFOnaGZpJBuT7UzXDuF6kdAehzwRXZ2dxcaXpcVtDZCa7dcI6osaGUrnavdwP4mP+183aup8AaOmvXD280k8VzHGkl611GUmYkkADdwVyCBj5R0xzz58akr6Ru/61PSlCNtZWR4hBcW9zqBGpeZDbOfnFsoXYcYB29P5VpHwdcTWTXmmXdtqEK87YSQ4+qkcH2/LNen6/c+H47228UWPh3Rr/AMOwXMNrezziU3YDBWLGNiq/dbC5DHjt2n8ZWWmab4Us/F/hKy+yWlxIocfZwrMgcgg9wGx39B611VHOKTjozlp+znK0tTygrdWN5p82mXNxaQ3yI6FGY7HztZT64ZTwc8Y61v3dlpuraRfzX0K22rafvFwLbaN5Xo2BwQT39qj8ba1ayaTYWdlGES4Au8bAuwHOAMDGckk49+xqFr17nSbbxJaRI15bj7Nfx7crKhXGWHcEcfj7Vhec4xk1a5ulGM3FO+hyuqnzbtZw2VliR8577QCPwII/CvUfgr480PwhY65FrM5t/MCTw7Yyxk2hgVGO/K4zx15FYsOk6L4s0TGnW6WFxFIvmMVJCE8Fc5wR6Vg3uk2nhXWI01CEajC6hgPmiI5646Hp6/XFb08RF+59pdDnqYaS99fC+p7h8JNPvfEfiPWviJqkexr9mt7KMn7sYIBI+gVUB/2Wr2PvXA+CPG1hqVnZ2YjggiaJEtTAAqYHATb/AAkYxj6jjiu8Ug9DWtOrGorxMKlOVN2kOoFFArQgWiiigBo6UtJnAFNd+M5GDxQBna5qsGl6eJZ5hCJJFjVyM8k9h1Jxk/hXi/iS3ngnhtk1ZtVjmu0TUWaMrIAjyvFu9VYsmSAQTEhz8wz2HxdurVbTSbe8lngQ3DTRzRqcLIowBnBGSHbgjkZ9K4Oxa8ijdrrUGuISEKySfKW2qFBYdCQBjPpyeea87F4l07xPQwuFdS0jMk0UXEpvLwfaJWmBw2fuM6A8dgVDcDswHbNeh/D97fS7i8eXzJHS0VFfG6RgHwF46kllAxjmuRbUbcACITSjkDyoXcfmBVvRvGVto1xd3dtb3F1erAY7e2WM7pJSRgEdcADJPbHrivPw1Sbqx5tj08RRToystTfuPhrfz+FdTsYZ7LT7jVriOS5gDu6pDHgQxB+uQASzYy5yMgNkY1/o2gaHZajceJfGFxrd2kXkx2tvG32a1zgBDFGWVB/CAdoweBnBrLuXi1OEX3iWz1S4MsCi5WKDzlRwdzMjKSVJA244XnBwORS1zxvaSwNd3kMOmzoAthp9uPMMER6fICoQ9Sc7SeOCuMesq/tINJXPCpQanefu2Me0/sjxjqtyj2AW3s4kjRzmN+p6qp4Xrx/+qprSNW1o6ZoTRW+mWybr0oocSOf4MnOeBjOfWug8FeFD4h0Vb3TnS21eOGZlW5UYuQ7EqXwBgbgD34NYvgXTb+GfWra4ihSWCUNNBEwcwtlgVO3IHTGM54rknCahKcHdJbfmejGceeMJLXucxpSyaX4/vLawtllIkkREMpjVVznt1wB0wfXHFdP44so7nw60rwkywuGVkI+X1z047fke1cj4zzpvjH7VbyMkuEmJXgqw4/pn8a6rW5Z9b8GRazBaSG0jmDzxK+coDtYEjkc9/Q5p1IylOnVXUVOSUalJ9DZ8PR3MOiWq3ePtO359q7SDzjOOpAA59u/WvdPDF++paFbXMsiPNtKSFTnkHHPv6/4V4dockE2jWjW07XEGwCNmxu25wAfRlxj3216T8N7o+ffWpkOGVJQuOMjIYj/x39KxwdVwxLg+ppjKSlh1JdD0GgUUCvbPFFooooAjJC+uar311b2dnLc3EqRxRqWd26AVO54wuMnuawPFOmSapp0FuCSv2lC4XuOQM/QkH8Kio2otounFSklLY8s1LW7vxLftcXTE2yNuhhJ+VDgEYHTIB5Pcse3AqzKz4SPGWOS7Lu2/Qev+fY2o9NSzBtfOkaVZXRlSCRzkOR/Cp4/Tmt6yXTLK2Ek8dxLcvIIYoPJbdJI3CrnGAD6kgAda8D2NatVbZ9FKrSowutjjGsHuMu0syAgYJlYsfQnnb+AH49qLHwrc3Woi8/tCYmFQzkquGXoFZj2PqegBPsfUrrwXbw3cM2/eXwHULgb/AFA9/wAh19a0rfT7hYxFYw20MDbWNxcBmLfRBjAxnBLDnsa6KOEq31Oarj6fJp1PK4tL8S28d8tvjUtTiUXEdo6mKOKMnpCSOWHHytjaGU8nNc8mq6DH5d9rdhbPeuPMLiMCMk+jN+8kx/eRSuRwxzmvYdS0qG3ukjbW7ePUwfNjSC2/fbv7wUFmxyR0IwSOhOeW1Lwv4fP2u213Q5byS6uJNQk8udxcAH5nkijJ3FOQGUAMMKCHwHr0I4aL1l+B58sVK+mq8yn4c+LHgu0nDzajdW4Vj8rWZVPTOE3Z479fX0q18I7vTtR8XeLToen7dAZovJmaLBZgWyCTktnJYA9ABwCa5fxnoPgK98Nu3h/T7jS5bG9hguriW2n3IsithSJCO4U5bpkdNwrf8F6Dc/Dzx9ZaBp2vtqkN/AJ720W2GxByBJkOSn8PJHzD14xtClGCtFHPOpKbuzkPj5pNjZ+KLa/sbwO1yhjuLdWLeVIgHPoMqy5XqOD/ABV6Hr2l2Vp8BEk0a++wwpYwzpOwCG4yoBWQHrv3bfqQOlZnxx8CWNxpN74wfU7mO5t1jjFu6q6NkhQq9CvLE9SOuAM1kaHrU/i34A6xpMn2qO60e3ZknAPlzxR4baT0JCHaVP8Asnr0uytYi7ZQ+CPh86zFqiXL3CWzDFswXMZkXbv57MAycHqG9q9a8KaMdH8TXNvckmYQb4HU/K8eQG4+oWqHwQsbS3+GdheW9osM12ZDMwYnzWWR1BOc44GK79JEa5VguH5Qgjkf/W4/UVjLDwc1UtqaxxE1B029C1igUUCtzEWiiigBo9ar3Kv5LsjYdfmUkZAP071YHSgjNAHmniyyu9JtrjU4ABYS7nckE/ZyxPzcj7uTu5GASR0xi58O7Ca+0qPWdUtbJrkSOLKaGSSX9393eAzMFLc/dxx9cV2t3ZLcWksGSFkQqyn5gQR0IOa4rTdKvPh94bvFtL5LnRrOGS48m9BZ4FGWZVZeq/eOCCR2Jzio0izV1XKCj2OxaTJM0drNI7DjOFIHHHJGOv8A+usq/sbu9zcarrD6fYxZbyLSUwjHrJMcNj/dKgZPLcVxvjDx3rfhvS9OvrtNMVb2SMxWmyUTFDkS5YMArqGTseSeuKveIdX/ALMgsdS0+zsLxbpSwmltySMYOcg5Hb6YpuoluKjRnVajE3bXUdI0myP9i2Ci1YlmuVKxQsRjLNIxy/BzuG7IBwT0rmvEIg8VaDHqWnawLu/00NchtMkiZPN2jaFd42IAw3THU5rA1K/vdZ1J7i5ikOcNA0ikrECMhcfw8H7y4bPXdjjz7xBdXGieKLe9tIG+1SybCq4EvmcZUsBtkVsgEMDnJHvUxmpM662XzpUlNs968UaHNrnw+1K2sIore8utty4ktRL5rqVY7kKncxCADI7DjiuR+EGmodb1nU7KGwuNFAMNreLarFPnKlo2ART0AJ4IzjB616hqOkWepaPLp19CslrKm2RAxXPTowIIOcYPavB/DPgdPE0PieHQvEM32rTr0wWbyT+ZG8BBwC6gMA2Dypxx0OTWhwC/FfxzJ4t1Wfw1otjcanpmn/v7mW03li68FsqCPLXOMkYz+BPdWmn6B4L+E088ka6e2p6WoniklJWS4a3IIx0DHGDjAJFbvgX4e6d4ItppYGkl1C8jj+2StIWUuAc7MjIXJPXJxjJrI+NGq6TbeDRpepsF/tGTy4XDjdC6jcshU8lQwVWx0D+4BAJvgwZk+E2iHG9CJ/k6H/XSdPWu8gmikmYowbI3D1B6H6dq5X4VXFnc/DPQ/sQVUig8qRVOcSqSH/Nsn8RXWIy/aWUdWGTxzxxQBPQKKBQAtFFFADR0paQdKWgBDXJeNLa8vvBWoW9iiyXciEFBH5gYFgduCQDnvnjGcgjg9aelZm50g2eS0UZPPX07kDjA78dBzSauB4z8SpU8V+FPBt1aSOzXN2U3OyNJwuGZtpwWGwk44HStmS4kn02GzyPIEgk+gI5UexP8zU+pnwPqHim+V7+4sNWs5mEkTs6oXKD94EbK8qduRt757Vg2h06O/t4z4y0mK2EqeZCbyLIXuASBj/69YVPf2PZy2pRpQbm9dzRnulgEe8sWc7VUHOT/AID/AD1rnNIsh4m+MOj6fhWt9IBvrnHGHGCP/HvKH4mrXjLxDo+j3t7f2Wpw3qP8ttDDKjrkgEgbe2Sck+gAzW38KtFm8KaBq3ibW1kW9ubeS7uMqd6RLlsY/vH5iR2yAelVShYvMsZGdKMY9TsfiT410/wd4YnM1zJHf3cMsdisQy5k24DewUkEk/kTxXhfwbXW9G+JOkQyxXNraatBK7LIpVLiMRuykZ4OCOo9T617Bo/hK2mvU8R6rbDV9fugJ2actJDZK/zLFEpOAFzwevU8bsVt63rHlTQOnhfUdR1C3YmFooEHkswwSsjkAZHpmtjwzA+KXxPtfB1ncaVbLJLrVxb7oQANkYYlQzH1ABIGOcCvmO91XV9dksre8vbm8aBBb2ySyFtozjaM/h+Qr3Xw78N7zxf451vX/HenhIXbZBZGb7xIBXJRuipgYz94n0Nauh/BjRdJ8RXpkbzE+129zpxYbmhSNg5Qk9cnIP8Asj16AFz4KRQ6f4NkR7eW2uo7t7a/ifIEc6cA7T0yhTPuM9816Z1uUP8AsN+PIqsLaxsprm4MUcT3WGnfGPMIGMn1OAB9APSpLWLaxx5gVCVXd3HBGPYdKALdAooFAC0UUUANHSlpB0paAEPSqlyxN1DFgHdllGeSRz9Ogq5Va8UfZmYlgEBY7Rk4weOOaAMvVfDmj60SdS0eyv5CoUPcRKxXHoxGQPp61nxfDnwiGZh4d0xkZT1tkPX0JGa2ra6echfJljDfJiRdpGMnOPpj9akjvVEcRkKpubYAeMngjH4c0AYFr4A8KWWpRXVpoNjFPE2d6wjj0x6EEdRzWne6Zpqafe2lxH50F5EYpYWY/MhGNuRz0JGfpV6G8jZYsAr5mCT2yQWP+fenxB5bhpCwCjjaOQehz/KgAslVYiiKE2EjaO3cfTgj/Iqx5annAyBgY7fSmpCEmeUE5dVB/DPP6/pUlAFdbRElkfAIkxkEce/59frUc1irzwSLkbCQfm6DHb07VcoIzQBRm80SC32+YrjjPVR3+vWruOaNo3BsDcB1pe9ABQKKBQAtFFFACAUUtFACUEZpaKAIHtkfJ2qG3Bs47joary6eHXorlUAQNx8wOeTz1wo/Cr9FAFVbGICPK5ZMfN3OKkhiaJnzjaT8v0/zn8hU1FACUUtFACUUtFACUUtFACUtFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//Z" transform="matrix(1 0 0 1 0 0)"/>
+	</g>
+</svg>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/group/bld.inf	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* bld.inf for tiger app
+*/
+
+PRJ_EXPORTS
+tiger.iby /epoc32/rom/include/tiger.iby
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+OPTION TARGETFILE tiger_icon.mif
+OPTION SOURCEDIR ../gfx
+OPTION SOURCES -c32 qgn_menu_tiger.svg
+OPTION SVGENCODINGVERSION 4
+END
+
+PRJ_MMPFILES
+tiger.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/group/tiger.iby	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:  
+* Component IBY file for the OpenVG Tiger Demo.
+*/
+
+#ifndef __TIGER_APP_IBY__
+#define __TIGER_APP_IBY__
+
+// Executable
+S60_APP_EXE( tiger )
+
+// Application icon & registration file
+S60_APP_AIF_ICONS( tiger )
+S60_APP_AIF_RSC( tiger )
+
+// Application specific resource file
+S60_APP_RESOURCE( tiger )
+
+#endif		// __TIGER_APP_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/group/tiger.mmp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,58 @@
+/*
+ * ==============================================================================
+ *  Name        : tiger.mmp
+ *  Part of     : Tiger OpenVG demo app
+ *
+ * ==============================================================================
+ */
+
+//New style application exe
+TARGET          tiger.exe
+TARGETTYPE      exe
+UID             0x100039CE 0xA000024A
+
+EPOCSTACKSIZE   30000
+EPOCHEAPSIZE  0x1000 0x2000000
+
+VENDORID        0
+CAPABILITY      NONE
+
+SOURCEPATH      ..\src
+SOURCE          tiger.cpp
+SOURCE          tigerapp.cpp
+SOURCE          tigerappui.cpp
+SOURCE          tigerdocument.cpp
+SOURCE          tigercontainer.cpp
+
+START RESOURCE  ..\data\tiger.rss
+HEADER
+TARGETPATH      \\resource\\apps
+LANG            SC
+END //RESOURCE
+
+macro __OPENVGHEADERS_USE_VG_1_1
+
+USERINCLUDE     .
+USERINCLUDE     ..\inc
+
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // OpenGL ES include files
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(egl) // EGL include files
+
+LIBRARY         euser.lib apparc.lib cone.lib eikcore.lib
+LIBRARY         avkon.lib fbscli.lib efsrv.lib
+library 		gdi.lib
+LIBRARY         ws32.lib
+LIBRARY			fntstr.lib
+//LIBRARY         sflibopenvgrefimpl.lib
+LIBRARY			libegl_sw.lib
+LIBRARY     libopenvg_sw.lib
+
+START RESOURCE ..\data\tiger_reg.rss
+#ifdef WINSCW
+TARGETPATH 	  \private\10003a3f\apps
+#else
+TARGETPATH 	  \private\10003a3f\import\apps
+#endif
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tiger.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* CTiger class declaration to render OpenVG tiger image
+*/
+
+#ifndef TIGER_H
+#define TIGER_H
+
+//  INCLUDES
+#include <e32base.h> // for CBase definition
+#include <egl.h>
+#include <openvg.h>
+//#include <vgu.h>
+#include <eglosnativewindowtype.h>
+
+////////////////////////////////////////////
+//Copied from ri_package_11\samples\tiger\tiger.h
+extern const int KtigerCommandCount;
+extern const char KtigerCommands[];
+extern const float KtigerMinX;
+extern const float KtigerMaxX;
+extern const float KtigerMinY;
+extern const float KtigerMaxY;
+extern const int KtigerPointCount;
+extern const float KtigerPoints[];
+
+// CLASS DECLARATION
+
+/**
+ * Class that does the actual OpenGL ES rendering.
+ */
+typedef struct
+{
+	VGFillRule		m_fillRule;
+	VGPaintMode		m_paintMode;
+	VGCapStyle		m_capStyle;
+	VGJoinStyle		m_joinStyle;
+	float			m_miterLimit;
+	float			m_strokeWidth;
+	VGPaint			m_fillPaint;
+	VGPaint			m_strokePaint;
+	VGPath			m_path;
+} PathData;
+
+typedef struct
+{
+	PathData*			m_paths;
+	int					m_numPaths;
+} PS;
+
+/////////////////////////////////////////////////////////////
+
+class RWindow;
+
+class CTiger : public CBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+         * Factory method for creating a new CTiger object.
+         */
+        static CTiger* NewL( TUint aWidth, TUint aHeight);
+
+        /**
+         * Destructor. Does nothing.
+         */
+        virtual ~CTiger();
+
+    public: // New functions
+
+        /**
+         * Initializes OpenGL ES, sets the vertex and color
+         * arrays and pointers. Also selects the shading mode.
+         */
+        void AppInit( RWindow& aWindow, CFbsBitmap* aBitmapToDraw=NULL );
+        
+        /**
+         * Called upon application exit. Does nothing.
+         */
+        void AppExit( void );
+
+        /**
+         * Notifies that the screen size has dynamically changed during execution of
+         * this program. Resets the viewport to this new size.
+         * @param aWidth New width of the screen.
+         * @param aHeight New height of the screen.
+         */
+        void SetScreenSize( TUint aWidth, TUint aHeight );
+        
+        void AppRender( const TRect& aRect, CFbsBitmap* aDst=NULL);
+
+    protected: // New functions
+
+        /**
+         * Standard constructor that must never Leave.
+         * Stores the given screen width and height.
+         * @param aWidth Width of the screen.
+         * @param aHeight Height of the screen.
+         */
+        CTiger(TUint aWidth, TUint aHeight);
+
+        /**
+         * Second phase contructor. Does nothing.
+         */
+        void ConstructL( void );
+        
+        //fucntions copied from ri_package_11\samples\tiger\main.c - no attempt to Symbianise!!
+        void PS_destruct(PS* ps);
+        void render(int w, int h);
+        void PS_render(PS* ps);
+        PS* PS_construct(const char* commands, int commandCount, const float* points, int pointCount);
+        void init(NativeWindowType window, CFbsBitmap* aBitmapToDraw=NULL);
+        void CreateImage(CFbsBitmap* aBitmapToDraw);
+        void renderFromBitmap(int w, int h);
+        
+
+    private: // Data
+
+        /** Width of the screen */
+        TUint           iScreenWidth;
+
+        /** Height of the screen */
+        TUint           iScreenHeight;
+
+    private: //OpenVG structures
+    	
+    	//copied from ri_package_11\samples\tiger\main.c - no attempt to symbianise
+    	PS* 				iTiger;
+    	int					iRenderWidth;
+    	int					iRenderHeight;
+    	EGLDisplay			iEgldisplay;
+    	EGLConfig			iEglconfig;
+    	EGLSurface			iEglsurface;
+    	EGLContext			iEglcontext;
+    	TNativeWindowType iNativeWindowType;
+    	VGImage iImage;
+    	CFbsBitmap* iBitmapToDraw;
+   	
+    };
+#endif // TIGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tiger.hrh	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger menu constants
+*/
+
+#ifndef TIGER_HRH
+#define TIGER_HRH
+
+// DATA TYPES
+enum TTigerMenuCommands
+{
+    ETigerShading = 1
+
+};
+
+#endif      // TIGER_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tiger.rls	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger localisation strings
+*/
+// LOCALISATION STRINGS
+
+rls_string STRING_r_app_caption_string       "Tiger"
+rls_string STRING_r_app_short_caption_string "Tiger"
+
+rls_string STRING_r_tiger_exit          "Exit"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tigerApp.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app main class declaration
+*/
+
+#ifndef TIGERAPP_H
+#define TIGERAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+/** UID of the application. */
+const TUid KUidTiger = { 0xA000024A };
+
+// CLASS DECLARATION
+
+/**
+ * Application class. Provides factory method to create a concrete document object.
+ */
+class CTigerApp : public CAknApplication
+    {
+    private: // Functions from base classes
+
+        /**
+         * From CApaApplication, creates and returns CTigerDocument document object.
+         * @return Pointer to the created document object.
+         */
+        CApaDocument* CreateDocumentL();
+
+        /**
+         * From CApaApplication, returns application's UID (KUidTiger).
+         * @return Value of KUidTiger.
+         */
+        TUid AppDllUid() const;
+    };
+
+// OTHER EXPORTED FUNCTIONS
+
+/**
+ * Factory method used by the E32Main method to create a new application instance.
+ */
+LOCAL_C CApaApplication* NewApplication();
+
+/**
+ * Entry point to the EXE application. Creates new application instance and
+ * runs it by giving it as parameter to EikStart::RunApplication() method.
+ */
+GLDEF_C TInt E32Main();
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tigerAppUi.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app UI clas declaration
+*/
+
+#ifndef TIGERAPPUI_H
+#define TIGERAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+
+// FORWARD DECLARATIONS
+class CTigerContainer;
+
+// CLASS DECLARATION
+
+/**
+ * Application UI class that contains the CTigerContainer
+ * (as required by the Symbian UI application architecture).
+ */
+class CTigerAppUi : public CAknAppUi
+    {
+    public: // Constructors and destructor
+
+        /**
+         * Second phase constructor. Creates the CTigerContainer
+         * and adds it to the control stack.
+         */
+        void ConstructL();
+
+        /**
+         * Destructor. Removes CTigerContainer from the control
+         * stack and destroys it.
+         */
+        virtual ~CTigerAppUi();
+
+    private: // Functions from base classes
+
+        /**
+         * This method is called by the EIKON framework just before it displays
+         * a menu pane. Does nothing in this implemenation.
+         */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+        /**
+         * CEikAppUi method that is used to handle user commands.
+         * Handles menu commands and application exit request.
+         * @param aCommand Command to be handled.
+         */
+        void HandleCommandL(TInt aCommand);
+
+        /**
+         * CEikAppUi method that is used to handle key events.
+         * Does nothing in this implemenation.
+         * @param aKeyEvent Event to handled (ignored by this implementation).
+         * @param aType Type of the key event (ignored by this implementation).
+         * @return Response code. Always EKeyWasNotConsumed in this implementation.
+         */
+        virtual TKeyResponse HandleKeyEventL(
+            const TKeyEvent& aKeyEvent,TEventCode aType);
+
+    private: //Data
+
+        /** GUI container that resides in this application UI. */
+        CTigerContainer* iAppContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tigerContainer.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app container class
+*/
+#ifndef TIGERCONTAINER_H
+#define TIGERCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include "tiger.h"
+#include <akndef.h>
+
+#include <eglosnativewindowtype.h>
+
+// CLASS DECLARATION
+
+/**
+ * Container control class that handles the OpenGL ES initialization and deinitializations.
+ * Also uses the CTiger class to do the actual OpenGL ES rendering.
+ */
+class CTicker;
+class CTigerContainer : public CCoeControl, MCoeControlObserver
+    {
+    public: // Constructors and destructor
+
+        /**
+         * EPOC default constructor. Initializes the OpenGL ES for rendering to the window surface.
+         * @param aRect Screen rectangle for container.
+         */
+        void ConstructL(const TRect& aRect);
+
+        /**
+         * Destructor. Destroys the CPeriodic, CTiger and uninitializes OpenGL ES.
+         */
+        virtual ~CTigerContainer();
+
+    private: // Functions from base classes
+
+        /**
+         * Method from CoeControl that gets called when the display size changes.
+         * If OpenGL has been initialized, notifies the renderer class that the screen
+         * size has changed.
+         */
+        void SizeChanged();
+
+        /**
+         * Handles a change to the control's resources. This method
+         * reacts to the KEikDynamicLayoutVariantSwitch event (that notifies of
+         * screen size change) by calling the SetExtentToWholeScreen() again so that
+         * this control fills the new screen size. This will then trigger a call to the
+         * SizeChanged() method.
+         * @param aType Message UID value, only KEikDynamicLayoutVariantSwitch is handled by this method.
+         */
+        void HandleResourceChange(TInt aType);
+
+        /**
+         * Method from CoeControl. Does nothing in this implementation.
+         */
+        TInt CountComponentControls() const;
+
+        /**
+         * Method from CCoeControl. Does nothing in this implementation.
+         */
+        CCoeControl* ComponentControl(TInt aIndex) const;
+
+        /**
+         * Method from CCoeControl. Does nothing in this implementation.
+         * All rendering is done in the DrawCallBack() method.
+         */
+        void Draw(const TRect& aRect) const;
+
+        /**
+         * Method from MCoeControlObserver that handles an event from the observed control.
+         * Does nothing in this implementation.
+		 * @param aControl   Control changing its state.
+		 * @param aEventType Type of the control event.
+         */
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+        
+        void  RenderBitmap(CWindowGc& aGc, CFbsBitmap* aBitmap) const;
+        void  CopyAndRender(CWindowGc& aGc) const;
+        TInt FlipVertical(CFbsBitmap& aBitmap) const;
+
+    private:  //data
+
+        CTiger* iTiger;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/inc/tigerDocument.h	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Tiger app document class
+*/
+
+#ifndef TIGERDOCUMENT_H
+#define TIGERDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+ * Document class that is just used as the container for the application
+ * (as required by the Symbian UI application architecture).
+ */
+class CTigerDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+
+        /**
+         * Factory method for creating a new CTigerDocument object.
+         */
+        static CTigerDocument* NewL(CEikApplication& aApp);
+
+        /**
+         * Destructor. Does nothing.
+         */
+        virtual ~CTigerDocument();
+
+    private:  // Functions from base classes
+
+        /**
+         * C++ constructor. Just passes the given application reference to the baseclass.
+         */
+        CTigerDocument(CEikApplication& aApp);
+
+        /**
+         * Second phase constructor. Does nothing.
+         */
+        void ConstructL();
+
+    private: // New functions
+
+        /**
+         * From CEikDocument, creates and returns CTigerAppUi application UI object.
+         */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/src/tiger.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,21711 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of CTiger class
+*/
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "Tiger.h"
+
+#define assert(a) __ASSERT_ALWAYS(a,User::Invariant());
+
+// CONSTANTS
+
+const float KaspectRatio = 612.0f / 792.0f;
+
+/*--------------------------------------------------------------*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTiger::NewL
+//
+// The usual Symbian NewL implementation.
+// Creates the object, pushes it to cleanup stack and calls ContructL.
+// Returns the contructed object or leaves.
+// -----------------------------------------------------------------------------
+//
+
+CTiger* CTiger::NewL(TUint aWidth, TUint aHeight)
+	{
+	/* Symbian 2-phase constructor. Calls both the default
+	 C++ constructor and Symbian ConstructL methods */
+	CTiger* self = new (ELeave) CTiger(aWidth, aHeight);
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop();
+
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CTiger::CTiger
+//
+// C++ constructor. Initializes the size instance variables from arguments.
+// -----------------------------------------------------------------------------
+//
+
+CTiger::CTiger(TUint aWidth,TUint aHeight) :
+	iScreenWidth(aWidth),iScreenHeight(aHeight)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CTiger::~CTiger
+//
+// C++ destructor.
+// -----------------------------------------------------------------------------
+//
+
+CTiger::~CTiger()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CTiger::ConstructL
+//
+// 2nd phase constructor.
+// -----------------------------------------------------------------------------
+//
+
+void CTiger::ConstructL(void)
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CTiger::AppInit
+//
+// Initializes OpenGL ES, sets the vertex and color arrays and pointers,
+// and selects the shading mode.
+// -----------------------------------------------------------------------------
+//
+
+void CTiger::AppInit(RWindow& /*aWindow*/, CFbsBitmap* aBitmapToDraw)
+	{
+	// Initialize viewport and projection.
+	SetScreenSize(iScreenWidth, iScreenHeight);
+	//render into half-screen dimensions 
+	iNativeWindowType.iSize = TSize(iScreenWidth, iScreenHeight);
+	
+	iBitmapToDraw = aBitmapToDraw;
+	init((NativeWindowType) &iNativeWindowType, aBitmapToDraw);
+	
+	//render now to save time on redraw
+	TRect rect(0, 0, iNativeWindowType.iSize.iWidth, iNativeWindowType.iSize.iHeight);
+	
+	//render now to stop render from taking place on draw which causes ViewSrv 11 panic
+	AppRender(iNativeWindowType.iSize);
+	}
+
+
+// -----------------------------------------------------------------------------
+// CTiger::AppExit
+//
+// Release any allocations made in AppInit.
+// -----------------------------------------------------------------------------
+//
+
+
+void CTiger::AppExit(void)
+	{
+	if(iTiger)
+		PS_destruct(iTiger);
+	eglMakeCurrent(iEgldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+	__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+	eglTerminate(iEgldisplay);
+	__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+	eglReleaseThread();
+	}
+
+void CTiger::PS_destruct(PS* ps)
+	{
+	int i;
+	__ASSERT_ALWAYS(ps,User::Invariant());
+	for (i = 0; i < ps->m_numPaths; i++)
+		{
+		vgDestroyPaint(ps->m_paths[i].m_fillPaint);
+		vgDestroyPaint(ps->m_paths[i].m_strokePaint);
+		vgDestroyPath(ps->m_paths[i].m_path);
+		}
+	delete[] ps->m_paths;
+	ps->m_paths = NULL;
+	delete ps;
+	ps = NULL;
+
+	}
+
+void CTiger::AppRender(const TRect& aRect, CFbsBitmap* aDst)
+	{	
+	TDisplayMode dispMode=ENone;
+	if (iBitmapToDraw == NULL)
+		{
+		//drawing tiger
+		dispMode = EColor16MA;
+		TRAPD(err, render(aRect.Width(), aRect.Height()));
+		if (err==KErrNoMemory)
+			{
+			//check heap metrics		
+			RDebug::Printf("If rendering fails with KErrNoMemory then you must modify epoc.ini file ");
+			RDebug::Printf("to increase the maximum total heap size e.g. to MegabytesOfFreeMemory 64.");
+			RDebug::Printf("The Kronos ref OpenVG seems to use a lot of heap so when both NVG engine");
+			RDebug::Printf("and the Tiger app are active it pushes it over limit of 48Mb.");
+			}
+		}
+	else
+		{
+		//draw bitmap
+		dispMode = iBitmapToDraw->DisplayMode();
+		renderFromBitmap(aRect.Width(), aRect.Height());
+		}
+	if(aDst)
+		{
+		//we want to render into the the aDst CFbsBitmap so set up the native window type for this
+		aDst->Create(iNativeWindowType.iSize, dispMode); //how does display mode relate to pixel buffer colour depth coming from OpenVG?#
+		iNativeWindowType.iBitmap = aDst;
+		
+		//swap buffers that will cause actual copy of data into CFbsBitmap
+		eglSwapBuffers(iEgldisplay, iEglsurface);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+		}
+	
+	//reset
+	iNativeWindowType.iBitmap = NULL;
+	
+	}
+
+void CTiger::SetScreenSize(TUint aWidth, TUint aHeight)
+	{
+	iScreenWidth = aWidth;
+	iScreenHeight = aHeight;
+	}
+
+///////////////////////////////////////////////////////////////////////////
+
+/*
+ * Copied from ri_package_11\samples\tiger\main.c
+ */
+
+void CTiger::render(int w, int h)
+	{
+	if (iRenderWidth != w || iRenderHeight != h)
+		{
+		float clearColor[4] =
+			{
+			1, 1, 1, 1
+			};
+		float scale = w / (KtigerMaxX - KtigerMinX);
+
+		eglSwapBuffers(iEgldisplay, iEglsurface); //force EGL to recognize resize
+
+		vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
+		vgClear(0, 0, w, h);
+
+		vgLoadIdentity();
+		vgScale(scale, scale);
+		vgTranslate(-KtigerMinX, -KtigerMinY + 0.5f * (h / scale - (KtigerMaxY
+				- KtigerMinY)));
+
+		PS_render(iTiger);
+		__ASSERT_ALWAYS(vgGetError() == VG_NO_ERROR,User::Invariant());
+
+		iRenderWidth = w;
+		iRenderHeight = h;
+		}
+	}
+
+void CTiger::renderFromBitmap(int w, int h)
+	{
+	if (iRenderWidth != w || iRenderHeight != h)
+		{
+		TSize sz = iBitmapToDraw->SizeInPixels();
+		float scale = w / (sz.iWidth);
+		vgLoadIdentity();
+		vgScale(scale, scale);
+		vgTranslate(-0.0, -0.0 + 0.5f * (h / scale - (sz.iHeight)));
+
+		iRenderWidth = w;
+		iRenderHeight = h;
+
+		vgDrawImage(iImage);
+		__ASSERT_ALWAYS(vgGetError() == VG_NO_ERROR,User::Invariant());
+		
+		eglSwapBuffers(iEgldisplay, iEglsurface); //force GL to recognise resize
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+		}
+	}
+
+void CTiger::PS_render(PS* ps)
+	{
+	int i;
+	__ASSERT_ALWAYS(ps,User::Invariant());
+	vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
+
+	for (i = 0; i < ps->m_numPaths; i++)
+		{
+		vgSeti(VG_FILL_RULE, ps->m_paths[i].m_fillRule);
+		vgSetPaint(ps->m_paths[i].m_fillPaint, VG_FILL_PATH);
+
+		if (ps->m_paths[i].m_paintMode & VG_STROKE_PATH)
+			{
+			vgSetf(VG_STROKE_LINE_WIDTH, ps->m_paths[i].m_strokeWidth);
+			vgSeti(VG_STROKE_CAP_STYLE, ps->m_paths[i].m_capStyle);
+			vgSeti(VG_STROKE_JOIN_STYLE, ps->m_paths[i].m_joinStyle);
+			vgSetf(VG_STROKE_MITER_LIMIT, ps->m_paths[i].m_miterLimit);
+			vgSetPaint(ps->m_paths[i].m_strokePaint, VG_STROKE_PATH);
+			}
+
+		vgDrawPath(ps->m_paths[i].m_path, ps->m_paths[i].m_paintMode);
+		}
+	__ASSERT_ALWAYS(vgGetError() == VG_NO_ERROR,User::Invariant());
+	}
+
+PS* CTiger::PS_construct(const char* commands, int commandCount,
+		const float* points, int /*pointCount*/)
+	{
+	PS* ps = new PS;
+	assert(ps);
+	int p = 0;
+	int c = 0;
+	int i = 0;
+	int paths = 0;
+	int maxElements = 0;
+	unsigned char* cmd;
+	//UNREF(pointCount);
+
+	while (c < commandCount)
+		{
+		int elements, e;
+		c += 4;
+		p += 8;
+		elements = (int) points[p++];
+		assert(elements> 0);
+		if (elements > maxElements)
+			maxElements = elements;
+		for (e = 0; e < elements; e++)
+			{
+			switch (commands[c])
+				{
+				case 'M':
+					p += 2;
+					break;
+				case 'L':
+					p += 2;
+					break;
+				case 'C':
+					p += 6;
+					break;
+				case 'E':
+					break;
+				default:
+					assert(0)
+					; //unknown command
+				}
+			c++;
+			}
+		paths++;
+		}
+
+	ps->m_numPaths = paths;
+	ps->m_paths = new PathData[paths];//(PathData*)malloc(paths * sizeof(PathData));
+	cmd = new unsigned char[maxElements];//(unsigned char*)malloc(maxElements);
+
+	i = 0;
+	p = 0;
+	c = 0;
+	while (c < commandCount)
+		{
+		int elements, startp, e;
+		float color[4];
+
+		//fill type
+		int paintMode = 0;
+		ps->m_paths[i].m_fillRule = VG_NON_ZERO;
+		switch (commands[c])
+			{
+			case 'N':
+				break;
+			case 'F':
+				ps->m_paths[i].m_fillRule = VG_NON_ZERO;
+				paintMode |= VG_FILL_PATH;
+				break;
+			case 'E':
+				ps->m_paths[i].m_fillRule = VG_EVEN_ODD;
+				paintMode |= VG_FILL_PATH;
+				break;
+			default:
+				assert(0)
+				; //unknown command
+			}
+		c++;
+
+		//stroke
+		switch (commands[c])
+			{
+			case 'N':
+				break;
+			case 'S':
+				paintMode |= VG_STROKE_PATH;
+				break;
+			default:
+				assert(0)
+				; //unknown command
+			}
+		ps->m_paths[i].m_paintMode = (VGPaintMode) paintMode;
+		c++;
+
+		//line cap
+		switch (commands[c])
+			{
+			case 'B':
+				ps->m_paths[i].m_capStyle = VG_CAP_BUTT;
+				break;
+			case 'R':
+				ps->m_paths[i].m_capStyle = VG_CAP_ROUND;
+				break;
+			case 'S':
+				ps->m_paths[i].m_capStyle = VG_CAP_SQUARE;
+				break;
+			default:
+				assert(0)
+				; //unknown command
+			}
+		c++;
+
+		//line join
+		switch (commands[c])
+			{
+			case 'M':
+				ps->m_paths[i].m_joinStyle = VG_JOIN_MITER;
+				break;
+			case 'R':
+				ps->m_paths[i].m_joinStyle = VG_JOIN_ROUND;
+				break;
+			case 'B':
+				ps->m_paths[i].m_joinStyle = VG_JOIN_BEVEL;
+				break;
+			default:
+				assert(0)
+				; //unknown command
+			}
+		c++;
+
+		//the rest of stroke attributes
+		ps->m_paths[i].m_miterLimit = points[p++];
+		ps->m_paths[i].m_strokeWidth = points[p++];
+
+		//paints
+		color[0] = points[p++];
+		color[1] = points[p++];
+		color[2] = points[p++];
+		color[3] = 1.0f;
+		ps->m_paths[i].m_strokePaint = vgCreatePaint();
+		vgSetParameteri(ps->m_paths[i].m_strokePaint, VG_PAINT_TYPE,
+				VG_PAINT_TYPE_COLOR);
+		vgSetParameterfv(ps->m_paths[i].m_strokePaint, VG_PAINT_COLOR, 4, color);
+
+		color[0] = points[p++];
+		color[1] = points[p++];
+		color[2] = points[p++];
+		color[3] = 1.0f;
+		ps->m_paths[i].m_fillPaint = vgCreatePaint();
+		vgSetParameteri(ps->m_paths[i].m_fillPaint, VG_PAINT_TYPE,
+				VG_PAINT_TYPE_COLOR);
+		vgSetParameterfv(ps->m_paths[i].m_fillPaint, VG_PAINT_COLOR, 4, color);
+
+		//read number of elements
+
+		elements = (int) points[p++];
+		assert(elements> 0);
+		startp = p;
+		for (e = 0; e < elements; e++)
+			{
+			switch (commands[c])
+				{
+				case 'M':
+					cmd[e] = VG_MOVE_TO | VG_ABSOLUTE;
+					p += 2;
+					break;
+				case 'L':
+					cmd[e] = VG_LINE_TO | VG_ABSOLUTE;
+					p += 2;
+					break;
+				case 'C':
+					cmd[e] = VG_CUBIC_TO | VG_ABSOLUTE;
+					p += 6;
+					break;
+				case 'E':
+					cmd[e] = VG_CLOSE_PATH;
+					break;
+				default:
+					assert(0)
+					; //unknown command
+				}
+			c++;
+			}
+
+		ps->m_paths[i].m_path = vgCreatePath(
+				VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0,
+				(unsigned int) VG_PATH_CAPABILITY_ALL);
+		vgAppendPathData(ps->m_paths[i].m_path, elements, cmd, points + startp);
+		i++;
+		}
+	delete[] cmd;
+	return ps;
+	}
+
+void CTiger::init(NativeWindowType window, CFbsBitmap* aBitmapToDraw)
+	{
+	static const EGLint s_configAttribs[] =
+		{
+				EGL_RED_SIZE,
+				8,
+				EGL_GREEN_SIZE,
+				8,
+				EGL_BLUE_SIZE,
+				8,
+				EGL_ALPHA_SIZE,
+				8,
+				EGL_LUMINANCE_SIZE,
+				EGL_DONT_CARE, //EGL_DONT_CARE
+				EGL_SURFACE_TYPE,
+				EGL_WINDOW_BIT,
+				EGL_SAMPLES,
+				1,
+				EGL_NONE
+		};
+	EGLint numconfigs;
+
+	iEgldisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+	eglInitialize(iEgldisplay, NULL, NULL);
+	assert(eglGetError() == EGL_SUCCESS);
+	eglBindAPI(EGL_OPENVG_API);
+
+	eglChooseConfig(iEgldisplay, s_configAttribs, &iEglconfig, 1, &numconfigs);
+	assert(eglGetError() == EGL_SUCCESS);
+	assert(numconfigs == 1);
+
+	iEglsurface = eglCreateWindowSurface(iEgldisplay, iEglconfig, window, NULL);
+	assert(eglGetError() == EGL_SUCCESS);
+	iEglcontext = eglCreateContext(iEgldisplay, iEglconfig, NULL, NULL);
+	assert(eglGetError() == EGL_SUCCESS);
+	eglMakeCurrent(iEgldisplay, iEglsurface, iEglsurface, iEglcontext);
+	assert(eglGetError() == EGL_SUCCESS);
+
+	if (aBitmapToDraw == NULL)//render tiger image
+		iTiger = PS_construct(KtigerCommands, KtigerCommandCount, KtigerPoints,
+				KtigerPointCount);
+	else
+		{
+		//render bitmap through OpenVG
+		CreateImage(aBitmapToDraw);
+		}
+	}
+
+void CTiger::CreateImage(CFbsBitmap* aBitmapToDraw)
+	{
+	TUint32* address = aBitmapToDraw->DataAddress();
+	TSize sz = aBitmapToDraw->SizeInPixels();
+
+	VGImageFormat dataFormat = VG_sRGB_565;
+	VGint width = sz.iWidth;
+	VGint height = sz.iHeight;
+	VGint dataStride = aBitmapToDraw->DataStride();
+
+	vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED);
+	vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
+
+	//Create VGImage
+
+	iImage = vgCreateImage(dataFormat, width, height,
+			VG_IMAGE_QUALITY_NONANTIALIASED);
+	__ASSERT_ALWAYS(vgGetError() == VG_NO_ERROR,User::Invariant());
+
+	//Load Symbian bitmap into VGImage
+	vgImageSubData(iImage, aBitmapToDraw->DataAddress(), dataStride,
+			dataFormat, 0, 0, width, height);
+	__ASSERT_ALWAYS(vgGetError() == VG_NO_ERROR,User::Invariant());
+
+	}
+
+const int KtigerCommandCount = 4151;
+const char KtigerCommands[4151] = {
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'L',
+			'L',
+			'L',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'L',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'L',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'L',
+			'L',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'L',
+			'C',
+			'C',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'L',
+			'L',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'B',
+			'M',
+			'M',
+			'C',
+			'C',
+			'L',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'C',
+			'C',
+			'C',
+			'E',
+			'F',
+			'N',
+			'R',
+			'M',
+			'M',
+			'L',
+			'C',
+			'L',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'L',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C',
+			'N',
+			'S',
+			'R',
+			'M',
+			'M',
+			'C'
+	};
+
+const float KtigerMinX = 0.0f;
+const float KtigerMaxX = 612.0f;
+const float KtigerMinY = 0.0f;
+const float KtigerMaxY = 792.0f;
+
+const int KtigerPointCount = 17005;
+const float KtigerPoints[17005] = {
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			0,
+			792,
+			0,
+			0,
+			612,
+			0,
+			612,
+			792,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			85.25f,
+			487.75f,
+			85.25f,
+			487.75f,
+			85.5742f,
+			485.199f,
+			84.25f,
+			484.746f,
+			83.7617f,
+			485.242f,
+			65.6641f,
+			538.125f,
+			43.2461f,
+			535.746f,
+			43.2422f,
+			535.746f,
+			62.6445f,
+			543.746f,
+			85.25f,
+			487.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			85.25f,
+			487.75f,
+			85.25f,
+			487.75f,
+			85.5742f,
+			485.199f,
+			84.25f,
+			484.746f,
+			83.7617f,
+			485.242f,
+			65.6641f,
+			538.125f,
+			43.2461f,
+			535.746f,
+			43.2422f,
+			535.746f,
+			62.6445f,
+			543.746f,
+			85.25f,
+			487.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			89.2461f,
+			490.75f,
+			89.2461f,
+			490.75f,
+			88.7422f,
+			488.613f,
+			88.2461f,
+			488.746f,
+			87.0508f,
+			489.27f,
+			88.0234f,
+			545.156f,
+			66.2461f,
+			550.746f,
+			66.2461f,
+			550.742f,
+			87.0977f,
+			551.469f,
+			89.2461f,
+			490.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			89.2461f,
+			490.75f,
+			89.2461f,
+			490.75f,
+			88.7422f,
+			488.613f,
+			88.2461f,
+			488.746f,
+			87.0508f,
+			489.27f,
+			88.0234f,
+			545.156f,
+			66.2461f,
+			550.746f,
+			66.2461f,
+			550.742f,
+			87.0977f,
+			551.469f,
+			89.2461f,
+			490.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			119.25f,
+			443.75f,
+			119.25f,
+			443.75f,
+			121.387f,
+			442.992f,
+			121.246f,
+			442.746f,
+			120.352f,
+			441.504f,
+			66.2578f,
+			455.586f,
+			56.25f,
+			435.75f,
+			56.25f,
+			435.75f,
+			59.9062f,
+			456.168f,
+			119.25f,
+			443.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			119.25f,
+			443.75f,
+			119.25f,
+			443.75f,
+			121.387f,
+			442.992f,
+			121.246f,
+			442.746f,
+			120.352f,
+			441.504f,
+			66.2578f,
+			455.586f,
+			56.25f,
+			435.75f,
+			56.25f,
+			435.75f,
+			59.9062f,
+			456.168f,
+			119.25f,
+			443.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			116.246f,
+			432.75f,
+			116.246f,
+			432.75f,
+			118.539f,
+			432.383f,
+			118.25f,
+			431.746f,
+			118.023f,
+			430.641f,
+			62.25f,
+			426.965f,
+			58.25f,
+			404.75f,
+			58.25f,
+			404.75f,
+			56.0391f,
+			425.516f,
+			116.246f,
+			432.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			116.246f,
+			432.75f,
+			116.246f,
+			432.75f,
+			118.539f,
+			432.383f,
+			118.25f,
+			431.746f,
+			118.023f,
+			430.641f,
+			62.25f,
+			426.965f,
+			58.25f,
+			404.75f,
+			58.25f,
+			404.75f,
+			56.0391f,
+			425.516f,
+			116.246f,
+			432.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			112.25f,
+			438.746f,
+			112.25f,
+			438.742f,
+			113.82f,
+			438.164f,
+			113.25f,
+			437.75f,
+			113.059f,
+			436.52f,
+			57.3437f,
+			441.016f,
+			50.2461f,
+			419.75f,
+			50.2461f,
+			419.75f,
+			50.9883f,
+			440.492f,
+			112.25f,
+			438.746f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			112.25f,
+			438.746f,
+			112.25f,
+			438.742f,
+			113.82f,
+			438.164f,
+			113.25f,
+			437.75f,
+			113.059f,
+			436.52f,
+			57.3437f,
+			441.016f,
+			50.2461f,
+			419.75f,
+			50.2461f,
+			419.75f,
+			50.9883f,
+			440.492f,
+			112.25f,
+			438.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			100.246f,
+			458.746f,
+			100.246f,
+			458.746f,
+			101.527f,
+			457.406f,
+			101.25f,
+			456.746f,
+			100.121f,
+			456.262f,
+			52.0039f,
+			484.699f,
+			36.25f,
+			467.746f,
+			36.25f,
+			467.746f,
+			46.0586f,
+			487.012f,
+			100.246f,
+			458.746f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			100.246f,
+			458.746f,
+			100.246f,
+			458.746f,
+			101.527f,
+			457.406f,
+			101.25f,
+			456.746f,
+			100.121f,
+			456.262f,
+			52.0039f,
+			484.699f,
+			36.25f,
+			467.746f,
+			36.25f,
+			467.746f,
+			46.0586f,
+			487.012f,
+			100.246f,
+			458.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			92.2461f,
+			454.75f,
+			92.2422f,
+			454.75f,
+			93.3906f,
+			452.969f,
+			93.2461f,
+			452.75f,
+			92.125f,
+			451.672f,
+			41.0976f,
+			474.484f,
+			27.25f,
+			456.746f,
+			27.25f,
+			456.746f,
+			34.9258f,
+			476.105f,
+			92.2461f,
+			454.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			92.2461f,
+			454.75f,
+			92.2422f,
+			454.75f,
+			93.3906f,
+			452.969f,
+			93.2461f,
+			452.75f,
+			92.125f,
+			451.672f,
+			41.0976f,
+			474.484f,
+			27.25f,
+			456.746f,
+			27.25f,
+			456.746f,
+			34.9258f,
+			476.105f,
+			92.2461f,
+			454.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			89.2461f,
+			449.746f,
+			89.2461f,
+			449.742f,
+			90.6992f,
+			448.723f,
+			90.25f,
+			447.746f,
+			89.6211f,
+			447.262f,
+			35.9609f,
+			462.906f,
+			25.25f,
+			442.746f,
+			25.25f,
+			442.742f,
+			29.625f,
+			463.676f,
+			89.2461f,
+			449.746f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			89.2461f,
+			449.746f,
+			89.2461f,
+			449.742f,
+			90.6992f,
+			448.723f,
+			90.25f,
+			447.746f,
+			89.6211f,
+			447.262f,
+			35.9609f,
+			462.906f,
+			25.25f,
+			442.746f,
+			25.25f,
+			442.742f,
+			29.625f,
+			463.676f,
+			89.2461f,
+			449.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			100.246f,
+			448.75f,
+			100.246f,
+			448.75f,
+			101.969f,
+			447.469f,
+			101.25f,
+			446.75f,
+			100.43f,
+			446.512f,
+			56.3516f,
+			480.887f,
+			39.2461f,
+			466.746f,
+			39.2461f,
+			466.742f,
+			50.75f,
+			483.941f,
+			100.246f,
+			448.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			100.246f,
+			448.75f,
+			100.246f,
+			448.75f,
+			101.969f,
+			447.469f,
+			101.25f,
+			446.75f,
+			100.43f,
+			446.512f,
+			56.3516f,
+			480.887f,
+			39.2461f,
+			466.746f,
+			39.2461f,
+			466.742f,
+			50.75f,
+			483.941f,
+			100.246f,
+			448.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			79.25f,
+			480.746f,
+			79.25f,
+			480.746f,
+			79.6367f,
+			479.02f,
+			79.25f,
+			478.746f,
+			77.8789f,
+			478.578f,
+			46.418f,
+			524.777f,
+			25.25f,
+			516.75f,
+			25.25f,
+			516.75f,
+			42.0195f,
+			529.398f,
+			79.25f,
+			480.746f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			79.25f,
+			480.746f,
+			79.25f,
+			480.746f,
+			79.6367f,
+			479.02f,
+			79.25f,
+			478.746f,
+			77.8789f,
+			478.578f,
+			46.418f,
+			524.777f,
+			25.25f,
+			516.75f,
+			25.25f,
+			516.75f,
+			42.0195f,
+			529.398f,
+			79.25f,
+			480.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			79.25f,
+			473.746f,
+			79.25f,
+			473.742f,
+			80.8164f,
+			471.527f,
+			80.25f,
+			470.75f,
+			79.1914f,
+			470.723f,
+			38.5078f,
+			509.051f,
+			19.25f,
+			496.75f,
+			19.25f,
+			496.75f,
+			33.2148f,
+			512.609f,
+			79.25f,
+			473.746f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			79.25f,
+			473.746f,
+			79.25f,
+			473.742f,
+			80.8164f,
+			471.527f,
+			80.25f,
+			470.75f,
+			79.1914f,
+			470.723f,
+			38.5078f,
+			509.051f,
+			19.25f,
+			496.75f,
+			19.25f,
+			496.75f,
+			33.2148f,
+			512.609f,
+			79.25f,
+			473.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			79.25f,
+			468.75f,
+			79.25f,
+			468.75f,
+			80.8516f,
+			466.828f,
+			80.25f,
+			466.746f,
+			79.3086f,
+			465.875f,
+			35.2305f,
+			500.246f,
+			17.25f,
+			485.75f,
+			17.25f,
+			485.75f,
+			29.6289f,
+			503.301f,
+			79.25f,
+			468.75f,
+			10,
+			0.1892f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			79.25f,
+			468.75f,
+			79.25f,
+			468.75f,
+			80.8516f,
+			466.828f,
+			80.25f,
+			466.746f,
+			79.3086f,
+			465.875f,
+			35.2305f,
+			500.246f,
+			17.25f,
+			485.75f,
+			17.25f,
+			485.75f,
+			29.6289f,
+			503.301f,
+			79.25f,
+			468.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			88,
+			77.2461f,
+			466.746f,
+			77.7383f,
+			459.973f,
+			78.8242f,
+			452.746f,
+			80.25f,
+			449.746f,
+			80.25f,
+			449.742f,
+			76.7773f,
+			435.676f,
+			86.25f,
+			420.746f,
+			86.25f,
+			420.742f,
+			86.0195f,
+			413.238f,
+			88.2461f,
+			409.746f,
+			88.2461f,
+			409.742f,
+			92.1797f,
+			400.477f,
+			97.25f,
+			399.75f,
+			101.73f,
+			398.887f,
+			111.324f,
+			395.508f,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			141.02f,
+			378.477f,
+			137.246f,
+			364.75f,
+			137.242f,
+			364.75f,
+			137.059f,
+			346.355f,
+			133.246f,
+			344.75f,
+			133.246f,
+			344.75f,
+			145.859f,
+			356.918f,
+			135.25f,
+			338.75f,
+			130.25f,
+			317.746f,
+			130.25f,
+			317.742f,
+			158.617f,
+			341.516f,
+			141.25f,
+			321.746f,
+			130.25f,
+			292.75f,
+			130.25f,
+			292.75f,
+			152.02f,
+			312.918f,
+			144.246f,
+			303.75f,
+			140.25f,
+			293.746f,
+			140.25f,
+			293.746f,
+			188.098f,
+			323.918f,
+			154.246f,
+			291.746f,
+			154.242f,
+			291.746f,
+			163.02f,
+			295.316f,
+			168.25f,
+			291.746f,
+			168.25f,
+			291.746f,
+			175.34f,
+			293.559f,
+			174.25f,
+			291.746f,
+			174.25f,
+			291.746f,
+			151.578f,
+			280.355f,
+			147.25f,
+			259.746f,
+			147.25f,
+			259.746f,
+			156.859f,
+			271.117f,
+			153.246f,
+			258.746f,
+			154.246f,
+			246.746f,
+			154.242f,
+			246.746f,
+			158.18f,
+			270.238f,
+			157.25f,
+			228.746f,
+			157.25f,
+			228.742f,
+			178.859f,
+			248.676f,
+			166.246f,
+			225.746f,
+			166.246f,
+			207.75f,
+			166.246f,
+			207.75f,
+			182.816f,
+			225.355f,
+			176.246f,
+			211.75f,
+			176.246f,
+			211.75f,
+			186.777f,
+			220.957f,
+			182.25f,
+			203.746f,
+			182.25f,
+			203.746f,
+			181.5f,
+			192.797f,
+			186.25f,
+			204.746f,
+			186.25f,
+			204.746f,
+			203.938f,
+			238.777f,
+			197.25f,
+			209.75f,
+			197.25f,
+			209.75f,
+			196.457f,
+			188.836f,
+			201.246f,
+			204.746f,
+			201.246f,
+			204.746f,
+			202.18f,
+			193.676f,
+			212.246f,
+			185.75f,
+			212.246f,
+			185.75f,
+			210.977f,
+			241.637f,
+			225.25f,
+			201.746f,
+			229.25f,
+			183.746f,
+			229.25f,
+			183.742f,
+			232.539f,
+			194.117f,
+			232.246f,
+			199.75f,
+			232.246f,
+			199.75f,
+			248.379f,
+			217.879f,
+			241.25f,
+			190.746f,
+			241.25f,
+			190.746f,
+			257.617f,
+			216.117f,
+			254.246f,
+			201.746f,
+			254.246f,
+			201.746f,
+			245.738f,
+			183.996f,
+			247.246f,
+			178.75f,
+			247.242f,
+			178.75f,
+			265.977f,
+			216.996f,
+			267.246f,
+			218.75f,
+			267.246f,
+			218.75f,
+			265.098f,
+			172.117f,
+			277.246f,
+			211.75f,
+			277.246f,
+			211.75f,
+			283.137f,
+			198.516f,
+			280.246f,
+			193.746f,
+			280.242f,
+			193.746f,
+			288.859f,
+			202.477f,
+			288.246f,
+			205.746f,
+			288.246f,
+			205.742f,
+			293.039f,
+			215.016f,
+			296.25f,
+			199.75f,
+			296.25f,
+			199.75f,
+			298.098f,
+			189.719f,
+			300.246f,
+			192.746f,
+			300.246f,
+			192.746f,
+			304.258f,
+			166.836f,
+			305.25f,
+			191.746f,
+			305.25f,
+			191.746f,
+			307.34f,
+			206.879f,
+			299.246f,
+			219.75f,
+			299.246f,
+			219.75f,
+			300.297f,
+			223.156f,
+			297.246f,
+			227.746f,
+			297.246f,
+			227.742f,
+			312.18f,
+			203.797f,
+			304.25f,
+			235.746f,
+			304.25f,
+			235.746f,
+			316.578f,
+			226.676f,
+			318.25f,
+			226.746f,
+			318.25f,
+			226.746f,
+			302.937f,
+			252.195f,
+			312.246f,
+			246.746f,
+			312.242f,
+			246.746f,
+			306.898f,
+			258.355f,
+			326.25f,
+			244.75f,
+			326.25f,
+			244.75f,
+			309.098f,
+			262.758f,
+			328.25f,
+			251.75f,
+			328.25f,
+			251.75f,
+			337.258f,
+			245.156f,
+			329.25f,
+			255.75f,
+			329.25f,
+			255.75f,
+			313.059f,
+			273.758f,
+			337.25f,
+			253.75f,
+			337.25f,
+			253.75f,
+			350.02f,
+			235.918f,
+			351.25f,
+			232.75f,
+			351.25f,
+			232.75f,
+			339.898f,
+			264.957f,
+			335.246f,
+			267.75f,
+			335.242f,
+			267.75f,
+			344.301f,
+			308.078f,
+			389.246f,
+			290.75f,
+			389.246f,
+			290.75f,
+			397.098f,
+			271.996f,
+			402.246f,
+			291.746f,
+			402.242f,
+			291.746f,
+			416.02f,
+			299.277f,
+			428.25f,
+			268.75f,
+			428.25f,
+			268.75f,
+			432.738f,
+			283.879f,
+			432.246f,
+			286.746f,
+			432.246f,
+			286.742f,
+			439.34f,
+			285.637f,
+			438.25f,
+			286.746f,
+			438.25f,
+			286.742f,
+			452.98f,
+			282.117f,
+			454.246f,
+			282.746f,
+			454.246f,
+			282.746f,
+			461.777f,
+			275.516f,
+			462.246f,
+			279.75f,
+			462.242f,
+			279.75f,
+			472.34f,
+			276.398f,
+			470.25f,
+			280.746f,
+			470.25f,
+			280.746f,
+			479.82f,
+			263.195f,
+			480.246f,
+			258.746f,
+			483.25f,
+			274.75f,
+			485.25f,
+			271.746f,
+			485.25f,
+			271.746f,
+			486.859f,
+			279.918f,
+			486.25f,
+			280.746f,
+			485.098f,
+			282.559f,
+			507.98f,
+			273.758f,
+			513.246f,
+			250.746f,
+			515.246f,
+			241.75f,
+			515.242f,
+			241.75f,
+			522.059f,
+			257.918f,
+			520.246f,
+			262.75f,
+			520.246f,
+			262.75f,
+			526.02f,
+			261.438f,
+			526.246f,
+			256.746f,
+			526.242f,
+			256.746f,
+			530.859f,
+			282.117f,
+			525.25f,
+			288.746f,
+			525.25f,
+			288.742f,
+			530.418f,
+			289.598f,
+			531.246f,
+			285.75f,
+			531.246f,
+			293.746f,
+			531.246f,
+			293.746f,
+			539.66f,
+			292.676f,
+			539.246f,
+			295.746f,
+			539.242f,
+			295.742f,
+			544.5f,
+			299.719f,
+			546.246f,
+			294.75f,
+			546.242f,
+			294.75f,
+			533.059f,
+			333.156f,
+			553.246f,
+			311.75f,
+			553.246f,
+			311.75f,
+			561.219f,
+			300.156f,
+			557.246f,
+			320.75f,
+			553.301f,
+			341.516f,
+			548.898f,
+			343.277f,
+			554.25f,
+			343.746f,
+			554.25f,
+			343.742f,
+			555.059f,
+			347.676f,
+			553.246f,
+			349.75f,
+			550.66f,
+			351.195f,
+			554.25f,
+			349.75f,
+			554.25f,
+			349.75f,
+			554.25f,
+			349.75f,
+			559.461f,
+			345.035f,
+			553.246f,
+			368.746f,
+			553.246f,
+			368.746f,
+			560.777f,
+			367.477f,
+			547.25f,
+			399.75f,
+			547.25f,
+			399.75f,
+			550.66f,
+			402.238f,
+			546.246f,
+			411.746f,
+			546.242f,
+			411.742f,
+			555.059f,
+			406.637f,
+			558.25f,
+			408.75f,
+			558.25f,
+			408.75f,
+			557.699f,
+			410.156f,
+			554.25f,
+			414.746f,
+			554.25f,
+			414.746f,
+			530.418f,
+			474.84f,
+			553.246f,
+			450.75f,
+			553.246f,
+			450.75f,
+			565.895f,
+			435.73f,
+			559.246f,
+			460.746f,
+			559.242f,
+			460.742f,
+			548.832f,
+			487.223f,
+			549.25f,
+			491.746f,
+			77.2461f,
+			466.746f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			88,
+			77.2461f,
+			466.746f,
+			77.7383f,
+			459.973f,
+			78.8242f,
+			452.746f,
+			80.25f,
+			449.746f,
+			80.25f,
+			449.742f,
+			76.7773f,
+			435.676f,
+			86.25f,
+			420.746f,
+			86.25f,
+			420.742f,
+			86.0195f,
+			413.238f,
+			88.2461f,
+			409.746f,
+			88.2461f,
+			409.742f,
+			92.1797f,
+			400.477f,
+			97.25f,
+			399.75f,
+			101.73f,
+			398.887f,
+			111.324f,
+			395.508f,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			141.02f,
+			378.477f,
+			137.246f,
+			364.75f,
+			137.242f,
+			364.75f,
+			137.059f,
+			346.355f,
+			133.246f,
+			344.75f,
+			133.246f,
+			344.75f,
+			145.859f,
+			356.918f,
+			135.25f,
+			338.75f,
+			130.25f,
+			317.746f,
+			130.25f,
+			317.742f,
+			158.617f,
+			341.516f,
+			141.25f,
+			321.746f,
+			130.25f,
+			292.75f,
+			130.25f,
+			292.75f,
+			152.02f,
+			312.918f,
+			144.246f,
+			303.75f,
+			140.25f,
+			293.746f,
+			140.25f,
+			293.746f,
+			188.098f,
+			323.918f,
+			154.246f,
+			291.746f,
+			154.242f,
+			291.746f,
+			163.02f,
+			295.316f,
+			168.25f,
+			291.746f,
+			168.25f,
+			291.746f,
+			175.34f,
+			293.559f,
+			174.25f,
+			291.746f,
+			174.25f,
+			291.746f,
+			151.578f,
+			280.355f,
+			147.25f,
+			259.746f,
+			147.25f,
+			259.746f,
+			156.859f,
+			271.117f,
+			153.246f,
+			258.746f,
+			154.246f,
+			246.746f,
+			154.242f,
+			246.746f,
+			158.18f,
+			270.238f,
+			157.25f,
+			228.746f,
+			157.25f,
+			228.742f,
+			178.859f,
+			248.676f,
+			166.246f,
+			225.746f,
+			166.246f,
+			207.75f,
+			166.246f,
+			207.75f,
+			182.816f,
+			225.355f,
+			176.246f,
+			211.75f,
+			176.246f,
+			211.75f,
+			186.777f,
+			220.957f,
+			182.25f,
+			203.746f,
+			182.25f,
+			203.746f,
+			181.5f,
+			192.797f,
+			186.25f,
+			204.746f,
+			186.25f,
+			204.746f,
+			203.938f,
+			238.777f,
+			197.25f,
+			209.75f,
+			197.25f,
+			209.75f,
+			196.457f,
+			188.836f,
+			201.246f,
+			204.746f,
+			201.246f,
+			204.746f,
+			202.18f,
+			193.676f,
+			212.246f,
+			185.75f,
+			212.246f,
+			185.75f,
+			210.977f,
+			241.637f,
+			225.25f,
+			201.746f,
+			229.25f,
+			183.746f,
+			229.25f,
+			183.742f,
+			232.539f,
+			194.117f,
+			232.246f,
+			199.75f,
+			232.246f,
+			199.75f,
+			248.379f,
+			217.879f,
+			241.25f,
+			190.746f,
+			241.25f,
+			190.746f,
+			257.617f,
+			216.117f,
+			254.246f,
+			201.746f,
+			254.246f,
+			201.746f,
+			245.738f,
+			183.996f,
+			247.246f,
+			178.75f,
+			247.242f,
+			178.75f,
+			265.977f,
+			216.996f,
+			267.246f,
+			218.75f,
+			267.246f,
+			218.75f,
+			265.098f,
+			172.117f,
+			277.246f,
+			211.75f,
+			277.246f,
+			211.75f,
+			283.137f,
+			198.516f,
+			280.246f,
+			193.746f,
+			280.242f,
+			193.746f,
+			288.859f,
+			202.477f,
+			288.246f,
+			205.746f,
+			288.246f,
+			205.742f,
+			293.039f,
+			215.016f,
+			296.25f,
+			199.75f,
+			296.25f,
+			199.75f,
+			298.098f,
+			189.719f,
+			300.246f,
+			192.746f,
+			300.246f,
+			192.746f,
+			304.258f,
+			166.836f,
+			305.25f,
+			191.746f,
+			305.25f,
+			191.746f,
+			307.34f,
+			206.879f,
+			299.246f,
+			219.75f,
+			299.246f,
+			219.75f,
+			300.297f,
+			223.156f,
+			297.246f,
+			227.746f,
+			297.246f,
+			227.742f,
+			312.18f,
+			203.797f,
+			304.25f,
+			235.746f,
+			304.25f,
+			235.746f,
+			316.578f,
+			226.676f,
+			318.25f,
+			226.746f,
+			318.25f,
+			226.746f,
+			302.937f,
+			252.195f,
+			312.246f,
+			246.746f,
+			312.242f,
+			246.746f,
+			306.898f,
+			258.355f,
+			326.25f,
+			244.75f,
+			326.25f,
+			244.75f,
+			309.098f,
+			262.758f,
+			328.25f,
+			251.75f,
+			328.25f,
+			251.75f,
+			337.258f,
+			245.156f,
+			329.25f,
+			255.75f,
+			329.25f,
+			255.75f,
+			313.059f,
+			273.758f,
+			337.25f,
+			253.75f,
+			337.25f,
+			253.75f,
+			350.02f,
+			235.918f,
+			351.25f,
+			232.75f,
+			351.25f,
+			232.75f,
+			339.898f,
+			264.957f,
+			335.246f,
+			267.75f,
+			335.242f,
+			267.75f,
+			344.301f,
+			308.078f,
+			389.246f,
+			290.75f,
+			389.246f,
+			290.75f,
+			397.098f,
+			271.996f,
+			402.246f,
+			291.746f,
+			402.242f,
+			291.746f,
+			416.02f,
+			299.277f,
+			428.25f,
+			268.75f,
+			428.25f,
+			268.75f,
+			432.738f,
+			283.879f,
+			432.246f,
+			286.746f,
+			432.246f,
+			286.742f,
+			439.34f,
+			285.637f,
+			438.25f,
+			286.746f,
+			438.25f,
+			286.742f,
+			452.98f,
+			282.117f,
+			454.246f,
+			282.746f,
+			454.246f,
+			282.746f,
+			461.777f,
+			275.516f,
+			462.246f,
+			279.75f,
+			462.242f,
+			279.75f,
+			472.34f,
+			276.398f,
+			470.25f,
+			280.746f,
+			470.25f,
+			280.746f,
+			479.82f,
+			263.195f,
+			480.246f,
+			258.746f,
+			483.25f,
+			274.75f,
+			485.25f,
+			271.746f,
+			485.25f,
+			271.746f,
+			486.859f,
+			279.918f,
+			486.25f,
+			280.746f,
+			485.098f,
+			282.559f,
+			507.98f,
+			273.758f,
+			513.246f,
+			250.746f,
+			515.246f,
+			241.75f,
+			515.242f,
+			241.75f,
+			522.059f,
+			257.918f,
+			520.246f,
+			262.75f,
+			520.246f,
+			262.75f,
+			526.02f,
+			261.438f,
+			526.246f,
+			256.746f,
+			526.242f,
+			256.746f,
+			530.859f,
+			282.117f,
+			525.25f,
+			288.746f,
+			525.25f,
+			288.742f,
+			530.418f,
+			289.598f,
+			531.246f,
+			285.75f,
+			531.246f,
+			293.746f,
+			531.246f,
+			293.746f,
+			539.66f,
+			292.676f,
+			539.246f,
+			295.746f,
+			539.242f,
+			295.742f,
+			544.5f,
+			299.719f,
+			546.246f,
+			294.75f,
+			546.242f,
+			294.75f,
+			533.059f,
+			333.156f,
+			553.246f,
+			311.75f,
+			553.246f,
+			311.75f,
+			561.219f,
+			300.156f,
+			557.246f,
+			320.75f,
+			553.301f,
+			341.516f,
+			548.898f,
+			343.277f,
+			554.25f,
+			343.746f,
+			554.25f,
+			343.742f,
+			555.059f,
+			347.676f,
+			553.246f,
+			349.75f,
+			550.66f,
+			351.195f,
+			554.25f,
+			349.75f,
+			554.25f,
+			349.75f,
+			554.25f,
+			349.75f,
+			559.461f,
+			345.035f,
+			553.246f,
+			368.746f,
+			553.246f,
+			368.746f,
+			560.777f,
+			367.477f,
+			547.25f,
+			399.75f,
+			547.25f,
+			399.75f,
+			550.66f,
+			402.238f,
+			546.246f,
+			411.746f,
+			546.242f,
+			411.742f,
+			555.059f,
+			406.637f,
+			558.25f,
+			408.75f,
+			558.25f,
+			408.75f,
+			557.699f,
+			410.156f,
+			554.25f,
+			414.746f,
+			554.25f,
+			414.746f,
+			530.418f,
+			474.84f,
+			553.246f,
+			450.75f,
+			553.246f,
+			450.75f,
+			565.895f,
+			435.73f,
+			559.246f,
+			460.746f,
+			559.242f,
+			460.742f,
+			548.832f,
+			487.223f,
+			549.25f,
+			491.746f,
+			77.2461f,
+			466.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			44,
+			549.25f,
+			491.746f,
+			550.379f,
+			491.531f,
+			552.805f,
+			490.293f,
+			554.25f,
+			488.746f,
+			554.25f,
+			488.742f,
+			561.66f,
+			476.598f,
+			556.25f,
+			496.75f,
+			556.25f,
+			496.75f,
+			545.82f,
+			528.52f,
+			555.246f,
+			515.746f,
+			555.246f,
+			515.742f,
+			562.098f,
+			508.277f,
+			558.25f,
+			522.746f,
+			554.328f,
+			541.309f,
+			551.25f,
+			548.746f,
+			551.25f,
+			548.746f,
+			551.25f,
+			548.746f,
+			564.301f,
+			543.039f,
+			535.246f,
+			586.75f,
+			544.246f,
+			582.75f,
+			544.246f,
+			582.75f,
+			522.938f,
+			626.199f,
+			499.25f,
+			631.746f,
+			490.25f,
+			638.746f,
+			490.25f,
+			638.742f,
+			532.621f,
+			680.316f,
+			518.25f,
+			720.75f,
+			518.25f,
+			720.75f,
+			511.059f,
+			726.52f,
+			500.246f,
+			716.75f,
+			500.246f,
+			716.75f,
+			493.461f,
+			711.117f,
+			487.246f,
+			712.75f,
+			487.246f,
+			712.75f,
+			452.98f,
+			711.559f,
+			451.25f,
+			711.746f,
+			448.578f,
+			711.559f,
+			410.301f,
+			752.477f,
+			338.25f,
+			732.746f,
+			338.25f,
+			732.742f,
+			332.418f,
+			730.918f,
+			327.25f,
+			731.75f,
+			327.25f,
+			731.75f,
+			307.34f,
+			749.84f,
+			253.246f,
+			724.746f,
+			253.246f,
+			724.746f,
+			242.656f,
+			722.559f,
+			241.25f,
+			722.746f,
+			239.137f,
+			722.559f,
+			236.059f,
+			722.559f,
+			227.25f,
+			715.746f,
+			218.457f,
+			708.477f,
+			218.02f,
+			707.598f,
+			216.25f,
+			705.75f,
+			216.25f,
+			705.75f,
+			197.777f,
+			693.52f,
+			192.25f,
+			692.75f,
+			192.25f,
+			692.75f,
+			179.738f,
+			685.598f,
+			175.25f,
+			674.75f,
+			171.246f,
+			673.746f,
+			171.246f,
+			673.742f,
+			169.18f,
+			665.359f,
+			168.25f,
+			663.75f,
+			168.25f,
+			663.75f,
+			163.457f,
+			660.078f,
+			162.25f,
+			653.746f,
+			162.25f,
+			653.742f,
+			152.898f,
+			647.316f,
+			153.246f,
+			642.746f,
+			153.242f,
+			642.742f,
+			151.578f,
+			636.758f,
+			150.246f,
+			631.746f,
+			150.246f,
+			631.742f,
+			142.777f,
+			626.199f,
+			143.246f,
+			622.75f,
+			143.242f,
+			622.75f,
+			135.297f,
+			607.719f,
+			136.25f,
+			599.75f,
+			136.25f,
+			599.75f,
+			129.578f,
+			600.68f,
+			126.246f,
+			597.75f,
+			126.242f,
+			597.75f,
+			125.617f,
+			592.758f,
+			124.25f,
+			592.746f,
+			124.25f,
+			592.746f,
+			120.777f,
+			591,
+			123.25f,
+			586.75f,
+			123.25f,
+			586.75f,
+			121.656f,
+			583.52f,
+			121.246f,
+			581.746f,
+			121.246f,
+			581.746f,
+			122.098f,
+			578.68f,
+			117.25f,
+			572.746f,
+			117.25f,
+			572.742f,
+			110.219f,
+			551.84f,
+			112.25f,
+			545.75f,
+			112.25f,
+			545.75f,
+			112.859f,
+			540.84f,
+			110.246f,
+			538.75f,
+			110.246f,
+			538.75f,
+			105.816f,
+			539.52f,
+			115.246f,
+			526.746f,
+			115.242f,
+			526.742f,
+			115.938f,
+			525,
+			112.25f,
+			522.746f,
+			112.25f,
+			522.746f,
+			93.5f,
+			518.398f,
+			91.25f,
+			500.746f,
+			91.25f,
+			500.746f,
+			75.8984f,
+			484.078f,
+			76.2461f,
+			478.746f,
+			75.8984f,
+			475.824f,
+			76.1953f,
+			472.359f,
+			77.2461f,
+			467.746f,
+			77.2461f,
+			467.746f,
+			76.3398f,
+			458.117f,
+			106.25f,
+			456.746f,
+			137.059f,
+			456.355f,
+			549.25f,
+			491.746f,
+			549.25f,
+			491.746f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			44,
+			549.25f,
+			491.746f,
+			550.379f,
+			491.531f,
+			552.805f,
+			490.293f,
+			554.25f,
+			488.746f,
+			554.25f,
+			488.742f,
+			561.66f,
+			476.598f,
+			556.25f,
+			496.75f,
+			556.25f,
+			496.75f,
+			545.82f,
+			528.52f,
+			555.246f,
+			515.746f,
+			555.246f,
+			515.742f,
+			562.098f,
+			508.277f,
+			558.25f,
+			522.746f,
+			554.328f,
+			541.309f,
+			551.25f,
+			548.746f,
+			551.25f,
+			548.746f,
+			551.25f,
+			548.746f,
+			564.301f,
+			543.039f,
+			535.246f,
+			586.75f,
+			544.246f,
+			582.75f,
+			544.246f,
+			582.75f,
+			522.938f,
+			626.199f,
+			499.25f,
+			631.746f,
+			490.25f,
+			638.746f,
+			490.25f,
+			638.742f,
+			532.621f,
+			680.316f,
+			518.25f,
+			720.75f,
+			518.25f,
+			720.75f,
+			511.059f,
+			726.52f,
+			500.246f,
+			716.75f,
+			500.246f,
+			716.75f,
+			493.461f,
+			711.117f,
+			487.246f,
+			712.75f,
+			487.246f,
+			712.75f,
+			452.98f,
+			711.559f,
+			451.25f,
+			711.746f,
+			448.578f,
+			711.559f,
+			410.301f,
+			752.477f,
+			338.25f,
+			732.746f,
+			338.25f,
+			732.742f,
+			332.418f,
+			730.918f,
+			327.25f,
+			731.75f,
+			327.25f,
+			731.75f,
+			307.34f,
+			749.84f,
+			253.246f,
+			724.746f,
+			253.246f,
+			724.746f,
+			242.656f,
+			722.559f,
+			241.25f,
+			722.746f,
+			239.137f,
+			722.559f,
+			236.059f,
+			722.559f,
+			227.25f,
+			715.746f,
+			218.457f,
+			708.477f,
+			218.02f,
+			707.598f,
+			216.25f,
+			705.75f,
+			216.25f,
+			705.75f,
+			197.777f,
+			693.52f,
+			192.25f,
+			692.75f,
+			192.25f,
+			692.75f,
+			179.738f,
+			685.598f,
+			175.25f,
+			674.75f,
+			171.246f,
+			673.746f,
+			171.246f,
+			673.742f,
+			169.18f,
+			665.359f,
+			168.25f,
+			663.75f,
+			168.25f,
+			663.75f,
+			163.457f,
+			660.078f,
+			162.25f,
+			653.746f,
+			162.25f,
+			653.742f,
+			152.898f,
+			647.316f,
+			153.246f,
+			642.746f,
+			153.242f,
+			642.742f,
+			151.578f,
+			636.758f,
+			150.246f,
+			631.746f,
+			150.246f,
+			631.742f,
+			142.777f,
+			626.199f,
+			143.246f,
+			622.75f,
+			143.242f,
+			622.75f,
+			135.297f,
+			607.719f,
+			136.25f,
+			599.75f,
+			136.25f,
+			599.75f,
+			129.578f,
+			600.68f,
+			126.246f,
+			597.75f,
+			126.242f,
+			597.75f,
+			125.617f,
+			592.758f,
+			124.25f,
+			592.746f,
+			124.25f,
+			592.746f,
+			120.777f,
+			591,
+			123.25f,
+			586.75f,
+			123.25f,
+			586.75f,
+			121.656f,
+			583.52f,
+			121.246f,
+			581.746f,
+			121.246f,
+			581.746f,
+			122.098f,
+			578.68f,
+			117.25f,
+			572.746f,
+			117.25f,
+			572.742f,
+			110.219f,
+			551.84f,
+			112.25f,
+			545.75f,
+			112.25f,
+			545.75f,
+			112.859f,
+			540.84f,
+			110.246f,
+			538.75f,
+			110.246f,
+			538.75f,
+			105.816f,
+			539.52f,
+			115.246f,
+			526.746f,
+			115.242f,
+			526.742f,
+			115.938f,
+			525,
+			112.25f,
+			522.746f,
+			112.25f,
+			522.746f,
+			93.5f,
+			518.398f,
+			91.25f,
+			500.746f,
+			91.25f,
+			500.746f,
+			75.8984f,
+			484.078f,
+			76.2461f,
+			478.746f,
+			75.8984f,
+			475.824f,
+			76.1953f,
+			472.359f,
+			77.2461f,
+			467.746f,
+			77.2461f,
+			467.746f,
+			76.3398f,
+			458.117f,
+			106.25f,
+			456.746f,
+			137.059f,
+			456.355f,
+			549.25f,
+			491.746f,
+			549.25f,
+			491.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			18,
+			93.2461f,
+			466.746f,
+			65.3398f,
+			510.477f,
+			81.2461f,
+			448.75f,
+			81.2461f,
+			448.75f,
+			90.8594f,
+			410.598f,
+			233.246f,
+			451.746f,
+			233.246f,
+			451.746f,
+			233.246f,
+			451.742f,
+			419.098f,
+			485.398f,
+			431.246f,
+			489.746f,
+			443.738f,
+			494.199f,
+			548.246f,
+			486.746f,
+			548.246f,
+			486.746f,
+			542.246f,
+			505.75f,
+			471.02f,
+			556.68f,
+			449.898f,
+			531.156f,
+			435.246f,
+			535.746f,
+			419.98f,
+			539.957f,
+			422.621f,
+			529.398f,
+			419.246f,
+			528.746f,
+			415.578f,
+			527.637f,
+			372.461f,
+			554.918f,
+			365.246f,
+			553.75f,
+			358.379f,
+			553.156f,
+			330.504f,
+			579.285f,
+			347.25f,
+			544.746f,
+			364.539f,
+			506.957f,
+			282.699f,
+			501.238f,
+			264.246f,
+			513.746f,
+			245.738f,
+			525.879f,
+			272.25f,
+			493.746f,
+			272.25f,
+			493.746f,
+			292.379f,
+			471.316f,
+			254.246f,
+			489.746f,
+			254.246f,
+			489.746f,
+			216.699f,
+			503.879f,
+			190.297f,
+			475.719f,
+			187.246f,
+			474.75f,
+			183.258f,
+			473.957f,
+			177.977f,
+			470.438f,
+			177.246f,
+			477.746f,
+			176.219f,
+			484.52f,
+			167.957f,
+			502.891f,
+			133.246f,
+			473.746f,
+			111.098f,
+			455.695f,
+			96.25f,
+			479.75f,
+			96.25f,
+			479.75f,
+			93.2461f,
+			466.746f,
+			10,
+			0,
+			0.91f,
+			0.5f,
+			0.228f,
+			0.91f,
+			0.5f,
+			0.228f,
+			19,
+			367.246f,
+			551.75f,
+			359.82f,
+			551.238f,
+			331.914f,
+			577.352f,
+			348.25f,
+			542.75f,
+			366.641f,
+			503.719f,
+			284.141f,
+			499.316f,
+			265.246f,
+			511.746f,
+			247.18f,
+			523.957f,
+			273.25f,
+			491.746f,
+			273.25f,
+			491.746f,
+			293.82f,
+			469.398f,
+			256.246f,
+			487.75f,
+			256.246f,
+			487.75f,
+			218.137f,
+			501.957f,
+			191.738f,
+			473.797f,
+			188.246f,
+			472.75f,
+			184.699f,
+			472.039f,
+			179.418f,
+			468.516f,
+			178.246f,
+			475.746f,
+			177.656f,
+			482.598f,
+			169.543f,
+			500.785f,
+			134.25f,
+			471.746f,
+			111.18f,
+			452.957f,
+			96.25f,
+			476.75f,
+			96.25f,
+			476.75f,
+			93.2461f,
+			465.75f,
+			65.3164f,
+			509.219f,
+			82.2461f,
+			444.746f,
+			82.2461f,
+			444.746f,
+			91.5781f,
+			407.238f,
+			235.246f,
+			449.746f,
+			235.246f,
+			449.746f,
+			235.242f,
+			449.742f,
+			420.539f,
+			483.477f,
+			433.246f,
+			487.75f,
+			445.18f,
+			492.277f,
+			549.25f,
+			485.75f,
+			549.25f,
+			485.75f,
+			543.25f,
+			504.746f,
+			471.578f,
+			555.398f,
+			451.34f,
+			529.238f,
+			436.25f,
+			533.746f,
+			421.418f,
+			538.039f,
+			424.059f,
+			527.477f,
+			420.246f,
+			526.746f,
+			417.02f,
+			525.719f,
+			373.898f,
+			552.996f,
+			367.246f,
+			551.75f,
+			10,
+			0,
+			0.919f,
+			0.55f,
+			0.305f,
+			0.919f,
+			0.55f,
+			0.305f,
+			19,
+			368.246f,
+			549.75f,
+			361.258f,
+			549.316f,
+			334.051f,
+			575.75f,
+			350.25f,
+			540.75f,
+			367.641f,
+			500.695f,
+			285.578f,
+			497.398f,
+			267.246f,
+			509.75f,
+			248.617f,
+			522.035f,
+			275.246f,
+			489.746f,
+			275.246f,
+			489.746f,
+			295.258f,
+			467.477f,
+			257.246f,
+			485.75f,
+			257.246f,
+			485.75f,
+			219.578f,
+			500.035f,
+			193.18f,
+			471.875f,
+			189.246f,
+			470.75f,
+			186.137f,
+			470.117f,
+			180.859f,
+			466.598f,
+			180.246f,
+			473.746f,
+			179.098f,
+			480.676f,
+			171.125f,
+			498.68f,
+			136.25f,
+			469.746f,
+			111.258f,
+			450.215f,
+			97.25f,
+			472.75f,
+			97.25f,
+			472.75f,
+			93.2461f,
+			463.75f,
+			66.6172f,
+			506.637f,
+			82.2461f,
+			441.75f,
+			82.2461f,
+			441.75f,
+			92.2969f,
+			403.879f,
+			236.25f,
+			447.746f,
+			236.25f,
+			447.746f,
+			236.25f,
+			447.746f,
+			421.98f,
+			481.559f,
+			434.246f,
+			485.75f,
+			446.617f,
+			490.355f,
+			549.25f,
+			483.75f,
+			549.25f,
+			483.75f,
+			543.25f,
+			502.746f,
+			472.141f,
+			554.117f,
+			452.777f,
+			527.316f,
+			438.25f,
+			531.75f,
+			422.859f,
+			536.117f,
+			425.5f,
+			525.559f,
+			422.246f,
+			524.746f,
+			418.457f,
+			523.797f,
+			375.34f,
+			551.078f,
+			368.246f,
+			549.75f,
+			10,
+			0,
+			0.928f,
+			0.6f,
+			0.382f,
+			0.928f,
+			0.6f,
+			0.382f,
+			19,
+			369.25f,
+			548.746f,
+			362.699f,
+			547.398f,
+			335.496f,
+			573.832f,
+			351.25f,
+			538.75f,
+			369.738f,
+			497.285f,
+			286.43f,
+			495.867f,
+			268.246f,
+			507.75f,
+			250.059f,
+			520.117f,
+			276.246f,
+			487.75f,
+			276.246f,
+			487.75f,
+			296.699f,
+			465.559f,
+			259.25f,
+			483.75f,
+			259.25f,
+			483.75f,
+			221.02f,
+			498.117f,
+			194.617f,
+			469.957f,
+			191.246f,
+			468.75f,
+			187.578f,
+			468.199f,
+			182.301f,
+			464.676f,
+			181.25f,
+			471.746f,
+			180.539f,
+			478.758f,
+			172.711f,
+			496.574f,
+			137.246f,
+			467.746f,
+			111.336f,
+			447.477f,
+			97.25f,
+			469.746f,
+			97.25f,
+			469.746f,
+			93.2461f,
+			461.75f,
+			68.7969f,
+			502.516f,
+			83.2461f,
+			438.746f,
+			83.2461f,
+			438.746f,
+			93.0195f,
+			400.516f,
+			237.25f,
+			445.746f,
+			237.25f,
+			445.746f,
+			237.25f,
+			445.746f,
+			423.418f,
+			479.637f,
+			435.246f,
+			483.75f,
+			448.059f,
+			488.438f,
+			550.246f,
+			481.75f,
+			550.246f,
+			481.75f,
+			544.246f,
+			501.75f,
+			472.699f,
+			552.84f,
+			454.219f,
+			525.398f,
+			439.25f,
+			529.75f,
+			424.301f,
+			534.199f,
+			426.938f,
+			523.637f,
+			423.246f,
+			522.746f,
+			419.898f,
+			521.879f,
+			376.777f,
+			549.156f,
+			369.25f,
+			548.746f,
+			10,
+			0,
+			0.937f,
+			0.65f,
+			0.46f,
+			0.937f,
+			0.65f,
+			0.46f,
+			19,
+			371.25f,
+			546.746f,
+			364.141f,
+			545.477f,
+			337.492f,
+			572.156f,
+			352.25f,
+			536.75f,
+			371.18f,
+			493.559f,
+			288.457f,
+			493.559f,
+			270.25f,
+			505.75f,
+			251.5f,
+			518.195f,
+			278.246f,
+			485.75f,
+			278.246f,
+			485.75f,
+			298.141f,
+			463.637f,
+			260.25f,
+			481.75f,
+			260.25f,
+			481.75f,
+			222.457f,
+			496.195f,
+			196.059f,
+			468.035f,
+			192.25f,
+			466.746f,
+			189.02f,
+			466.277f,
+			183.738f,
+			462.758f,
+			183.25f,
+			469.746f,
+			181.98f,
+			476.836f,
+			174.297f,
+			494.473f,
+			139.246f,
+			466.746f,
+			111.418f,
+			444.738f,
+			97.25f,
+			466.746f,
+			97.25f,
+			466.746f,
+			93.2461f,
+			460.746f,
+			70.9766f,
+			498.617f,
+			84.25f,
+			434.746f,
+			84.25f,
+			434.746f,
+			93.7383f,
+			397.156f,
+			239.25f,
+			444.746f,
+			239.25f,
+			444.746f,
+			239.25f,
+			444.742f,
+			424.859f,
+			477.715f,
+			437.25f,
+			481.75f,
+			449.5f,
+			486.516f,
+			550.246f,
+			479.75f,
+			550.246f,
+			479.75f,
+			544.246f,
+			500.746f,
+			473.262f,
+			551.559f,
+			455.66f,
+			523.477f,
+			440.25f,
+			527.75f,
+			425.738f,
+			532.277f,
+			428.379f,
+			521.715f,
+			425.25f,
+			520.75f,
+			421.34f,
+			519.957f,
+			378.219f,
+			547.238f,
+			371.25f,
+			546.746f,
+			10,
+			0,
+			0.946f,
+			0.7f,
+			0.537f,
+			0.946f,
+			0.7f,
+			0.537f,
+			19,
+			372.25f,
+			544.746f,
+			365.578f,
+			543.559f,
+			337.02f,
+			569.352f,
+			354.246f,
+			534.75f,
+			375.258f,
+			492.078f,
+			289.898f,
+			491.637f,
+			271.25f,
+			503.75f,
+			252.938f,
+			516.277f,
+			279.246f,
+			483.75f,
+			279.246f,
+			483.75f,
+			299.578f,
+			461.719f,
+			261.25f,
+			479.75f,
+			261.25f,
+			479.75f,
+			223.898f,
+			494.277f,
+			197.5f,
+			466.117f,
+			194.25f,
+			464.746f,
+			190.457f,
+			464.355f,
+			185.18f,
+			460.836f,
+			184.25f,
+			467.746f,
+			183.418f,
+			474.918f,
+			175.879f,
+			492.367f,
+			140.25f,
+			464.746f,
+			111.5f,
+			441.996f,
+			98.2461f,
+			462.746f,
+			98.2461f,
+			462.746f,
+			92.2461f,
+			458.746f,
+			72.9375f,
+			495.156f,
+			85.25f,
+			431.746f,
+			85.25f,
+			431.746f,
+			94.457f,
+			393.797f,
+			240.25f,
+			442.746f,
+			240.25f,
+			442.746f,
+			240.25f,
+			442.742f,
+			426.301f,
+			475.797f,
+			438.25f,
+			479.75f,
+			450.941f,
+			484.598f,
+			551.25f,
+			477.746f,
+			551.25f,
+			477.746f,
+			545.25f,
+			498.75f,
+			473.82f,
+			550.277f,
+			457.102f,
+			521.559f,
+			442.246f,
+			525.75f,
+			427.18f,
+			530.355f,
+			429.82f,
+			519.797f,
+			426.25f,
+			518.75f,
+			422.781f,
+			518.039f,
+			379.66f,
+			545.316f,
+			372.25f,
+			544.746f,
+			10,
+			0,
+			0.955f,
+			0.75f,
+			0.614f,
+			0.955f,
+			0.75f,
+			0.614f,
+			19,
+			374.25f,
+			542.75f,
+			367.02f,
+			541.637f,
+			338.043f,
+			567.223f,
+			355.246f,
+			532.746f,
+			378.02f,
+			488.836f,
+			291.34f,
+			489.715f,
+			273.25f,
+			501.75f,
+			254.379f,
+			514.355f,
+			281.25f,
+			481.75f,
+			281.25f,
+			481.75f,
+			301.02f,
+			459.797f,
+			263.25f,
+			478.746f,
+			263.25f,
+			478.746f,
+			225.34f,
+			492.355f,
+			198.938f,
+			464.195f,
+			195.25f,
+			463.75f,
+			191.898f,
+			462.438f,
+			186.617f,
+			458.918f,
+			185.25f,
+			465.75f,
+			184.859f,
+			472.996f,
+			177.465f,
+			490.262f,
+			141.25f,
+			462.746f,
+			111.578f,
+			439.258f,
+			98.2461f,
+			459.75f,
+			98.2461f,
+			459.75f,
+			92.2461f,
+			456.746f,
+			75.1172f,
+			490.156f,
+			85.25f,
+			428.75f,
+			85.25f,
+			428.75f,
+			95.1797f,
+			390.438f,
+			242.246f,
+			440.746f,
+			242.246f,
+			440.746f,
+			242.246f,
+			440.742f,
+			427.738f,
+			473.875f,
+			440.25f,
+			478.746f,
+			452.379f,
+			482.676f,
+			551.25f,
+			475.746f,
+			551.25f,
+			475.746f,
+			545.25f,
+			497.746f,
+			474.379f,
+			548.996f,
+			458.539f,
+			519.637f,
+			443.246f,
+			523.75f,
+			428.621f,
+			528.438f,
+			431.258f,
+			517.875f,
+			427.25f,
+			516.75f,
+			424.219f,
+			516.117f,
+			381.102f,
+			543.398f,
+			374.25f,
+			542.75f,
+			10,
+			0,
+			0.964f,
+			0.8f,
+			0.691f,
+			0.964f,
+			0.8f,
+			0.691f,
+			19,
+			375.246f,
+			540.75f,
+			368.461f,
+			539.719f,
+			338.273f,
+			564.66f,
+			357.246f,
+			530.746f,
+			381.219f,
+			487.355f,
+			292.777f,
+			487.797f,
+			274.25f,
+			499.746f,
+			255.82f,
+			512.438f,
+			282.25f,
+			479.75f,
+			282.25f,
+			479.75f,
+			302.457f,
+			457.879f,
+			264.246f,
+			476.75f,
+			264.246f,
+			476.75f,
+			226.777f,
+			490.438f,
+			200.379f,
+			462.277f,
+			197.25f,
+			461.75f,
+			193.34f,
+			460.516f,
+			188.059f,
+			456.996f,
+			187.246f,
+			463.75f,
+			186.297f,
+			471.078f,
+			179.047f,
+			488.156f,
+			143.246f,
+			460.746f,
+			111.656f,
+			436.516f,
+			99.2461f,
+			456.746f,
+			99.2461f,
+			456.746f,
+			92.2461f,
+			454.75f,
+			76.8555f,
+			486.477f,
+			86.25f,
+			424.75f,
+			86.25f,
+			424.75f,
+			95.8984f,
+			387.074f,
+			243.246f,
+			438.746f,
+			243.246f,
+			438.746f,
+			243.246f,
+			438.742f,
+			429.18f,
+			471.957f,
+			441.246f,
+			476.75f,
+			453.82f,
+			480.758f,
+			552.25f,
+			474.75f,
+			552.25f,
+			474.75f,
+			546.246f,
+			496.75f,
+			474.941f,
+			547.719f,
+			459.98f,
+			517.719f,
+			445.246f,
+			521.746f,
+			430.059f,
+			526.516f,
+			432.699f,
+			515.957f,
+			429.25f,
+			514.75f,
+			425.66f,
+			514.195f,
+			382.539f,
+			541.477f,
+			375.246f,
+			540.75f,
+			10,
+			0,
+			0.973f,
+			0.85f,
+			0.769f,
+			0.973f,
+			0.85f,
+			0.769f,
+			19,
+			377.246f,
+			538.75f,
+			369.898f,
+			537.797f,
+			339.715f,
+			562.738f,
+			358.25f,
+			528.746f,
+			382.66f,
+			485.437f,
+			294.219f,
+			485.875f,
+			275.246f,
+			497.746f,
+			257.258f,
+			510.516f,
+			283.25f,
+			477.746f,
+			283.25f,
+			477.746f,
+			303.898f,
+			455.957f,
+			266.246f,
+			474.75f,
+			266.246f,
+			474.75f,
+			228.219f,
+			488.516f,
+			201.816f,
+			460.355f,
+			198.246f,
+			459.75f,
+			194.777f,
+			458.598f,
+			189.5f,
+			455.078f,
+			188.246f,
+			461.75f,
+			187.738f,
+			469.156f,
+			180.633f,
+			486.051f,
+			144.246f,
+			458.746f,
+			111.738f,
+			433.777f,
+			99.2461f,
+			452.75f,
+			99.2461f,
+			452.75f,
+			92.2461f,
+			453.746f,
+			77.7188f,
+			482.578f,
+			87.2461f,
+			421.75f,
+			87.2461f,
+			421.75f,
+			96.6172f,
+			383.715f,
+			245.246f,
+			436.746f,
+			245.246f,
+			436.746f,
+			245.246f,
+			436.746f,
+			430.621f,
+			470.035f,
+			443.246f,
+			474.75f,
+			455.258f,
+			478.836f,
+			552.25f,
+			472.75f,
+			552.25f,
+			472.75f,
+			547.25f,
+			495.746f,
+			475.5f,
+			546.438f,
+			461.418f,
+			515.797f,
+			446.246f,
+			519.746f,
+			431.5f,
+			524.598f,
+			434.141f,
+			514.035f,
+			430.246f,
+			512.75f,
+			427.098f,
+			512.277f,
+			383.98f,
+			539.555f,
+			377.246f,
+			538.75f,
+			10,
+			0,
+			0.982f,
+			0.9f,
+			0.846f,
+			0.982f,
+			0.9f,
+			0.846f,
+			19,
+			378.246f,
+			536.75f,
+			371.34f,
+			535.879f,
+			341.578f,
+			561.055f,
+			360.25f,
+			526.746f,
+			384.098f,
+			482.195f,
+			295.66f,
+			483.957f,
+			277.246f,
+			496.75f,
+			258.699f,
+			508.598f,
+			285.25f,
+			475.746f,
+			285.25f,
+			475.746f,
+			305.34f,
+			454.035f,
+			267.246f,
+			472.75f,
+			267.246f,
+			472.75f,
+			229.66f,
+			486.598f,
+			203.258f,
+			458.438f,
+			199.246f,
+			457.75f,
+			196.219f,
+			456.676f,
+			190.937f,
+			453.156f,
+			190.246f,
+			459.75f,
+			189.18f,
+			467.238f,
+			182.219f,
+			483.949f,
+			146.25f,
+			456.746f,
+			111.82f,
+			431.035f,
+			99.2461f,
+			449.746f,
+			99.2461f,
+			449.746f,
+			92.2461f,
+			451.746f,
+			78.3594f,
+			478.238f,
+			87.2461f,
+			417.75f,
+			87.2461f,
+			417.75f,
+			97.3399f,
+			380.355f,
+			246.246f,
+			434.746f,
+			246.246f,
+			434.746f,
+			246.242f,
+			434.746f,
+			432.059f,
+			468.117f,
+			444.246f,
+			472.75f,
+			456.699f,
+			476.918f,
+			553.246f,
+			470.75f,
+			553.246f,
+			470.75f,
+			547.25f,
+			493.746f,
+			476.059f,
+			545.156f,
+			462.859f,
+			513.879f,
+			448.25f,
+			518.75f,
+			432.938f,
+			522.676f,
+			435.578f,
+			512.117f,
+			432.246f,
+			510.746f,
+			428.539f,
+			510.355f,
+			385.418f,
+			537.637f,
+			378.246f,
+			536.75f,
+			10,
+			0,
+			0.991f,
+			0.95f,
+			0.923f,
+			0.991f,
+			0.95f,
+			0.923f,
+			19,
+			380.25f,
+			534.75f,
+			372.777f,
+			533.957f,
+			344.207f,
+			559.746f,
+			361.25f,
+			524.746f,
+			384.66f,
+			478.078f,
+			297.098f,
+			482.035f,
+			278.246f,
+			494.75f,
+			260.141f,
+			506.676f,
+			286.246f,
+			473.746f,
+			286.246f,
+			473.746f,
+			306.777f,
+			452.117f,
+			269.246f,
+			470.75f,
+			269.246f,
+			470.75f,
+			231.098f,
+			484.676f,
+			204.699f,
+			456.516f,
+			201.246f,
+			455.746f,
+			197.66f,
+			454.758f,
+			192.379f,
+			451.238f,
+			191.246f,
+			458.746f,
+			190.621f,
+			465.316f,
+			183.801f,
+			481.844f,
+			147.25f,
+			454.75f,
+			111.898f,
+			428.297f,
+			100.246f,
+			446.75f,
+			100.246f,
+			446.75f,
+			92.2461f,
+			449.746f,
+			78.5586f,
+			475.656f,
+			88.2461f,
+			414.746f,
+			88.2461f,
+			414.746f,
+			98.0586f,
+			376.996f,
+			248.25f,
+			432.75f,
+			248.25f,
+			432.75f,
+			248.25f,
+			432.75f,
+			433.5f,
+			466.195f,
+			446.246f,
+			470.75f,
+			458.141f,
+			474.996f,
+			553.246f,
+			468.75f,
+			553.246f,
+			468.75f,
+			548.246f,
+			492.75f,
+			476.621f,
+			543.879f,
+			464.301f,
+			511.957f,
+			449.25f,
+			516.75f,
+			434.379f,
+			520.758f,
+			437.02f,
+			510.195f,
+			433.246f,
+			509.75f,
+			429.98f,
+			508.438f,
+			386.859f,
+			535.719f,
+			380.25f,
+			534.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			18,
+			92.2461f,
+			448.75f,
+			78.5391f,
+			472.637f,
+			89.2461f,
+			411.746f,
+			89.2461f,
+			411.746f,
+			98.7773f,
+			373.637f,
+			249.25f,
+			430.75f,
+			249.25f,
+			430.75f,
+			249.25f,
+			430.75f,
+			434.938f,
+			464.277f,
+			447.25f,
+			468.75f,
+			459.578f,
+			473.078f,
+			553.246f,
+			466.746f,
+			553.246f,
+			466.746f,
+			548.246f,
+			491.746f,
+			477.18f,
+			542.598f,
+			465.738f,
+			510.039f,
+			451.25f,
+			514.75f,
+			435.82f,
+			518.84f,
+			438.461f,
+			508.277f,
+			435.246f,
+			507.75f,
+			431.418f,
+			506.52f,
+			388.301f,
+			533.797f,
+			381.25f,
+			532.746f,
+			374.219f,
+			532.039f,
+			346.477f,
+			558.227f,
+			363.25f,
+			522.746f,
+			387.23f,
+			470.762f,
+			295.941f,
+			481.848f,
+			280.246f,
+			492.75f,
+			261.578f,
+			504.758f,
+			288.246f,
+			471.746f,
+			288.246f,
+			471.746f,
+			308.219f,
+			450.195f,
+			270.25f,
+			468.75f,
+			270.25f,
+			468.75f,
+			232.539f,
+			482.758f,
+			206.137f,
+			454.598f,
+			202.246f,
+			453.746f,
+			199.098f,
+			452.836f,
+			193.816f,
+			449.316f,
+			193.25f,
+			456.746f,
+			192.059f,
+			463.398f,
+			185.387f,
+			479.738f,
+			149.246f,
+			452.75f,
+			111.977f,
+			425.559f,
+			100.246f,
+			442.746f,
+			100.246f,
+			442.746f,
+			92.2461f,
+			448.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			138.246f,
+			415.75f,
+			138.246f,
+			415.75f,
+			130.457f,
+			402.676f,
+			153.246f,
+			387.746f,
+			153.242f,
+			387.742f,
+			154.879f,
+			386.617f,
+			135.25f,
+			390.746f,
+			135.25f,
+			390.746f,
+			128.258f,
+			393.438f,
+			126.246f,
+			404.75f,
+			126.242f,
+			404.75f,
+			121.219f,
+			409.719f,
+			116.246f,
+			415.75f,
+			110.656f,
+			422.035f,
+			138.246f,
+			415.75f,
+			138.246f,
+			415.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			8,
+			292.25f,
+			467.746f,
+			292.25f,
+			467.746f,
+			311.848f,
+			438.297f,
+			311.246f,
+			432.75f,
+			309.758f,
+			421.598f,
+			309.539f,
+			411.035f,
+			313.246f,
+			406.75f,
+			316.578f,
+			402.238f,
+			326.25f,
+			365.746f,
+			326.25f,
+			365.746f,
+			326.25f,
+			365.742f,
+			325.82f,
+			364.398f,
+			339.25f,
+			405.746f,
+			339.25f,
+			405.742f,
+			352.219f,
+			423.797f,
+			330.25f,
+			443.75f,
+			330.25f,
+			443.75f,
+			291.5f,
+			475.719f,
+			292.25f,
+			467.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			15,
+			160.246f,
+			385.746f,
+			160.246f,
+			385.742f,
+			172.699f,
+			378.035f,
+			157.25f,
+			343.746f,
+			164.246f,
+			346.746f,
+			164.242f,
+			346.746f,
+			163.02f,
+			334.035f,
+			159.246f,
+			331.75f,
+			167.25f,
+			334.75f,
+			167.25f,
+			334.75f,
+			172.699f,
+			326.117f,
+			168.25f,
+			320.75f,
+			168.25f,
+			320.75f,
+			186.777f,
+			312.035f,
+			186.25f,
+			304.746f,
+			186.25f,
+			304.746f,
+			192.938f,
+			313.797f,
+			188.246f,
+			320.75f,
+			184.137f,
+			327.879f,
+			176.219f,
+			323.477f,
+			177.246f,
+			343.746f,
+			167.25f,
+			339.746f,
+			167.25f,
+			339.742f,
+			173.578f,
+			349.879f,
+			173.25f,
+			356.75f,
+			165.246f,
+			354.746f,
+			165.242f,
+			354.742f,
+			181.793f,
+			383.512f,
+			170.246f,
+			384.75f,
+			163.457f,
+			385.957f,
+			160.246f,
+			385.746f,
+			160.246f,
+			385.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			196.25f,
+			367.75f,
+			196.25f,
+			367.75f,
+			199.098f,
+			372.316f,
+			196.25f,
+			371.75f,
+			192.938f,
+			370.559f,
+			158.617f,
+			354.277f,
+			152.25f,
+			343.746f,
+			152.25f,
+			343.742f,
+			189.859f,
+			370.559f,
+			196.25f,
+			367.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			207.25f,
+			358.75f,
+			207.25f,
+			358.75f,
+			210.539f,
+			363.516f,
+			207.25f,
+			362.75f,
+			204.379f,
+			361.758f,
+			170.059f,
+			345.477f,
+			163.25f,
+			334.75f,
+			163.25f,
+			334.75f,
+			201.297f,
+			361.758f,
+			207.25f,
+			358.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			222.246f,
+			375.75f,
+			222.246f,
+			375.75f,
+			225.059f,
+			380.238f,
+			222.246f,
+			379.746f,
+			218.898f,
+			378.477f,
+			184.578f,
+			362.195f,
+			178.246f,
+			351.75f,
+			178.246f,
+			351.75f,
+			215.816f,
+			378.477f,
+			222.246f,
+			375.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			196.25f,
+			327.75f,
+			196.25f,
+			327.75f,
+			196.457f,
+			334.035f,
+			193.25f,
+			332.746f,
+			190.297f,
+			332.277f,
+			150.699f,
+			312.918f,
+			144.246f,
+			302.746f,
+			144.246f,
+			302.746f,
+			190.297f,
+			330.516f,
+			196.25f,
+			327.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			198.246f,
+			339.746f,
+			198.246f,
+			339.742f,
+			199.098f,
+			344.598f,
+			196.25f,
+			343.746f,
+			193.816f,
+			343.719f,
+			164.777f,
+			330.957f,
+			158.25f,
+			320.75f,
+			158.25f,
+			320.75f,
+			190.738f,
+			344.156f,
+			198.246f,
+			339.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			24,
+			182.25f,
+			286.746f,
+			171.246f,
+			278.75f,
+			171.246f,
+			278.75f,
+			182.379f,
+			286.957f,
+			186.25f,
+			285.75f,
+			186.25f,
+			285.75f,
+			178.859f,
+			273.316f,
+			178.246f,
+			267.75f,
+			178.246f,
+			267.75f,
+			189.418f,
+			281.676f,
+			195.25f,
+			280.746f,
+			195.25f,
+			280.746f,
+			203.938f,
+			280.797f,
+			204.25f,
+			268.75f,
+			204.25f,
+			268.75f,
+			210.098f,
+			280.355f,
+			213.246f,
+			279.75f,
+			213.242f,
+			279.75f,
+			214.938f,
+			272.879f,
+			213.246f,
+			265.75f,
+			213.242f,
+			265.75f,
+			218.02f,
+			273.758f,
+			222.246f,
+			271.746f,
+			222.246f,
+			271.746f,
+			229.457f,
+			274.195f,
+			228.25f,
+			261.746f,
+			228.25f,
+			261.742f,
+			228.578f,
+			249.996f,
+			227.25f,
+			246.746f,
+			227.25f,
+			246.746f,
+			233.859f,
+			275.957f,
+			236.25f,
+			276.75f,
+			236.25f,
+			276.75f,
+			245.297f,
+			277.719f,
+			250.25f,
+			267.75f,
+			250.25f,
+			267.75f,
+			246.18f,
+			276.398f,
+			251.25f,
+			273.746f,
+			251.25f,
+			273.742f,
+			263.34f,
+			272.438f,
+			267.246f,
+			264.746f,
+			267.246f,
+			264.742f,
+			259.379f,
+			278.156f,
+			265.246f,
+			274.75f,
+			265.246f,
+			274.75f,
+			273.02f,
+			274.637f,
+			274.25f,
+			267.75f,
+			274.25f,
+			267.75f,
+			283.578f,
+			244.277f,
+			286.246f,
+			242.75f,
+			286.246f,
+			242.75f,
+			277.418f,
+			266.277f,
+			279.246f,
+			266.746f,
+			279.242f,
+			266.742f,
+			276.977f,
+			279.477f,
+			282.25f,
+			262.75f,
+			282.25f,
+			262.75f,
+			279.18f,
+			278.598f,
+			285.25f,
+			277.746f,
+			291.5f,
+			276.836f,
+			296.34f,
+			265.836f,
+			305.25f,
+			268.75f,
+			305.25f,
+			268.75f,
+			316.141f,
+			262.316f,
+			318.25f,
+			338.75f,
+			182.25f,
+			286.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			15,
+			187.246f,
+			388.75f,
+			187.246f,
+			388.75f,
+			203.5f,
+			395.637f,
+			247.246f,
+			388.75f,
+			247.242f,
+			388.75f,
+			255.418f,
+			388.598f,
+			263.25f,
+			398.746f,
+			270.379f,
+			407.957f,
+			299.859f,
+			415.879f,
+			307.25f,
+			413.75f,
+			317.25f,
+			406.75f,
+			318.25f,
+			405.746f,
+			318.25f,
+			405.742f,
+			331.98f,
+			393.879f,
+			332.246f,
+			385.746f,
+			332.859f,
+			377.156f,
+			316.578f,
+			324.355f,
+			306.25f,
+			306.746f,
+			295.457f,
+			289.156f,
+			284.898f,
+			275.516f,
+			264.246f,
+			277.746f,
+			264.246f,
+			277.742f,
+			240.898f,
+			282.559f,
+			212.246f,
+			277.746f,
+			212.246f,
+			277.742f,
+			180.617f,
+			279.918f,
+			177.246f,
+			288.746f,
+			174.457f,
+			297.516f,
+			190.246f,
+			313.746f,
+			190.246f,
+			313.746f,
+			190.246f,
+			313.746f,
+			194.699f,
+			323.477f,
+			193.25f,
+			339.746f,
+			192.059f,
+			355.156f,
+			192.5f,
+			385.957f,
+			187.246f,
+			388.75f,
+			10,
+			0,
+			0.9f,
+			0.4f,
+			0.55f,
+			0.9f,
+			0.4f,
+			0.55f,
+			8,
+			211.246f,
+			386.75f,
+			220.656f,
+			366.598f,
+			188.246f,
+			294.75f,
+			188.246f,
+			294.75f,
+			185.898f,
+			293.117f,
+			202.023f,
+			286.469f,
+			213.246f,
+			288.746f,
+			225.219f,
+			292.059f,
+			269.246f,
+			287.75f,
+			269.246f,
+			287.75f,
+			295.457f,
+			304.559f,
+			309.246f,
+			353.75f,
+			309.246f,
+			353.75f,
+			309.246f,
+			353.75f,
+			320.98f,
+			379.797f,
+			301.246f,
+			383.746f,
+			282.258f,
+			386.836f,
+			211.246f,
+			386.75f,
+			211.246f,
+			386.75f,
+			10,
+			0,
+			0.7f,
+			0.2f,
+			0.35f,
+			0.7f,
+			0.2f,
+			0.35f,
+			6,
+			209.246f,
+			352.746f,
+			212.844f,
+			366.922f,
+			214.586f,
+			379.902f,
+			211.246f,
+			386.75f,
+			211.246f,
+			386.75f,
+			280.059f,
+			379.797f,
+			292.25f,
+			402.75f,
+			297.043f,
+			411.34f,
+			313.277f,
+			377.598f,
+			313.246f,
+			366.75f,
+			313.242f,
+			366.75f,
+			243.539f,
+			351.195f,
+			227.25f,
+			363.746f,
+			209.246f,
+			352.746f,
+			10,
+			0,
+			0.65f,
+			0.15f,
+			0.3f,
+			0.65f,
+			0.15f,
+			0.3f,
+			13,
+			214.25f,
+			334.75f,
+			214.25f,
+			334.75f,
+			216.258f,
+			326.996f,
+			213.246f,
+			322.75f,
+			213.242f,
+			322.75f,
+			211.859f,
+			321.719f,
+			210.246f,
+			321.746f,
+			210.246f,
+			321.742f,
+			211.859f,
+			317.316f,
+			218.25f,
+			315.746f,
+			218.25f,
+			315.746f,
+			220.656f,
+			310.719f,
+			223.246f,
+			310.746f,
+			225.938f,
+			309.836f,
+			231.219f,
+			303.676f,
+			235.246f,
+			304.746f,
+			240.02f,
+			306.316f,
+			252.25f,
+			310.746f,
+			252.25f,
+			310.746f,
+			252.25f,
+			310.742f,
+			258.5f,
+			314.238f,
+			268.246f,
+			310.746f,
+			268.242f,
+			310.742f,
+			270.789f,
+			311.16f,
+			271.25f,
+			315.746f,
+			271.809f,
+			320.727f,
+			275.219f,
+			324.797f,
+			277.246f,
+			326.746f,
+			279.617f,
+			329.195f,
+			290.18f,
+			343.277f,
+			289.246f,
+			343.746f,
+			287.539f,
+			344.156f,
+			214.25f,
+			334.75f,
+			214.25f,
+			334.75f,
+			10,
+			0,
+			1,
+			0.45f,
+			0.5f,
+			1,
+			0.45f,
+			0.5f,
+			12,
+			209.246f,
+			387.746f,
+			209.246f,
+			387.742f,
+			206.137f,
+			363.516f,
+			209.246f,
+			354.746f,
+			213.18f,
+			345.035f,
+			212.297f,
+			342.836f,
+			211.246f,
+			338.75f,
+			210.539f,
+			334.035f,
+			215.379f,
+			323.035f,
+			221.246f,
+			316.75f,
+			234.246f,
+			314.75f,
+			234.246f,
+			314.75f,
+			251.457f,
+			318.637f,
+			261.25f,
+			315.746f,
+			261.25f,
+			315.746f,
+			271.473f,
+			314.078f,
+			275.246f,
+			330.746f,
+			275.246f,
+			330.742f,
+			280.5f,
+			337.559f,
+			288.246f,
+			340.75f,
+			296.34f,
+			343.719f,
+			304.258f,
+			389.477f,
+			300.246f,
+			398.746f,
+			295.457f,
+			407.078f,
+			279.617f,
+			411.918f,
+			262.25f,
+			394.746f,
+			244.418f,
+			377.598f,
+			242.219f,
+			396.078f,
+			209.246f,
+			387.746f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			12,
+			209.246f,
+			387.746f,
+			209.246f,
+			387.742f,
+			206.137f,
+			363.516f,
+			209.246f,
+			354.746f,
+			213.18f,
+			345.035f,
+			212.297f,
+			342.836f,
+			211.246f,
+			338.75f,
+			210.539f,
+			334.035f,
+			215.379f,
+			323.035f,
+			221.246f,
+			316.75f,
+			234.246f,
+			314.75f,
+			234.246f,
+			314.75f,
+			251.457f,
+			318.637f,
+			261.25f,
+			315.746f,
+			261.25f,
+			315.746f,
+			271.473f,
+			314.078f,
+			275.246f,
+			330.746f,
+			275.246f,
+			330.742f,
+			280.5f,
+			337.559f,
+			288.246f,
+			340.75f,
+			296.34f,
+			343.719f,
+			304.258f,
+			389.477f,
+			300.246f,
+			398.746f,
+			295.457f,
+			407.078f,
+			279.617f,
+			411.918f,
+			262.25f,
+			394.746f,
+			244.418f,
+			377.598f,
+			242.219f,
+			396.078f,
+			209.246f,
+			387.746f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			7,
+			211.246f,
+			305.75f,
+			211.246f,
+			305.75f,
+			210.098f,
+			308.078f,
+			205.25f,
+			308.746f,
+			205.25f,
+			308.742f,
+			180.617f,
+			312.477f,
+			171.246f,
+			325.75f,
+			171.246f,
+			325.75f,
+			163.898f,
+			332.277f,
+			168.25f,
+			319.746f,
+			168.25f,
+			319.742f,
+			180.18f,
+			297.078f,
+			187.246f,
+			293.746f,
+			187.246f,
+			293.746f,
+			205.699f,
+			289.598f,
+			211.246f,
+			305.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			211.246f,
+			305.75f,
+			211.246f,
+			305.75f,
+			210.098f,
+			308.078f,
+			205.25f,
+			308.746f,
+			205.25f,
+			308.742f,
+			180.617f,
+			312.477f,
+			171.246f,
+			325.75f,
+			171.246f,
+			325.75f,
+			163.898f,
+			332.277f,
+			168.25f,
+			319.746f,
+			168.25f,
+			319.742f,
+			180.18f,
+			297.078f,
+			187.246f,
+			293.746f,
+			187.246f,
+			293.746f,
+			205.699f,
+			289.598f,
+			211.246f,
+			305.75f,
+			10,
+			0,
+			0.8f,
+			0.25f,
+			0.3f,
+			0.8f,
+			0.25f,
+			0.3f,
+			9,
+			299.246f,
+			375.75f,
+			299.641f,
+			384.941f,
+			301.789f,
+			394.418f,
+			300.246f,
+			398.746f,
+			292.766f,
+			412.461f,
+			274.098f,
+			406.535f,
+			262.25f,
+			394.746f,
+			244.418f,
+			377.598f,
+			242.219f,
+			396.078f,
+			209.246f,
+			387.746f,
+			209.246f,
+			387.742f,
+			207.297f,
+			372.797f,
+			208.25f,
+			361.746f,
+			208.25f,
+			361.742f,
+			249.258f,
+			374.516f,
+			250.25f,
+			368.746f,
+			250.25f,
+			368.746f,
+			251.898f,
+			371.879f,
+			262.25f,
+			371.75f,
+			272.137f,
+			371.879f,
+			297.152f,
+			373.168f,
+			299.246f,
+			375.75f,
+			10,
+			2.2f,
+			0.65f,
+			0.1f,
+			0.15f,
+			0.65f,
+			0.1f,
+			0.15f,
+			3,
+			251.25f,
+			387.746f,
+			251.25f,
+			387.742f,
+			256.738f,
+			381.996f,
+			253.246f,
+			371.75f,
+			253.246f,
+			371.75f,
+			236.938f,
+			353.836f,
+			239.25f,
+			338.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			198.246f,
+			293.746f,
+			198.246f,
+			293.746f,
+			193.816f,
+			308.078f,
+			203.25f,
+			300.75f,
+			203.25f,
+			300.75f,
+			208.777f,
+			298.398f,
+			207.25f,
+			296.75f,
+			206.137f,
+			294.879f,
+			199.977f,
+			290.477f,
+			198.246f,
+			293.746f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			198.246f,
+			293.746f,
+			198.246f,
+			293.746f,
+			193.816f,
+			308.078f,
+			203.25f,
+			300.75f,
+			203.25f,
+			300.75f,
+			208.777f,
+			298.398f,
+			207.25f,
+			296.75f,
+			206.137f,
+			294.879f,
+			199.977f,
+			290.477f,
+			198.246f,
+			293.746f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			204.25f,
+			292.75f,
+			204.25f,
+			292.75f,
+			200.328f,
+			303.941f,
+			208.25f,
+			297.746f,
+			208.25f,
+			297.742f,
+			212.937f,
+			295.266f,
+			211.246f,
+			294.75f,
+			206.227f,
+			293.383f,
+			211.242f,
+			290.566f,
+			204.25f,
+			292.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			204.25f,
+			292.75f,
+			204.25f,
+			292.75f,
+			200.328f,
+			303.941f,
+			208.25f,
+			297.746f,
+			208.25f,
+			297.742f,
+			212.937f,
+			295.266f,
+			211.246f,
+			294.75f,
+			206.227f,
+			293.383f,
+			211.242f,
+			290.566f,
+			204.25f,
+			292.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			209.246f,
+			292.75f,
+			209.246f,
+			292.75f,
+			205.609f,
+			303.941f,
+			213.246f,
+			297.746f,
+			213.242f,
+			297.742f,
+			218.168f,
+			295.414f,
+			216.25f,
+			294.75f,
+			212.824f,
+			293.383f,
+			216.523f,
+			290.566f,
+			209.246f,
+			292.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			209.246f,
+			292.75f,
+			209.246f,
+			292.75f,
+			205.609f,
+			303.941f,
+			213.246f,
+			297.746f,
+			213.242f,
+			297.742f,
+			218.168f,
+			295.414f,
+			216.25f,
+			294.75f,
+			212.824f,
+			293.383f,
+			216.523f,
+			290.566f,
+			209.246f,
+			292.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			216.25f,
+			292.75f,
+			216.25f,
+			292.75f,
+			212.871f,
+			303.723f,
+			220.246f,
+			297.746f,
+			220.246f,
+			297.742f,
+			225.434f,
+			295.172f,
+			224.246f,
+			294.75f,
+			220.527f,
+			293.383f,
+			223.781f,
+			290.344f,
+			216.25f,
+			292.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			216.25f,
+			292.75f,
+			216.25f,
+			292.75f,
+			212.871f,
+			303.723f,
+			220.246f,
+			297.746f,
+			220.246f,
+			297.742f,
+			225.434f,
+			295.172f,
+			224.246f,
+			294.75f,
+			220.527f,
+			293.383f,
+			223.781f,
+			290.344f,
+			216.25f,
+			292.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			224.246f,
+			292.75f,
+			224.242f,
+			292.75f,
+			220,
+			303.809f,
+			227.25f,
+			297.746f,
+			227.25f,
+			297.742f,
+			231.969f,
+			296.066f,
+			231.246f,
+			294.75f,
+			229.855f,
+			293.25f,
+			230.91f,
+			290.434f,
+			224.246f,
+			292.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			224.246f,
+			292.75f,
+			224.242f,
+			292.75f,
+			220,
+			303.809f,
+			227.25f,
+			297.746f,
+			227.25f,
+			297.742f,
+			231.969f,
+			296.066f,
+			231.246f,
+			294.75f,
+			229.855f,
+			293.25f,
+			230.91f,
+			290.434f,
+			224.246f,
+			292.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			231.246f,
+			291.746f,
+			231.246f,
+			291.746f,
+			225.938f,
+			305.438f,
+			236.25f,
+			298.75f,
+			236.25f,
+			298.75f,
+			241.34f,
+			296.195f,
+			240.25f,
+			294.75f,
+			238.699f,
+			292.676f,
+			240.02f,
+			289.156f,
+			231.246f,
+			291.746f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			231.246f,
+			291.746f,
+			231.246f,
+			291.746f,
+			225.938f,
+			305.438f,
+			236.25f,
+			298.75f,
+			236.25f,
+			298.75f,
+			241.34f,
+			296.195f,
+			240.25f,
+			294.75f,
+			238.699f,
+			292.676f,
+			240.02f,
+			289.156f,
+			231.246f,
+			291.746f,
+			10,
+			2.2f,
+			0.65f,
+			0.15f,
+			0.3f,
+			0.65f,
+			0.15f,
+			0.3f,
+			4,
+			200.246f,
+			310.746f,
+			200.246f,
+			310.742f,
+			214.5f,
+			313.797f,
+			221.246f,
+			310.746f,
+			221.246f,
+			310.742f,
+			227.699f,
+			308.957f,
+			229.25f,
+			309.75f,
+			230.34f,
+			309.836f,
+			234.246f,
+			310.746f,
+			234.246f,
+			310.746f,
+			10,
+			2.2f,
+			0.65f,
+			0.15f,
+			0.3f,
+			0.65f,
+			0.15f,
+			0.3f,
+			4,
+			237.25f,
+			300.75f,
+			237.25f,
+			300.75f,
+			250.578f,
+			315.996f,
+			264.246f,
+			310.746f,
+			271.496f,
+			308.328f,
+			270.379f,
+			312.035f,
+			271.25f,
+			314.75f,
+			272.137f,
+			318.195f,
+			272.359f,
+			322.816f,
+			278.246f,
+			325.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			7,
+			256.246f,
+			318.75f,
+			256.246f,
+			318.75f,
+			251.898f,
+			330.516f,
+			249.25f,
+			316.75f,
+			245.738f,
+			302.355f,
+			242.219f,
+			298.398f,
+			240.25f,
+			295.746f,
+			240.25f,
+			295.742f,
+			240.457f,
+			289.598f,
+			249.25f,
+			289.75f,
+			249.25f,
+			289.75f,
+			261.578f,
+			290.477f,
+			262.25f,
+			293.746f,
+			262.457f,
+			296.637f,
+			260.699f,
+			309.398f,
+			256.246f,
+			318.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			256.246f,
+			318.75f,
+			256.246f,
+			318.75f,
+			251.898f,
+			330.516f,
+			249.25f,
+			316.75f,
+			245.738f,
+			302.355f,
+			242.219f,
+			298.398f,
+			240.25f,
+			295.746f,
+			240.25f,
+			295.742f,
+			240.457f,
+			289.598f,
+			249.25f,
+			289.75f,
+			249.25f,
+			289.75f,
+			261.578f,
+			290.477f,
+			262.25f,
+			293.746f,
+			262.457f,
+			296.637f,
+			260.699f,
+			309.398f,
+			256.246f,
+			318.75f,
+			10,
+			2.2f,
+			0.65f,
+			0.15f,
+			0.3f,
+			0.65f,
+			0.15f,
+			0.3f,
+			2,
+			271.25f,
+			310.746f,
+			271.25f,
+			310.742f,
+			275.656f,
+			313.355f,
+			278.246f,
+			311.75f,
+			10,
+			2.2f,
+			0.65f,
+			0.15f,
+			0.3f,
+			0.65f,
+			0.15f,
+			0.3f,
+			2,
+			279.246f,
+			328.746f,
+			279.242f,
+			328.742f,
+			282.039f,
+			334.148f,
+			287.246f,
+			334.75f,
+			10,
+			0,
+			0.7f,
+			0.7f,
+			0.7f,
+			0.7f,
+			0.7f,
+			0.7f,
+			6,
+			191.246f,
+			288.746f,
+			191.242f,
+			288.742f,
+			211.418f,
+			284.758f,
+			216.25f,
+			286.746f,
+			216.25f,
+			286.742f,
+			225.938f,
+			286.516f,
+			216.25f,
+			284.746f,
+			216.25f,
+			284.742f,
+			202.617f,
+			284.316f,
+			194.25f,
+			285.75f,
+			194.25f,
+			285.75f,
+			181.059f,
+			291.797f,
+			191.246f,
+			288.746f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			7,
+			207.25f,
+			390.746f,
+			207.25f,
+			390.746f,
+			226.379f,
+			390.797f,
+			228.25f,
+			389.75f,
+			228.25f,
+			389.75f,
+			236.5f,
+			356.035f,
+			232.246f,
+			347.75f,
+			232.246f,
+			347.75f,
+			231.219f,
+			344.598f,
+			228.25f,
+			350.746f,
+			228.25f,
+			350.742f,
+			207.898f,
+			386.836f,
+			204.25f,
+			388.75f,
+			200.859f,
+			391.238f,
+			205.699f,
+			390.797f,
+			207.25f,
+			390.746f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			207.25f,
+			390.746f,
+			207.25f,
+			390.746f,
+			226.379f,
+			390.797f,
+			228.25f,
+			389.75f,
+			228.25f,
+			389.75f,
+			236.5f,
+			356.035f,
+			232.246f,
+			347.75f,
+			232.246f,
+			347.75f,
+			231.219f,
+			344.598f,
+			228.25f,
+			350.746f,
+			228.25f,
+			350.742f,
+			207.898f,
+			386.836f,
+			204.25f,
+			388.75f,
+			200.859f,
+			391.238f,
+			205.699f,
+			390.797f,
+			207.25f,
+			390.746f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			7,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			132,
+			391.898f,
+			146.25f,
+			388.75f,
+			146.25f,
+			388.75f,
+			151.137f,
+			364.398f,
+			154.246f,
+			358.75f,
+			158.18f,
+			353.836f,
+			154.219f,
+			353.836f,
+			150.246f,
+			356.75f,
+			146.297f,
+			359.996f,
+			130.02f,
+			375.398f,
+			128.25f,
+			379.746f,
+			125.617f,
+			385.078f,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			132,
+			391.898f,
+			146.25f,
+			388.75f,
+			146.25f,
+			388.75f,
+			151.137f,
+			364.398f,
+			154.246f,
+			358.75f,
+			158.18f,
+			353.836f,
+			154.219f,
+			353.836f,
+			150.246f,
+			356.75f,
+			146.297f,
+			359.996f,
+			130.02f,
+			375.398f,
+			128.25f,
+			379.746f,
+			125.617f,
+			385.078f,
+			122.246f,
+			393.75f,
+			122.246f,
+			393.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			6,
+			146.25f,
+			388.75f,
+			146.25f,
+			388.75f,
+			152.637f,
+			387.094f,
+			153.246f,
+			384.75f,
+			154.855f,
+			382.223f,
+			152.25f,
+			378.75f,
+			152.25f,
+			378.75f,
+			152.25f,
+			378.75f,
+			151.324f,
+			374.961f,
+			150.246f,
+			377.75f,
+			148.68f,
+			379.719f,
+			145.52f,
+			388.145f,
+			146.25f,
+			388.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			6,
+			146.25f,
+			388.75f,
+			146.25f,
+			388.75f,
+			152.637f,
+			387.094f,
+			153.246f,
+			384.75f,
+			154.855f,
+			382.223f,
+			152.25f,
+			378.75f,
+			152.25f,
+			378.75f,
+			152.25f,
+			378.75f,
+			151.324f,
+			374.961f,
+			150.246f,
+			377.75f,
+			148.68f,
+			379.719f,
+			145.52f,
+			388.145f,
+			146.25f,
+			388.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			10,
+			146.25f,
+			388.75f,
+			146.25f,
+			388.75f,
+			150.258f,
+			383.316f,
+			154.246f,
+			383.746f,
+			158.18f,
+			383.316f,
+			158.598f,
+			383.77f,
+			161.246f,
+			382.75f,
+			166.758f,
+			381.996f,
+			166.316f,
+			384.195f,
+			173.25f,
+			382.75f,
+			176.48f,
+			382.348f,
+			179.297f,
+			383.316f,
+			182.25f,
+			381.746f,
+			185.457f,
+			380.676f,
+			188.977f,
+			381.559f,
+			190.246f,
+			383.746f,
+			191.617f,
+			385.957f,
+			197.25f,
+			390.746f,
+			197.25f,
+			390.746f,
+			197.25f,
+			390.746f,
+			182.816f,
+			388.598f,
+			179.246f,
+			387.746f,
+			179.246f,
+			387.742f,
+			155.098f,
+			386.398f,
+			146.25f,
+			388.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			6,
+			195.25f,
+			388.75f,
+			195.25f,
+			388.75f,
+			188.262f,
+			384.969f,
+			188.246f,
+			382.75f,
+			187.383f,
+			379.688f,
+			193.25f,
+			375.75f,
+			193.25f,
+			375.75f,
+			193.25f,
+			375.75f,
+			196.625f,
+			370.559f,
+			197.25f,
+			372.746f,
+			197.941f,
+			375.836f,
+			196.238f,
+			388.379f,
+			195.25f,
+			388.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			6,
+			195.25f,
+			388.75f,
+			195.25f,
+			388.75f,
+			188.262f,
+			384.969f,
+			188.246f,
+			382.75f,
+			187.383f,
+			379.688f,
+			193.25f,
+			375.75f,
+			193.25f,
+			375.75f,
+			193.25f,
+			375.75f,
+			196.625f,
+			370.559f,
+			197.25f,
+			372.746f,
+			197.941f,
+			375.836f,
+			196.238f,
+			388.379f,
+			195.25f,
+			388.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			154.246f,
+			382.75f,
+			154.242f,
+			382.75f,
+			161.832f,
+			370.5f,
+			162.25f,
+			382.75f,
+			162.25f,
+			382.75f,
+			162.684f,
+			384.215f,
+			160.246f,
+			383.746f,
+			154.066f,
+			384.324f,
+			155.738f,
+			388.836f,
+			154.246f,
+			382.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			154.246f,
+			382.75f,
+			154.242f,
+			382.75f,
+			161.832f,
+			370.5f,
+			162.25f,
+			382.75f,
+			162.25f,
+			382.75f,
+			162.684f,
+			384.215f,
+			160.246f,
+			383.746f,
+			154.066f,
+			384.324f,
+			155.738f,
+			388.836f,
+			154.246f,
+			382.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			162.25f,
+			382.75f,
+			162.25f,
+			382.75f,
+			170.734f,
+			370.227f,
+			170.246f,
+			382.75f,
+			170.242f,
+			382.75f,
+			170.043f,
+			383,
+			168.25f,
+			382.75f,
+			162.891f,
+			383.625f,
+			163.27f,
+			388.594f,
+			162.25f,
+			382.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			162.25f,
+			382.75f,
+			162.25f,
+			382.75f,
+			170.734f,
+			370.227f,
+			170.246f,
+			382.75f,
+			170.242f,
+			382.75f,
+			170.043f,
+			383,
+			168.25f,
+			382.75f,
+			162.891f,
+			383.625f,
+			163.27f,
+			388.594f,
+			162.25f,
+			382.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			170.246f,
+			382.75f,
+			170.242f,
+			382.75f,
+			178.711f,
+			370.832f,
+			178.246f,
+			381.746f,
+			178.246f,
+			381.746f,
+			178.105f,
+			382.82f,
+			176.246f,
+			382.75f,
+			172.004f,
+			383.93f,
+			171.773f,
+			387.504f,
+			170.246f,
+			382.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			170.246f,
+			382.75f,
+			170.242f,
+			382.75f,
+			178.711f,
+			370.832f,
+			178.246f,
+			381.746f,
+			178.246f,
+			381.746f,
+			178.105f,
+			382.82f,
+			176.246f,
+			382.75f,
+			172.004f,
+			383.93f,
+			171.773f,
+			387.504f,
+			170.246f,
+			382.75f,
+			10,
+			0,
+			1,
+			1,
+			0.8f,
+			1,
+			1,
+			0.8f,
+			5,
+			177.246f,
+			382.75f,
+			177.246f,
+			382.75f,
+			186.207f,
+			369.719f,
+			186.25f,
+			380.75f,
+			186.25f,
+			380.75f,
+			188.398f,
+			381.992f,
+			186.25f,
+			381.746f,
+			180.078f,
+			383.051f,
+			180.957f,
+			387.953f,
+			177.246f,
+			382.75f,
+			10,
+			0.55f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			177.246f,
+			382.75f,
+			177.246f,
+			382.75f,
+			186.207f,
+			369.719f,
+			186.25f,
+			380.75f,
+			186.25f,
+			380.75f,
+			188.398f,
+			381.992f,
+			186.25f,
+			381.746f,
+			180.078f,
+			383.051f,
+			180.957f,
+			387.953f,
+			177.246f,
+			382.75f,
+			10,
+			0,
+			0.9f,
+			0.9f,
+			0.7f,
+			0.9f,
+			0.9f,
+			0.7f,
+			6,
+			137.246f,
+			378.75f,
+			129.25f,
+			379.746f,
+			126.441f,
+			385.738f,
+			124.25f,
+			392.746f,
+			124.25f,
+			392.746f,
+			124.25f,
+			392.746f,
+			131.117f,
+			391.402f,
+			145.25f,
+			388.75f,
+			145.25f,
+			388.75f,
+			145.832f,
+			384.672f,
+			147.25f,
+			378.75f,
+			137.246f,
+			378.75f,
+			10,
+			0,
+			0.9f,
+			0.9f,
+			0.7f,
+			0.9f,
+			0.9f,
+			0.7f,
+			7,
+			209.246f,
+			383.746f,
+			207.469f,
+			386.437f,
+			206.02f,
+			388.371f,
+			205.25f,
+			388.75f,
+			201.992f,
+			390.891f,
+			206.547f,
+			390.477f,
+			208.25f,
+			390.746f,
+			208.25f,
+			390.746f,
+			226.02f,
+			390.477f,
+			228.25f,
+			389.75f,
+			228.25f,
+			389.75f,
+			228.668f,
+			387.18f,
+			229.25f,
+			383.746f,
+			229.25f,
+			383.742f,
+			218.32f,
+			385.66f,
+			209.246f,
+			383.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			10,
+			268.246f,
+			535.746f,
+			298.758f,
+			531.289f,
+			326.832f,
+			570.492f,
+			329.25f,
+			580.75f,
+			330.703f,
+			591.789f,
+			319.25f,
+			604.75f,
+			319.25f,
+			604.75f,
+			321.023f,
+			608.246f,
+			315.699f,
+			623.734f,
+			310.246f,
+			633.75f,
+			304.082f,
+			644.063f,
+			286.594f,
+			642.992f,
+			267.246f,
+			643.75f,
+			249.875f,
+			645.031f,
+			229.547f,
+			619.379f,
+			228.25f,
+			617.75f,
+			226.641f,
+			615.508f,
+			233.418f,
+			573.398f,
+			235.246f,
+			566.75f,
+			236.32f,
+			560.813f,
+			233.246f,
+			531.75f,
+			233.246f,
+			531.75f,
+			271.082f,
+			541.781f,
+			237.773f,
+			540,
+			268.246f,
+			535.746f,
+			10,
+			0,
+			0.92f,
+			0.56f,
+			0.32f,
+			0.92f,
+			0.56f,
+			0.32f,
+			10,
+			229.25f,
+			616.746f,
+			227.469f,
+			614.828f,
+			234.121f,
+			573.484f,
+			235.246f,
+			567.75f,
+			236.973f,
+			561.129f,
+			234.246f,
+			532.746f,
+			234.246f,
+			532.746f,
+			270.063f,
+			542.387f,
+			238.398f,
+			540.695f,
+			268.246f,
+			536.75f,
+			298.273f,
+			532.141f,
+			325.836f,
+			570.633f,
+			327.25f,
+			580.75f,
+			329.637f,
+			591.543f,
+			318.25f,
+			604.75f,
+			318.25f,
+			604.75f,
+			320.133f,
+			607.699f,
+			314.906f,
+			622.906f,
+			309.246f,
+			632.75f,
+			303.504f,
+			642.867f,
+			286.332f,
+			641.813f,
+			267.246f,
+			642.746f,
+			250.277f,
+			643.816f,
+			230.32f,
+			618.629f,
+			229.25f,
+			616.746f,
+			10,
+			0,
+			0.94f,
+			0.67f,
+			0.49f,
+			0.94f,
+			0.67f,
+			0.49f,
+			10,
+			229.25f,
+			615.75f,
+			228.297f,
+			614.152f,
+			234.824f,
+			573.574f,
+			236.25f,
+			567.75f,
+			237.625f,
+			561.445f,
+			235.246f,
+			533.746f,
+			235.246f,
+			533.746f,
+			269.371f,
+			543.539f,
+			239.023f,
+			541.391f,
+			268.246f,
+			536.75f,
+			297.793f,
+			532.996f,
+			324.844f,
+			570.773f,
+			326.25f,
+			580.75f,
+			328.574f,
+			591.297f,
+			318.25f,
+			603.746f,
+			318.25f,
+			603.746f,
+			319.246f,
+			607.156f,
+			314.113f,
+			622.078f,
+			308.246f,
+			631.746f,
+			302.922f,
+			641.668f,
+			286.066f,
+			640.637f,
+			267.246f,
+			641.75f,
+			250.684f,
+			642.602f,
+			231.094f,
+			617.883f,
+			229.25f,
+			615.75f,
+			10,
+			0,
+			0.96f,
+			0.78f,
+			0.66f,
+			0.96f,
+			0.78f,
+			0.66f,
+			10,
+			230.25f,
+			615.75f,
+			229.125f,
+			613.473f,
+			235.531f,
+			573.66f,
+			237.25f,
+			567.75f,
+			238.277f,
+			561.762f,
+			235.246f,
+			534.75f,
+			235.246f,
+			534.75f,
+			267.91f,
+			544.25f,
+			239.648f,
+			542.086f,
+			268.246f,
+			537.746f,
+			297.309f,
+			533.852f,
+			323.848f,
+			570.914f,
+			325.25f,
+			580.75f,
+			327.508f,
+			591.051f,
+			317.25f,
+			603.746f,
+			317.25f,
+			603.746f,
+			318.355f,
+			606.609f,
+			313.324f,
+			621.254f,
+			308.246f,
+			630.75f,
+			302.34f,
+			640.473f,
+			285.805f,
+			639.457f,
+			267.246f,
+			640.746f,
+			251.09f,
+			641.387f,
+			231.871f,
+			617.133f,
+			230.25f,
+			615.75f,
+			10,
+			0,
+			0.98f,
+			0.89f,
+			0.83f,
+			0.98f,
+			0.89f,
+			0.83f,
+			10,
+			231.246f,
+			614.746f,
+			229.949f,
+			612.797f,
+			236.234f,
+			573.75f,
+			237.25f,
+			567.75f,
+			238.926f,
+			562.082f,
+			236.25f,
+			534.75f,
+			236.25f,
+			534.75f,
+			266.891f,
+			544.965f,
+			240.273f,
+			542.781f,
+			268.246f,
+			538.75f,
+			296.824f,
+			534.703f,
+			322.855f,
+			571.055f,
+			324.246f,
+			580.75f,
+			326.445f,
+			590.805f,
+			316.25f,
+			602.75f,
+			316.25f,
+			602.75f,
+			317.469f,
+			606.063f,
+			312.531f,
+			620.426f,
+			307.25f,
+			629.746f,
+			301.762f,
+			639.273f,
+			285.543f,
+			638.281f,
+			267.246f,
+			639.75f,
+			251.492f,
+			640.172f,
+			232.645f,
+			616.387f,
+			231.246f,
+			614.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			10,
+			268.246f,
+			539.746f,
+			296.34f,
+			535.559f,
+			321.859f,
+			571.199f,
+			323.246f,
+			580.75f,
+			325.379f,
+			590.559f,
+			315.25f,
+			602.75f,
+			315.25f,
+			602.75f,
+			316.578f,
+			605.52f,
+			311.738f,
+			619.598f,
+			306.25f,
+			628.75f,
+			301.18f,
+			638.078f,
+			285.277f,
+			637.102f,
+			267.246f,
+			637.75f,
+			251.898f,
+			638.957f,
+			233.418f,
+			615.637f,
+			232.246f,
+			613.75f,
+			230.777f,
+			612.117f,
+			236.938f,
+			573.84f,
+			238.25f,
+			567.75f,
+			239.578f,
+			562.398f,
+			237.25f,
+			535.746f,
+			237.25f,
+			535.746f,
+			264.988f,
+			545.457f,
+			240.898f,
+			543.477f,
+			268.246f,
+			539.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			319.25f,
+			576.746f,
+			319.25f,
+			576.742f,
+			289.078f,
+			568.559f,
+			276.246f,
+			570.746f,
+			276.246f,
+			570.746f,
+			258.937f,
+			577.578f,
+			249.25f,
+			553.75f,
+			249.25f,
+			553.75f,
+			245.297f,
+			545.68f,
+			243.246f,
+			543.746f,
+			240.898f,
+			541.277f,
+			319.25f,
+			576.746f,
+			319.25f,
+			576.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			11,
+			324.246f,
+			579.746f,
+			324.242f,
+			579.746f,
+			291.937f,
+			565.918f,
+			281.25f,
+			566.75f,
+			281.25f,
+			566.75f,
+			262.898f,
+			571.418f,
+			253.246f,
+			555.75f,
+			253.246f,
+			555.75f,
+			244.418f,
+			545.238f,
+			241.25f,
+			543.746f,
+			241.25f,
+			543.742f,
+			240.457f,
+			541.719f,
+			247.246f,
+			545.75f,
+			259.25f,
+			540.75f,
+			259.25f,
+			540.75f,
+			275.219f,
+			529.84f,
+			286.246f,
+			547.75f,
+			286.246f,
+			547.75f,
+			290.18f,
+			559.758f,
+			290.246f,
+			561.746f,
+			290.18f,
+			564.156f,
+			313.5f,
+			570.316f,
+			315.25f,
+			570.746f,
+			317.02f,
+			571.199f,
+			324.277f,
+			575.816f,
+			324.246f,
+			579.746f,
+			10,
+			0,
+			0.6f,
+			0.8f,
+			0.2f,
+			0.6f,
+			0.8f,
+			0.2f,
+			6,
+			271.25f,
+			539.746f,
+			264.141f,
+			539.832f,
+			254.93f,
+			544.086f,
+			255.246f,
+			550.746f,
+			254.93f,
+			557.832f,
+			264.141f,
+			564.723f,
+			271.25f,
+			564.75f,
+			279.258f,
+			564.723f,
+			285.387f,
+			559.152f,
+			285.25f,
+			552.746f,
+			285.387f,
+			545.402f,
+			279.258f,
+			539.832f,
+			271.25f,
+			539.746f,
+			10,
+			0,
+			0.4f,
+			0.6f,
+			0,
+			0.4f,
+			0.6f,
+			0,
+			6,
+			267.246f,
+			557.746f,
+			262.383f,
+			557.391f,
+			256.785f,
+			555.738f,
+			257.246f,
+			555.75f,
+			258.559f,
+			561.055f,
+			265.555f,
+			564.723f,
+			271.25f,
+			564.75f,
+			276.422f,
+			564.723f,
+			280.59f,
+			562.547f,
+			283.25f,
+			558.75f,
+			283.25f,
+			558.75f,
+			277.203f,
+			559.598f,
+			267.246f,
+			557.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			4,
+			281.25f,
+			558.75f,
+			281.25f,
+			558.75f,
+			276.098f,
+			561.957f,
+			276.246f,
+			559.746f,
+			276.246f,
+			559.746f,
+			280.059f,
+			554.699f,
+			281.25f,
+			558.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			6,
+			270.25f,
+			549.75f,
+			267.187f,
+			549.5f,
+			264.961f,
+			551.727f,
+			265.246f,
+			554.746f,
+			264.961f,
+			557.227f,
+			267.187f,
+			559.457f,
+			270.25f,
+			559.746f,
+			272.687f,
+			559.457f,
+			274.918f,
+			557.227f,
+			275.246f,
+			554.746f,
+			274.918f,
+			551.727f,
+			272.687f,
+			549.5f,
+			270.25f,
+			549.75f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			15,
+			155.246f,
+			563.746f,
+			155.246f,
+			563.742f,
+			152.02f,
+			587.477f,
+			154.246f,
+			592.746f,
+			154.242f,
+			592.746f,
+			166.539f,
+			603.316f,
+			166.246f,
+			607.746f,
+			166.246f,
+			607.742f,
+			165.656f,
+			627.078f,
+			164.246f,
+			627.746f,
+			163.02f,
+			628.84f,
+			154.656f,
+			635.438f,
+			148.246f,
+			628.75f,
+			148.242f,
+			628.75f,
+			136.617f,
+			608.598f,
+			137.246f,
+			601.746f,
+			137.246f,
+			599.75f,
+			137.242f,
+			599.75f,
+			129.137f,
+			599.797f,
+			127.246f,
+			597.75f,
+			127.246f,
+			597.75f,
+			126.059f,
+			591.879f,
+			124.25f,
+			591.75f,
+			124.25f,
+			591.75f,
+			121.656f,
+			588.797f,
+			124.25f,
+			585.746f,
+			124.25f,
+			585.742f,
+			121.656f,
+			583.078f,
+			122.246f,
+			578.75f,
+			130.25f,
+			574.746f,
+			130.25f,
+			574.742f,
+			132.656f,
+			558.438f,
+			144.246f,
+			552.746f,
+			149.859f,
+			550.156f,
+			153.34f,
+			557.559f,
+			155.246f,
+			563.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			15,
+			154.246f,
+			565.746f,
+			154.242f,
+			565.742f,
+			151.27f,
+			587.172f,
+			153.246f,
+			591.75f,
+			153.242f,
+			591.75f,
+			164.34f,
+			601.426f,
+			164.246f,
+			604.75f,
+			164.242f,
+			604.75f,
+			163.547f,
+			622.809f,
+			162.25f,
+			623.746f,
+			161.172f,
+			624.395f,
+			153.645f,
+			630.336f,
+			147.25f,
+			623.746f,
+			147.25f,
+			623.746f,
+			137.41f,
+			606.18f,
+			138.246f,
+			599.75f,
+			138.246f,
+			597.75f,
+			138.246f,
+			597.75f,
+			130.68f,
+			598.258f,
+			129.25f,
+			596.746f,
+			129.25f,
+			596.742f,
+			127.906f,
+			591.129f,
+			126.246f,
+			590.746f,
+			126.242f,
+			590.746f,
+			123.945f,
+			588.359f,
+			126.246f,
+			585.746f,
+			126.242f,
+			585.742f,
+			123.945f,
+			583.211f,
+			124.25f,
+			579.746f,
+			132.246f,
+			575.75f,
+			132.246f,
+			575.75f,
+			133.848f,
+			561.035f,
+			144.246f,
+			555.75f,
+			149.324f,
+			553.582f,
+			152.457f,
+			560.242f,
+			154.246f,
+			565.746f,
+			10,
+			0,
+			0.925f,
+			0.588f,
+			0.363f,
+			0.925f,
+			0.588f,
+			0.363f,
+			15,
+			164.246f,
+			626.75f,
+			162.645f,
+			627.816f,
+			154.406f,
+			634.16f,
+			148.246f,
+			627.746f,
+			148.242f,
+			627.742f,
+			136.816f,
+			607.992f,
+			137.246f,
+			600.75f,
+			137.246f,
+			598.746f,
+			137.242f,
+			598.742f,
+			129.523f,
+			599.414f,
+			128.25f,
+			597.75f,
+			128.25f,
+			597.75f,
+			126.52f,
+			591.691f,
+			125.25f,
+			591.75f,
+			125.25f,
+			591.75f,
+			122.23f,
+			588.688f,
+			124.25f,
+			585.746f,
+			124.25f,
+			585.742f,
+			122.23f,
+			583.109f,
+			122.246f,
+			578.75f,
+			131.246f,
+			574.746f,
+			131.242f,
+			574.742f,
+			132.953f,
+			559.086f,
+			144.246f,
+			553.75f,
+			149.723f,
+			551.012f,
+			153.117f,
+			558.23f,
+			155.246f,
+			564.75f,
+			155.246f,
+			564.75f,
+			151.832f,
+			587.402f,
+			154.246f,
+			591.75f,
+			154.242f,
+			591.75f,
+			165.988f,
+			602.844f,
+			165.246f,
+			606.75f,
+			165.242f,
+			606.75f,
+			165.129f,
+			626.012f,
+			164.246f,
+			626.75f,
+			10,
+			0,
+			0.95f,
+			0.725f,
+			0.575f,
+			0.95f,
+			0.725f,
+			0.575f,
+			15,
+			163.25f,
+			625.746f,
+			162.27f,
+			626.793f,
+			154.152f,
+			632.887f,
+			148.246f,
+			625.746f,
+			148.242f,
+			625.746f,
+			137.016f,
+			607.387f,
+			138.246f,
+			600.75f,
+			138.246f,
+			598.746f,
+			138.246f,
+			598.742f,
+			129.906f,
+			599.027f,
+			128.25f,
+			596.746f,
+			128.25f,
+			596.742f,
+			126.98f,
+			591.504f,
+			125.25f,
+			590.746f,
+			125.25f,
+			590.746f,
+			122.801f,
+			588.578f,
+			125.25f,
+			585.746f,
+			125.25f,
+			585.742f,
+			122.801f,
+			583.145f,
+			123.25f,
+			578.75f,
+			131.246f,
+			574.746f,
+			131.242f,
+			574.742f,
+			133.254f,
+			559.734f,
+			144.246f,
+			554.746f,
+			149.59f,
+			551.867f,
+			152.898f,
+			558.898f,
+			155.246f,
+			564.75f,
+			155.246f,
+			564.75f,
+			151.645f,
+			587.324f,
+			154.246f,
+			591.75f,
+			154.242f,
+			591.75f,
+			165.438f,
+			602.371f,
+			165.246f,
+			605.746f,
+			165.242f,
+			605.742f,
+			164.602f,
+			624.945f,
+			163.25f,
+			625.746f,
+			10,
+			0,
+			0.975f,
+			0.863f,
+			0.788f,
+			0.975f,
+			0.863f,
+			0.788f,
+			15,
+			163.25f,
+			624.75f,
+			161.895f,
+			625.77f,
+			153.898f,
+			631.609f,
+			148.246f,
+			624.75f,
+			148.242f,
+			624.75f,
+			137.211f,
+			606.781f,
+			138.246f,
+			600.75f,
+			138.246f,
+			597.75f,
+			138.246f,
+			597.75f,
+			130.293f,
+			598.645f,
+			128.25f,
+			596.746f,
+			128.25f,
+			596.742f,
+			127.445f,
+			591.316f,
+			126.246f,
+			590.746f,
+			126.242f,
+			590.746f,
+			123.375f,
+			588.469f,
+			125.25f,
+			585.746f,
+			125.25f,
+			585.742f,
+			123.375f,
+			583.176f,
+			124.25f,
+			578.75f,
+			131.246f,
+			574.746f,
+			131.242f,
+			574.742f,
+			133.551f,
+			560.387f,
+			144.246f,
+			554.746f,
+			149.457f,
+			552.727f,
+			152.68f,
+			559.57f,
+			154.246f,
+			565.746f,
+			154.242f,
+			565.742f,
+			151.457f,
+			587.246f,
+			154.246f,
+			591.75f,
+			154.242f,
+			591.75f,
+			164.887f,
+			601.898f,
+			164.246f,
+			605.746f,
+			164.242f,
+			605.742f,
+			164.074f,
+			623.879f,
+			163.25f,
+			624.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			15,
+			154.246f,
+			566.75f,
+			154.242f,
+			566.75f,
+			151.27f,
+			587.172f,
+			153.246f,
+			591.75f,
+			153.242f,
+			591.75f,
+			164.34f,
+			601.426f,
+			164.246f,
+			604.75f,
+			164.242f,
+			604.75f,
+			163.547f,
+			622.809f,
+			162.25f,
+			623.746f,
+			161.523f,
+			624.746f,
+			153.645f,
+			630.336f,
+			147.25f,
+			623.746f,
+			147.25f,
+			623.746f,
+			137.41f,
+			606.18f,
+			138.246f,
+			599.75f,
+			138.246f,
+			597.75f,
+			138.246f,
+			597.75f,
+			130.68f,
+			598.258f,
+			129.25f,
+			596.746f,
+			129.25f,
+			596.742f,
+			127.906f,
+			591.129f,
+			126.246f,
+			590.746f,
+			126.242f,
+			590.746f,
+			123.945f,
+			588.359f,
+			126.246f,
+			585.746f,
+			126.242f,
+			585.742f,
+			123.945f,
+			583.211f,
+			124.25f,
+			579.746f,
+			132.246f,
+			575.75f,
+			132.246f,
+			575.75f,
+			133.848f,
+			561.035f,
+			144.246f,
+			555.75f,
+			149.324f,
+			553.582f,
+			152.457f,
+			560.352f,
+			154.246f,
+			566.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			151.25f,
+			572.746f,
+			151.25f,
+			572.742f,
+			127.27f,
+			584.398f,
+			126.246f,
+			585.746f,
+			126.242f,
+			585.742f,
+			136.289f,
+			576.258f,
+			137.246f,
+			576.746f,
+			138.047f,
+			576.258f,
+			151.25f,
+			572.746f,
+			151.25f,
+			572.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			132.246f,
+			579.746f,
+			132.246f,
+			579.746f,
+			152.457f,
+			576.039f,
+			152.25f,
+			570.746f,
+			152.457f,
+			567.996f,
+			152.191f,
+			553.234f,
+			146.25f,
+			554.746f,
+			137.059f,
+			557.559f,
+			141.02f,
+			573.398f,
+			132.246f,
+			579.746f,
+			10,
+			0,
+			0.6f,
+			0.8f,
+			0.2f,
+			0.6f,
+			0.8f,
+			0.2f,
+			5,
+			141.25f,
+			575.75f,
+			141.25f,
+			575.75f,
+			151.332f,
+			574.195f,
+			152.25f,
+			570.746f,
+			153.117f,
+			569.438f,
+			153.848f,
+			560.301f,
+			148.246f,
+			558.75f,
+			142.832f,
+			558.098f,
+			140.379f,
+			569.34f,
+			141.25f,
+			575.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			44,
+			236.25f,
+			528.746f,
+			235.504f,
+			530.93f,
+			236.949f,
+			530.785f,
+			239.25f,
+			531.75f,
+			241.117f,
+			532.039f,
+			254.539f,
+			536.219f,
+			255.246f,
+			538.75f,
+			256.297f,
+			541.938f,
+			271.25f,
+			536.75f,
+			271.25f,
+			536.75f,
+			272.797f,
+			536.219f,
+			277.246f,
+			533.746f,
+			277.246f,
+			533.746f,
+			282.918f,
+			532.039f,
+			290.246f,
+			531.75f,
+			290.246f,
+			531.75f,
+			292.816f,
+			530.5f,
+			296.25f,
+			527.75f,
+			296.25f,
+			527.75f,
+			312.617f,
+			516.199f,
+			326.25f,
+			523.75f,
+			326.25f,
+			523.75f,
+			348.258f,
+			531.379f,
+			341.25f,
+			550.746f,
+			341.25f,
+			550.746f,
+			338.359f,
+			560.199f,
+			342.246f,
+			563.746f,
+			342.246f,
+			563.746f,
+			342.098f,
+			568.117f,
+			350.25f,
+			560.75f,
+			350.25f,
+			560.75f,
+			352.879f,
+			556.457f,
+			354.246f,
+			550.746f,
+			354.246f,
+			550.746f,
+			362.559f,
+			538.637f,
+			359.25f,
+			557.746f,
+			359.25f,
+			557.746f,
+			359.039f,
+			559.316f,
+			355.961f,
+			563.277f,
+			356.246f,
+			564.75f,
+			355.961f,
+			565.918f,
+			354.246f,
+			569.75f,
+			354.246f,
+			569.75f,
+			350.68f,
+			573.398f,
+			353.246f,
+			580.75f,
+			353.246f,
+			580.75f,
+			355.301f,
+			596.277f,
+			353.246f,
+			594.746f,
+			353.246f,
+			594.746f,
+			351.559f,
+			596.277f,
+			341.25f,
+			585.746f,
+			341.25f,
+			585.746f,
+			339.02f,
+			581.539f,
+			332.246f,
+			579.746f,
+			332.246f,
+			579.746f,
+			329.34f,
+			577.797f,
+			325.25f,
+			579.746f,
+			325.25f,
+			579.746f,
+			322.738f,
+			579.777f,
+			316.25f,
+			571.75f,
+			316.25f,
+			571.75f,
+			319.66f,
+			572.297f,
+			322.301f,
+			567.457f,
+			325.25f,
+			566.75f,
+			327.578f,
+			567.02f,
+			329.559f,
+			569.879f,
+			331.246f,
+			570.746f,
+			333.078f,
+			571.199f,
+			336.25f,
+			564.75f,
+			336.25f,
+			564.75f,
+			336.598f,
+			561.957f,
+			330.25f,
+			556.75f,
+			330.25f,
+			556.75f,
+			330,
+			551.617f,
+			328.25f,
+			553.75f,
+			328.25f,
+			553.75f,
+			324.938f,
+			554.039f,
+			323.621f,
+			549.859f,
+			322.246f,
+			544.746f,
+			321.418f,
+			539.738f,
+			317.25f,
+			539.746f,
+			317.25f,
+			539.746f,
+			315.039f,
+			531.156f,
+			313.246f,
+			534.75f,
+			313.246f,
+			534.75f,
+			313.5f,
+			540.617f,
+			307.25f,
+			533.746f,
+			307.25f,
+			533.746f,
+			305.578f,
+			532.039f,
+			300.246f,
+			534.75f,
+			300.246f,
+			534.75f,
+			293.039f,
+			536.656f,
+			295.25f,
+			538.75f,
+			295.25f,
+			538.75f,
+			297.656f,
+			541.277f,
+			310.246f,
+			538.75f,
+			310.246f,
+			538.75f,
+			312.398f,
+			540.617f,
+			303.25f,
+			544.746f,
+			303.25f,
+			544.746f,
+			302.937f,
+			547,
+			304.25f,
+			551.75f,
+			304.25f,
+			551.75f,
+			305.359f,
+			555.359f,
+			313.246f,
+			561.746f,
+			313.246f,
+			561.746f,
+			323.18f,
+			562.84f,
+			320.246f,
+			564.75f,
+			320.246f,
+			564.75f,
+			313.277f,
+			570.316f,
+			307.25f,
+			561.746f,
+			307.25f,
+			561.746f,
+			304.477f,
+			555.137f,
+			285.25f,
+			538.75f,
+			285.25f,
+			538.75f,
+			280.059f,
+			534.898f,
+			282.918f,
+			542.379f,
+			278.246f,
+			538.75f,
+			274.117f,
+			534.898f,
+			251.25f,
+			544.746f,
+			251.25f,
+			544.746f,
+			238.738f,
+			546.109f,
+			235.734f,
+			528.793f,
+			232.246f,
+			531.75f,
+			232.246f,
+			531.75f,
+			237.813f,
+			522.855f,
+			236.25f,
+			528.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			12,
+			450.25f,
+			711.746f,
+			450.25f,
+			711.746f,
+			422.18f,
+			703.199f,
+			419.246f,
+			682.746f,
+			419.246f,
+			682.742f,
+			416.461f,
+			657.438f,
+			439.25f,
+			637.75f,
+			439.25f,
+			637.75f,
+			439.34f,
+			631.039f,
+			441.246f,
+			627.746f,
+			441.246f,
+			627.742f,
+			439.777f,
+			622.238f,
+			460.246f,
+			630.75f,
+			490.25f,
+			639.75f,
+			490.25f,
+			639.75f,
+			497.418f,
+			642.477f,
+			503.25f,
+			651.746f,
+			508.859f,
+			661.84f,
+			525.578f,
+			682.52f,
+			521.25f,
+			709.75f,
+			521.25f,
+			709.75f,
+			522.938f,
+			722.559f,
+			516.25f,
+			722.746f,
+			516.25f,
+			722.746f,
+			507.098f,
+			724.758f,
+			499.25f,
+			716.75f,
+			499.25f,
+			716.75f,
+			491.699f,
+			712.879f,
+			489.246f,
+			713.746f,
+			450.25f,
+			711.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			8,
+			510.25f,
+			712.75f,
+			510.25f,
+			712.75f,
+			512.73f,
+			722.91f,
+			507.25f,
+			717.746f,
+			507.25f,
+			717.742f,
+			499.664f,
+			711.293f,
+			491.246f,
+			711.746f,
+			491.242f,
+			711.746f,
+			475.465f,
+			708.875f,
+			470.25f,
+			694.75f,
+			470.25f,
+			694.75f,
+			466.266f,
+			664.828f,
+			475.25f,
+			658.746f,
+			475.25f,
+			658.746f,
+			480.305f,
+			650.309f,
+			488.25f,
+			657.75f,
+			495.793f,
+			664.828f,
+			512.844f,
+			698.082f,
+			510.25f,
+			712.75f,
+			10,
+			0,
+			0.2f,
+			0.2f,
+			0.2f,
+			0.2f,
+			0.2f,
+			0.2f,
+			8,
+			510.25f,
+			712.75f,
+			510.25f,
+			712.75f,
+			512.309f,
+			722.313f,
+			507.25f,
+			716.75f,
+			507.25f,
+			716.75f,
+			499.48f,
+			710.906f,
+			491.246f,
+			710.746f,
+			491.242f,
+			710.742f,
+			475.719f,
+			708.531f,
+			471.246f,
+			694.75f,
+			471.242f,
+			694.75f,
+			466.691f,
+			665.289f,
+			475.25f,
+			658.746f,
+			475.25f,
+			658.746f,
+			480.469f,
+			651.031f,
+			488.25f,
+			657.75f,
+			495.68f,
+			665.289f,
+			512.387f,
+			697.961f,
+			510.25f,
+			712.75f,
+			10,
+			0,
+			0.4f,
+			0.4f,
+			0.4f,
+			0.4f,
+			0.4f,
+			0.4f,
+			8,
+			509.246f,
+			712.75f,
+			509.246f,
+			712.75f,
+			511.887f,
+			721.715f,
+			507.25f,
+			716.75f,
+			507.25f,
+			716.75f,
+			499.293f,
+			710.52f,
+			491.246f,
+			710.746f,
+			491.242f,
+			710.742f,
+			475.973f,
+			708.188f,
+			471.246f,
+			693.746f,
+			471.242f,
+			693.742f,
+			467.113f,
+			665.746f,
+			475.25f,
+			659.75f,
+			475.25f,
+			659.75f,
+			480.637f,
+			651.754f,
+			488.25f,
+			658.746f,
+			495.563f,
+			665.746f,
+			511.93f,
+			697.84f,
+			509.246f,
+			712.75f,
+			10,
+			0,
+			0.6f,
+			0.6f,
+			0.6f,
+			0.6f,
+			0.6f,
+			0.6f,
+			8,
+			509.246f,
+			711.746f,
+			509.246f,
+			711.746f,
+			511.465f,
+			721.113f,
+			506.246f,
+			715.746f,
+			506.242f,
+			715.742f,
+			499.109f,
+			710.133f,
+			491.246f,
+			709.75f,
+			491.242f,
+			709.75f,
+			476.23f,
+			707.844f,
+			471.246f,
+			693.746f,
+			471.242f,
+			693.742f,
+			467.535f,
+			666.203f,
+			476.246f,
+			660.746f,
+			476.246f,
+			660.742f,
+			480.805f,
+			652.477f,
+			488.25f,
+			659.75f,
+			495.449f,
+			666.203f,
+			511.477f,
+			697.719f,
+			509.246f,
+			711.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			8,
+			509.246f,
+			711.746f,
+			509.246f,
+			711.746f,
+			511.043f,
+			720.516f,
+			506.246f,
+			715.746f,
+			506.242f,
+			715.742f,
+			498.926f,
+			709.746f,
+			491.246f,
+			709.75f,
+			491.242f,
+			709.75f,
+			476.484f,
+			707.5f,
+			472.25f,
+			693.746f,
+			472.25f,
+			693.742f,
+			467.957f,
+			666.66f,
+			476.246f,
+			660.746f,
+			476.246f,
+			660.742f,
+			480.973f,
+			653.195f,
+			488.25f,
+			659.75f,
+			495.332f,
+			666.66f,
+			511.02f,
+			697.598f,
+			509.246f,
+			711.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			8,
+			508.25f,
+			710.746f,
+			508.25f,
+			710.742f,
+			510.621f,
+			719.918f,
+			506.246f,
+			714.75f,
+			506.242f,
+			714.75f,
+			498.738f,
+			709.359f,
+			491.246f,
+			709.75f,
+			491.242f,
+			709.75f,
+			476.738f,
+			707.156f,
+			472.25f,
+			693.746f,
+			472.25f,
+			693.742f,
+			468.379f,
+			667.117f,
+			476.246f,
+			661.75f,
+			476.246f,
+			661.75f,
+			481.141f,
+			653.918f,
+			488.25f,
+			660.746f,
+			495.219f,
+			667.117f,
+			510.563f,
+			697.477f,
+			508.25f,
+			710.746f,
+			10,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			24,
+			275.246f,
+			487.75f,
+			275.246f,
+			487.75f,
+			253.219f,
+			508.719f,
+			244.246f,
+			509.75f,
+			244.246f,
+			509.75f,
+			206.578f,
+			514,
+			190.246f,
+			493.746f,
+			190.246f,
+			493.742f,
+			209.656f,
+			516.637f,
+			240.25f,
+			510.746f,
+			240.25f,
+			510.742f,
+			216.258f,
+			515.316f,
+			202.246f,
+			511.746f,
+			202.242f,
+			511.746f,
+			184.137f,
+			511.797f,
+			173.25f,
+			496.75f,
+			170.246f,
+			490.75f,
+			170.242f,
+			490.75f,
+			174.898f,
+			507.398f,
+			195.25f,
+			513.746f,
+			195.25f,
+			513.746f,
+			220.219f,
+			519.277f,
+			232.246f,
+			513.746f,
+			232.246f,
+			513.746f,
+			208.34f,
+			521.477f,
+			197.25f,
+			519.746f,
+			197.25f,
+			519.742f,
+			163.898f,
+			521.918f,
+			150.246f,
+			492.75f,
+			150.246f,
+			492.75f,
+			154.219f,
+			508.719f,
+			170.246f,
+			516.75f,
+			170.242f,
+			516.75f,
+			185.457f,
+			526.316f,
+			208.25f,
+			522.746f,
+			208.25f,
+			522.746f,
+			223.738f,
+			519.719f,
+			229.25f,
+			516.75f,
+			235.18f,
+			514.438f,
+			233.859f,
+			517.52f,
+			224.246f,
+			522.746f,
+			224.242f,
+			522.746f,
+			218.457f,
+			533.797f,
+			203.25f,
+			533.746f,
+			203.25f,
+			533.746f,
+			155.977f,
+			529.398f,
+			144.246f,
+			515.746f,
+			144.246f,
+			515.742f,
+			159.5f,
+			528.52f,
+			171.246f,
+			531.75f,
+			171.246f,
+			531.75f,
+			195.578f,
+			540.398f,
+			205.25f,
+			539.746f,
+			205.25f,
+			539.742f,
+			232.098f,
+			538.418f,
+			240.25f,
+			542.75f,
+			240.25f,
+			542.75f,
+			228.137f,
+			537.316f,
+			231.246f,
+			533.746f,
+			235.18f,
+			530.277f,
+			242.656f,
+			521.918f,
+			242.246f,
+			520.75f,
+			242.656f,
+			519.277f,
+			269.277f,
+			494.969f,
+			273.25f,
+			489.746f,
+			275.246f,
+			487.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			428.25f,
+			273.746f,
+			428.25f,
+			273.742f,
+			410.848f,
+			314.348f,
+			397.246f,
+			324.746f,
+			397.246f,
+			324.746f,
+			425.699f,
+			307.199f,
+			429.25f,
+			287.75f,
+			429.25f,
+			287.75f,
+			429.547f,
+			276.398f,
+			428.25f,
+			273.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			7,
+			479.25f,
+			265.75f,
+			479.25f,
+			265.75f,
+			450.449f,
+			326.449f,
+			430.246f,
+			352.746f,
+			430.246f,
+			352.742f,
+			477.949f,
+			311.598f,
+			483.25f,
+			282.746f,
+			484.246f,
+			276.75f,
+			480.246f,
+			278.75f,
+			480.242f,
+			278.75f,
+			480.148f,
+			269.25f,
+			479.25f,
+			265.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			542.246f,
+			319.746f,
+			542.246f,
+			319.742f,
+			473,
+			384.75f,
+			471.246f,
+			387.746f,
+			471.242f,
+			387.742f,
+			537.898f,
+			314.898f,
+			541.25f,
+			306.746f,
+			541.25f,
+			306.742f,
+			539,
+			316.547f,
+			542.246f,
+			319.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			334.246f,
+			271.746f,
+			334.246f,
+			271.746f,
+			355.848f,
+			328.648f,
+			377.246f,
+			303.75f,
+			377.246f,
+			303.75f,
+			393.25f,
+			292.898f,
+			392.25f,
+			289.75f,
+			392.25f,
+			289.75f,
+			388.297f,
+			296.75f,
+			368.246f,
+			295.746f,
+			368.242f,
+			295.742f,
+			347.598f,
+			299.5f,
+			334.246f,
+			271.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			544.246f,
+			411.746f,
+			544.246f,
+			411.742f,
+			494.449f,
+			443.047f,
+			486.25f,
+			444.746f,
+			473.211f,
+			447.297f,
+			540.648f,
+			412.797f,
+			546.246f,
+			400.75f,
+			546.242f,
+			400.75f,
+			548.348f,
+			404,
+			544.246f,
+			411.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			63,
+			378.246f,
+			294.75f,
+			378.246f,
+			294.75f,
+			400.621f,
+			296.637f,
+			408.246f,
+			303.75f,
+			413.246f,
+			299.746f,
+			432.246f,
+			342.75f,
+			436.25f,
+			336.75f,
+			436.25f,
+			336.75f,
+			452.098f,
+			352.957f,
+			451.25f,
+			361.746f,
+			450.34f,
+			370.559f,
+			465.246f,
+			354.746f,
+			465.246f,
+			354.746f,
+			465.246f,
+			354.742f,
+			464.418f,
+			367.918f,
+			472.25f,
+			360.75f,
+			472.25f,
+			360.75f,
+			469.699f,
+			377.598f,
+			479.25f,
+			368.746f,
+			479.25f,
+			368.746f,
+			467.348f,
+			401.969f,
+			492.25f,
+			373.75f,
+			498.301f,
+			366.598f,
+			493.246f,
+			373.75f,
+			493.246f,
+			373.75f,
+			493.242f,
+			373.75f,
+			464.859f,
+			426.879f,
+			488.25f,
+			410.75f,
+			488.25f,
+			410.75f,
+			490.82f,
+			436.117f,
+			489.246f,
+			440.746f,
+			488.18f,
+			445.797f,
+			485.98f,
+			470.438f,
+			480.246f,
+			475.746f,
+			475.418f,
+			481.879f,
+			481.141f,
+			483.637f,
+			487.246f,
+			477.746f,
+			487.246f,
+			477.742f,
+			474.98f,
+			504.316f,
+			489.246f,
+			490.75f,
+			489.246f,
+			490.75f,
+			485.539f,
+			507.84f,
+			480.246f,
+			510.746f,
+			480.242f,
+			510.742f,
+			474.539f,
+			529.84f,
+			491.246f,
+			517.746f,
+			491.242f,
+			517.742f,
+			486.418f,
+			531.598f,
+			483.25f,
+			534.75f,
+			483.25f,
+			534.75f,
+			470.141f,
+			565.477f,
+			478.246f,
+			559.746f,
+			483.25f,
+			555.75f,
+			483.25f,
+			555.75f,
+			475.418f,
+			571.637f,
+			482.246f,
+			566.75f,
+			489.5f,
+			561.957f,
+			489.246f,
+			562.75f,
+			489.246f,
+			562.75f,
+			489.246f,
+			562.75f,
+			466.18f,
+			598.918f,
+			488.25f,
+			579.746f,
+			488.25f,
+			579.746f,
+			479.645f,
+			594.867f,
+			476.246f,
+			602.75f,
+			476.246f,
+			602.75f,
+			455.18f,
+			624.879f,
+			471.246f,
+			617.75f,
+			476.246f,
+			615.75f,
+			476.246f,
+			615.75f,
+			466.621f,
+			627.078f,
+			458.246f,
+			628.75f,
+			449.02f,
+			630.598f,
+			460.461f,
+			637.637f,
+			467.246f,
+			635.75f,
+			474.539f,
+			633.238f,
+			491.246f,
+			624.75f,
+			491.246f,
+			624.75f,
+			491.242f,
+			624.75f,
+			505.777f,
+			604.199f,
+			510.25f,
+			603.746f,
+			510.25f,
+			603.746f,
+			488.18f,
+			612.117f,
+			495.246f,
+			603.746f,
+			495.242f,
+			603.746f,
+			510.621f,
+			587.918f,
+			502.246f,
+			588.75f,
+			502.242f,
+			588.75f,
+			496.098f,
+			580.438f,
+			501.25f,
+			570.746f,
+			501.25f,
+			570.746f,
+			481.074f,
+			590.988f,
+			497.25f,
+			562.75f,
+			505.25f,
+			544.746f,
+			505.25f,
+			544.746f,
+			478.059f,
+			572.078f,
+			490.25f,
+			547.75f,
+			490.25f,
+			547.75f,
+			509.301f,
+			521.918f,
+			511.246f,
+			521.746f,
+			513.699f,
+			521.039f,
+			518.25f,
+			511.746f,
+			518.25f,
+			511.746f,
+			513.246f,
+			513.746f,
+			519.25f,
+			503.75f,
+			519.25f,
+			503.75f,
+			507.098f,
+			517.078f,
+			513.246f,
+			502.746f,
+			520.246f,
+			486.746f,
+			520.246f,
+			486.742f,
+			497.418f,
+			510.918f,
+			512.25f,
+			478.746f,
+			512.25f,
+			478.746f,
+			494.34f,
+			484.078f,
+			504.246f,
+			464.746f,
+			504.242f,
+			464.742f,
+			502.258f,
+			447.559f,
+			502.246f,
+			441.75f,
+			503.141f,
+			436.117f,
+			504.461f,
+			404.879f,
+			499.25f,
+			395.75f,
+			494.777f,
+			387.277f,
+			506.219f,
+			366.156f,
+			508.25f,
+			361.746f,
+			510.621f,
+			357.355f,
+			514.578f,
+			345.477f,
+			505.25f,
+			355.75f,
+			495.219f,
+			365.719f,
+			500.059f,
+			359.559f,
+			502.246f,
+			349.75f,
+			504.461f,
+			340.195f,
+			511.059f,
+			323.035f,
+			510.25f,
+			316.75f,
+			510.25f,
+			316.75f,
+			508.859f,
+			315.559f,
+			505.25f,
+			319.746f,
+			505.25f,
+			319.742f,
+			489.059f,
+			344.598f,
+			491.246f,
+			328.746f,
+			491.242f,
+			328.742f,
+			489.5f,
+			319.957f,
+			486.25f,
+			310.746f,
+			486.25f,
+			310.742f,
+			482.461f,
+			298.398f,
+			482.246f,
+			307.75f,
+			482.242f,
+			307.75f,
+			478.938f,
+			326.559f,
+			476.246f,
+			317.746f,
+			472.777f,
+			309.836f,
+			468.82f,
+			303.238f,
+			465.246f,
+			300.75f,
+			462.66f,
+			297.957f,
+			456.938f,
+			323.035f,
+			455.25f,
+			311.75f,
+			455.25f,
+			311.75f,
+			442.418f,
+			325.238f,
+			437.25f,
+			306.746f,
+			424.246f,
+			288.746f,
+			424.242f,
+			288.742f,
+			423.938f,
+			302.797f,
+			422.246f,
+			295.746f,
+			422.246f,
+			295.742f,
+			389.621f,
+			289.598f,
+			378.246f,
+			294.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			34,
+			340.25f,
+			686.746f,
+			340.25f,
+			686.742f,
+			327.578f,
+			695.719f,
+			323.246f,
+			695.746f,
+			318.777f,
+			694.84f,
+			353.539f,
+			704.957f,
+			399.246f,
+			674.75f,
+			399.246f,
+			674.75f,
+			404.141f,
+			671.52f,
+			408.246f,
+			671.746f,
+			408.246f,
+			671.742f,
+			411.621f,
+			669.316f,
+			408.246f,
+			665.75f,
+			408.246f,
+			665.75f,
+			398.859f,
+			654.797f,
+			411.246f,
+			642.746f,
+			411.246f,
+			642.742f,
+			431.418f,
+			635,
+			425.25f,
+			644.75f,
+			425.25f,
+			644.75f,
+			437.141f,
+			640.277f,
+			440.25f,
+			635.75f,
+			442.418f,
+			631.477f,
+			441.246f,
+			635.75f,
+			441.246f,
+			635.75f,
+			441.246f,
+			635.75f,
+			434.059f,
+			643.797f,
+			427.25f,
+			649.746f,
+			427.25f,
+			649.742f,
+			421.738f,
+			651.719f,
+			418.25f,
+			660.746f,
+			415.578f,
+			670.199f,
+			412.938f,
+			681.199f,
+			418.25f,
+			684.746f,
+			418.25f,
+			684.742f,
+			413.379f,
+			679.879f,
+			414.25f,
+			684.746f,
+			415.141f,
+			688.68f,
+			419.098f,
+			692.637f,
+			421.246f,
+			692.75f,
+			422.621f,
+			693.52f,
+			440.66f,
+			710.898f,
+			448.25f,
+			711.746f,
+			448.25f,
+			711.746f,
+			438.02f,
+			709.797f,
+			434.246f,
+			710.746f,
+			431.418f,
+			712,
+			402.16f,
+			724.539f,
+			395.25f,
+			725.75f,
+			395.25f,
+			725.75f,
+			377.078f,
+			733.117f,
+			390.246f,
+			730.746f,
+			390.242f,
+			730.742f,
+			429.66f,
+			726.738f,
+			449.25f,
+			711.746f,
+			449.25f,
+			711.746f,
+			441.758f,
+			721.457f,
+			421.246f,
+			728.746f,
+			421.246f,
+			728.742f,
+			397.098f,
+			743.02f,
+			358.25f,
+			737.746f,
+			358.25f,
+			737.742f,
+			338.801f,
+			734,
+			330.25f,
+			731.75f,
+			330.25f,
+			731.75f,
+			327.359f,
+			732.68f,
+			326.25f,
+			732.746f,
+			326.039f,
+			733.559f,
+			313.059f,
+			743.457f,
+			282.25f,
+			735.746f,
+			282.25f,
+			735.746f,
+			264,
+			730.699f,
+			254.246f,
+			725.75f,
+			254.246f,
+			725.75f,
+			237.816f,
+			724.098f,
+			234.246f,
+			720.75f,
+			234.246f,
+			720.75f,
+			213.398f,
+			704.52f,
+			211.246f,
+			703.75f,
+			209,
+			702.758f,
+			196.457f,
+			694.398f,
+			195.25f,
+			693.746f,
+			195.25f,
+			693.742f,
+			222.637f,
+			701.219f,
+			225.25f,
+			703.75f,
+			227.918f,
+			706.5f,
+			247.059f,
+			709.359f,
+			249.25f,
+			707.75f,
+			252.34f,
+			706.277f,
+			261.578f,
+			706.938f,
+			251.25f,
+			706.746f,
+			251.25f,
+			706.742f,
+			334.18f,
+			690,
+			335.246f,
+			687.75f,
+			335.938f,
+			685.598f,
+			340.25f,
+			686.746f,
+			340.25f,
+			686.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			13,
+			419.246f,
+			696.75f,
+			419.246f,
+			696.75f,
+			407.66f,
+			705.18f,
+			405.25f,
+			704.746f,
+			403.258f,
+			705.18f,
+			389.621f,
+			716.398f,
+			385.25f,
+			715.746f,
+			380.379f,
+			715.52f,
+			366.961f,
+			726.52f,
+			337.25f,
+			717.746f,
+			337.25f,
+			717.742f,
+			336.16f,
+			719.699f,
+			340.25f,
+			720.75f,
+			340.25f,
+			720.75f,
+			347.16f,
+			723,
+			347.25f,
+			723.75f,
+			347.25f,
+			723.75f,
+			369.82f,
+			728.277f,
+			377.246f,
+			724.746f,
+			377.246f,
+			724.746f,
+			387.859f,
+			721.457f,
+			394.25f,
+			714.75f,
+			394.25f,
+			714.75f,
+			407,
+			711.117f,
+			410.246f,
+			711.746f,
+			410.246f,
+			711.746f,
+			420.199f,
+			709.797f,
+			420.246f,
+			707.75f,
+			420.246f,
+			707.75f,
+			427.02f,
+			704.52f,
+			425.25f,
+			701.75f,
+			425.25f,
+			701.75f,
+			425.48f,
+			699.898f,
+			419.246f,
+			696.75f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			38,
+			405.25f,
+			699.746f,
+			406.047f,
+			698.664f,
+			407.168f,
+			698.555f,
+			408.246f,
+			697.746f,
+			408.094f,
+			697.32f,
+			407.773f,
+			696.961f,
+			407.25f,
+			696.75f,
+			406.281f,
+			696.504f,
+			405.121f,
+			697.133f,
+			404.25f,
+			696.75f,
+			403.422f,
+			696.258f,
+			402.715f,
+			696.457f,
+			402.246f,
+			696.75f,
+			400.313f,
+			697.105f,
+			398.301f,
+			697.137f,
+			396.25f,
+			696.75f,
+			394.254f,
+			697.621f,
+			391.66f,
+			696.977f,
+			389.246f,
+			697.746f,
+			389.309f,
+			698.109f,
+			389.063f,
+			697.727f,
+			389.246f,
+			697.746f,
+			385.629f,
+			699.016f,
+			381.512f,
+			698.707f,
+			379.246f,
+			700.746f,
+			376.168f,
+			701.672f,
+			373.574f,
+			702.18f,
+			371.25f,
+			702.746f,
+			368.906f,
+			703.488f,
+			367.355f,
+			704.574f,
+			365.246f,
+			705.75f,
+			364.059f,
+			706.27f,
+			362.457f,
+			706.844f,
+			361.25f,
+			707.75f,
+			358.719f,
+			707.75f,
+			356.703f,
+			707.625f,
+			354.246f,
+			707.75f,
+			354.52f,
+			708.227f,
+			354.309f,
+			707.848f,
+			354.246f,
+			707.75f,
+			353.863f,
+			707.996f,
+			353.543f,
+			708.637f,
+			353.246f,
+			708.746f,
+			351.508f,
+			708.004f,
+			349.871f,
+			709.074f,
+			348.25f,
+			708.746f,
+			346.742f,
+			710.043f,
+			344.844f,
+			709.773f,
+			343.246f,
+			710.746f,
+			339.883f,
+			711.195f,
+			336.414f,
+			709.797f,
+			333.246f,
+			710.746f,
+			337.602f,
+			712.926f,
+			342.758f,
+			711.57f,
+			347.25f,
+			713.746f,
+			349.789f,
+			715.148f,
+			352.715f,
+			713.938f,
+			355.246f,
+			714.75f,
+			356.078f,
+			714.934f,
+			356.84f,
+			715.152f,
+			357.246f,
+			714.75f,
+			357.426f,
+			714.566f,
+			357.625f,
+			714.828f,
+			357.246f,
+			714.75f,
+			360.387f,
+			713.527f,
+			362.934f,
+			712.125f,
+			365.246f,
+			710.746f,
+			366.039f,
+			710.793f,
+			366.621f,
+			711.047f,
+			367.246f,
+			710.746f,
+			368.57f,
+			709.488f,
+			370.711f,
+			709.602f,
+			372.25f,
+			708.746f,
+			374.105f,
+			708.809f,
+			376.078f,
+			708.391f,
+			378.246f,
+			708.746f,
+			378.066f,
+			709.109f,
+			378.324f,
+			708.734f,
+			378.246f,
+			708.746f,
+			379.602f,
+			709.582f,
+			380.875f,
+			709.281f,
+			382.25f,
+			708.746f,
+			382.227f,
+			708.82f,
+			382.957f,
+			708.551f,
+			383.25f,
+			708.746f,
+			384.531f,
+			708.164f,
+			385.473f,
+			707.637f,
+			387.246f,
+			707.75f,
+			386.895f,
+			707.414f,
+			387.098f,
+			707.789f,
+			387.246f,
+			707.75f,
+			388.41f,
+			707.277f,
+			389.559f,
+			707.34f,
+			390.246f,
+			705.75f,
+			390.426f,
+			706.207f,
+			390.609f,
+			706.469f,
+			390.246f,
+			706.746f,
+			391.828f,
+			706.066f,
+			392.543f,
+			705.238f,
+			394.25f,
+			704.746f,
+			394.289f,
+			704.855f,
+			394.961f,
+			704.168f,
+			395.25f,
+			703.75f,
+			398.227f,
+			703.168f,
+			400.254f,
+			701.488f,
+			402.246f,
+			700.746f,
+			403.5f,
+			700.16f,
+			404.465f,
+			699.902f,
+			405.25f,
+			699.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			23,
+			321.246f,
+			714.75f,
+			318.094f,
+			716.91f,
+			315.488f,
+			718.125f,
+			313.246f,
+			719.746f,
+			312.605f,
+			720.234f,
+			312.207f,
+			720.051f,
+			312.246f,
+			719.746f,
+			310.879f,
+			720.852f,
+			309.902f,
+			721.492f,
+			309.246f,
+			722.746f,
+			308.227f,
+			722.68f,
+			307.324f,
+			722.664f,
+			307.25f,
+			722.746f,
+			303.969f,
+			724.371f,
+			301.074f,
+			724.984f,
+			298.246f,
+			726.746f,
+			299.066f,
+			727,
+			300.301f,
+			726.73f,
+			301.246f,
+			727.75f,
+			301.172f,
+			727.309f,
+			301.434f,
+			726.996f,
+			302.246f,
+			726.746f,
+			303.668f,
+			728.203f,
+			305.703f,
+			728.371f,
+			307.25f,
+			728.746f,
+			309.422f,
+			728.172f,
+			311.313f,
+			727.836f,
+			313.246f,
+			727.75f,
+			313.605f,
+			727.484f,
+			313.824f,
+			726.91f,
+			314.25f,
+			726.746f,
+			316.629f,
+			726.074f,
+			319.258f,
+			726.648f,
+			321.246f,
+			725.75f,
+			323.336f,
+			725.035f,
+			325.066f,
+			724.133f,
+			326.25f,
+			722.746f,
+			326.703f,
+			722.441f,
+			326.348f,
+			722.113f,
+			326.25f,
+			721.746f,
+			326.465f,
+			722.02f,
+			326.766f,
+			721.793f,
+			327.25f,
+			721.746f,
+			326.98f,
+			721.184f,
+			326.98f,
+			720.852f,
+			327.25f,
+			720.75f,
+			326.766f,
+			720.246f,
+			326.457f,
+			720.133f,
+			326.25f,
+			719.746f,
+			324.5f,
+			719.871f,
+			326.449f,
+			721.387f,
+			325.25f,
+			720.75f,
+			324.277f,
+			720,
+			325.098f,
+			718.453f,
+			324.246f,
+			716.75f,
+			323.973f,
+			717.27f,
+			323.719f,
+			717.512f,
+			324.246f,
+			717.746f,
+			324.098f,
+			717.363f,
+			323.434f,
+			717.043f,
+			323.246f,
+			716.75f,
+			322.824f,
+			715.898f,
+			321.836f,
+			714.344f,
+			321.246f,
+			714.75f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			25,
+			285.25f,
+			706.746f,
+			281.645f,
+			707.801f,
+			278.293f,
+			707.676f,
+			275.246f,
+			708.746f,
+			274.898f,
+			709.109f,
+			274.656f,
+			708.727f,
+			274.25f,
+			708.746f,
+			273.082f,
+			709.41f,
+			272.07f,
+			710.473f,
+			271.25f,
+			711.746f,
+			269.883f,
+			712.602f,
+			268.059f,
+			712.176f,
+			266.246f,
+			712.75f,
+			266.301f,
+			712.848f,
+			266.078f,
+			713.41f,
+			266.246f,
+			713.746f,
+			264.406f,
+			713.625f,
+			263.387f,
+			714.672f,
+			262.25f,
+			715.746f,
+			264.809f,
+			716.172f,
+			267.461f,
+			716.137f,
+			270.25f,
+			716.75f,
+			270.293f,
+			716.582f,
+			270.453f,
+			716.227f,
+			270.25f,
+			715.746f,
+			270.746f,
+			716.227f,
+			270.891f,
+			716.469f,
+			271.25f,
+			716.75f,
+			271.254f,
+			716.309f,
+			271.586f,
+			715.953f,
+			272.25f,
+			715.746f,
+			272.469f,
+			716.824f,
+			273.082f,
+			716.617f,
+			273.25f,
+			716.75f,
+			273.836f,
+			716.563f,
+			273.973f,
+			716.227f,
+			274.25f,
+			715.746f,
+			274.27f,
+			716.227f,
+			274.41f,
+			716.57f,
+			274.25f,
+			716.75f,
+			274.707f,
+			716.57f,
+			274.852f,
+			716.227f,
+			275.246f,
+			715.746f,
+			275.148f,
+			716.227f,
+			275.289f,
+			716.469f,
+			275.246f,
+			716.75f,
+			276.199f,
+			715.758f,
+			277.172f,
+			716.367f,
+			278.246f,
+			715.746f,
+			279.219f,
+			715.922f,
+			279.512f,
+			714.656f,
+			280.246f,
+			714.75f,
+			285.879f,
+			712.895f,
+			290.43f,
+			710.535f,
+			295.25f,
+			707.75f,
+			295.566f,
+			708.078f,
+			295.801f,
+			707.805f,
+			295.25f,
+			707.75f,
+			295.973f,
+			707.379f,
+			296.316f,
+			707.477f,
+			296.25f,
+			707.75f,
+			297.688f,
+			706.523f,
+			298.832f,
+			705.922f,
+			299.246f,
+			704.746f,
+			299.84f,
+			704.34f,
+			299.477f,
+			703.895f,
+			299.246f,
+			703.75f,
+			294.348f,
+			705.047f,
+			289.941f,
+			705.715f,
+			285.25f,
+			706.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			10,
+			270.25f,
+			658.746f,
+			268.117f,
+			659.637f,
+			267.477f,
+			661.871f,
+			266.246f,
+			663.75f,
+			266,
+			664.215f,
+			266.301f,
+			664.563f,
+			266.246f,
+			664.746f,
+			267.266f,
+			664.832f,
+			267.863f,
+			664.309f,
+			268.246f,
+			663.75f,
+			270.234f,
+			663.137f,
+			271.922f,
+			661.77f,
+			274.25f,
+			661.75f,
+			276.309f,
+			659.16f,
+			280.992f,
+			658.738f,
+			281.25f,
+			654.75f,
+			281,
+			654.074f,
+			279.43f,
+			655.082f,
+			279.246f,
+			653.746f,
+			276.262f,
+			655.242f,
+			273.633f,
+			655.129f,
+			271.25f,
+			656.746f,
+			270.336f,
+			657.16f,
+			270.699f,
+			657.66f,
+			270.25f,
+			658.746f,
+			10,
+			0,
+			0.8f,
+			0.45f,
+			0.15f,
+			0.8f,
+			0.45f,
+			0.15f,
+			6,
+			239.25f,
+			715.746f,
+			239.727f,
+			716.129f,
+			247.461f,
+			715.871f,
+			247.246f,
+			715.746f,
+			247.391f,
+			715.406f,
+			238.891f,
+			714.254f,
+			238.25f,
+			714.75f,
+			238.309f,
+			714.523f,
+			230.047f,
+			711.852f,
+			230.25f,
+			711.746f,
+			230.191f,
+			712.148f,
+			239.285f,
+			716.129f,
+			239.25f,
+			715.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			80,
+			256.246f,
+			705.75f,
+			256.246f,
+			705.75f,
+			240.238f,
+			703.418f,
+			235.246f,
+			701.75f,
+			230.559f,
+			700.777f,
+			210.098f,
+			692.418f,
+			207.25f,
+			689.746f,
+			207.25f,
+			689.746f,
+			192.059f,
+			684.277f,
+			173.25f,
+			662.746f,
+			173.25f,
+			662.742f,
+			181.719f,
+			666.02f,
+			184.25f,
+			668.75f,
+			184.25f,
+			668.75f,
+			199.098f,
+			682.957f,
+			199.246f,
+			679.75f,
+			199.246f,
+			679.75f,
+			212.297f,
+			689.559f,
+			211.246f,
+			686.746f,
+			211.246f,
+			686.742f,
+			238.477f,
+			699.457f,
+			236.25f,
+			695.746f,
+			236.25f,
+			695.742f,
+			260.039f,
+			701,
+			259.25f,
+			698.75f,
+			259.25f,
+			698.75f,
+			279.617f,
+			693.957f,
+			276.246f,
+			693.746f,
+			276.246f,
+			693.742f,
+			270.156f,
+			692.418f,
+			277.246f,
+			688.746f,
+			277.246f,
+			688.742f,
+			273.457f,
+			683.617f,
+			267.246f,
+			687.75f,
+			261.578f,
+			692.418f,
+			264.879f,
+			690,
+			259.25f,
+			688.746f,
+			259.25f,
+			688.742f,
+			256.52f,
+			688.02f,
+			251.25f,
+			692.75f,
+			251.25f,
+			692.75f,
+			245.297f,
+			697.477f,
+			235.246f,
+			693.746f,
+			235.242f,
+			693.742f,
+			201.957f,
+			679.656f,
+			200.246f,
+			678.746f,
+			200.246f,
+			678.746f,
+			195.797f,
+			675.918f,
+			193.25f,
+			671.746f,
+			193.25f,
+			671.742f,
+			186.777f,
+			667.117f,
+			183.25f,
+			665.75f,
+			183.25f,
+			665.75f,
+			169.398f,
+			652.816f,
+			168.25f,
+			651.746f,
+			168.25f,
+			651.742f,
+			164.34f,
+			645.559f,
+			163.25f,
+			644.75f,
+			163.25f,
+			644.75f,
+			170.5f,
+			649.297f,
+			172.25f,
+			651.746f,
+			172.25f,
+			651.742f,
+			188.098f,
+			662.5f,
+			194.25f,
+			663.75f,
+			194.25f,
+			663.75f,
+			198.879f,
+			666.68f,
+			200.246f,
+			667.746f,
+			200.246f,
+			667.746f,
+			215.598f,
+			678.34f,
+			220.246f,
+			678.746f,
+			220.246f,
+			678.746f,
+			230.34f,
+			672.617f,
+			233.246f,
+			680.746f,
+			233.246f,
+			680.746f,
+			239.359f,
+			682.297f,
+			245.246f,
+			680.746f,
+			245.246f,
+			680.746f,
+			249.039f,
+			683.84f,
+			248.25f,
+			686.746f,
+			248.25f,
+			686.742f,
+			249.918f,
+			688.238f,
+			251.25f,
+			683.75f,
+			251.25f,
+			683.75f,
+			254.758f,
+			680.098f,
+			260.25f,
+			682.746f,
+			260.25f,
+			682.742f,
+			264.437f,
+			682.52f,
+			262.25f,
+			679.75f,
+			262.25f,
+			679.75f,
+			257.398f,
+			675.699f,
+			244.246f,
+			675.746f,
+			244.246f,
+			675.742f,
+			230.777f,
+			674.816f,
+			212.246f,
+			666.75f,
+			212.246f,
+			666.75f,
+			179.957f,
+			655.02f,
+			170.246f,
+			643.75f,
+			170.242f,
+			643.75f,
+			162.797f,
+			633.898f,
+			157.25f,
+			632.75f,
+			157.25f,
+			632.75f,
+			150.477f,
+			631.699f,
+			144.246f,
+			623.746f,
+			144.246f,
+			623.746f,
+			154.656f,
+			629.938f,
+			164.246f,
+			629.746f,
+			164.242f,
+			629.742f,
+			168.957f,
+			632.578f,
+			165.246f,
+			628.75f,
+			165.242f,
+			628.75f,
+			160.816f,
+			620.258f,
+			162.25f,
+			614.746f,
+			162.25f,
+			614.746f,
+			161.918f,
+			608.598f,
+			161.246f,
+			606.75f,
+			161.246f,
+			606.75f,
+			152.457f,
+			592.758f,
+			152.25f,
+			589.75f,
+			152.457f,
+			587.477f,
+			153.777f,
+			576.699f,
+			154.246f,
+			575.75f,
+			154.656f,
+			575.379f,
+			153.117f,
+			577.797f,
+			157.25f,
+			574.746f,
+			161.477f,
+			572.52f,
+			164.559f,
+			570.758f,
+			165.246f,
+			567.75f,
+			166.316f,
+			564.598f,
+			163.238f,
+			573.617f,
+			163.25f,
+			575.75f,
+			162.797f,
+			577.578f,
+			158.18f,
+			585.5f,
+			159.246f,
+			587.746f,
+			159.242f,
+			587.742f,
+			160.156f,
+			587.039f,
+			161.246f,
+			585.746f,
+			161.246f,
+			585.742f,
+			160.379f,
+			586.156f,
+			161.246f,
+			589.75f,
+			161.246f,
+			589.75f,
+			161.918f,
+			595.84f,
+			163.25f,
+			599.75f,
+			165,
+			602.879f,
+			167.199f,
+			607.059f,
+			167.25f,
+			607.746f,
+			168.078f,
+			608.816f,
+			168.078f,
+			615.199f,
+			169.25f,
+			612.746f,
+			173.25f,
+			609.746f,
+			173.25f,
+			609.742f,
+			170.277f,
+			612.34f,
+			172.25f,
+			614.746f,
+			172.25f,
+			614.746f,
+			171.598f,
+			620.918f,
+			173.25f,
+			623.746f,
+			173.25f,
+			623.746f,
+			181.277f,
+			633.02f,
+			183.25f,
+			633.75f,
+			184.797f,
+			635.219f,
+			183.25f,
+			634.746f,
+			183.25f,
+			634.746f,
+			183.25f,
+			634.746f,
+			189.859f,
+			639.398f,
+			183.25f,
+			637.75f,
+			183.25f,
+			637.75f,
+			179.078f,
+			635.879f,
+			176.246f,
+			635.75f,
+			176.246f,
+			635.75f,
+			167.418f,
+			633.68f,
+			172.25f,
+			638.746f,
+			176.219f,
+			642.918f,
+			187.219f,
+			648.859f,
+			191.246f,
+			648.75f,
+			192.25f,
+			646.75f,
+			204.25f,
+			649.746f,
+			203.25f,
+			648.75f,
+			203.25f,
+			648.75f,
+			203.059f,
+			648.859f,
+			207.25f,
+			649.746f,
+			212.297f,
+			649.738f,
+			218.68f,
+			648.199f,
+			220.246f,
+			649.746f,
+			221.758f,
+			652.156f,
+			225.5f,
+			653.258f,
+			225.25f,
+			651.746f,
+			224.617f,
+			650.18f,
+			224.246f,
+			647.746f,
+			224.246f,
+			647.746f,
+			224.242f,
+			647.746f,
+			229.898f,
+			654.359f,
+			229.25f,
+			651.746f,
+			228.578f,
+			649.52f,
+			219.559f,
+			643.797f,
+			218.25f,
+			636.746f,
+			229.25f,
+			645.746f,
+			233.246f,
+			649.746f,
+			233.246f,
+			649.742f,
+			237.379f,
+			646.879f,
+			237.25f,
+			648.75f,
+			237.816f,
+			650.398f,
+			242.879f,
+			656.777f,
+			244.246f,
+			656.746f,
+			245.52f,
+			656.34f,
+			247.719f,
+			659.418f,
+			247.246f,
+			656.746f,
+			247.277f,
+			653.699f,
+			255.246f,
+			647.746f,
+			255.246f,
+			647.746f,
+			255.246f,
+			647.746f,
+			259.156f,
+			649.738f,
+			260.25f,
+			647.746f,
+			262.238f,
+			646.656f,
+			267.246f,
+			669.746f,
+			267.246f,
+			669.746f,
+			294.25f,
+			681.75f,
+			342.246f,
+			685.75f,
+			323.246f,
+			692.75f,
+			256.246f,
+			705.75f,
+			10,
+			2.2f,
+			0.3f,
+			0,
+			0,
+			0.3f,
+			0,
+			0,
+			3,
+			276.246f,
+			486.746f,
+			276.246f,
+			486.742f,
+			260.039f,
+			504.977f,
+			251.25f,
+			507.75f,
+			251.25f,
+			507.75f,
+			236.059f,
+			515.316f,
+			209.246f,
+			506.746f,
+			10,
+			2.2f,
+			0.3f,
+			0,
+			0,
+			0.3f,
+			0,
+			0,
+			3,
+			247.246f,
+			509.75f,
+			247.242f,
+			509.75f,
+			219.559f,
+			518.18f,
+			202.246f,
+			513.746f,
+			202.242f,
+			513.746f,
+			182.379f,
+			511.359f,
+			173.25f,
+			495.746f,
+			10,
+			2.2f,
+			0.3f,
+			0,
+			0,
+			0.3f,
+			0,
+			0,
+			4,
+			243.246f,
+			510.746f,
+			243.246f,
+			510.742f,
+			224.617f,
+			518.617f,
+			208.25f,
+			520.75f,
+			208.25f,
+			520.75f,
+			190.078f,
+			523.898f,
+			172.25f,
+			515.746f,
+			172.25f,
+			515.742f,
+			158.398f,
+			509.379f,
+			152.25f,
+			497.746f,
+			10,
+			2.2f,
+			0.3f,
+			0,
+			0,
+			0.3f,
+			0,
+			0,
+			4,
+			244.246f,
+			510.746f,
+			244.246f,
+			510.742f,
+			227.477f,
+			522.359f,
+			226.25f,
+			523.75f,
+			226.25f,
+			523.75f,
+			218.68f,
+			536,
+			204.25f,
+			536.75f,
+			204.25f,
+			536.75f,
+			180.84f,
+			535.559f,
+			162.25f,
+			526.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			169,
+			243.246f,
+			519.746f,
+			244.68f,
+			518.543f,
+			274.25f,
+			486.746f,
+			274.25f,
+			486.746f,
+			313.059f,
+			446.457f,
+			282.25f,
+			483.75f,
+			282.25f,
+			483.75f,
+			273.898f,
+			489.359f,
+			264.246f,
+			509.75f,
+			264.246f,
+			509.75f,
+			262.457f,
+			513.117f,
+			279.246f,
+			501.75f,
+			279.246f,
+			501.75f,
+			283.578f,
+			501.238f,
+			298.246f,
+			479.75f,
+			298.246f,
+			479.75f,
+			291.059f,
+			482.758f,
+			296.25f,
+			474.75f,
+			296.25f,
+			474.75f,
+			299.418f,
+			472.637f,
+			322.246f,
+			455.746f,
+			322.246f,
+			455.746f,
+			325.82f,
+			451.078f,
+			330.25f,
+			449.746f,
+			330.25f,
+			449.746f,
+			345.621f,
+			455.035f,
+			338.25f,
+			440.746f,
+			338.25f,
+			440.746f,
+			341.219f,
+			433.035f,
+			347.25f,
+			445.746f,
+			347.25f,
+			445.746f,
+			359.699f,
+			464.277f,
+			341.25f,
+			461.75f,
+			341.25f,
+			461.75f,
+			308.656f,
+			458.559f,
+			301.246f,
+			475.746f,
+			301.246f,
+			475.746f,
+			298.539f,
+			478.797f,
+			308.246f,
+			475.746f,
+			308.246f,
+			475.746f,
+			317.461f,
+			473.957f,
+			300.246f,
+			489.746f,
+			300.246f,
+			489.746f,
+			302.937f,
+			489.797f,
+			313.246f,
+			482.746f,
+			313.246f,
+			482.746f,
+			324.5f,
+			472.199f,
+			326.25f,
+			474.75f,
+			326.25f,
+			474.75f,
+			346.5f,
+			484.078f,
+			358.25f,
+			475.746f,
+			358.25f,
+			475.746f,
+			360.141f,
+			473.957f,
+			353.98f,
+			466.477f,
+			355.246f,
+			460.746f,
+			357.5f,
+			455.035f,
+			363.25f,
+			441.75f,
+			363.25f,
+			441.75f,
+			360.141f,
+			439.637f,
+			360.25f,
+			427.746f,
+			360.25f,
+			427.746f,
+			379.059f,
+			402.238f,
+			368.246f,
+			404.75f,
+			368.246f,
+			404.75f,
+			351.34f,
+			404.879f,
+			367.246f,
+			396.746f,
+			367.246f,
+			396.746f,
+			371.141f,
+			394.316f,
+			381.25f,
+			386.75f,
+			381.25f,
+			386.75f,
+			377.738f,
+			387.719f,
+			376.246f,
+			381.746f,
+			376.246f,
+			381.746f,
+			381.258f,
+			377.598f,
+			378.246f,
+			372.746f,
+			378.246f,
+			372.746f,
+			371.578f,
+			370.996f,
+			370.25f,
+			366.75f,
+			370.25f,
+			366.75f,
+			377.738f,
+			357.797f,
+			366.246f,
+			357.746f,
+			366.246f,
+			357.746f,
+			370.699f,
+			352.516f,
+			365.246f,
+			339.746f,
+			365.246f,
+			339.746f,
+			360.141f,
+			339.316f,
+			353.246f,
+			332.746f,
+			353.246f,
+			332.746f,
+			355.738f,
+			327.879f,
+			344.246f,
+			321.746f,
+			344.246f,
+			321.746f,
+			335.059f,
+			319.957f,
+			338.25f,
+			312.75f,
+			338.25f,
+			312.75f,
+			329.34f,
+			305.879f,
+			326.25f,
+			288.746f,
+			326.25f,
+			288.746f,
+			325.82f,
+			276.836f,
+			323.18f,
+			273.316f,
+			329.25f,
+			275.746f,
+			334.621f,
+			277.719f,
+			333.246f,
+			291.746f,
+			333.246f,
+			291.746f,
+			328.461f,
+			308.516f,
+			375.246f,
+			325.75f,
+			375.246f,
+			325.75f,
+			379.938f,
+			327.879f,
+			381.25f,
+			333.75f,
+			381.25f,
+			333.75f,
+			383.02f,
+			333.156f,
+			392.25f,
+			324.746f,
+			392.25f,
+			324.746f,
+			401.059f,
+			312.477f,
+			401.246f,
+			322.75f,
+			401.246f,
+			322.75f,
+			402.82f,
+			326.559f,
+			401.246f,
+			332.746f,
+			401.246f,
+			332.746f,
+			407.66f,
+			356.918f,
+			392.25f,
+			363.746f,
+			392.25f,
+			363.746f,
+			381.258f,
+			400.918f,
+			396.25f,
+			391.75f,
+			396.25f,
+			391.75f,
+			399.738f,
+			385.516f,
+			411.246f,
+			379.746f,
+			411.246f,
+			379.746f,
+			415.25f,
+			382.75f,
+			413.82f,
+			387.719f,
+			423.246f,
+			394.746f,
+			423.246f,
+			394.746f,
+			426.141f,
+			387.277f,
+			432.246f,
+			395.75f,
+			432.246f,
+			395.75f,
+			436.699f,
+			422.918f,
+			450.25f,
+			406.75f,
+			450.25f,
+			406.75f,
+			454.738f,
+			405.758f,
+			456.246f,
+			412.746f,
+			456.246f,
+			412.746f,
+			460.02f,
+			424.676f,
+			456.246f,
+			439.75f,
+			456.246f,
+			439.75f,
+			460.02f,
+			440.078f,
+			470.25f,
+			433.746f,
+			470.25f,
+			433.746f,
+			473.66f,
+			437.438f,
+			463.539f,
+			455.918f,
+			468.25f,
+			453.746f,
+			472.34f,
+			450.637f,
+			477.25f,
+			448.75f,
+			477.25f,
+			448.75f,
+			478.059f,
+			451.078f,
+			467.246f,
+			464.746f,
+			467.246f,
+			464.746f,
+			462.219f,
+			467.797f,
+			456.246f,
+			489.746f,
+			456.246f,
+			489.746f,
+			464.418f,
+			486.277f,
+			453.25f,
+			502.746f,
+			453.25f,
+			502.746f,
+			453.418f,
+			506.52f,
+			460.246f,
+			518.75f,
+			460.246f,
+			518.75f,
+			459.141f,
+			526.316f,
+			460.246f,
+			525.75f,
+			460.246f,
+			525.75f,
+			463.098f,
+			524.559f,
+			471.898f,
+			522.797f,
+			464.25f,
+			529.75f,
+			456.938f,
+			536.879f,
+			465.246f,
+			541.746f,
+			465.246f,
+			541.746f,
+			470.141f,
+			545.238f,
+			455.25f,
+			544.746f,
+			455.25f,
+			544.746f,
+			449.461f,
+			549.637f,
+			450.25f,
+			553.75f,
+			450.25f,
+			553.75f,
+			458.699f,
+			551.84f,
+			442.859f,
+			567.68f,
+			440.25f,
+			571.75f,
+			437.578f,
+			575.598f,
+			448.25f,
+			581.746f,
+			448.25f,
+			581.746f,
+			462.66f,
+			585.277f,
+			450.25f,
+			588.75f,
+			450.25f,
+			588.75f,
+			428.34f,
+			588.359f,
+			440.25f,
+			599.75f,
+			440.25f,
+			599.75f,
+			446.82f,
+			599.797f,
+			445.246f,
+			602.75f,
+			445.246f,
+			602.75f,
+			439.34f,
+			603.758f,
+			429.25f,
+			610.75f,
+			429.25f,
+			610.75f,
+			424.379f,
+			614.758f,
+			428.25f,
+			613.75f,
+			428.25f,
+			613.75f,
+			446.82f,
+			612.559f,
+			415.25f,
+			624.75f,
+			415.25f,
+			624.75f,
+			423.938f,
+			624.879f,
+			404.25f,
+			636.746f,
+			404.25f,
+			636.746f,
+			401.938f,
+			638.078f,
+			398.246f,
+			646.75f,
+			398.246f,
+			646.75f,
+			391.82f,
+			652.156f,
+			386.246f,
+			659.75f,
+			386.246f,
+			659.75f,
+			386.098f,
+			664.477f,
+			381.25f,
+			669.746f,
+			381.25f,
+			669.746f,
+			368.059f,
+			684.719f,
+			362.25f,
+			684.746f,
+			362.25f,
+			684.746f,
+			345.621f,
+			688.238f,
+			340.25f,
+			687.75f,
+			340.25f,
+			687.75f,
+			282.25f,
+			682.746f,
+			252.777f,
+			668.438f,
+			261.25f,
+			645.746f,
+			261.25f,
+			645.746f,
+			268.398f,
+			636.098f,
+			278.246f,
+			640.746f,
+			278.246f,
+			640.746f,
+			283.578f,
+			647.098f,
+			296.25f,
+			644.75f,
+			296.25f,
+			644.75f,
+			318.777f,
+			641.156f,
+			316.25f,
+			644.75f,
+			316.25f,
+			644.75f,
+			313.277f,
+			650.18f,
+			295.457f,
+			657,
+			295.25f,
+			657.75f,
+			295.02f,
+			658.316f,
+			285.25f,
+			661.75f,
+			285.25f,
+			661.75f,
+			282.039f,
+			663.379f,
+			277.246f,
+			673.746f,
+			277.246f,
+			673.746f,
+			273.68f,
+			677.238f,
+			291.246f,
+			670.75f,
+			291.246f,
+			670.75f,
+			289.738f,
+			669.758f,
+			298.246f,
+			665.75f,
+			298.246f,
+			665.75f,
+			317.02f,
+			666.457f,
+			328.25f,
+			654.75f,
+			328.25f,
+			654.75f,
+			340.559f,
+			636.316f,
+			341.25f,
+			645.746f,
+			341.25f,
+			645.746f,
+			343.859f,
+			655.68f,
+			331.246f,
+			678.746f,
+			331.246f,
+			678.746f,
+			331.32f,
+			681.199f,
+			340.25f,
+			673.746f,
+			340.25f,
+			673.746f,
+			341.879f,
+			676.137f,
+			343.246f,
+			669.746f,
+			343.246f,
+			669.746f,
+			342.98f,
+			667.117f,
+			347.25f,
+			658.746f,
+			347.25f,
+			658.746f,
+			350.238f,
+			644.02f,
+			354.246f,
+			651.746f,
+			354.246f,
+			651.746f,
+			359.25f,
+			641.75f,
+			360.801f,
+			638.957f,
+			354.246f,
+			630.75f,
+			354.246f,
+			630.75f,
+			353.98f,
+			627.52f,
+			354.859f,
+			627.738f,
+			348.25f,
+			619.75f,
+			342.539f,
+			611.02f,
+			346.246f,
+			605.746f,
+			346.246f,
+			605.746f,
+			344.738f,
+			598.918f,
+			354.246f,
+			599.75f,
+			354.246f,
+			599.75f,
+			357.277f,
+			596.938f,
+			361.25f,
+			596.746f,
+			361.25f,
+			596.746f,
+			363,
+			594.738f,
+			365.246f,
+			595.75f,
+			365.246f,
+			595.75f,
+			367.398f,
+			599.578f,
+			374.25f,
+			597.75f,
+			374.25f,
+			597.75f,
+			375.758f,
+			600.02f,
+			385.25f,
+			600.75f,
+			385.25f,
+			600.75f,
+			385.879f,
+			603.316f,
+			386.32f,
+			605.078f,
+			390.246f,
+			605.746f,
+			393.801f,
+			606.398f,
+			366.246f,
+			653.746f,
+			366.246f,
+			653.746f,
+			373.777f,
+			654.578f,
+			365.246f,
+			667.746f,
+			365.246f,
+			667.746f,
+			362.34f,
+			675.477f,
+			374.879f,
+			659.418f,
+			377.246f,
+			657.75f,
+			379.719f,
+			656.34f,
+			380.82f,
+			653.918f,
+			379.246f,
+			653.746f,
+			377.301f,
+			654.359f,
+			375.32f,
+			651.938f,
+			377.246f,
+			651.746f,
+			378.398f,
+			651.5f,
+			392.699f,
+			635,
+			396.25f,
+			623.746f,
+			400.18f,
+			612.559f,
+			406.777f,
+			608.156f,
+			413.246f,
+			601.746f,
+			420.418f,
+			594.957f,
+			419.246f,
+			568.746f,
+			419.246f,
+			568.746f,
+			419.098f,
+			558.656f,
+			425.25f,
+			546.746f,
+			425.25f,
+			546.746f,
+			427.898f,
+			542.816f,
+			423.246f,
+			522.746f,
+			423.246f,
+			522.746f,
+			421.078f,
+			520.379f,
+			422.246f,
+			519.746f,
+			422.246f,
+			519.746f,
+			423.719f,
+			518.18f,
+			431.246f,
+			503.75f,
+			431.246f,
+			503.75f,
+			429.219f,
+			503.879f,
+			433.246f,
+			499.746f,
+			433.246f,
+			499.746f,
+			438.898f,
+			493.316f,
+			432.246f,
+			496.75f,
+			432.246f,
+			496.75f,
+			425.258f,
+			498.379f,
+			433.246f,
+			487.75f,
+			433.246f,
+			487.75f,
+			434.277f,
+			485.617f,
+			424.246f,
+			490.75f,
+			424.246f,
+			490.75f,
+			414.258f,
+			491.34f,
+			427.25f,
+			483.75f,
+			427.25f,
+			483.75f,
+			436.48f,
+			475.5f,
+			424.246f,
+			480.746f,
+			424.246f,
+			480.746f,
+			418.879f,
+			482.316f,
+			422.246f,
+			474.75f,
+			422.246f,
+			474.75f,
+			425.918f,
+			473.078f,
+			445.246f,
+			465.75f,
+			445.246f,
+			465.75f,
+			445.277f,
+			461.195f,
+			442.246f,
+			455.746f,
+			442.246f,
+			455.746f,
+			442.418f,
+			451.297f,
+			440.25f,
+			447.746f,
+			440.25f,
+			447.746f,
+			438.68f,
+			438.535f,
+			438.25f,
+			437.75f,
+			438.25f,
+			437.75f,
+			433.398f,
+			437.438f,
+			425.25f,
+			422.746f,
+			425.25f,
+			422.746f,
+			423.277f,
+			419.398f,
+			412.246f,
+			405.746f,
+			412.246f,
+			405.746f,
+			409.859f,
+			398.496f,
+			390.246f,
+			406.75f,
+			390.246f,
+			406.75f,
+			382.801f,
+			402.676f,
+			385.25f,
+			406.75f,
+			385.25f,
+			406.75f,
+			384.559f,
+			408.836f,
+			390.246f,
+			415.75f,
+			390.246f,
+			415.75f,
+			397.539f,
+			418.297f,
+			394.25f,
+			429.746f,
+			394.25f,
+			429.746f,
+			399.078f,
+			431.719f,
+			386.758f,
+			434.797f,
+			387.246f,
+			435.75f,
+			387.199f,
+			437.438f,
+			393.25f,
+			438.746f,
+			393.25f,
+			438.746f,
+			402.379f,
+			441.176f,
+			397.246f,
+			443.75f,
+			397.246f,
+			443.75f,
+			396.879f,
+			448.219f,
+			400.246f,
+			454.75f,
+			400.246f,
+			454.75f,
+			412.938f,
+			455.258f,
+			400.246f,
+			472.75f,
+			400.246f,
+			472.75f,
+			388.301f,
+			481.438f,
+			387.246f,
+			487.75f,
+			387.246f,
+			487.75f,
+			401.059f,
+			496.84f,
+			392.039f,
+			510.477f,
+			392.25f,
+			514.75f,
+			392.48f,
+			518.398f,
+			394.25f,
+			541.746f,
+			394.25f,
+			541.746f,
+			391.598f,
+			548.977f,
+			388.246f,
+			563.746f,
+			388.246f,
+			563.746f,
+			390.719f,
+			569.656f,
+			399.246f,
+			583.746f,
+			399.246f,
+			583.746f,
+			401.938f,
+			588.137f,
+			411.621f,
+			593.418f,
+			409.246f,
+			596.746f,
+			406.777f,
+			600.02f,
+			398.246f,
+			597.75f,
+			398.246f,
+			597.75f,
+			389.621f,
+			599.578f,
+			390.246f,
+			593.75f,
+			390.246f,
+			593.75f,
+			388.52f,
+			592.758f,
+			387.246f,
+			587.746f,
+			387.246f,
+			587.746f,
+			386.848f,
+			578.531f,
+			377.246f,
+			571.75f,
+			377.246f,
+			571.75f,
+			364.758f,
+			564.816f,
+			375.246f,
+			560.75f,
+			375.246f,
+			560.75f,
+			381.48f,
+			553.156f,
+			370.25f,
+			552.746f,
+			370.25f,
+			552.746f,
+			358.598f,
+			554.918f,
+			367.246f,
+			543.746f,
+			367.246f,
+			543.746f,
+			379.5f,
+			529.617f,
+			376.246f,
+			526.746f,
+			376.246f,
+			526.746f,
+			364.98f,
+			525.438f,
+			379.246f,
+			515.746f,
+			379.246f,
+			515.746f,
+			379.242f,
+			515.742f,
+			377.961f,
+			517.52f,
+			378.246f,
+			515.746f,
+			378.398f,
+			513.559f,
+			381.699f,
+			508.938f,
+			382.25f,
+			506.746f,
+			383.461f,
+			504.539f,
+			379.246f,
+			504.746f,
+			379.246f,
+			504.746f,
+			379.719f,
+			493.758f,
+			363.25f,
+			498.75f,
+			363.25f,
+			498.75f,
+			363.25f,
+			498.75f,
+			362.777f,
+			498.379f,
+			361.25f,
+			497.746f,
+			359.258f,
+			497.938f,
+			346.938f,
+			498.816f,
+			340.25f,
+			500.746f,
+			334.18f,
+			503.656f,
+			326.25f,
+			503.75f,
+			326.25f,
+			503.75f,
+			326.25f,
+			503.75f,
+			322.301f,
+			501.68f,
+			314.25f,
+			501.75f,
+			305.578f,
+			502.117f,
+			297.246f,
+			498.75f,
+			297.246f,
+			498.75f,
+			291.937f,
+			499.477f,
+			301.398f,
+			504.316f,
+			301.246f,
+			503.75f,
+			301.84f,
+			503.879f,
+			308,
+			510.039f,
+			299.246f,
+			509.75f,
+			275.223f,
+			507.578f,
+			263.25f,
+			518.75f,
+			263.25f,
+			518.75f,
+			261.137f,
+			520.379f,
+			258.246f,
+			523.75f,
+			258.246f,
+			523.75f,
+			247.277f,
+			525.656f,
+			260.25f,
+			509.75f,
+			260.25f,
+			509.75f,
+			261.137f,
+			508.277f,
+			259.25f,
+			506.746f,
+			259.25f,
+			506.746f,
+			258.719f,
+			508.938f,
+			250.25f,
+			514.75f,
+			250.25f,
+			514.75f,
+			247.047f,
+			515.949f,
+			245.547f,
+			517.414f,
+			243.246f,
+			519.746f,
+			10,
+			0,
+			0.3f,
+			0,
+			0,
+			0.3f,
+			0,
+			0,
+			7,
+			216.25f,
+			532.746f,
+			216.25f,
+			532.742f,
+			229.457f,
+			526.758f,
+			232.246f,
+			523.75f,
+			235.18f,
+			520.598f,
+			250.25f,
+			507.75f,
+			250.25f,
+			507.75f,
+			250.25f,
+			507.75f,
+			244.637f,
+			510.258f,
+			242.246f,
+			511.746f,
+			238.918f,
+			514.219f,
+			227.25f,
+			522.746f,
+			227.25f,
+			522.746f,
+			227.25f,
+			522.746f,
+			222.859f,
+			529.84f,
+			216.25f,
+			532.746f,
+			10,
+			0,
+			0.6f,
+			0.8f,
+			0.2f,
+			0.6f,
+			0.8f,
+			0.2f,
+			6,
+			153.246f,
+			566.75f,
+			153.258f,
+			567.398f,
+			152.684f,
+			570.379f,
+			152.25f,
+			570.746f,
+			151.332f,
+			573.977f,
+			141.25f,
+			575.75f,
+			141.25f,
+			575.75f,
+			141.207f,
+			574.098f,
+			141.148f,
+			572.34f,
+			141.25f,
+			570.746f,
+			141.25f,
+			570.746f,
+			146.621f,
+			564.469f,
+			153.246f,
+			566.75f,
+			10,
+			0,
+			0.4f,
+			0.6f,
+			0,
+			0.4f,
+			0.6f,
+			0,
+			6,
+			153.246f,
+			567.75f,
+			152.395f,
+			567.281f,
+			152.871f,
+			570.461f,
+			152.25f,
+			570.746f,
+			151.555f,
+			573.977f,
+			141.25f,
+			575.75f,
+			141.25f,
+			575.75f,
+			141.207f,
+			574.207f,
+			141.148f,
+			572.449f,
+			141.25f,
+			570.746f,
+			141.25f,
+			570.746f,
+			145.961f,
+			565.02f,
+			153.246f,
+			567.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			6,
+			148.246f,
+			567.75f,
+			147.371f,
+			567.297f,
+			146.812f,
+			568.551f,
+			147.25f,
+			569.75f,
+			146.812f,
+			571.645f,
+			147.371f,
+			572.898f,
+			148.246f,
+			572.746f,
+			148.746f,
+			572.898f,
+			149.305f,
+			571.645f,
+			149.246f,
+			569.75f,
+			149.305f,
+			568.551f,
+			148.746f,
+			567.297f,
+			148.246f,
+			567.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			17,
+			98.2461f,
+			459.75f,
+			98.2422f,
+			459.75f,
+			91.7383f,
+			448.438f,
+			119.25f,
+			454.75f,
+			119.25f,
+			454.75f,
+			134.418f,
+			456.355f,
+			137.246f,
+			458.746f,
+			138.379f,
+			458.117f,
+			147.582f,
+			454.891f,
+			150.246f,
+			453.746f,
+			158.18f,
+			452.398f,
+			167.25f,
+			463.75f,
+			167.25f,
+			463.75f,
+			167.25f,
+			463.75f,
+			172.477f,
+			474.949f,
+			175.25f,
+			474.75f,
+			178.637f,
+			474.949f,
+			175.25f,
+			472.75f,
+			175.25f,
+			472.75f,
+			175.25f,
+			472.75f,
+			167.859f,
+			462.078f,
+			168.25f,
+			460.746f,
+			168.25f,
+			460.742f,
+			162.578f,
+			438.316f,
+			145.25f,
+			437.75f,
+			145.25f,
+			437.75f,
+			127.215f,
+			436.391f,
+			128.25f,
+			429.746f,
+			128.25f,
+			429.742f,
+			138.379f,
+			432.598f,
+			141.25f,
+			429.746f,
+			141.25f,
+			429.742f,
+			152.898f,
+			430.398f,
+			144.246f,
+			423.746f,
+			136.25f,
+			410.75f,
+			136.25f,
+			410.75f,
+			136.773f,
+			406.289f,
+			125.25f,
+			409.746f,
+			114.84f,
+			413.898f,
+			103.25f,
+			427.746f,
+			103.25f,
+			427.746f,
+			103.25f,
+			427.742f,
+			85.9648f,
+			444.094f,
+			98.2461f,
+			459.75f,
+			10,
+			0,
+			0.9f,
+			0.6f,
+			0.6f,
+			0.9f,
+			0.6f,
+			0.6f,
+			14,
+			96.25f,
+			454.75f,
+			96.25f,
+			454.75f,
+			94.3789f,
+			444.477f,
+			135.25f,
+			455.746f,
+			135.25f,
+			455.742f,
+			139.699f,
+			455.918f,
+			142.246f,
+			454.75f,
+			144.977f,
+			454.156f,
+			158.18f,
+			451.078f,
+			160.246f,
+			452.75f,
+			160.246f,
+			452.75f,
+			152.457f,
+			437.438f,
+			139.246f,
+			438.746f,
+			139.246f,
+			438.742f,
+			125.18f,
+			437.438f,
+			125.25f,
+			431.746f,
+			125.25f,
+			431.742f,
+			130.02f,
+			424.238f,
+			135.25f,
+			421.75f,
+			135.25f,
+			421.75f,
+			138.379f,
+			418.957f,
+			138.246f,
+			415.75f,
+			137.5f,
+			411.918f,
+			134.418f,
+			410.156f,
+			132.246f,
+			409.746f,
+			130.02f,
+			408.398f,
+			126.5f,
+			411.918f,
+			124.25f,
+			411.746f,
+			122.977f,
+			411.918f,
+			113.738f,
+			418.957f,
+			109.246f,
+			423.746f,
+			104.059f,
+			429.516f,
+			94.8164f,
+			442.719f,
+			95.25f,
+			445.746f,
+			95.6992f,
+			448.879f,
+			96.25f,
+			454.75f,
+			96.25f,
+			454.75f,
+			10,
+			0,
+			0.7f,
+			0.4f,
+			0.4f,
+			0.7f,
+			0.4f,
+			0.4f,
+			13,
+			100.246f,
+			435.75f,
+			102.957f,
+			431.496f,
+			106.477f,
+			426.879f,
+			109.246f,
+			423.746f,
+			113.738f,
+			418.957f,
+			122.977f,
+			411.918f,
+			124.25f,
+			411.746f,
+			126.5f,
+			411.918f,
+			130.02f,
+			408.398f,
+			132.246f,
+			409.746f,
+			134.418f,
+			410.156f,
+			137.5f,
+			411.918f,
+			138.246f,
+			415.75f,
+			138.379f,
+			418.957f,
+			135.25f,
+			421.75f,
+			135.25f,
+			421.75f,
+			131.926f,
+			423.285f,
+			128.91f,
+			427.125f,
+			127.246f,
+			429.746f,
+			127.246f,
+			429.742f,
+			127.379f,
+			426.879f,
+			121.246f,
+			427.746f,
+			115.938f,
+			428.637f,
+			110.219f,
+			431.719f,
+			108.25f,
+			434.746f,
+			106.699f,
+			438.758f,
+			104.059f,
+			441.398f,
+			106.25f,
+			437.75f,
+			107.578f,
+			433.477f,
+			110.219f,
+			429.516f,
+			112.25f,
+			428.75f,
+			113.738f,
+			428.637f,
+			113.297f,
+			427.316f,
+			110.246f,
+			427.746f,
+			108.02f,
+			428.195f,
+			104.938f,
+			428.637f,
+			100.246f,
+			434.746f,
+			10,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			20,
+			97.25f,
+			458.746f,
+			97.25f,
+			458.746f,
+			99.2187f,
+			473.957f,
+			100.246f,
+			478.746f,
+			100.246f,
+			478.746f,
+			99.6563f,
+			485.84f,
+			102.25f,
+			490.75f,
+			104.938f,
+			495.078f,
+			107.137f,
+			501.898f,
+			110.246f,
+			507.75f,
+			113.738f,
+			513.777f,
+			113.957f,
+			518.18f,
+			118.25f,
+			519.746f,
+			122.758f,
+			521.699f,
+			129.359f,
+			531.156f,
+			132.246f,
+			532.746f,
+			135.52f,
+			533.359f,
+			135.25f,
+			532.746f,
+			135.25f,
+			532.746f,
+			135.25f,
+			532.742f,
+			142.777f,
+			548.758f,
+			157.25f,
+			544.746f,
+			157.25f,
+			544.746f,
+			139.918f,
+			547.438f,
+			157.25f,
+			557.746f,
+			157.25f,
+			557.746f,
+			152.02f,
+			556.566f,
+			155.246f,
+			564.75f,
+			158.07f,
+			569.402f,
+			157.52f,
+			561.957f,
+			145.25f,
+			548.746f,
+			145.25f,
+			548.746f,
+			139.918f,
+			539.52f,
+			134.25f,
+			535.746f,
+			128.477f,
+			532.918f,
+			115.277f,
+			525.219f,
+			114.25f,
+			520.75f,
+			112.637f,
+			516.859f,
+			109.117f,
+			510.477f,
+			107.25f,
+			508.746f,
+			104.719f,
+			506.957f,
+			101.637f,
+			502.34f,
+			101.25f,
+			498.75f,
+			101.25f,
+			498.75f,
+			99.8789f,
+			494.199f,
+			98.2461f,
+			492.75f,
+			96.7969f,
+			491.559f,
+			96.5781f,
+			488.039f,
+			96.25f,
+			485.75f,
+			96.5781f,
+			483.637f,
+			94.3789f,
+			480.559f,
+			94.2461f,
+			477.746f,
+			94.2461f,
+			477.742f,
+			95.4766f,
+			457.016f,
+			95.25f,
+			454.75f,
+			97.25f,
+			458.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			6,
+			88.2461f,
+			453.746f,
+			88.2461f,
+			453.742f,
+			85.5781f,
+			455.477f,
+			80.25f,
+			448.75f,
+			80.25f,
+			448.75f,
+			88.7695f,
+			412.578f,
+			89.2461f,
+			410.75f,
+			89.2461f,
+			410.75f,
+			89.9766f,
+			413.348f,
+			88.2461f,
+			421.75f,
+			87.1172f,
+			429.188f,
+			86.25f,
+			442.746f,
+			86.25f,
+			442.746f,
+			88.2461f,
+			453.746f,
+			10,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			13,
+			111.246f,
+			520.75f,
+			111.246f,
+			520.75f,
+			92.1797f,
+			517.078f,
+			92.2461f,
+			484.746f,
+			91.25f,
+			457.75f,
+			91.25f,
+			457.75f,
+			90.418f,
+			485.84f,
+			89.2461f,
+			487.75f,
+			87.7773f,
+			489.359f,
+			92.1797f,
+			501.68f,
+			88.2461f,
+			494.75f,
+			88.2461f,
+			494.75f,
+			73.2578f,
+			479.68f,
+			82.2461f,
+			456.746f,
+			82.2422f,
+			456.746f,
+			83.707f,
+			452.727f,
+			80.25f,
+			457.75f,
+			80.25f,
+			457.75f,
+			75.3477f,
+			471.648f,
+			76.2461f,
+			478.746f,
+			76.2422f,
+			478.746f,
+			76.7773f,
+			481.109f,
+			79.25f,
+			483.75f,
+			79.25f,
+			483.75f,
+			88.3281f,
+			497.059f,
+			91.25f,
+			499.746f,
+			91.25f,
+			499.742f,
+			93.2773f,
+			515.43f,
+			110.246f,
+			520.75f,
+			110.246f,
+			520.75f,
+			116.488f,
+			523.68f,
+			111.246f,
+			520.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			28,
+			265.246f,
+			593.75f,
+			265.605f,
+			593.809f,
+			265.594f,
+			594.875f,
+			266.246f,
+			594.746f,
+			267.496f,
+			595.441f,
+			267.676f,
+			596.617f,
+			268.246f,
+			597.75f,
+			269.207f,
+			598.93f,
+			269.418f,
+			600.617f,
+			270.25f,
+			602.75f,
+			270.359f,
+			603.027f,
+			270.387f,
+			604.078f,
+			270.25f,
+			604.75f,
+			268.754f,
+			607.531f,
+			267.98f,
+			610.227f,
+			266.246f,
+			612.746f,
+			266.098f,
+			613.391f,
+			265.812f,
+			614.262f,
+			265.246f,
+			614.746f,
+			265.082f,
+			616.441f,
+			263.699f,
+			617.535f,
+			263.25f,
+			618.746f,
+			262.434f,
+			619.469f,
+			263.012f,
+			620.488f,
+			262.25f,
+			620.746f,
+			261.238f,
+			620.695f,
+			259.645f,
+			621.332f,
+			259.25f,
+			619.75f,
+			258.742f,
+			617.359f,
+			259.852f,
+			614.586f,
+			261.25f,
+			611.75f,
+			260.059f,
+			611.137f,
+			260.426f,
+			610.125f,
+			260.25f,
+			609.746f,
+			261.375f,
+			605.313f,
+			260.055f,
+			601.625f,
+			259.25f,
+			597.75f,
+			259.191f,
+			597.691f,
+			259.57f,
+			597.473f,
+			259.25f,
+			597.75f,
+			258.195f,
+			594.449f,
+			256.598f,
+			591.762f,
+			254.246f,
+			588.75f,
+			253.762f,
+			588.051f,
+			252.805f,
+			587.043f,
+			252.25f,
+			585.746f,
+			251.852f,
+			585.008f,
+			251.402f,
+			583.945f,
+			251.25f,
+			582.75f,
+			247.898f,
+			579.801f,
+			245.426f,
+			575.57f,
+			242.246f,
+			571.75f,
+			242.043f,
+			570.594f,
+			242.363f,
+			569.262f,
+			243.246f,
+			568.746f,
+			243.863f,
+			568.527f,
+			244.918f,
+			569.656f,
+			245.246f,
+			570.746f,
+			245.859f,
+			571.352f,
+			246.25f,
+			572.066f,
+			247.246f,
+			572.746f,
+			246.937f,
+			572.969f,
+			246.738f,
+			573.43f,
+			247.246f,
+			573.75f,
+			249.785f,
+			576.145f,
+			251.621f,
+			579.375f,
+			254.246f,
+			581.746f,
+			256.465f,
+			582.34f,
+			258.152f,
+			583.438f,
+			260.25f,
+			584.75f,
+			260.414f,
+			584.75f,
+			260.992f,
+			584.477f,
+			261.25f,
+			584.75f,
+			263.238f,
+			585.984f,
+			263.238f,
+			588.223f,
+			263.25f,
+			590.746f,
+			263.41f,
+			591.297f,
+			263.625f,
+			592.746f,
+			265.246f,
+			593.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			19,
+			255.246f,
+			598.746f,
+			255.289f,
+			598.414f,
+			255.117f,
+			598.879f,
+			255.246f,
+			598.746f,
+			255.418f,
+			599.477f,
+			255.859f,
+			599.68f,
+			256.246f,
+			599.75f,
+			256.16f,
+			600.277f,
+			255.98f,
+			600.695f,
+			256.246f,
+			600.75f,
+			258.695f,
+			603.543f,
+			258.977f,
+			606.867f,
+			258.246f,
+			609.746f,
+			258.965f,
+			610.82f,
+			259.031f,
+			612.207f,
+			258.246f,
+			612.746f,
+			257.625f,
+			615.012f,
+			257.414f,
+			617.129f,
+			256.246f,
+			618.746f,
+			255.457f,
+			620.223f,
+			253.723f,
+			621.59f,
+			252.25f,
+			619.75f,
+			251.75f,
+			619.719f,
+			251.398f,
+			618.852f,
+			251.25f,
+			617.75f,
+			251.773f,
+			617.887f,
+			252.09f,
+			617.727f,
+			252.25f,
+			617.75f,
+			251.941f,
+			617.281f,
+			251.34f,
+			617.035f,
+			251.25f,
+			616.746f,
+			251.301f,
+			615.09f,
+			250.25f,
+			613.43f,
+			251.25f,
+			611.75f,
+			251.793f,
+			610.176f,
+			252.695f,
+			608.133f,
+			253.246f,
+			605.746f,
+			252.082f,
+			603.852f,
+			253.219f,
+			601.156f,
+			251.25f,
+			598.746f,
+			251.141f,
+			598.93f,
+			251.148f,
+			598.508f,
+			251.25f,
+			598.746f,
+			251.605f,
+			597.75f,
+			252.051f,
+			597.305f,
+			252.25f,
+			596.746f,
+			252.809f,
+			596.848f,
+			253.191f,
+			596.848f,
+			253.246f,
+			596.746f,
+			254.047f,
+			597.383f,
+			254.484f,
+			597.918f,
+			255.246f,
+			598.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			21,
+			324.246f,
+			609.746f,
+			325.773f,
+			607.703f,
+			326.094f,
+			604.629f,
+			324.246f,
+			602.75f,
+			324.445f,
+			599.457f,
+			328.129f,
+			601.637f,
+			330.25f,
+			601.746f,
+			330.32f,
+			602.645f,
+			330.57f,
+			603.023f,
+			331.246f,
+			602.75f,
+			332.043f,
+			603.047f,
+			332.789f,
+			604.18f,
+			334.246f,
+			603.746f,
+			334.438f,
+			605.691f,
+			336.238f,
+			606.465f,
+			337.25f,
+			607.746f,
+			338.844f,
+			612.047f,
+			338.195f,
+			616.746f,
+			335.246f,
+			620.746f,
+			335.129f,
+			620.598f,
+			335.371f,
+			621.164f,
+			335.246f,
+			621.75f,
+			334.402f,
+			623.996f,
+			332.125f,
+			624.34f,
+			330.25f,
+			624.75f,
+			328.703f,
+			629.359f,
+			327.977f,
+			633.793f,
+			326.25f,
+			637.75f,
+			324.266f,
+			638.133f,
+			323.496f,
+			640.047f,
+			322.246f,
+			640.746f,
+			320.559f,
+			641.629f,
+			319.934f,
+			639.891f,
+			320.246f,
+			638.746f,
+			319.988f,
+			638.516f,
+			320.484f,
+			638.27f,
+			320.246f,
+			637.75f,
+			320.215f,
+			637.688f,
+			319.926f,
+			637.566f,
+			320.246f,
+			637.75f,
+			319.93f,
+			637.27f,
+			320.172f,
+			637.125f,
+			320.246f,
+			636.746f,
+			319.309f,
+			636.074f,
+			317.742f,
+			635.551f,
+			317.25f,
+			634.746f,
+			316.371f,
+			630.211f,
+			319.199f,
+			626.773f,
+			321.246f,
+			623.746f,
+			321.684f,
+			622.004f,
+			320.875f,
+			620.605f,
+			320.246f,
+			619.75f,
+			319.559f,
+			618.512f,
+			319.676f,
+			617.273f,
+			320.246f,
+			616.746f,
+			320.809f,
+			613.766f,
+			322.559f,
+			611.855f,
+			324.246f,
+			609.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			73,
+			283.25f,
+			589.75f,
+			281.734f,
+			587.41f,
+			277.98f,
+			584.586f,
+			281.25f,
+			582.75f,
+			281.402f,
+			582.324f,
+			281.809f,
+			582.32f,
+			282.25f,
+			582.75f,
+			284.223f,
+			584.188f,
+			286.426f,
+			585.18f,
+			289.246f,
+			585.746f,
+			289.242f,
+			585.852f,
+			289.543f,
+			585.34f,
+			290.246f,
+			585.746f,
+			291.727f,
+			586.289f,
+			293.938f,
+			586.227f,
+			295.25f,
+			587.746f,
+			299.383f,
+			587.453f,
+			303.305f,
+			588.68f,
+			307.25f,
+			589.75f,
+			308.309f,
+			590.609f,
+			309.707f,
+			591.227f,
+			311.246f,
+			591.75f,
+			312.543f,
+			592.41f,
+			313.867f,
+			593.434f,
+			315.25f,
+			594.746f,
+			315.234f,
+			594.836f,
+			315.625f,
+			594.738f,
+			316.25f,
+			594.746f,
+			315.875f,
+			595.688f,
+			316.934f,
+			595.828f,
+			317.25f,
+			596.746f,
+			317.305f,
+			596.766f,
+			317.141f,
+			597.203f,
+			317.25f,
+			597.75f,
+			319.641f,
+			599.105f,
+			320.652f,
+			601.328f,
+			319.25f,
+			603.746f,
+			319.051f,
+			604.578f,
+			318.777f,
+			605.258f,
+			318.25f,
+			605.746f,
+			316.961f,
+			606.781f,
+			315.75f,
+			605.844f,
+			314.25f,
+			605.746f,
+			314.422f,
+			605.488f,
+			313.621f,
+			605.676f,
+			313.246f,
+			605.746f,
+			312.25f,
+			604.977f,
+			310.785f,
+			605.621f,
+			310.246f,
+			604.75f,
+			308.344f,
+			604.371f,
+			306.977f,
+			604.188f,
+			305.25f,
+			603.746f,
+			305.07f,
+			603.684f,
+			304.215f,
+			603.789f,
+			304.25f,
+			602.75f,
+			303.891f,
+			603.246f,
+			303.727f,
+			603.504f,
+			303.25f,
+			603.746f,
+			301.512f,
+			603.043f,
+			300.125f,
+			602.809f,
+			298.246f,
+			600.75f,
+			298.582f,
+			600.801f,
+			298.098f,
+			600.996f,
+			298.246f,
+			600.75f,
+			296.867f,
+			599.961f,
+			296.422f,
+			598.602f,
+			295.25f,
+			597.75f,
+			294.992f,
+			597.727f,
+			294.602f,
+			597.914f,
+			294.25f,
+			597.75f,
+			293.68f,
+			597.297f,
+			293.277f,
+			596.59f,
+			292.25f,
+			595.75f,
+			292.207f,
+			595.848f,
+			291.766f,
+			596.207f,
+			292.25f,
+			596.746f,
+			292.07f,
+			598.629f,
+			292.789f,
+			600.594f,
+			292.25f,
+			602.75f,
+			294.441f,
+			605.43f,
+			297.211f,
+			607.574f,
+			299.246f,
+			610.75f,
+			299.215f,
+			612.961f,
+			299.977f,
+			615.32f,
+			300.246f,
+			617.75f,
+			299.84f,
+			617.816f,
+			299.523f,
+			618.625f,
+			299.246f,
+			618.746f,
+			299.043f,
+			619.945f,
+			300.039f,
+			621.117f,
+			299.246f,
+			621.75f,
+			297.566f,
+			623.238f,
+			296.145f,
+			622.273f,
+			295.25f,
+			620.746f,
+			293.215f,
+			620.27f,
+			290.945f,
+			619.508f,
+			289.246f,
+			620.746f,
+			288.102f,
+			621.73f,
+			287.465f,
+			622.727f,
+			286.246f,
+			623.746f,
+			285.504f,
+			625.32f,
+			285.871f,
+			626.898f,
+			286.246f,
+			628.75f,
+			285.953f,
+			628.762f,
+			285.609f,
+			628.91f,
+			285.25f,
+			628.75f,
+			285.609f,
+			629.207f,
+			285.852f,
+			629.352f,
+			286.246f,
+			629.746f,
+			285.223f,
+			630.188f,
+			284.918f,
+			631.352f,
+			284.25f,
+			631.746f,
+			284.133f,
+			632.898f,
+			283.391f,
+			633.871f,
+			282.25f,
+			633.75f,
+			280.238f,
+			634.965f,
+			278.395f,
+			632.859f,
+			276.246f,
+			632.75f,
+			275.746f,
+			632.758f,
+			275.23f,
+			633.902f,
+			274.25f,
+			634.746f,
+			274.043f,
+			634.496f,
+			273.27f,
+			634.531f,
+			273.25f,
+			633.75f,
+			272.113f,
+			633.688f,
+			271.465f,
+			633.559f,
+			270.25f,
+			633.75f,
+			268.852f,
+			632.855f,
+			267.449f,
+			631.652f,
+			266.246f,
+			630.75f,
+			264.188f,
+			629.77f,
+			263.137f,
+			628.188f,
+			262.25f,
+			626.75f,
+			260.914f,
+			625.469f,
+			260.762f,
+			622.813f,
+			262.25f,
+			622.75f,
+			264.352f,
+			621.547f,
+			265.785f,
+			624.523f,
+			268.246f,
+			623.746f,
+			268.293f,
+			624.105f,
+			268.52f,
+			623.766f,
+			268.246f,
+			623.746f,
+			268.824f,
+			623.219f,
+			269.066f,
+			623.469f,
+			269.246f,
+			623.746f,
+			270.223f,
+			622.656f,
+			271.504f,
+			622.285f,
+			272.25f,
+			621.75f,
+			273.602f,
+			620.332f,
+			275.523f,
+			620.793f,
+			276.246f,
+			619.75f,
+			278.32f,
+			618.043f,
+			277.707f,
+			615.094f,
+			280.246f,
+			613.75f,
+			279.195f,
+			612.215f,
+			278.527f,
+			610.809f,
+			278.246f,
+			608.75f,
+			277.848f,
+			607.914f,
+			278.941f,
+			606.598f,
+			280.246f,
+			606.75f,
+			281.656f,
+			606.801f,
+			281.945f,
+			607.633f,
+			282.25f,
+			608.75f,
+			282.773f,
+			608.523f,
+			283.289f,
+			608.199f,
+			283.25f,
+			607.746f,
+			282.738f,
+			605.336f,
+			281.609f,
+			603.141f,
+			281.25f,
+			600.75f,
+			281.043f,
+			600.121f,
+			280.707f,
+			599.898f,
+			280.246f,
+			599.75f,
+			279.762f,
+			595.453f,
+			275.305f,
+			592.82f,
+			272.25f,
+			589.75f,
+			272.063f,
+			588.785f,
+			272.059f,
+			587.414f,
+			272.25f,
+			586.75f,
+			274.051f,
+			585.445f,
+			276.207f,
+			587.145f,
+			278.246f,
+			587.746f,
+			278.313f,
+			589.023f,
+			279.258f,
+			590.063f,
+			280.246f,
+			589.75f,
+			281.004f,
+			589.988f,
+			281.262f,
+			590.586f,
+			281.25f,
+			590.746f,
+			282,
+			590.879f,
+			282.555f,
+			590.633f,
+			283.25f,
+			590.746f,
+			284.77f,
+			592.164f,
+			286.32f,
+			593.383f,
+			288.246f,
+			594.746f,
+			288.441f,
+			594.832f,
+			288.82f,
+			594.66f,
+			289.246f,
+			594.746f,
+			289.414f,
+			594.957f,
+			289.621f,
+			595.383f,
+			290.246f,
+			595.75f,
+			290.359f,
+			595.805f,
+			290.625f,
+			595.484f,
+			291.246f,
+			594.746f,
+			290.129f,
+			594.793f,
+			290.125f,
+			593.742f,
+			289.246f,
+			593.75f,
+			288.629f,
+			593.223f,
+			288.012f,
+			592.66f,
+			287.246f,
+			591.75f,
+			286.949f,
+			591.957f,
+			286.227f,
+			592.23f,
+			286.246f,
+			591.75f,
+			285.453f,
+			590.902f,
+			284.152f,
+			590.418f,
+			283.25f,
+			589.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			30,
+			222.246f,
+			643.75f,
+			222.246f,
+			643.75f,
+			212.258f,
+			646.957f,
+			200.246f,
+			618.746f,
+			200.246f,
+			618.742f,
+			197.34f,
+			613,
+			194.25f,
+			610.75f,
+			192.059f,
+			608.598f,
+			179.738f,
+			604.637f,
+			177.246f,
+			599.75f,
+			166.246f,
+			582.75f,
+			166.246f,
+			582.75f,
+			182.379f,
+			600.238f,
+			186.25f,
+			602.75f,
+			186.25f,
+			602.75f,
+			194.699f,
+			612.117f,
+			191.246f,
+			604.75f,
+			191.242f,
+			604.75f,
+			175.777f,
+			592.758f,
+			177.246f,
+			582.75f,
+			177.246f,
+			582.75f,
+			170.938f,
+			566.797f,
+			170.246f,
+			564.75f,
+			170.242f,
+			564.75f,
+			187.656f,
+			599.797f,
+			190.246f,
+			600.75f,
+			192.938f,
+			602.438f,
+			194.258f,
+			602.438f,
+			193.25f,
+			598.746f,
+			191.617f,
+			594.52f,
+			191.18f,
+			576.477f,
+			188.246f,
+			574.746f,
+			188.246f,
+			574.742f,
+			196.898f,
+			596.719f,
+			196.25f,
+			599.75f,
+			196.25f,
+			599.75f,
+			199.539f,
+			604.199f,
+			202.246f,
+			598.746f,
+			201.246f,
+			580.75f,
+			205.25f,
+			567.75f,
+			205.25f,
+			567.75f,
+			203.059f,
+			580,
+			205.25f,
+			596.746f,
+			205.25f,
+			596.742f,
+			202.617f,
+			608.598f,
+			207.25f,
+			602.75f,
+			211.418f,
+			596.277f,
+			221.977f,
+			589.68f,
+			222.246f,
+			584.75f,
+			222.246f,
+			584.75f,
+			216.258f,
+			603.758f,
+			206.25f,
+			608.75f,
+			201.246f,
+			602.75f,
+			200.246f,
+			604.75f,
+			200.246f,
+			604.75f,
+			196.457f,
+			605.52f,
+			201.246f,
+			612.746f,
+			206.137f,
+			620.477f,
+			205.25f,
+			621.75f,
+			205.25f,
+			621.75f,
+			205.25f,
+			621.75f,
+			212.738f,
+			613.438f,
+			214.25f,
+			613.75f,
+			214.25f,
+			613.75f,
+			229.02f,
+			621.797f,
+			230.25f,
+			594.746f,
+			230.25f,
+			594.742f,
+			237.816f,
+			610.797f,
+			227.25f,
+			618.746f,
+			227.25f,
+			618.742f,
+			211.418f,
+			620.477f,
+			212.246f,
+			625.746f,
+			220.246f,
+			639.75f,
+			224.617f,
+			645.559f,
+			223.246f,
+			642.746f,
+			223.246f,
+			642.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			6,
+			200.246f,
+			625.746f,
+			200.246f,
+			625.746f,
+			186.34f,
+			625.758f,
+			183.25f,
+			619.75f,
+			175.25f,
+			609.746f,
+			175.25f,
+			609.742f,
+			193.816f,
+			620.477f,
+			198.246f,
+			621.75f,
+			202.617f,
+			623.117f,
+			200.246f,
+			625.746f,
+			200.246f,
+			625.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			7,
+			156.25f,
+			618.746f,
+			156.25f,
+			618.742f,
+			154.219f,
+			617.398f,
+			154.246f,
+			614.746f,
+			153.34f,
+			611.238f,
+			150.699f,
+			610.797f,
+			151.25f,
+			607.746f,
+			152.457f,
+			604.637f,
+			154.656f,
+			602,
+			154.246f,
+			606.75f,
+			154.656f,
+			610.797f,
+			156.418f,
+			613,
+			157.25f,
+			614.746f,
+			158.18f,
+			615.637f,
+			159.938f,
+			620.477f,
+			156.25f,
+			618.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			10,
+			146.25f,
+			551.75f,
+			146.25f,
+			551.75f,
+			137.5f,
+			555.797f,
+			134.25f,
+			559.746f,
+			130.457f,
+			563.719f,
+			130.957f,
+			558.035f,
+			125.25f,
+			558.75f,
+			119.187f,
+			558.922f,
+			120.246f,
+			576.746f,
+			120.246f,
+			576.746f,
+			116.246f,
+			567.75f,
+			116.246f,
+			567.75f,
+			114.617f,
+			552.277f,
+			123.25f,
+			554.746f,
+			127.715f,
+			556.207f,
+			129.137f,
+			554.477f,
+			127.246f,
+			553.75f,
+			125.617f,
+			552.719f,
+			133.539f,
+			552.277f,
+			130.25f,
+			550.746f,
+			127.379f,
+			548.758f,
+			143.219f,
+			554.477f,
+			140.25f,
+			542.75f,
+			146.25f,
+			551.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			8,
+			133.246f,
+			535.746f,
+			133.246f,
+			535.746f,
+			115.938f,
+			530.719f,
+			112.25f,
+			541.746f,
+			112.25f,
+			541.742f,
+			106.699f,
+			538.637f,
+			109.246f,
+			535.746f,
+			111.539f,
+			532.039f,
+			113.25f,
+			531.75f,
+			113.25f,
+			531.75f,
+			113.25f,
+			531.75f,
+			118.797f,
+			530.277f,
+			118.25f,
+			529.75f,
+			117.477f,
+			528.52f,
+			115.246f,
+			524.746f,
+			115.246f,
+			524.746f,
+			115.242f,
+			524.746f,
+			126.059f,
+			531.379f,
+			133.246f,
+			535.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			24,
+			384.25f,
+			449.746f,
+			383.648f,
+			447.191f,
+			381.813f,
+			446.309f,
+			379.246f,
+			445.746f,
+			377.609f,
+			446.629f,
+			374.754f,
+			450.047f,
+			372.25f,
+			447.746f,
+			372.156f,
+			448.305f,
+			371.301f,
+			448.371f,
+			371.25f,
+			448.75f,
+			370.41f,
+			450.086f,
+			370.711f,
+			451.238f,
+			370.25f,
+			451.746f,
+			369.734f,
+			453.516f,
+			368.953f,
+			455.016f,
+			369.25f,
+			456.746f,
+			371.145f,
+			457.359f,
+			371.801f,
+			459.457f,
+			371.25f,
+			461.75f,
+			371.203f,
+			461.68f,
+			370.73f,
+			461.895f,
+			371.25f,
+			462.746f,
+			371.156f,
+			462.633f,
+			371.504f,
+			462.883f,
+			372.25f,
+			462.746f,
+			371.652f,
+			463.031f,
+			371.492f,
+			462.773f,
+			371.25f,
+			462.746f,
+			370.699f,
+			462.91f,
+			370.836f,
+			463.613f,
+			371.25f,
+			463.75f,
+			371.621f,
+			465.957f,
+			373.836f,
+			466.25f,
+			375.246f,
+			464.746f,
+			375.602f,
+			465.559f,
+			376.16f,
+			465.348f,
+			376.246f,
+			465.75f,
+			376.586f,
+			466.016f,
+			377.031f,
+			466.594f,
+			377.246f,
+			466.746f,
+			377.82f,
+			468.266f,
+			379.613f,
+			467.047f,
+			380.25f,
+			467.746f,
+			381.672f,
+			468.629f,
+			382.844f,
+			469.398f,
+			384.25f,
+			468.75f,
+			386.02f,
+			467.621f,
+			387.898f,
+			466.285f,
+			389.246f,
+			464.746f,
+			389.848f,
+			463.453f,
+			390.113f,
+			462.047f,
+			390.246f,
+			460.746f,
+			390.008f,
+			460.281f,
+			388.488f,
+			460.668f,
+			388.246f,
+			459.75f,
+			387.402f,
+			457.723f,
+			389.414f,
+			457.152f,
+			390.246f,
+			455.746f,
+			390.465f,
+			455.297f,
+			390.176f,
+			454.961f,
+			390.246f,
+			454.75f,
+			389.375f,
+			454.711f,
+			388.516f,
+			454.922f,
+			388.246f,
+			454.75f,
+			389.734f,
+			450.91f,
+			386.703f,
+			450.164f,
+			384.25f,
+			449.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			11,
+			373.25f,
+			427.746f,
+			373.551f,
+			429.891f,
+			371.789f,
+			431.82f,
+			373.25f,
+			433.746f,
+			373.27f,
+			433.551f,
+			373.41f,
+			433.305f,
+			373.25f,
+			433.746f,
+			373.707f,
+			433.305f,
+			373.852f,
+			433.551f,
+			374.25f,
+			433.746f,
+			375.645f,
+			431.258f,
+			379.66f,
+			430.238f,
+			379.246f,
+			426.75f,
+			379.48f,
+			426.617f,
+			378.285f,
+			425.605f,
+			379.246f,
+			424.75f,
+			377.285f,
+			423.414f,
+			377.223f,
+			420.809f,
+			376.246f,
+			418.746f,
+			374.836f,
+			419.051f,
+			373.504f,
+			419.449f,
+			372.25f,
+			419.75f,
+			372.625f,
+			421.691f,
+			372.496f,
+			423.543f,
+			373.25f,
+			424.75f,
+			373.879f,
+			425.766f,
+			373.563f,
+			426.949f,
+			373.25f,
+			427.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			15,
+			190.246f,
+			437.75f,
+			190.246f,
+			437.75f,
+			172.195f,
+			426.727f,
+			187.246f,
+			443.75f,
+			197.34f,
+			454.156f,
+			208.25f,
+			460.746f,
+			208.25f,
+			460.746f,
+			208.25f,
+			460.742f,
+			219.777f,
+			465.156f,
+			223.246f,
+			466.746f,
+			227.699f,
+			467.797f,
+			244.418f,
+			473.52f,
+			248.25f,
+			473.746f,
+			251.457f,
+			474.398f,
+			262.02f,
+			478.797f,
+			269.246f,
+			474.75f,
+			276.977f,
+			470,
+			286.246f,
+			464.746f,
+			286.246f,
+			464.746f,
+			286.246f,
+			464.742f,
+			267.738f,
+			474.398f,
+			264.246f,
+			471.746f,
+			259.816f,
+			469.117f,
+			251.898f,
+			469.559f,
+			245.246f,
+			465.75f,
+			245.246f,
+			465.75f,
+			229.02f,
+			461.195f,
+			225.25f,
+			458.746f,
+			221.977f,
+			456.797f,
+			210.539f,
+			444.035f,
+			209.246f,
+			444.746f,
+			207.02f,
+			445.797f,
+			209.219f,
+			446.238f,
+			210.246f,
+			449.746f,
+			211.859f,
+			452.398f,
+			209.656f,
+			454.156f,
+			201.246f,
+			446.75f,
+			192.059f,
+			440.078f,
+			190.246f,
+			437.75f,
+			190.246f,
+			437.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			11,
+			199.246f,
+			444.746f,
+			199.246f,
+			444.742f,
+			200.434f,
+			458.785f,
+			210.246f,
+			456.746f,
+			210.246f,
+			456.746f,
+			218.809f,
+			461.539f,
+			222.246f,
+			463.75f,
+			222.246f,
+			463.75f,
+			230.758f,
+			465.578f,
+			232.246f,
+			466.746f,
+			252.523f,
+			475.824f,
+			268.715f,
+			470.855f,
+			269.246f,
+			471.746f,
+			269.918f,
+			473.316f,
+			291.504f,
+			465.488f,
+			295.25f,
+			460.746f,
+			295.906f,
+			460.508f,
+			284.219f,
+			467.152f,
+			273.25f,
+			468.75f,
+			264.453f,
+			471.008f,
+			240.691f,
+			468.961f,
+			228.25f,
+			462.746f,
+			225.422f,
+			461.211f,
+			215.582f,
+			454.848f,
+			213.246f,
+			454.75f,
+			210.016f,
+			455.094f,
+			199.246f,
+			444.746f,
+			199.246f,
+			444.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			11,
+			194.25f,
+			416.746f,
+			194.25f,
+			416.742f,
+			177.977f,
+			418.957f,
+			196.25f,
+			420.746f,
+			196.25f,
+			420.742f,
+			216.258f,
+			422.918f,
+			220.246f,
+			428.75f,
+			220.246f,
+			428.75f,
+			235.617f,
+			438.758f,
+			238.25f,
+			438.746f,
+			241.777f,
+			439.637f,
+			274.777f,
+			447.559f,
+			275.246f,
+			449.746f,
+			275.656f,
+			452.836f,
+			281.816f,
+			452.836f,
+			283.25f,
+			451.746f,
+			285.34f,
+			451.078f,
+			284.457f,
+			449.758f,
+			281.25f,
+			448.75f,
+			278.297f,
+			447.996f,
+			243.977f,
+			429.957f,
+			237.25f,
+			428.75f,
+			229.898f,
+			427.316f,
+			217.137f,
+			418.957f,
+			212.246f,
+			417.75f,
+			206.578f,
+			416.316f,
+			194.25f,
+			416.746f,
+			194.25f,
+			416.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			11,
+			216.25f,
+			424.75f,
+			216.25f,
+			424.75f,
+			206.73f,
+			425.367f,
+			216.25f,
+			426.75f,
+			216.25f,
+			426.75f,
+			225.887f,
+			430.035f,
+			228.25f,
+			432.75f,
+			228.25f,
+			432.75f,
+			235.801f,
+			438.145f,
+			237.25f,
+			438.746f,
+			238.957f,
+			438.594f,
+			254.313f,
+			442.652f,
+			254.246f,
+			443.75f,
+			254.762f,
+			445.355f,
+			292.234f,
+			459.191f,
+			297.246f,
+			455.746f,
+			300.301f,
+			453.371f,
+			289.406f,
+			455.219f,
+			279.246f,
+			450.75f,
+			277.32f,
+			449.684f,
+			240.082f,
+			433.637f,
+			236.25f,
+			432.75f,
+			232.871f,
+			432.285f,
+			226.34f,
+			428.008f,
+			223.246f,
+			427.746f,
+			220.934f,
+			426.656f,
+			216.25f,
+			424.75f,
+			216.25f,
+			424.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			207.25f,
+			421.75f,
+			207.25f,
+			421.75f,
+			213.18f,
+			422.477f,
+			212.246f,
+			420.746f,
+			210.539f,
+			418.957f,
+			208.25f,
+			419.75f,
+			208.25f,
+			419.75f,
+			207.25f,
+			421.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			199.246f,
+			420.746f,
+			199.246f,
+			420.742f,
+			205.258f,
+			420.719f,
+			204.25f,
+			418.746f,
+			202.617f,
+			417.195f,
+			200.246f,
+			417.75f,
+			200.246f,
+			417.75f,
+			199.246f,
+			420.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			188.246f,
+			418.746f,
+			188.246f,
+			418.742f,
+			193.816f,
+			418.957f,
+			192.25f,
+			416.746f,
+			191.18f,
+			415.438f,
+			188.246f,
+			416.746f,
+			188.246f,
+			416.746f,
+			188.246f,
+			418.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			179.246f,
+			417.75f,
+			179.246f,
+			417.75f,
+			185.457f,
+			418.078f,
+			184.25f,
+			416.746f,
+			182.816f,
+			414.559f,
+			180.246f,
+			415.75f,
+			180.246f,
+			415.75f,
+			179.246f,
+			417.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			222.246f,
+			460.746f,
+			222.246f,
+			460.742f,
+			226.816f,
+			461.195f,
+			225.25f,
+			459.75f,
+			224.18f,
+			457.676f,
+			220.246f,
+			457.75f,
+			220.246f,
+			457.75f,
+			222.246f,
+			460.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			211.246f,
+			454.75f,
+			211.246f,
+			454.75f,
+			218.133f,
+			457.391f,
+			215.25f,
+			453.746f,
+			214.059f,
+			451.957f,
+			211.246f,
+			452.75f,
+			211.246f,
+			452.75f,
+			211.246f,
+			454.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			198.246f,
+			449.746f,
+			198.246f,
+			449.742f,
+			204.379f,
+			450.195f,
+			203.25f,
+			448.75f,
+			201.738f,
+			446.676f,
+			199.246f,
+			447.746f,
+			199.246f,
+			447.746f,
+			198.246f,
+			449.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			190.246f,
+			442.746f,
+			190.246f,
+			442.742f,
+			196.02f,
+			443.598f,
+			194.25f,
+			441.75f,
+			193.379f,
+			440.078f,
+			190.246f,
+			440.746f,
+			190.246f,
+			440.746f,
+			190.246f,
+			442.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			183.25f,
+			437.75f,
+			183.25f,
+			437.75f,
+			188.539f,
+			438.316f,
+			187.246f,
+			436.746f,
+			185.898f,
+			434.797f,
+			183.25f,
+			435.75f,
+			183.25f,
+			435.75f,
+			183.25f,
+			437.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			226.25f,
+			430.75f,
+			226.25f,
+			430.75f,
+			233.422f,
+			431.426f,
+			231.246f,
+			428.75f,
+			229.906f,
+			426.742f,
+			226.25f,
+			427.746f,
+			226.25f,
+			427.746f,
+			226.25f,
+			430.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			237.25f,
+			435.75f,
+			237.25f,
+			435.75f,
+			244.863f,
+			436.707f,
+			243.246f,
+			434.746f,
+			241.348f,
+			432.02f,
+			238.25f,
+			432.75f,
+			238.25f,
+			432.75f,
+			237.25f,
+			435.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			249.25f,
+			440.746f,
+			249.25f,
+			440.742f,
+			256.742f,
+			441.547f,
+			255.246f,
+			438.746f,
+			253.227f,
+			436.859f,
+			249.25f,
+			437.75f,
+			249.25f,
+			437.75f,
+			249.25f,
+			440.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			260.25f,
+			445.746f,
+			260.25f,
+			445.746f,
+			268.18f,
+			446.824f,
+			266.246f,
+			444.746f,
+			264.668f,
+			442.141f,
+			261.25f,
+			443.75f,
+			261.25f,
+			443.75f,
+			260.25f,
+			445.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			230.25f,
+			465.75f,
+			230.25f,
+			465.75f,
+			237.82f,
+			466.625f,
+			236.25f,
+			464.746f,
+			234.309f,
+			461.941f,
+			230.25f,
+			461.75f,
+			230.25f,
+			461.75f,
+			230.25f,
+			465.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			241.25f,
+			469.746f,
+			241.25f,
+			469.746f,
+			248.82f,
+			470.145f,
+			247.246f,
+			467.746f,
+			245.309f,
+			465.461f,
+			240.25f,
+			465.75f,
+			240.25f,
+			465.75f,
+			241.25f,
+			469.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			216.25f,
+			425.746f,
+			216.25f,
+			425.746f,
+			221.977f,
+			425.996f,
+			220.246f,
+			423.746f,
+			219.34f,
+			422.477f,
+			216.25f,
+			423.746f,
+			216.25f,
+			423.746f,
+			216.25f,
+			425.746f,
+			10,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			5,
+			135.25f,
+			534.75f,
+			135.25f,
+			534.75f,
+			130.898f,
+			525,
+			130.25f,
+			521.746f,
+			130.25f,
+			521.742f,
+			131.34f,
+			531.156f,
+			132.246f,
+			533.746f,
+			133.977f,
+			535.559f,
+			135.25f,
+			534.75f,
+			135.25f,
+			534.75f,
+			10,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			0.6f,
+			0.15f,
+			0,
+			5,
+			115.246f,
+			519.746f,
+			115.242f,
+			519.742f,
+			111.977f,
+			503.438f,
+			112.25f,
+			500.746f,
+			112.25f,
+			500.746f,
+			111.098f,
+			513.117f,
+			111.246f,
+			514.75f,
+			111.977f,
+			515.758f,
+			115.246f,
+			519.746f,
+			115.246f,
+			519.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			138.246f,
+			601.746f,
+			138.246f,
+			597.75f,
+			135.25f,
+			597.75f,
+			135.25f,
+			597.75f,
+			151.359f,
+			583.738f,
+			152.25f,
+			575.75f,
+			152.25f,
+			575.75f,
+			152.898f,
+			584.398f,
+			138.246f,
+			601.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			28,
+			143.246f,
+			599.75f,
+			142.285f,
+			600.402f,
+			142.527f,
+			601.223f,
+			142.246f,
+			601.746f,
+			141.188f,
+			602.078f,
+			143.508f,
+			602.141f,
+			143.246f,
+			602.75f,
+			142.836f,
+			604.254f,
+			143.039f,
+			604.277f,
+			143.246f,
+			605.746f,
+			142.844f,
+			606.34f,
+			143.488f,
+			608.031f,
+			144.246f,
+			608.75f,
+			145.504f,
+			610.332f,
+			144.047f,
+			613.559f,
+			146.25f,
+			615.75f,
+			146.188f,
+			615.582f,
+			146.598f,
+			616.191f,
+			147.25f,
+			616.746f,
+			147.637f,
+			617.711f,
+			148.941f,
+			618.246f,
+			150.246f,
+			618.746f,
+			150.336f,
+			619.461f,
+			150.113f,
+			620.371f,
+			150.246f,
+			620.746f,
+			151.523f,
+			620.141f,
+			152.891f,
+			620.285f,
+			153.246f,
+			619.75f,
+			152.715f,
+			617.027f,
+			151.254f,
+			615.137f,
+			150.246f,
+			613.75f,
+			150.344f,
+			612.527f,
+			149.84f,
+			611.828f,
+			149.246f,
+			610.75f,
+			148.059f,
+			608.336f,
+			148.266f,
+			605.207f,
+			148.246f,
+			601.746f,
+			148.07f,
+			601.992f,
+			147.73f,
+			601.906f,
+			147.25f,
+			601.746f,
+			148.129f,
+			599.277f,
+			148.77f,
+			596.859f,
+			149.246f,
+			594.746f,
+			150.141f,
+			593.387f,
+			150.66f,
+			592.402f,
+			151.25f,
+			591.75f,
+			150.945f,
+			590.625f,
+			151.059f,
+			589.711f,
+			150.246f,
+			588.75f,
+			152.848f,
+			585.754f,
+			151.41f,
+			582.84f,
+			152.25f,
+			578.75f,
+			152.922f,
+			578.27f,
+			154.785f,
+			576.164f,
+			154.246f,
+			576.746f,
+			151.512f,
+			577.297f,
+			151.387f,
+			577.734f,
+			151.25f,
+			578.75f,
+			151.031f,
+			579.25f,
+			150.668f,
+			580.762f,
+			150.246f,
+			581.746f,
+			150.336f,
+			581.605f,
+			150.148f,
+			583.68f,
+			150.246f,
+			583.746f,
+			148.398f,
+			586.434f,
+			149.895f,
+			586.238f,
+			148.246f,
+			588.75f,
+			146.816f,
+			589.582f,
+			145.754f,
+			590.797f,
+			144.246f,
+			591.75f,
+			144.301f,
+			592.297f,
+			145.559f,
+			593.094f,
+			145.25f,
+			593.75f,
+			144.156f,
+			594.746f,
+			142.887f,
+			595.59f,
+			143.246f,
+			596.746f,
+			143.43f,
+			597.992f,
+			143.578f,
+			599.156f,
+			143.246f,
+			599.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			11,
+			139.246f,
+			597.75f,
+			139.246f,
+			597.75f,
+			139.258f,
+			590.559f,
+			142.246f,
+			588.75f,
+			144.539f,
+			587.039f,
+			143.219f,
+			587.918f,
+			139.246f,
+			588.75f,
+			136.18f,
+			590.559f,
+			137.246f,
+			591.75f,
+			137.246f,
+			591.75f,
+			137.242f,
+			591.75f,
+			134.418f,
+			591,
+			137.246f,
+			588.75f,
+			139.699f,
+			586.598f,
+			143.656f,
+			583.957f,
+			142.246f,
+			583.746f,
+			140.137f,
+			583.957f,
+			131.777f,
+			588.359f,
+			132.246f,
+			591.75f,
+			131.777f,
+			594.52f,
+			130.25f,
+			598.746f,
+			130.25f,
+			598.746f,
+			130.25f,
+			598.742f,
+			131.887f,
+			599.906f,
+			137.246f,
+			599.75f,
+			137.242f,
+			599.75f,
+			138.707f,
+			599.027f,
+			139.246f,
+			597.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			138.246f,
+			577.75f,
+			138.246f,
+			577.75f,
+			128.566f,
+			580.648f,
+			108.25f,
+			576.746f,
+			108.25f,
+			576.742f,
+			118.172f,
+			579.203f,
+			139.246f,
+			576.746f,
+			150.148f,
+			575.324f,
+			138.246f,
+			577.75f,
+			138.246f,
+			577.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			138.246f,
+			577.75f,
+			138.246f,
+			577.75f,
+			128.566f,
+			580.648f,
+			108.25f,
+			576.746f,
+			108.25f,
+			576.742f,
+			118.172f,
+			579.203f,
+			139.246f,
+			576.746f,
+			150.148f,
+			575.324f,
+			138.246f,
+			577.75f,
+			138.246f,
+			577.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			140.25f,
+			577.75f,
+			140.25f,
+			577.75f,
+			131.176f,
+			581.527f,
+			110.246f,
+			579.746f,
+			110.246f,
+			579.746f,
+			120.695f,
+			580.984f,
+			141.25f,
+			576.746f,
+			152.215f,
+			574.355f,
+			140.25f,
+			577.75f,
+			140.25f,
+			577.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			140.25f,
+			577.75f,
+			140.25f,
+			577.75f,
+			131.176f,
+			581.527f,
+			110.246f,
+			579.746f,
+			110.246f,
+			579.746f,
+			120.695f,
+			580.984f,
+			141.25f,
+			576.746f,
+			152.215f,
+			574.355f,
+			140.25f,
+			577.75f,
+			140.25f,
+			577.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			142.246f,
+			577.75f,
+			142.242f,
+			577.75f,
+			133.453f,
+			582.086f,
+			113.25f,
+			581.746f,
+			113.25f,
+			581.746f,
+			122.965f,
+			582.328f,
+			143.246f,
+			576.746f,
+			153.902f,
+			573.371f,
+			142.246f,
+			577.75f,
+			142.246f,
+			577.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			142.246f,
+			577.75f,
+			142.242f,
+			577.75f,
+			133.453f,
+			582.086f,
+			113.25f,
+			581.746f,
+			113.25f,
+			581.746f,
+			122.965f,
+			582.328f,
+			143.246f,
+			576.746f,
+			153.902f,
+			573.371f,
+			142.246f,
+			577.75f,
+			142.246f,
+			577.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			143.246f,
+			577.75f,
+			143.242f,
+			577.75f,
+			136.102f,
+			582.047f,
+			117.25f,
+			583.746f,
+			117.25f,
+			583.742f,
+			126.715f,
+			583.066f,
+			144.246f,
+			576.746f,
+			153.77f,
+			572.66f,
+			143.246f,
+			577.75f,
+			143.246f,
+			577.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			143.246f,
+			577.75f,
+			143.242f,
+			577.75f,
+			136.102f,
+			582.047f,
+			117.25f,
+			583.746f,
+			117.25f,
+			583.742f,
+			126.715f,
+			583.066f,
+			144.246f,
+			576.746f,
+			153.77f,
+			572.66f,
+			143.246f,
+			577.75f,
+			143.246f,
+			577.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			270.25f,
+			565.746f,
+			270.25f,
+			565.742f,
+			269.398f,
+			565.031f,
+			269.246f,
+			566.75f,
+			269.871f,
+			567.629f,
+			300.898f,
+			582.117f,
+			305.25f,
+			581.746f,
+			305.25f,
+			581.746f,
+			271.602f,
+			567.316f,
+			270.25f,
+			565.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			270.25f,
+			565.746f,
+			270.25f,
+			565.742f,
+			269.398f,
+			565.031f,
+			269.246f,
+			566.75f,
+			269.871f,
+			567.629f,
+			300.898f,
+			582.117f,
+			305.25f,
+			581.746f,
+			305.25f,
+			581.746f,
+			271.602f,
+			567.316f,
+			270.25f,
+			565.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			266.246f,
+			564.75f,
+			266.246f,
+			564.75f,
+			265.727f,
+			564.25f,
+			266.246f,
+			565.746f,
+			265.992f,
+			566.879f,
+			295.785f,
+			583.758f,
+			300.246f,
+			583.746f,
+			300.246f,
+			583.742f,
+			267.742f,
+			566.699f,
+			266.246f,
+			564.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			266.246f,
+			564.75f,
+			266.246f,
+			564.75f,
+			265.727f,
+			564.25f,
+			266.246f,
+			565.746f,
+			265.992f,
+			566.879f,
+			295.785f,
+			583.758f,
+			300.246f,
+			583.746f,
+			300.246f,
+			583.742f,
+			267.742f,
+			566.699f,
+			266.246f,
+			564.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			263.25f,
+			563.746f,
+			263.25f,
+			563.742f,
+			262.164f,
+			562.676f,
+			262.25f,
+			563.746f,
+			262.254f,
+			565.316f,
+			284.055f,
+			582.363f,
+			295.25f,
+			584.75f,
+			295.25f,
+			584.75f,
+			275.016f,
+			575.484f,
+			263.25f,
+			563.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			263.25f,
+			563.746f,
+			263.25f,
+			563.742f,
+			262.164f,
+			562.676f,
+			262.25f,
+			563.746f,
+			262.254f,
+			565.316f,
+			284.055f,
+			582.363f,
+			295.25f,
+			584.75f,
+			295.25f,
+			584.75f,
+			275.016f,
+			575.484f,
+			263.25f,
+			563.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			260.25f,
+			561.746f,
+			260.25f,
+			561.742f,
+			259.09f,
+			560.711f,
+			259.25f,
+			561.746f,
+			259.176f,
+			563.086f,
+			278.793f,
+			578.43f,
+			288.246f,
+			580.75f,
+			288.246f,
+			580.75f,
+			270.656f,
+			572.238f,
+			260.25f,
+			561.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			260.25f,
+			561.746f,
+			260.25f,
+			561.742f,
+			259.09f,
+			560.711f,
+			259.25f,
+			561.746f,
+			259.176f,
+			563.086f,
+			278.793f,
+			578.43f,
+			288.246f,
+			580.75f,
+			288.246f,
+			580.75f,
+			270.656f,
+			572.238f,
+			260.25f,
+			561.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			11,
+			225.25f,
+			398.746f,
+			225.25f,
+			398.742f,
+			208.34f,
+			401.355f,
+			227.25f,
+			402.75f,
+			227.25f,
+			402.75f,
+			246.617f,
+			405.316f,
+			251.25f,
+			410.75f,
+			251.25f,
+			410.75f,
+			265.977f,
+			421.156f,
+			269.246f,
+			421.75f,
+			272.137f,
+			422.035f,
+			290.18f,
+			425.996f,
+			290.246f,
+			428.75f,
+			291.059f,
+			431.277f,
+			297.656f,
+			433.918f,
+			299.246f,
+			432.75f,
+			301.18f,
+			432.156f,
+			301.18f,
+			422.035f,
+			298.246f,
+			420.746f,
+			295.02f,
+			420.277f,
+			274.34f,
+			412.355f,
+			267.246f,
+			410.75f,
+			260.258f,
+			409.719f,
+			247.5f,
+			401.355f,
+			242.246f,
+			399.75f,
+			236.938f,
+			398.719f,
+			225.25f,
+			398.746f,
+			225.25f,
+			398.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			11,
+			305.25f,
+			439.75f,
+			305.25f,
+			439.75f,
+			302.059f,
+			438.098f,
+			300.246f,
+			434.746f,
+			300.246f,
+			434.746f,
+			293.699f,
+			423.578f,
+			278.246f,
+			419.75f,
+			278.246f,
+			419.75f,
+			252.777f,
+			410.156f,
+			244.246f,
+			407.746f,
+			244.246f,
+			407.742f,
+			229.457f,
+			402.457f,
+			221.246f,
+			403.746f,
+			221.246f,
+			403.746f,
+			213.617f,
+			403.117f,
+			220.246f,
+			401.746f,
+			220.246f,
+			401.746f,
+			242.656f,
+			403.559f,
+			246.246f,
+			405.746f,
+			246.242f,
+			405.742f,
+			263.559f,
+			411.258f,
+			267.246f,
+			413.75f,
+			270.156f,
+			416.977f,
+			290.18f,
+			422.477f,
+			292.25f,
+			424.75f,
+			295.02f,
+			426.879f,
+			305.797f,
+			436.117f,
+			305.25f,
+			439.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			241.25f,
+			404.75f,
+			241.25f,
+			404.75f,
+			246.52f,
+			405.445f,
+			245.246f,
+			403.746f,
+			243.984f,
+			402.035f,
+			241.25f,
+			402.75f,
+			241.25f,
+			402.75f,
+			241.25f,
+			404.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			233.246f,
+			403.746f,
+			233.246f,
+			403.746f,
+			238.598f,
+			403.957f,
+			237.25f,
+			402.75f,
+			236.063f,
+			400.547f,
+			233.246f,
+			401.746f,
+			233.246f,
+			401.746f,
+			233.246f,
+			403.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			221.246f,
+			402.75f,
+			221.246f,
+			402.75f,
+			227.125f,
+			402.586f,
+			226.25f,
+			400.75f,
+			224.59f,
+			399.176f,
+			222.246f,
+			399.75f,
+			222.246f,
+			399.75f,
+			221.246f,
+			402.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			213.246f,
+			401.746f,
+			213.242f,
+			401.746f,
+			218.73f,
+			401.984f,
+			217.25f,
+			400.75f,
+			216.191f,
+			398.578f,
+			213.246f,
+			399.75f,
+			213.246f,
+			399.75f,
+			213.246f,
+			401.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			259.25f,
+			413.75f,
+			259.25f,
+			413.75f,
+			266.609f,
+			413.664f,
+			265.246f,
+			411.746f,
+			263.234f,
+			409.129f,
+			259.25f,
+			410.75f,
+			259.25f,
+			410.75f,
+			259.25f,
+			413.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			270.25f,
+			417.75f,
+			270.25f,
+			417.75f,
+			276.855f,
+			421.832f,
+			276.246f,
+			416.746f,
+			275.973f,
+			413.453f,
+			271.25f,
+			415.75f,
+			271.25f,
+			415.75f,
+			270.25f,
+			417.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			280.246f,
+			421.75f,
+			280.242f,
+			421.75f,
+			288.223f,
+			425.367f,
+			286.246f,
+			419.75f,
+			285.457f,
+			416.664f,
+			281.25f,
+			418.746f,
+			281.25f,
+			418.746f,
+			280.246f,
+			421.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			291.246f,
+			426.75f,
+			291.242f,
+			426.75f,
+			295.605f,
+			431.996f,
+			297.246f,
+			424.75f,
+			297.227f,
+			421.875f,
+			291.246f,
+			423.746f,
+			291.246f,
+			423.746f,
+			291.246f,
+			426.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			249.25f,
+			408.75f,
+			249.25f,
+			408.75f,
+			255.266f,
+			408.652f,
+			254.246f,
+			406.75f,
+			252.73f,
+			405.242f,
+			250.25f,
+			405.746f,
+			250.25f,
+			405.746f,
+			249.25f,
+			408.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			288.246f,
+			541.746f,
+			288.246f,
+			541.742f,
+			287.875f,
+			541.203f,
+			288.246f,
+			542.75f,
+			287.875f,
+			543.559f,
+			307.109f,
+			558.148f,
+			317.25f,
+			559.746f,
+			317.25f,
+			559.746f,
+			299.125f,
+			552.27f,
+			288.246f,
+			541.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			288.246f,
+			541.746f,
+			288.246f,
+			541.742f,
+			287.875f,
+			541.203f,
+			288.246f,
+			542.75f,
+			287.875f,
+			543.559f,
+			307.109f,
+			558.148f,
+			317.25f,
+			559.746f,
+			317.25f,
+			559.746f,
+			299.125f,
+			552.27f,
+			288.246f,
+			541.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			10,
+			292.25f,
+			471.746f,
+			292.25f,
+			471.742f,
+			316.141f,
+			447.117f,
+			326.25f,
+			442.746f,
+			326.25f,
+			442.742f,
+			336.379f,
+			430.836f,
+			332.246f,
+			401.746f,
+			332.246f,
+			401.746f,
+			328.461f,
+			393.879f,
+			325.25f,
+			416.746f,
+			325.25f,
+			416.742f,
+			328.461f,
+			444.477f,
+			316.25f,
+			426.75f,
+			316.25f,
+			426.75f,
+			306.898f,
+			437.766f,
+			314.25f,
+			437.75f,
+			314.25f,
+			437.75f,
+			317.461f,
+			435.238f,
+			318.25f,
+			436.746f,
+			318.34f,
+			438.758f,
+			309.539f,
+			453.719f,
+			290.246f,
+			469.746f,
+			271.699f,
+			485.398f,
+			292.25f,
+			471.746f,
+			292.25f,
+			471.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			227.25f,
+			428.75f,
+			227.25f,
+			428.75f,
+			227.477f,
+			431.059f,
+			229.25f,
+			429.746f,
+			231.438f,
+			429.297f,
+			335.059f,
+			422.477f,
+			370.25f,
+			395.75f,
+			370.25f,
+			395.75f,
+			320.098f,
+			421.598f,
+			227.25f,
+			428.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			227.25f,
+			428.75f,
+			227.25f,
+			428.75f,
+			227.477f,
+			431.059f,
+			229.25f,
+			429.746f,
+			231.438f,
+			429.297f,
+			335.059f,
+			422.477f,
+			370.25f,
+			395.75f,
+			370.25f,
+			395.75f,
+			320.098f,
+			421.598f,
+			227.25f,
+			428.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			239.25f,
+			433.746f,
+			239.25f,
+			433.742f,
+			238.918f,
+			435.898f,
+			241.25f,
+			434.746f,
+			242.879f,
+			434.137f,
+			393.141f,
+			435.238f,
+			419.246f,
+			399.75f,
+			419.246f,
+			399.75f,
+			394.898f,
+			427.316f,
+			239.25f,
+			433.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			239.25f,
+			433.746f,
+			239.25f,
+			433.742f,
+			238.918f,
+			435.898f,
+			241.25f,
+			434.746f,
+			242.879f,
+			434.137f,
+			393.141f,
+			435.238f,
+			419.246f,
+			399.75f,
+			419.246f,
+			399.75f,
+			394.898f,
+			427.316f,
+			239.25f,
+			433.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			252.25f,
+			438.746f,
+			252.25f,
+			438.742f,
+			251.68f,
+			440.297f,
+			253.246f,
+			439.75f,
+			255.637f,
+			438.535f,
+			446.379f,
+			452.836f,
+			472.25f,
+			416.746f,
+			472.25f,
+			416.742f,
+			461.777f,
+			445.355f,
+			252.25f,
+			438.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			252.25f,
+			438.746f,
+			252.25f,
+			438.742f,
+			251.68f,
+			440.297f,
+			253.246f,
+			439.75f,
+			255.637f,
+			438.535f,
+			446.379f,
+			452.836f,
+			472.25f,
+			416.746f,
+			472.25f,
+			416.742f,
+			461.777f,
+			445.355f,
+			252.25f,
+			438.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			263.25f,
+			443.75f,
+			263.25f,
+			443.75f,
+			262.68f,
+			445.578f,
+			264.246f,
+			444.746f,
+			266.637f,
+			443.816f,
+			401.059f,
+			486.277f,
+			427.25f,
+			450.75f,
+			427.25f,
+			450.75f,
+			412.277f,
+			477.699f,
+			263.25f,
+			443.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			263.25f,
+			443.75f,
+			263.25f,
+			443.75f,
+			262.68f,
+			445.578f,
+			264.246f,
+			444.746f,
+			266.637f,
+			443.816f,
+			401.059f,
+			486.277f,
+			427.25f,
+			450.75f,
+			427.25f,
+			450.75f,
+			412.277f,
+			477.699f,
+			263.25f,
+			443.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			199.246f,
+			418.746f,
+			199.246f,
+			418.742f,
+			198.879f,
+			420.496f,
+			201.246f,
+			419.75f,
+			202.84f,
+			418.738f,
+			222.418f,
+			416.316f,
+			224.246f,
+			373.75f,
+			224.242f,
+			373.75f,
+			216.699f,
+			419.836f,
+			199.246f,
+			418.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			199.246f,
+			418.746f,
+			199.246f,
+			418.742f,
+			198.879f,
+			420.496f,
+			201.246f,
+			419.75f,
+			202.84f,
+			418.738f,
+			222.418f,
+			416.316f,
+			224.246f,
+			373.75f,
+			224.242f,
+			373.75f,
+			216.699f,
+			419.836f,
+			199.246f,
+			418.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			189.246f,
+			416.746f,
+			189.246f,
+			416.742f,
+			189.199f,
+			418.738f,
+			191.246f,
+			417.75f,
+			193.156f,
+			416.977f,
+			208.777f,
+			422.035f,
+			205.25f,
+			379.746f,
+			205.25f,
+			379.746f,
+			207.02f,
+			418.078f,
+			189.246f,
+			416.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			189.246f,
+			416.746f,
+			189.246f,
+			416.742f,
+			189.199f,
+			418.738f,
+			191.246f,
+			417.75f,
+			193.156f,
+			416.977f,
+			208.777f,
+			422.035f,
+			205.25f,
+			379.746f,
+			205.25f,
+			379.746f,
+			207.02f,
+			418.078f,
+			189.246f,
+			416.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			180.246f,
+			416.746f,
+			180.242f,
+			416.742f,
+			180.398f,
+			418.297f,
+			182.25f,
+			417.75f,
+			184.359f,
+			416.535f,
+			201.297f,
+			415.879f,
+			187.246f,
+			390.746f,
+			187.246f,
+			390.746f,
+			198.219f,
+			417.637f,
+			180.246f,
+			416.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			180.246f,
+			416.746f,
+			180.242f,
+			416.742f,
+			180.398f,
+			418.297f,
+			182.25f,
+			417.75f,
+			184.359f,
+			416.535f,
+			201.297f,
+			415.879f,
+			187.246f,
+			390.746f,
+			187.246f,
+			390.746f,
+			198.219f,
+			417.637f,
+			180.246f,
+			416.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			232.246f,
+			464.746f,
+			232.246f,
+			464.742f,
+			232.187f,
+			462.887f,
+			234.246f,
+			463.75f,
+			251.566f,
+			478.113f,
+			287.254f,
+			542.906f,
+			348.25f,
+			548.746f,
+			348.25f,
+			548.746f,
+			306.367f,
+			562.426f,
+			232.246f,
+			464.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			232.246f,
+			464.746f,
+			232.246f,
+			464.742f,
+			232.187f,
+			462.887f,
+			234.246f,
+			463.75f,
+			251.566f,
+			478.113f,
+			287.254f,
+			542.906f,
+			348.25f,
+			548.746f,
+			348.25f,
+			548.746f,
+			306.367f,
+			562.426f,
+			232.246f,
+			464.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			245.246f,
+			466.746f,
+			245.246f,
+			466.742f,
+			243.496f,
+			468.379f,
+			245.246f,
+			468.75f,
+			247.605f,
+			469.754f,
+			371.293f,
+			549.508f,
+			414.25f,
+			540.75f,
+			414.25f,
+			540.75f,
+			384.688f,
+			549.004f,
+			245.246f,
+			466.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			245.246f,
+			466.746f,
+			245.246f,
+			466.742f,
+			243.496f,
+			468.379f,
+			245.246f,
+			468.75f,
+			247.605f,
+			469.754f,
+			371.293f,
+			549.508f,
+			414.25f,
+			540.75f,
+			414.25f,
+			540.75f,
+			384.688f,
+			549.004f,
+			245.246f,
+			466.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			222.246f,
+			460.746f,
+			222.246f,
+			460.742f,
+			221.512f,
+			458.594f,
+			223.246f,
+			459.75f,
+			233.266f,
+			465.301f,
+			237.242f,
+			528.234f,
+			285.25f,
+			529.75f,
+			285.25f,
+			529.75f,
+			249.523f,
+			545.801f,
+			222.246f,
+			460.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			222.246f,
+			460.746f,
+			222.246f,
+			460.742f,
+			221.512f,
+			458.594f,
+			223.246f,
+			459.75f,
+			233.266f,
+			465.301f,
+			237.242f,
+			528.234f,
+			285.25f,
+			529.75f,
+			285.25f,
+			529.75f,
+			249.523f,
+			545.801f,
+			222.246f,
+			460.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			200.246f,
+			447.746f,
+			200.246f,
+			447.746f,
+			198.973f,
+			446.812f,
+			201.246f,
+			446.75f,
+			212.391f,
+			448.555f,
+			235.937f,
+			493.953f,
+			285.25f,
+			488.746f,
+			285.25f,
+			488.742f,
+			249.656f,
+			504.148f,
+			200.246f,
+			447.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			200.246f,
+			447.746f,
+			200.246f,
+			447.746f,
+			198.973f,
+			446.812f,
+			201.246f,
+			446.75f,
+			212.391f,
+			448.555f,
+			235.937f,
+			493.953f,
+			285.25f,
+			488.746f,
+			285.25f,
+			488.742f,
+			249.656f,
+			504.148f,
+			200.246f,
+			447.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			212.246f,
+			454.75f,
+			212.246f,
+			454.75f,
+			211.625f,
+			453.348f,
+			213.246f,
+			453.746f,
+			224.461f,
+			457.637f,
+			238.852f,
+			506.711f,
+			288.246f,
+			510.746f,
+			288.246f,
+			510.742f,
+			250.363f,
+			519.348f,
+			212.246f,
+			454.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			212.246f,
+			454.75f,
+			212.246f,
+			454.75f,
+			211.625f,
+			453.348f,
+			213.246f,
+			453.746f,
+			224.461f,
+			457.637f,
+			238.852f,
+			506.711f,
+			288.246f,
+			510.746f,
+			288.246f,
+			510.742f,
+			250.363f,
+			519.348f,
+			212.246f,
+			454.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			192.25f,
+			442.746f,
+			192.25f,
+			442.742f,
+			191.453f,
+			441.449f,
+			193.25f,
+			441.75f,
+			202.32f,
+			442.863f,
+			221.395f,
+			479.633f,
+			261.25f,
+			474.75f,
+			261.25f,
+			474.75f,
+			232.508f,
+			487.891f,
+			192.25f,
+			442.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			192.25f,
+			442.746f,
+			192.25f,
+			442.742f,
+			191.453f,
+			441.449f,
+			193.25f,
+			441.75f,
+			202.32f,
+			442.863f,
+			221.395f,
+			479.633f,
+			261.25f,
+			474.75f,
+			261.25f,
+			474.75f,
+			232.508f,
+			487.891f,
+			192.25f,
+			442.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			184.25f,
+			435.75f,
+			184.25f,
+			435.75f,
+			182.949f,
+			434.945f,
+			184.25f,
+			434.746f,
+			189.281f,
+			435.414f,
+			222.984f,
+			471.801f,
+			243.246f,
+			454.75f,
+			243.246f,
+			454.75f,
+			230.082f,
+			475.344f,
+			184.25f,
+			435.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			184.25f,
+			435.75f,
+			184.25f,
+			435.75f,
+			182.949f,
+			434.945f,
+			184.25f,
+			434.746f,
+			189.281f,
+			435.414f,
+			222.984f,
+			471.801f,
+			243.246f,
+			454.75f,
+			243.246f,
+			454.75f,
+			230.082f,
+			475.344f,
+			184.25f,
+			435.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			260.25f,
+			470.75f,
+			260.25f,
+			470.75f,
+			259.219f,
+			472.699f,
+			261.25f,
+			472.75f,
+			263.469f,
+			473.547f,
+			396.242f,
+			537.031f,
+			438.25f,
+			522.746f,
+			438.25f,
+			522.746f,
+			409.465f,
+			534.84f,
+			260.25f,
+			470.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			260.25f,
+			470.75f,
+			260.25f,
+			470.75f,
+			259.219f,
+			472.699f,
+			261.25f,
+			472.75f,
+			263.469f,
+			473.547f,
+			396.242f,
+			537.031f,
+			438.25f,
+			522.746f,
+			438.25f,
+			522.746f,
+			409.465f,
+			534.84f,
+			260.25f,
+			470.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			223.246f,
+			400.75f,
+			223.246f,
+			400.75f,
+			223.52f,
+			402.457f,
+			225.25f,
+			401.746f,
+			227.477f,
+			400.695f,
+			244.418f,
+			400.035f,
+			231.246f,
+			375.75f,
+			231.246f,
+			375.75f,
+			241.34f,
+			401.797f,
+			223.246f,
+			400.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			223.246f,
+			400.75f,
+			223.246f,
+			400.75f,
+			223.52f,
+			402.457f,
+			225.25f,
+			401.746f,
+			227.477f,
+			400.695f,
+			244.418f,
+			400.035f,
+			231.246f,
+			375.75f,
+			231.246f,
+			375.75f,
+			241.34f,
+			401.797f,
+			223.246f,
+			400.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			235.246f,
+			401.746f,
+			235.242f,
+			401.746f,
+			234.957f,
+			404.219f,
+			237.25f,
+			403.746f,
+			238.918f,
+			402.457f,
+			258.5f,
+			400.035f,
+			260.25f,
+			357.746f,
+			260.25f,
+			357.746f,
+			252.777f,
+			403.559f,
+			235.246f,
+			401.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			235.246f,
+			401.746f,
+			235.242f,
+			401.746f,
+			234.957f,
+			404.219f,
+			237.25f,
+			403.746f,
+			238.918f,
+			402.457f,
+			258.5f,
+			400.035f,
+			260.25f,
+			357.746f,
+			260.25f,
+			357.746f,
+			252.777f,
+			403.559f,
+			235.246f,
+			401.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			242.246f,
+			403.746f,
+			242.246f,
+			403.746f,
+			242.437f,
+			405.977f,
+			244.246f,
+			404.75f,
+			246.398f,
+			404.219f,
+			273.457f,
+			400.477f,
+			299.246f,
+			364.75f,
+			299.246f,
+			364.75f,
+			260.258f,
+			405.316f,
+			242.246f,
+			403.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			242.246f,
+			403.746f,
+			242.246f,
+			403.746f,
+			242.437f,
+			405.977f,
+			244.246f,
+			404.75f,
+			246.398f,
+			404.219f,
+			273.457f,
+			400.477f,
+			299.246f,
+			364.75f,
+			299.246f,
+			364.75f,
+			260.258f,
+			405.316f,
+			242.246f,
+			403.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			251.25f,
+			405.746f,
+			251.25f,
+			405.742f,
+			250.566f,
+			408.164f,
+			252.25f,
+			407.746f,
+			254.723f,
+			406.945f,
+			277.199f,
+			409.031f,
+			319.25f,
+			371.75f,
+			319.25f,
+			371.75f,
+			268.316f,
+			409.875f,
+			251.25f,
+			405.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			251.25f,
+			405.746f,
+			251.25f,
+			405.742f,
+			250.566f,
+			408.164f,
+			252.25f,
+			407.746f,
+			254.723f,
+			406.945f,
+			277.199f,
+			409.031f,
+			319.25f,
+			371.75f,
+			319.25f,
+			371.75f,
+			268.316f,
+			409.875f,
+			251.25f,
+			405.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			262.25f,
+			410.75f,
+			262.25f,
+			410.75f,
+			262.004f,
+			413.004f,
+			264.246f,
+			412.746f,
+			266.164f,
+			411.785f,
+			304.48f,
+			406.832f,
+			361.25f,
+			368.746f,
+			361.25f,
+			368.746f,
+			279.754f,
+			414.715f,
+			262.25f,
+			410.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			262.25f,
+			410.75f,
+			262.25f,
+			410.75f,
+			262.004f,
+			413.004f,
+			264.246f,
+			412.746f,
+			266.164f,
+			411.785f,
+			304.48f,
+			406.832f,
+			361.25f,
+			368.746f,
+			361.25f,
+			368.746f,
+			279.754f,
+			414.715f,
+			262.25f,
+			410.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			218.25f,
+			423.746f,
+			218.25f,
+			423.746f,
+			217.797f,
+			425.777f,
+			220.246f,
+			424.75f,
+			221.758f,
+			424.016f,
+			280.5f,
+			421.156f,
+			314.25f,
+			391.75f,
+			314.25f,
+			391.75f,
+			275.547f,
+			418.93f,
+			218.25f,
+			423.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			218.25f,
+			423.746f,
+			218.25f,
+			423.746f,
+			217.797f,
+			425.777f,
+			220.246f,
+			424.75f,
+			221.758f,
+			424.016f,
+			280.5f,
+			421.156f,
+			314.25f,
+			391.75f,
+			314.25f,
+			391.75f,
+			275.547f,
+			418.93f,
+			218.25f,
+			423.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			207.25f,
+			419.75f,
+			207.25f,
+			419.75f,
+			206.797f,
+			421.379f,
+			209.246f,
+			420.746f,
+			210.758f,
+			419.617f,
+			237.816f,
+			415.879f,
+			264.246f,
+			379.746f,
+			264.246f,
+			379.746f,
+			224.617f,
+			420.719f,
+			207.25f,
+			419.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			207.25f,
+			419.75f,
+			207.25f,
+			419.75f,
+			206.797f,
+			421.379f,
+			209.246f,
+			420.746f,
+			210.758f,
+			419.617f,
+			237.816f,
+			415.879f,
+			264.246f,
+			379.746f,
+			264.246f,
+			379.746f,
+			224.617f,
+			420.719f,
+			207.25f,
+			419.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			274.25f,
+			415.75f,
+			274.25f,
+			415.75f,
+			273.828f,
+			418.031f,
+			276.246f,
+			417.75f,
+			278.066f,
+			417.125f,
+			316.645f,
+			414.992f,
+			376.246f,
+			380.75f,
+			376.246f,
+			380.75f,
+			290.746f,
+			418.625f,
+			274.25f,
+			415.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			274.25f,
+			415.75f,
+			274.25f,
+			415.75f,
+			273.828f,
+			418.031f,
+			276.246f,
+			417.75f,
+			278.066f,
+			417.125f,
+			316.645f,
+			414.992f,
+			376.246f,
+			380.75f,
+			376.246f,
+			380.75f,
+			290.746f,
+			418.625f,
+			274.25f,
+			415.75f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			283.25f,
+			418.746f,
+			283.25f,
+			418.742f,
+			283.07f,
+			420.672f,
+			285.25f,
+			419.75f,
+			287.309f,
+			419.762f,
+			325.883f,
+			417.633f,
+			385.25f,
+			383.746f,
+			385.25f,
+			383.742f,
+			300.648f,
+			421.703f,
+			283.25f,
+			418.746f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			283.25f,
+			418.746f,
+			283.25f,
+			418.742f,
+			283.07f,
+			420.672f,
+			285.25f,
+			419.75f,
+			287.309f,
+			419.762f,
+			325.883f,
+			417.633f,
+			385.25f,
+			383.746f,
+			385.25f,
+			383.742f,
+			300.648f,
+			421.703f,
+			283.25f,
+			418.746f,
+			10,
+			0,
+			1,
+			1,
+			1,
+			1,
+			1,
+			1,
+			5,
+			294.25f,
+			424.75f,
+			294.25f,
+			424.75f,
+			293.629f,
+			426.172f,
+			296.25f,
+			425.746f,
+			297.867f,
+			425.262f,
+			345.242f,
+			420.492f,
+			444.246f,
+			382.75f,
+			444.246f,
+			382.75f,
+			311.207f,
+			427.203f,
+			294.25f,
+			424.75f,
+			10,
+			0.11f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			5,
+			294.25f,
+			424.75f,
+			294.25f,
+			424.75f,
+			293.629f,
+			426.172f,
+			296.25f,
+			425.746f,
+			297.867f,
+			425.262f,
+			345.242f,
+			420.492f,
+			444.246f,
+			382.75f,
+			444.246f,
+			382.75f,
+			311.207f,
+			427.203f,
+			294.25f,
+			424.75f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			172.25f,
+			416.746f,
+			172.25f,
+			416.742f,
+			177.539f,
+			417.195f,
+			176.246f,
+			415.75f,
+			174.898f,
+			413.676f,
+			172.25f,
+			414.746f,
+			172.25f,
+			414.746f,
+			172.25f,
+			416.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			205.25f,
+			401.746f,
+			205.25f,
+			401.746f,
+			211.418f,
+			401.797f,
+			210.246f,
+			399.75f,
+			208.777f,
+			398.277f,
+			206.25f,
+			398.746f,
+			206.25f,
+			398.746f,
+			205.25f,
+			401.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			196.25f,
+			401.746f,
+			196.25f,
+			401.746f,
+			201.738f,
+			402.238f,
+			200.246f,
+			400.75f,
+			199.098f,
+			398.719f,
+			196.25f,
+			399.75f,
+			196.25f,
+			399.75f,
+			196.25f,
+			401.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			91.25f,
+			414.746f,
+			91.25f,
+			414.746f,
+			96.6602f,
+			413.344f,
+			95.25f,
+			411.746f,
+			93.0156f,
+			410.879f,
+			91.25f,
+			412.746f,
+			91.25f,
+			412.746f,
+			91.25f,
+			414.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			93.2461f,
+			425.746f,
+			93.2422f,
+			425.746f,
+			98.8633f,
+			423.902f,
+			97.25f,
+			422.746f,
+			95.2148f,
+			421.441f,
+			93.2461f,
+			422.746f,
+			93.2461f,
+			422.746f,
+			93.2461f,
+			425.746f,
+			10,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			4,
+			85.25f,
+			429.746f,
+			85.25f,
+			429.742f,
+			90.9414f,
+			428.742f,
+			89.2461f,
+			427.746f,
+			87.2969f,
+			426.281f,
+			85.25f,
+			427.746f,
+			85.25f,
+			427.746f,
+			85.25f,
+			429.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			173.25f,
+			347.75f,
+			173.25f,
+			347.75f,
+			171.379f,
+			347.676f,
+			167.25f,
+			345.75f,
+			164.777f,
+			345.477f,
+			152.457f,
+			341.516f,
+			146.25f,
+			330.746f,
+			146.25f,
+			330.742f,
+			159.938f,
+			341.078f,
+			173.25f,
+			347.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			9,
+			269.246f,
+			245.746f,
+			269.781f,
+			245.484f,
+			269.84f,
+			245.02f,
+			270.25f,
+			244.75f,
+			270.887f,
+			244.957f,
+			272.242f,
+			244.625f,
+			272.25f,
+			245.746f,
+			271.172f,
+			250.063f,
+			270.211f,
+			255.492f,
+			265.246f,
+			257.746f,
+			264.961f,
+			257.789f,
+			263.375f,
+			257.332f,
+			263.25f,
+			256.746f,
+			263.156f,
+			254.684f,
+			263.027f,
+			253.203f,
+			263.25f,
+			251.75f,
+			263.695f,
+			250.027f,
+			266.07f,
+			250.016f,
+			267.246f,
+			251.75f,
+			268.109f,
+			249.699f,
+			268.582f,
+			247.672f,
+			269.246f,
+			245.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			9,
+			257.246f,
+			240.75f,
+			258.262f,
+			239.004f,
+			258.121f,
+			236.961f,
+			259.25f,
+			236.746f,
+			260.492f,
+			236.016f,
+			262.527f,
+			237.09f,
+			262.25f,
+			238.746f,
+			261.188f,
+			240.539f,
+			260.758f,
+			243,
+			259.25f,
+			244.75f,
+			259.012f,
+			245.281f,
+			259.277f,
+			245.867f,
+			259.25f,
+			245.746f,
+			258.445f,
+			247.57f,
+			257.188f,
+			248.379f,
+			255.246f,
+			247.746f,
+			254.41f,
+			245.594f,
+			255.676f,
+			243.25f,
+			257.246f,
+			241.75f,
+			257.5f,
+			241.203f,
+			257.316f,
+			240.793f,
+			257.246f,
+			240.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			11,
+			214.25f,
+			246.746f,
+			213.758f,
+			246.684f,
+			213.719f,
+			247.191f,
+			214.25f,
+			247.746f,
+			214.484f,
+			248.68f,
+			215.355f,
+			249.914f,
+			215.25f,
+			250.746f,
+			214.602f,
+			252.203f,
+			213.375f,
+			252,
+			212.246f,
+			251.75f,
+			211.41f,
+			250.281f,
+			211.355f,
+			248.273f,
+			210.246f,
+			246.746f,
+			210.379f,
+			246.355f,
+			210.438f,
+			245.723f,
+			210.246f,
+			245.746f,
+			209.43f,
+			244.832f,
+			208.945f,
+			243.152f,
+			209.246f,
+			242.75f,
+			209.109f,
+			242.18f,
+			208.91f,
+			231.281f,
+			209.246f,
+			231.75f,
+			209.836f,
+			232.379f,
+			213.188f,
+			243.086f,
+			213.246f,
+			243.75f,
+			213.328f,
+			244.871f,
+			214.133f,
+			245.383f,
+			214.25f,
+			246.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			7,
+			185.25f,
+			253.75f,
+			188.574f,
+			256.488f,
+			191.641f,
+			259.746f,
+			191.246f,
+			263.75f,
+			191.027f,
+			264.902f,
+			189.074f,
+			264.32f,
+			189.246f,
+			263.75f,
+			187.988f,
+			259.402f,
+			185.746f,
+			256.477f,
+			183.25f,
+			253.75f,
+			180.504f,
+			251.594f,
+			178.457f,
+			244.617f,
+			178.246f,
+			243.75f,
+			182.266f,
+			249.84f,
+			184.746f,
+			252.859f,
+			185.25f,
+			253.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			10,
+			170.246f,
+			260.746f,
+			171.32f,
+			260.707f,
+			170.988f,
+			261.246f,
+			171.246f,
+			261.746f,
+			172.273f,
+			263.215f,
+			173.707f,
+			264.586f,
+			173.25f,
+			266.746f,
+			173.73f,
+			266.805f,
+			173.313f,
+			267.145f,
+			173.25f,
+			266.746f,
+			172.641f,
+			266.695f,
+			172.262f,
+			266.551f,
+			172.25f,
+			266.746f,
+			169.91f,
+			263.715f,
+			168.371f,
+			260.777f,
+			167.25f,
+			257.746f,
+			166.582f,
+			257.289f,
+			165.324f,
+			252.352f,
+			165.246f,
+			251.75f,
+			165.934f,
+			252.133f,
+			167.824f,
+			256.734f,
+			168.25f,
+			256.746f,
+			169.445f,
+			257.613f,
+			169.457f,
+			259.391f,
+			170.246f,
+			260.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			189.246f,
+			238.746f,
+			189.641f,
+			239.758f,
+			191.371f,
+			241.078f,
+			191.246f,
+			241.75f,
+			191.117f,
+			243.078f,
+			191.633f,
+			244.664f,
+			190.246f,
+			243.75f,
+			189.246f,
+			242.867f,
+			185.453f,
+			241.383f,
+			185.25f,
+			234.746f,
+			185.129f,
+			234.363f,
+			188.398f,
+			237.328f,
+			189.246f,
+			238.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			19,
+			205.25f,
+			257.746f,
+			205.477f,
+			258.434f,
+			206.258f,
+			257.91f,
+			207.25f,
+			257.746f,
+			207.473f,
+			258.609f,
+			208.148f,
+			259.223f,
+			208.25f,
+			259.746f,
+			209.535f,
+			262.301f,
+			211.48f,
+			264.305f,
+			211.246f,
+			266.746f,
+			209.996f,
+			268.484f,
+			209.25f,
+			266.238f,
+			208.25f,
+			264.746f,
+			207.102f,
+			266.988f,
+			206.004f,
+			264.926f,
+			204.25f,
+			264.746f,
+			204.496f,
+			264.324f,
+			204.262f,
+			264.707f,
+			204.25f,
+			264.746f,
+			202.887f,
+			264.195f,
+			202.137f,
+			263.004f,
+			201.246f,
+			261.746f,
+			200.852f,
+			261.996f,
+			200.406f,
+			262.195f,
+			200.246f,
+			261.746f,
+			199.527f,
+			261.383f,
+			198.457f,
+			261.027f,
+			198.246f,
+			260.746f,
+			196.93f,
+			257.297f,
+			193.473f,
+			254.992f,
+			191.246f,
+			246.746f,
+			191.816f,
+			245.695f,
+			196.359f,
+			254.004f,
+			197.25f,
+			254.75f,
+			197.816f,
+			256.086f,
+			197.945f,
+			252.945f,
+			199.246f,
+			253.75f,
+			199.406f,
+			253.707f,
+			199.609f,
+			253.445f,
+			200.246f,
+			253.75f,
+			199.973f,
+			253.605f,
+			200.211f,
+			253.855f,
+			200.246f,
+			253.75f,
+			200.637f,
+			254.176f,
+			200.492f,
+			254.789f,
+			200.246f,
+			254.75f,
+			202.074f,
+			256.039f,
+			201.98f,
+			257.215f,
+			203.25f,
+			258.746f,
+			203.344f,
+			257.711f,
+			204.508f,
+			258.5f,
+			205.25f,
+			257.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			271.25f,
+			197.75f,
+			271.25f,
+			197.75f,
+			278.957f,
+			220.297f,
+			274.25f,
+			232.75f,
+			274.25f,
+			232.75f,
+			286.656f,
+			208.855f,
+			281.25f,
+			196.75f,
+			281.25f,
+			196.75f,
+			281.156f,
+			207.977f,
+			277.246f,
+			213.746f,
+			277.246f,
+			213.746f,
+			272.359f,
+			199.398f,
+			271.25f,
+			197.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			254.246f,
+			200.75f,
+			254.246f,
+			200.75f,
+			260.477f,
+			210.398f,
+			251.25f,
+			230.75f,
+			251.25f,
+			230.75f,
+			250.797f,
+			208.195f,
+			243.246f,
+			195.746f,
+			243.246f,
+			195.742f,
+			258.937f,
+			218.316f,
+			254.246f,
+			200.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			243.246f,
+			202.746f,
+			243.246f,
+			202.746f,
+			243.316f,
+			224.918f,
+			244.246f,
+			227.746f,
+			244.246f,
+			227.742f,
+			239.578f,
+			209.957f,
+			228.25f,
+			199.75f,
+			228.25f,
+			199.75f,
+			244.199f,
+			212.598f,
+			243.246f,
+			202.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			233.246f,
+			237.746f,
+			233.246f,
+			237.746f,
+			239.578f,
+			223.156f,
+			228.25f,
+			202.746f,
+			228.25f,
+			202.746f,
+			235.617f,
+			216.336f,
+			230.25f,
+			223.746f,
+			230.25f,
+			223.746f,
+			233.199f,
+			227.777f,
+			233.246f,
+			237.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			8,
+			212.246f,
+			203.746f,
+			212.246f,
+			203.746f,
+			210.758f,
+			220.516f,
+			212.246f,
+			222.75f,
+			212.246f,
+			222.75f,
+			212.957f,
+			229.977f,
+			212.246f,
+			230.75f,
+			212.246f,
+			230.75f,
+			216.918f,
+			237.898f,
+			217.25f,
+			229.75f,
+			217.25f,
+			229.75f,
+			218.68f,
+			221.176f,
+			222.246f,
+			215.746f,
+			222.246f,
+			215.746f,
+			225.719f,
+			210.176f,
+			225.25f,
+			202.746f,
+			225.25f,
+			202.746f,
+			214.5f,
+			236.355f,
+			212.246f,
+			203.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			208.25f,
+			233.75f,
+			208.25f,
+			233.75f,
+			200.637f,
+			221.836f,
+			198.246f,
+			200.75f,
+			198.246f,
+			200.75f,
+			197.117f,
+			207.758f,
+			201.246f,
+			223.746f,
+			201.246f,
+			223.746f,
+			205.918f,
+			240.535f,
+			208.25f,
+			233.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			184.25f,
+			211.75f,
+			184.25f,
+			211.75f,
+			189.418f,
+			217.879f,
+			191.246f,
+			223.746f,
+			191.242f,
+			223.746f,
+			194.918f,
+			240.758f,
+			188.246f,
+			231.75f,
+			188.246f,
+			231.75f,
+			188.098f,
+			222.496f,
+			179.246f,
+			214.746f,
+			179.246f,
+			214.746f,
+			184.359f,
+			216.996f,
+			184.25f,
+			211.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			177.246f,
+			217.746f,
+			177.246f,
+			217.742f,
+			181.277f,
+			236.578f,
+			182.25f,
+			237.746f,
+			182.25f,
+			237.746f,
+			184.137f,
+			241.195f,
+			181.25f,
+			237.746f,
+			181.25f,
+			237.746f,
+			171.379f,
+			216.559f,
+			167.25f,
+			209.75f,
+			167.25f,
+			209.75f,
+			175.777f,
+			219.418f,
+			177.246f,
+			217.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			4,
+			171.246f,
+			235.746f,
+			171.246f,
+			235.746f,
+			183.918f,
+			260.336f,
+			160.246f,
+			231.75f,
+			160.246f,
+			231.75f,
+			172.039f,
+			242.738f,
+			171.246f,
+			235.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			6,
+			154.246f,
+			251.75f,
+			154.242f,
+			251.75f,
+			159.5f,
+			272.438f,
+			162.25f,
+			271.746f,
+			162.25f,
+			271.746f,
+			171.379f,
+			282.117f,
+			164.246f,
+			270.75f,
+			164.242f,
+			270.75f,
+			157.52f,
+			259.898f,
+			158.25f,
+			248.746f,
+			158.25f,
+			248.746f,
+			157.52f,
+			259.676f,
+			154.246f,
+			251.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			517.246f,
+			264.746f,
+			517.242f,
+			264.742f,
+			504.348f,
+			275.297f,
+			501.25f,
+			278.75f,
+			501.25f,
+			278.75f,
+			516.449f,
+			258.797f,
+			516.25f,
+			250.746f,
+			516.25f,
+			250.742f,
+			519.199f,
+			259.348f,
+			517.246f,
+			264.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			523.25f,
+			288.746f,
+			523.25f,
+			288.742f,
+			500.5f,
+			305,
+			496.25f,
+			312.75f,
+			496.25f,
+			312.75f,
+			525.797f,
+			280.797f,
+			526.246f,
+			275.746f,
+			526.242f,
+			275.742f,
+			526.348f,
+			285.75f,
+			523.25f,
+			288.746f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			5,
+			542.246f,
+			457.75f,
+			542.246f,
+			457.75f,
+			529.098f,
+			466.699f,
+			527.25f,
+			464.746f,
+			527.25f,
+			464.742f,
+			539,
+			457.348f,
+			542.246f,
+			447.746f,
+			542.246f,
+			447.746f,
+			540.098f,
+			457.898f,
+			542.246f,
+			457.75f,
+			10,
+			0,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			0.8f,
+			4,
+			551.25f,
+			369.75f,
+			532.25f,
+			382.75f,
+			532.25f,
+			382.75f,
+			553.297f,
+			363.848f,
+			554.25f,
+			359.746f,
+			551.25f,
+			369.75f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			2,
+			122.246f,
+			393.75f,
+			146.25f,
+			388.75f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			2,
+			177.246f,
+			215.746f,
+			177.246f,
+			215.746f,
+			176.547f,
+			219.75f,
+			166.246f,
+			207.75f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			2,
+			183.25f,
+			210.75f,
+			183.25f,
+			210.75f,
+			185.348f,
+			217.547f,
+			178.246f,
+			212.746f,
+			10,
+			1.1f,
+			0,
+			0,
+			0,
+			0,
+			0,
+			0,
+			2,
+			242.246f,
+			200.75f,
+			242.246f,
+			200.75f,
+			244.199f,
+			213.148f,
+			231.246f,
+			198.75f
+	};
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/src/tigerApp.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of CTigerApp
+*/
+
+// INCLUDE FILES
+#include    <eikstart.h>
+#include    "TigerApp.h"
+#include    "TigerDocument.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTigerApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CTigerApp::AppDllUid() const
+    {
+    return KUidTiger;
+    }
+
+
+// ---------------------------------------------------------
+// CTigerApp::CreateDocumentL()
+// Creates CTigerDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CTigerApp::CreateDocumentL()
+    {
+    return CTigerDocument::NewL( *this );
+    }
+
+
+// ================= OTHER EXPORTED FUNCTIONS ==============
+
+
+CApaApplication* NewApplication()
+    {
+    return new CTigerApp;
+    }
+
+TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/src/tigerAppUi.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of CTigerAppUi class
+*/
+
+
+// INCLUDE FILES
+#include "TigerAppUi.h"
+#include "TigerContainer.h"
+#include <Tiger.rsg>
+#include "Tiger.hrh"
+
+#include <avkon.hrh>
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CTigerAppUi::ConstructL()
+// ----------------------------------------------------------
+//
+void CTigerAppUi::ConstructL()
+    {
+    BaseConstructL();
+    iAppContainer = new (ELeave) CTigerContainer;
+    iAppContainer->SetMopParent(this);
+    iAppContainer->ConstructL( ClientRect() );
+    AddToStackL( iAppContainer );
+    }
+
+// ----------------------------------------------------
+// CTigerAppUi::~CTigerAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CTigerAppUi::~CTigerAppUi()
+{
+    if ( iAppContainer )
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+}
+
+// ------------------------------------------------------------------------------
+// CTigerAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
+//  This function is called by the EIKON framework just before it displays
+//  a menu pane. Its default implementation is empty, and by overriding it,
+//  the application can set the state of menu items dynamically according
+//  to the state of application data.
+// ------------------------------------------------------------------------------
+//
+void CTigerAppUi::DynInitMenuPaneL(
+    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
+    {
+    }
+
+// ----------------------------------------------------
+// CTigerAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// Key event handler
+// ----------------------------------------------------
+//
+TKeyResponse CTigerAppUi::HandleKeyEventL(
+    const TKeyEvent& /*aKeyEvent*/ ,TEventCode /*aType*/)
+{
+    return EKeyWasNotConsumed;
+}
+
+// ----------------------------------------------------
+// CTigerAppUi::HandleCommandL(TInt aCommand)
+// Command handler
+// ----------------------------------------------------
+//
+void CTigerAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }
+        default:
+            break;
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/src/tigerContainer.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of CTigerContainer class
+*/
+
+
+// INCLUDE FILES
+#include "TigerContainer.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTigerContainer::ConstructL(const TRect& aRect)
+// EPOC two phased constructor
+// ---------------------------------------------------------
+//
+void CTigerContainer::ConstructL(const TRect& /*aRect*/)
+    {
+//    iOpenGlInitialized = EFalse;
+    CreateWindowL();
+
+    SetExtentToWholeScreen();                // Take the whole screen into use
+    ActivateL();
+            
+    TSize size;
+    size = this->Size();
+
+    iTiger = CTiger::NewL(size.iWidth, size.iHeight ); // Create an instance of Tiger
+    
+    iTiger->AppInit(Window());
+    
+    return;
+    }
+
+// Destructor
+CTigerContainer::~CTigerContainer()
+    {
+    /* AppExit call is made to release
+       any allocations made in AppInit. */
+    if ( iTiger )
+        {
+        iTiger->AppExit();
+        delete iTiger;
+        }
+    }
+
+// ---------------------------------------------------------
+// CTigerContainer::SizeChanged()
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CTigerContainer::SizeChanged()
+    {
+    if( iTiger )
+        {
+        TSize size;
+        size = this->Size();
+        iTiger->SetScreenSize( size.iWidth, size.iHeight );
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CTigerContainer::HandleResourceChange(
+//     TInt aType)
+// Dynamic screen resize changes by calling the
+// SetExtentToWholeScreen() method again.
+// ---------------------------------------------------------
+//
+ void CTigerContainer::HandleResourceChange(TInt aType)
+    {
+	switch( aType )
+    	{
+	    case KEikDynamicLayoutVariantSwitch:
+		    SetExtentToWholeScreen();
+		    break;
+	    }
+    }
+
+// ---------------------------------------------------------
+// CTigerContainer::CountComponentControls() const
+// ---------------------------------------------------------
+//
+TInt CTigerContainer::CountComponentControls() const
+    {
+    return 0;
+    }
+
+// ---------------------------------------------------------
+// CTigerContainer::ComponentControl(TInt aIndex) const
+// ---------------------------------------------------------
+//
+CCoeControl* CTigerContainer::ComponentControl(TInt /*aIndex*/ ) const
+    {
+    return NULL;
+    }
+
+// ---------------------------------------------------------
+// CTigerContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CTigerContainer::Draw(const TRect& aRect ) const
+    {
+    
+    CWindowGc& gc = SystemGc();
+    TRgb color(KRgbRed);
+    gc.SetBrushColor(color);
+	gc.SetPenStyle(CGraphicsContext::ENullPen);
+	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
+	gc.DrawRect(Rect());
+	
+	//set up destination CFbsBitmap object
+	CFbsBitmap* bitmap=NULL;
+	TRAPD(err, bitmap = new(ELeave)CFbsBitmap;);
+	if(bitmap)
+		{
+		const TDisplayMode dispMode = Window().DisplayMode();
+			//copy from source (EGL) to target(CFbsBitmap) buffer
+		iTiger->AppRender(aRect, bitmap);		
+		RenderBitmap(gc, bitmap);
+		delete bitmap;
+		}
+	}
+
+void  CTigerContainer::RenderBitmap(CWindowGc& aGc, CFbsBitmap* aBitmap) const
+	{
+	//draw bitmap
+	// calculate position for top left of bitmap so it is centered
+	TSize bmpSizeInPixels=aBitmap->SizeInPixels();
+	TRect rect=Rect(); // a centered rectangle of the default size
+	TInt xDelta=(rect.Width()-bmpSizeInPixels.iWidth)/2;
+	TInt yDelta=(rect.Height()-bmpSizeInPixels.iHeight)/2;
+	TPoint pos=TPoint(xDelta,yDelta); // displacement vector
+	pos+=rect.iTl; // bitmap top left corner position
+	aGc.BitBlt(pos, aBitmap); // CWindowGc member function	
+	}
+
+
+
+// ---------------------------------------------------------
+// CTigerContainer::HandleControlEventL(
+//     CCoeControl* aControl,TCoeEvent aEventType)
+// ---------------------------------------------------------
+//
+void CTigerContainer::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/test/src/tigerDocument.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of CTigerDocument class
+*/
+
+
+// INCLUDE FILES
+#include "TigerDocument.h"
+#include "TigerAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CTigerDocument::CTigerDocument
+//
+// Just calls the base class constructor.
+// -----------------------------------------------------------------------------
+//
+
+CTigerDocument::CTigerDocument(CEikApplication& aApp)
+: CAknDocument(aApp)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTigerDocument::~CTigerDocument
+//
+// Empty destructor.
+// -----------------------------------------------------------------------------
+//
+
+CTigerDocument::~CTigerDocument()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTigerDocument::ConstructL
+//
+// Empty 2nd phase constructor.
+// -----------------------------------------------------------------------------
+//
+
+void CTigerDocument::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTigerDocument::NewL
+//
+// -----------------------------------------------------------------------------
+//
+
+CTigerDocument* CTigerDocument::NewL(
+        CEikApplication& aApp)     // CTigerApp reference
+    {
+    CTigerDocument* self = new (ELeave) CTigerDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// ----------------------------------------------------
+// CTigerDocument::CreateAppUiL()
+// Constructs and returns a CTigerAppUi object.
+// ----------------------------------------------------
+//
+
+CEikAppUi* CTigerDocument::CreateAppUiL()
+    {
+    return new (ELeave) CTigerAppUi;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/vgi/vgi.cpp	Wed Jun 02 13:14:22 2010 +0100
@@ -0,0 +1,200 @@
+/*
+* Copyright (c) 2009 Symbian Foundation Ltd
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Symbian Foundation Ltd - initial contribution.
+* 
+* Contributors:
+*
+* Description:
+* Implementation of VGI interface
+*/
+
+#include <e32std.h>
+#include <vg\vgcontext.h>
+#include <vg\vgcontext_symbian.h>
+#include <egl.h>
+
+#define MAX_WIDTH 		640 //*4 // in bytes
+#define MAX_HEIGHT 		640 //*4 // in bytes
+class TEgl
+	{
+public:
+	TEgl() :
+	iEgldisplay(0),
+	iEglsurface(0),
+	iEglcontext(0),
+	iInitialised(EFalse),
+	iPixmap(NULL)
+	{};
+
+public: //data
+	EGLDisplay iEgldisplay;
+	EGLSurface iEglsurface;
+	EGLContext iEglcontext;
+	TBool iInitialised;
+	CFbsBitmap* iPixmap;
+	};
+
+
+TEgl& GetEglInstance()
+	{
+	//use TLS
+	//use TLS to store static global egl
+	TEgl* pEgl=NULL; 
+	if((pEgl = static_cast<TEgl*>(Dll::Tls()))==NULL)
+		{
+		//create TLS instance
+		pEgl = new(ELeave)TEgl;
+		Dll::SetTls(pEgl);
+		}
+	return *pEgl;
+	}
+
+void ReleaseTls()
+	{
+	TEgl* pEgl = static_cast<TEgl*>(Dll::Tls());
+	if (pEgl)
+		delete pEgl; 
+	Dll::SetTls(NULL);
+	}
+
+VGI_API_CALL int VGIInitialize( int /*width*/, int /*height*/, VGIColorSpace /*colorSpace*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL int VGIInitializeEx( int /*width*/, int /*height*/, VGIColorSpace /*colorSpace*/, int /*premultiplied*/, int /*conformant*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL int VGICopyToTarget( VGIColorBufferFormat /*format*/, int /*bufferStride*/, void */*buffer*/, int /*maskStride*/, void */*mask*/, VGICopyToTargetHint /*hint*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL void VGITerminate( void )
+	{
+
+	}
+
+VGI_API_CALL int VGIResize( int /*width*/, int /*height*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL int VGIBindToImage( VGImage /*image*/ )
+	{
+	return VGI_OK;
+	}	
+
+VGI_API_CALL int VGIUnBindImage( void )
+	{
+	return VGI_OK;
+	}
+
+
+
+VGI_API_CALL TInt VGISymbianInitialize( TSize aSize, VGIColorSpace /*aColorSpace*/ )
+	{
+	TEgl& egl = GetEglInstance();
+	//only init once
+	if(!egl.iInitialised)
+		{
+		egl.iInitialised = ETrue;
+		static const EGLint s_configAttribs[] =
+			{
+					EGL_RED_SIZE,
+					8,
+					EGL_GREEN_SIZE,
+					8,
+					EGL_BLUE_SIZE,
+					8,
+					EGL_ALPHA_SIZE,
+					8,
+					EGL_LUMINANCE_SIZE,
+					EGL_DONT_CARE, //EGL_DONT_CARE
+					EGL_SURFACE_TYPE,
+					EGL_WINDOW_BIT,
+					EGL_SAMPLES,
+					1,
+					EGL_NONE
+			};
+		EGLint numconfigs;
+		
+		egl.iEgldisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+		eglInitialize(egl.iEgldisplay, NULL, NULL);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+		eglBindAPI(EGL_OPENVG_API);
+		
+		EGLConfig  eglconfig;
+		
+		eglChooseConfig(egl.iEgldisplay, s_configAttribs, &eglconfig, 1, &numconfigs);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+		__ASSERT_ALWAYS(numconfigs == 1,User::Invariant());
+		
+		TSize maxSize(MAX_WIDTH,MAX_HEIGHT);
+		egl.iPixmap = new(ELeave) CFbsBitmap();
+		egl.iPixmap->Create( maxSize, EColor16MA );
+		 
+		egl.iEglsurface = eglCreatePixmapSurface(egl.iEgldisplay, eglconfig, (EGLNativePixmapType)egl.iPixmap, NULL);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+				
+		egl.iEglcontext = eglCreateContext(egl.iEgldisplay, eglconfig, NULL, NULL);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+		eglMakeCurrent(egl.iEgldisplay, egl.iEglsurface, egl.iEglsurface, egl.iEglcontext);
+		__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+	
+		}
+		return VGI_OK;
+	}
+
+VGI_API_CALL TInt VGISymbianInitializeEx( TSize /*aSize*/, VGIColorSpace /*aColorSpace*/, TBool /*aPremultiplied*/, TBool /*aConformant*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL TInt VGISymbianCopyToBitmap( CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, VGICopyToTargetHint /*aHint*/ )
+	{
+	TEgl& egl = GetEglInstance();	
+	
+	eglCopyBuffers(egl.iEgldisplay, egl.iEglsurface,(EGLNativePixmapType)aBitmap);
+	
+	if(aMaskBitmap)
+		{
+		eglCopyBuffers(egl.iEgldisplay, egl.iEglsurface,(EGLNativePixmapType)aMaskBitmap);		
+		}
+	
+	__ASSERT_ALWAYS(eglGetError() == EGL_SUCCESS,User::Invariant());
+	return VGI_OK;
+	}
+
+VGI_API_CALL void VGISymbianTerminate()
+{
+	TEgl& egl = GetEglInstance();
+	eglDestroyContext(egl.iEgldisplay, egl.iEglcontext);
+	eglDestroySurface(egl.iEgldisplay, egl.iEglsurface);
+	delete egl.iPixmap;
+	ReleaseTls();
+}
+
+VGI_API_CALL TInt VGISymbianResize( TSize aSize )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL TInt VGISymbianBindToImage( VGImage /*aImage*/ )
+	{
+	return VGI_OK;
+	}
+
+VGI_API_CALL TInt VGISymbianUnBindImage()
+	{
+	return VGI_OK;
+	}
+
--- a/windowing/windowserver/group/openwfc/WServ_nga.MMP	Thu May 27 14:13:51 2010 +0300
+++ b/windowing/windowserver/group/openwfc/WServ_nga.MMP	Wed Jun 02 13:14:22 2010 +0100
@@ -23,10 +23,10 @@
 TARGETTYPE        exe
 
 EPOCSTACKSIZE	  0x4000
-// 3Mb max heap for Winscw builds (default 1Mb used for target builds)
+// 6Mb max heap for Winscw builds (default 1Mb used for target builds)
 
 #ifdef WINS
-EPOCHEAPSIZE	    0x00010000 0x00300000
+EPOCHEAPSIZE	    0x00010000 0x00600000
 #endif
 EPOCFIXEDPROCESS
 CAPABILITY        PowerMgmt ReadDeviceData WriteDeviceData ProtServ
--- a/windowing/windowserver/nga/CLIENT/RWINDOW.CPP	Thu May 27 14:13:51 2010 +0300
+++ b/windowing/windowserver/nga/CLIENT/RWINDOW.CPP	Wed Jun 02 13:14:22 2010 +0100
@@ -1182,7 +1182,9 @@
 	__ASSERT_DEBUG(!aRegion.CheckError(),Panic(EW32PanicInvalidRegion));
 	const TInt regionCount=aRegion.Count();
 	TPtrC8 ptrRect(reinterpret_cast<const TUint8*>(aRegion.RectangleList()),regionCount*sizeof(TRect));
-	return(WriteReplyByProvidingRemoteReadAccess(&regionCount,sizeof(regionCount),&ptrRect,EWsWinOpSetShape));
+//	return(WriteReplyByProvidingRemoteReadAccess(&regionCount,sizeof(regionCount),&ptrRect,EWsWinOpSetShape));
+	RDebug::Printf("Bug 1863 - RWindowBase::SetShape() deprecated and non-functional. Disabling the panic.");
+	return KErrNone;
 	}
 
 /**