First drop of port from guestEGL ? enables ebt test drawing a line using composition EGL_MERGE
authorMartin Jakl <jakl.martin@cell-telecom.com>
Thu, 18 Nov 2010 23:28:27 +0000
branchEGL_MERGE
changeset 216 b87045f2f5d7
parent 212 a8e55d78eb52
child 217 205d3af68142
First drop of port from guestEGL ? enables ebt test drawing a line using composition
graphicscomposition/openwfcompositionengine/group/openwfc.mmp
graphicscomposition/openwfsupport/group/openwfc_interop.mmp
graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh
graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp
openvg/openvgrefimplementation/sfopenvg/bwins/sflibopenvgrefimplu.def
openvg/openvgrefimplementation/sfopenvg/group/egl.mmp
openvg/openvgrefimplementation/sfopenvg/group/sfopenvg.mmp
openvg/openvgrefimplementation/sfopenvg/sfopenvg/extensions/eglsync.cpp
openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/eglapi.h
openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/eglsync.h
openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.cpp
openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.h
openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/eglosnativewindowtype.h
openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/riEGLOS.cpp
--- a/graphicscomposition/openwfcompositionengine/group/openwfc.mmp	Tue Nov 02 08:37:41 2010 +0000
+++ b/graphicscomposition/openwfcompositionengine/group/openwfc.mmp	Thu Nov 18 23:28:27 2010 +0000
@@ -36,7 +36,6 @@
 
 MACRO			__KHR_EXPORTS
 TARGETTYPE		dll
-CAPABILITY		PowerMgmt ReadDeviceData WriteDeviceData ProtServ
 UID				0 KUidOpenWfcDllUidValue
 
 OS_LAYER_SYSTEMINCLUDE_SYMBIAN
@@ -95,3 +94,4 @@
 
 SMPSAFE
 
+CAPABILITY All -TCB
--- a/graphicscomposition/openwfsupport/group/openwfc_interop.mmp	Tue Nov 02 08:37:41 2010 +0000
+++ b/graphicscomposition/openwfsupport/group/openwfc_interop.mmp	Thu Nov 18 23:28:27 2010 +0000
@@ -16,7 +16,6 @@
 
 TARGET			wfcinterop.dll
 TARGETTYPE		dll
-CAPABILITY 		PowerMgmt ReadDeviceData WriteDeviceData ProtServ
 UID				0x1000008d 0x10286FC5
 VENDORID		0x70000001
 
@@ -44,3 +43,4 @@
 LIBRARY         hal.lib
 
 SMPSAFE
+CAPABILITY All -TCB
--- a/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh	Tue Nov 02 08:37:41 2010 +0000
+++ b/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmh	Thu Nov 18 23:28:27 2010 +0000
@@ -13,7 +13,6 @@
 // Description:
 //
 
-CAPABILITY PowerMgmt ReadDeviceData WriteDeviceData ProtServ
 targettype        DLL
 VENDORID 0x70000001
 
--- a/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp	Tue Nov 02 08:37:41 2010 +0000
+++ b/graphicscomposition/surfaceupdate/group/surfaceupdateserver.mmp	Thu Nov 18 23:28:27 2010 +0000
@@ -24,3 +24,4 @@
 uid		0x1000008D 0x10283036
 
 SMPSAFE
+CAPABILITY All -TCB
--- a/openvg/openvgrefimplementation/sfopenvg/bwins/sflibopenvgrefimplu.def	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/bwins/sflibopenvgrefimplu.def	Thu Nov 18 23:28:27 2010 +0000
@@ -1,134 +1,141 @@
 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
+	?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 *)
+	?IsWindow@TNativeWindowType@@QBEHXZ @ 131 NONAME ; int TNativeWindowType::IsWindow(void) const
+	?SetNativeWindow@TNativeWindowType@@QAEXPAX@Z @ 132 NONAME ; void TNativeWindowType::SetNativeWindow(void *)
+	?EglSyncDisplayCreate@CEglSyncExtension@@QAEHH@Z @ 133 NONAME ; int CEglSyncExtension::EglSyncDisplayCreate(int)
+	??0TNativeWindowType@@QAE@XZ @ 134 NONAME ; TNativeWindowType::TNativeWindowType(void)
+	?IsValid@TNativeWindowType@@QBEHXZ @ 135 NONAME ; int TNativeWindowType::IsValid(void) const
+	?ScreenNumber@TNativeWindowType@@QBEHXZ @ 136 NONAME ; int TNativeWindowType::ScreenNumber(void) const
+	?SizeInPixels@TNativeWindowType@@QBE?AVTSize@@XZ @ 137 NONAME ; class TSize TNativeWindowType::SizeInPixels(void) const
+	??0TNativeWindowType@@QAE@PAX@Z @ 138 NONAME ; TNativeWindowType::TNativeWindowType(void *)
 
--- a/openvg/openvgrefimplementation/sfopenvg/group/egl.mmp	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/egl.mmp	Thu Nov 18 23:28:27 2010 +0000
@@ -24,11 +24,16 @@
 CAPABILITY	ALL -tcb
 //noexportlibrary
 
+MACRO EGL_COMPOSITION // temp to build EGL with Surface Manager
+
+userinclude     ..\sfopenvg
 userinclude     ..\sfopenvg\include //for internal egl functions e.g. do_eglXXX
 
 OS_LAYER_SYSTEMINCLUDE
 OS_LAYER_LIBC_SYSTEMINCLUDE
+OS_LAYER_STDCPP_SYSTEMINCLUDE
 SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(egl) // EGL include files
+SYSTEMINCLUDE  OS_LAYER_PUBLIC_EXPORT_PATH(vg) // 
 
 
 
--- a/openvg/openvgrefimplementation/sfopenvg/group/sfopenvg.mmp	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/group/sfopenvg.mmp	Thu Nov 18 23:28:27 2010 +0000
@@ -38,7 +38,10 @@
 
 MACRO 		BUILD_WITH_PRIVATE_OPENVG //same meaning as macro BUILD_WITH_PRIVATE_EGL except applies to the OpenVG API.
 								   //see riAPI.cpp
-								   
+
+MACRO EGL_COMPOSITION // temp to build EGL with Surface Manager 
+						// see riMiniEGL.cpp								   
+//userinclude     ..\egl			// Local egl include files
 userinclude     ..\sfopenvg			// Local include files
 userinclude     ..\sfopenvg\include			// Local include files
 
@@ -63,6 +66,9 @@
 source riPixelPipe.cpp
 source riRasterizer.cpp
 source riVGU.cpp
+//
+SOURCEPATH ..\sfopenvg\extensions
+source eglsync.cpp
 
 //for EGL
 SOURCEPATH ..\sfopenvg\symbian
@@ -76,8 +82,9 @@
 library         libstdcpp.lib      		// standard lib
 library         libc.lib      		// standard lib
 library         libm.lib      		// standard lib
+library 		surfacemanager.lib	// Surface Manager
+library 		surfaceupdateclient.lib	// Surface Update
 
 
 
 
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/extensions/eglsync.cpp	Thu Nov 18 23:28:27 2010 +0000
@@ -0,0 +1,718 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "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:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// EGL sync implementation
+
+#include "eglapi.h"
+#include <e32std.h>
+#include <e32base.h>
+#include <e32cmn.h>
+#include <eglext.h>
+#include "egltypes.h"
+
+#include "eglsync.h"
+
+
+
+const EGLint CEglSync::KSupportedFlags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR;
+
+// ToDo get rid of these macros
+//#define EGL_SET_ERROR(e)                    { Instance().SetError(e); }
+//#define EGL_SET_ERROR(e)					{setEglError(e);}  
+#define EGL_SET_ERROR(e)
+#define TEST_AND_RET(c, r, t)               { if (!(c)) { EGL_TRACE(t); return (r); } }
+#define TEST_CLEANUP_RET(c, r, clnp, t)     { if (!(c)) { clnp; EGL_TRACE(t); return (r); } }
+#define CHECK_AND_RET(c, e, r, t)           { if (!(c)) { EGL_SET_ERROR(e); EGL_TRACE(t); return (r); } }
+#define CHECK_CLEANUP_RET(c, e, r, clnp, t) { if (!(c)) { EGL_SET_ERROR(e); clnp; EGL_TRACE(t); return (r); } }
+#define RESET_EGL_ERROR()                   { EGL_SET_ERROR(EGL_SUCCESS); }
+
+// ToDo use EGL Panics & panic messages
+void SyncPanic(TInt aPanic)
+    {
+    _LIT(KPanic, "EGL SYNC");
+    User::Panic(KPanic, aPanic);
+    }
+
+
+
+CEglSync* CEglSync::Create(RFastLock& aFrontLock, EGLSyncKHR aSync, EGLDisplay aDisplay, EGLenum aType)
+    {
+    CEglSync* sync= new CEglSync(aFrontLock, aSync, aDisplay, aType);
+    TEST_AND_RET(sync != NULL, sync, "CEglSync::Create couldn't create the object");
+    if (KErrNone == sync->Initialize())
+        {
+        EGL_TRACE("CEglSync::Create OK aDisplay=%d aSync=%d aSyncType=0x%x", aDisplay, aSync, aType);
+        return sync;
+        }
+    else
+        {
+        EGL_TRACE("CEglSync::Create FAILED aDisplay=%d aSync=%d aSyncType=0x%x", aDisplay, aSync, aType);
+        delete sync;
+        return NULL;
+        }
+    }
+
+TInt CEglSync::Initialize()
+    {
+    TInt err = KErrNone;
+    err = iSyncMutex.CreateLocal();
+    TEST_AND_RET(err == KErrNone, err, "CEglSync::Initialize failed to create mutex");
+    err = iSyncCondVar.CreateLocal();
+    TEST_AND_RET(err == KErrNone, err, "CEglSync::Initialize failed to create cond var");
+    return err;
+    }
+
+
+CEglSync::CEglSync(RFastLock& aFrontLock, EGLSyncKHR aSync, EGLDisplay aDisplay, EGLenum aType):
+iEglSync(aSync),
+iDisplay(aDisplay),
+iSyncType(aType),
+iSyncState(EGL_UNSIGNALED_KHR),
+iDestroyed(EGL_FALSE),
+iWaiters(0),
+iFrontLock(aFrontLock)
+    {
+
+    }
+
+CEglSync::~CEglSync()
+    {
+    iSyncMutex.Close();
+    iSyncCondVar.Close();
+    EGL_TRACE("CEglSync::~CEglSync iDisplay=%d iEglSync=%d", iDisplay, iEglSync);
+    }
+
+EGLBoolean CEglSync::DestroySyncReady()
+    {
+    EGL_TRACE("CEglSync::DestroySync iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
+    iSyncMutex.Wait();
+    if (iWaiters == 0)
+        {
+        EGL_TRACE("CEglSync::DestroySync READY TO DESTROY iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
+        iDestroyed = EGL_TRUE;
+        return EGL_TRUE;
+        }
+    else if (!iDestroyed)
+        {
+        EGL_TRACE("CEglSync::DestroySync BROADCAST iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
+        iSyncCondVar.Broadcast();
+        }
+    iDestroyed = EGL_TRUE;
+    iSyncMutex.Signal();
+    return EGL_FALSE;
+    }
+
+
+EGLint CEglSync::SignalSync(EGLenum aMode)
+    {
+    EGL_TRACE("CEglSync::SignalSync aMode=%d", aMode);
+
+    iSyncMutex.Wait();
+    if (aMode != iSyncState)
+        {
+        iSyncState = aMode;
+        if (aMode == EGL_SIGNALED_KHR)
+            {
+            iSyncCondVar.Broadcast();
+            }
+        }
+
+    iSyncMutex.Signal();
+    return EGL_SUCCESS;
+    }
+
+EGLint CEglSync::ClientWaitSync(EGLint aFlags, EGLTimeKHR aTimeout)
+    {
+    EGL_TRACE("CEglSync::ClientWaitSync aFlags=%d aTimeout=%d", aFlags, aTimeout);
+
+    CHECK_CLEANUP_RET(!(aFlags & (~KSupportedFlags)),
+                  EGL_BAD_PARAMETER,
+                  EGL_FALSE,
+                  iFrontLock.Signal();,
+                  "CEglSync::ClientWaitSync bad flags parameter");
+
+    iSyncMutex.Wait();
+    iFrontLock.Signal();
+
+    CHECK_CLEANUP_RET(!iDestroyed ,
+                      EGL_BAD_PARAMETER,
+                      EGL_FALSE,
+                      iSyncMutex.Signal();,
+                      "CEglSync::ClientWaitSync sync already destroyed");
+
+    EGLint ret = (EGLint) EGL_FALSE;
+    if (iSyncState == EGL_UNSIGNALED_KHR)
+        {
+        if (aTimeout && (aFlags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR) && (eglGetCurrentContext() != EGL_NO_CONTEXT))
+            {
+            switch(eglQueryAPI())
+                {
+                case EGL_OPENGL_ES_API:
+                    //ToDo: make sure these cases are covered
+                    //glFlush();
+                    break;
+                case EGL_OPENVG_API:
+                    //ToDo: make sure these cases are covered
+                    //vgFlush();
+                    break;
+                default:
+                	SyncPanic(__LINE__);
+                }
+            }
+
+        switch (aTimeout)
+            {
+            case 0:
+                ret = EGL_TIMEOUT_EXPIRED_KHR;
+                break;
+
+            case EGL_FOREVER_KHR:
+                {
+                EGLint res = KErrNone;
+                ++iWaiters;
+                EGL_TRACE("CEglSync::ClientWaitSync iSyncCondVar.Wait");
+                res = iSyncCondVar.Wait(iSyncMutex);
+                --iWaiters;
+                if (res == KErrNone)
+                    {
+                    ret = EGL_CONDITION_SATISFIED_KHR;
+                    }
+                else
+                    {
+                    ret = EGL_FALSE;
+                    }
+                break;
+                }
+
+            default:
+                {
+                    /*
+                     * Since the supported range of timeout at function RCondVar::TimedWait(mutex, timeout)
+                     * is 0 to KMaxTInt, looping mechanism below is used to support 64bit timeout.
+                     */
+                    EGLint res = KErrTimedOut;
+                    EGL_TRACE("CEglSync::ClientWaitSync iSyncCondVar.TimedWait");
+                    for(TInt64 timeoutMicroseconds = aTimeout/1000; (res == KErrTimedOut) && (timeoutMicroseconds > 0); timeoutMicroseconds -= KMaxTInt)
+                        {
+                        ++iWaiters;
+                        res = iSyncCondVar.TimedWait(iSyncMutex, (timeoutMicroseconds > KMaxTInt) ? KMaxTInt:timeoutMicroseconds);
+                        --iWaiters;
+                        }
+                    switch (res)
+                        {
+                        case KErrNone:
+                            ret = EGL_CONDITION_SATISFIED_KHR;
+                            break;
+                        case KErrTimedOut:
+                            ret = EGL_TIMEOUT_EXPIRED_KHR;
+                            break;
+                        default:
+                            ret = EGL_FALSE;
+                            break;
+                        }
+                    break;
+                }
+            }
+        }
+    else
+        {
+            ret = EGL_CONDITION_SATISFIED_KHR;
+            EGL_TRACE("CEglSync::ClientWaitSync sync in signalled state");
+        }
+    if (iDestroyed && (iWaiters == 0))
+        {
+        EGL_TRACE("CEglSync::ClientWaitSync sync autodestroyed");
+        delete this;
+        }
+    else
+        {
+        EGL_TRACE("CEglSync::ClientWaitSync release sync mutex");
+        iSyncMutex.Signal();
+        }
+    EGL_TRACE("CEglSync::ClientWaitSync sync exit ret=0x%x", ret);
+    return ret;
+    }
+
+EGLBoolean CEglSync::GetSyncAttrib(EGLint aAttribute, EGLint *aValue)
+    {
+    EGL_TRACE("CEglSync::GetSyncAttrib aAttribute=0x%x aValue", aValue);
+
+    CHECK_AND_RET(aValue,
+                  EGL_BAD_PARAMETER,
+                  EGL_FALSE,
+                  "CEglSync::GetSyncAttrib undefined parameter aValue is NUL");
+
+    CHECK_AND_RET((aAttribute == EGL_SYNC_TYPE_KHR) || (aAttribute == EGL_SYNC_STATUS_KHR),
+                  EGL_BAD_ATTRIBUTE,
+                  EGL_FALSE,
+                  "CEglSync::GetSyncAttrib unnexpected attribute parameter");
+
+
+    iSyncMutex.Wait();
+    EGLBoolean ret = EGL_FALSE;
+    switch(aAttribute)
+        {
+        case EGL_SYNC_TYPE_KHR:
+            {
+            *aValue = iSyncType;
+            ret = EGL_TRUE;
+            break;
+            }
+        case EGL_SYNC_STATUS_KHR:
+            {
+            *aValue = iSyncState;
+            ret = EGL_TRUE;
+            break;
+            }
+        default:
+            {
+            EGL_SET_ERROR(EGL_BAD_ATTRIBUTE);
+            }
+        }
+    iSyncMutex.Signal();
+    return ret;
+    }
+
+
+CEglSyncExtension* CEglSyncExtension::Create(OpenVGRI::EGL& aEglInstance)
+    {
+    EGL_TRACE("CEglSyncExtension::Create");
+    CEglSyncExtension* eglSyncExt= new CEglSyncExtension(aEglInstance);
+    if (eglSyncExt && eglSyncExt->Construct())
+        {
+        return eglSyncExt;
+        }
+
+    delete eglSyncExt;
+    return NULL;
+    }
+
+EGLBoolean CEglSyncExtension::Construct()
+    {
+    if  (iEglSyncMapLock.CreateLocal() == KErrNone)
+        {
+        EGL_TRACE("CEglSyncExtension::Construct OK");
+        return EGL_TRUE;
+        }
+
+    EGL_TRACE("CEglSyncExtension::Construct FAILED");
+    return EGL_FALSE;
+    }
+
+CEglSyncExtension::CEglSyncExtension(OpenVGRI::EGL& aEglInstance):
+iEglSyncMap(),
+iEglSyncId(0)/*,
+iEglInstance(aEglInstance)*/
+    {
+
+    }
+
+CEglSyncExtension::~CEglSyncExtension()
+    {
+    if (iEglSyncMapLock.Handle())
+        {
+        iEglSyncMapLock.Wait();
+        }
+
+    EglDestroySync(EGL_NO_DISPLAY);
+
+    iEglSyncMap.Close();
+    iEglSyncMapLock.Close();
+    }
+
+EXPORT_C TInt CEglSyncExtension::EglSyncDisplayCreate(EGLDisplay aDisplay)
+    {
+        return KErrNone;
+    }
+
+void CEglSyncExtension::EglDestroySync(EGLDisplay aDisplay)
+	{
+	EGL_TRACE("CEglSyncExtension::EglDestroySync");
+	REglSyncHashMap::TIter iter(iEglSyncMap);
+
+	while (iter.NextKey())
+		{
+		CEglSync* const* syncpp = NULL;
+		syncpp = iter.CurrentValue();
+		if (syncpp && *syncpp && ((aDisplay == EGL_NO_DISPLAY) || (*syncpp)->Display() == aDisplay))
+			{
+			const EGLint* key = iter.CurrentKey();
+			EGLPANIC_ASSERT(key, EEglPanicTemp);
+			if (aDisplay != EGL_NO_DISPLAY)
+				{
+				// we expect that the map is to be closed after removing the elements
+				// therefore we can skip to remove the syncs from map
+				if (KErrNone != iEglSyncMap.Remove(*key))
+					{
+					SyncPanic(__LINE__);
+					}
+				}
+			if ((*syncpp)->DestroySyncReady())
+				{
+				delete *syncpp;
+				}
+			}
+		}
+	}
+
+void CEglSyncExtension::EglSyncDisplayDestroy(EGLDisplay aDisplay)
+    {
+    iEglSyncMapLock.Wait();
+    EglDestroySync(aDisplay);
+    iEglSyncMapLock.Signal();
+    }
+
+EGLSyncKHR CEglSyncExtension::EglCreateSyncKHR(EGLDisplay aDisplay, EGLenum aType, const EGLint* aAttribList)
+    {
+    EGL_TRACE("CEglSyncExtension::EglCreateSyncKHR aDisplay=%d, aType=%d", aDisplay, aType);
+    RESET_EGL_ERROR();
+
+    CHECK_AND_RET(aType == EGL_SYNC_REUSABLE_KHR,
+                  EGL_BAD_ATTRIBUTE,
+                  EGL_NO_SYNC_KHR,
+                  "CEglSyncExtension::EglCreateSyncKHR unsupported sync type");
+
+    CHECK_AND_RET((aAttribList == NULL) || (*aAttribList == EGL_NONE),
+                  EGL_BAD_ATTRIBUTE,
+                  EGL_NO_SYNC_KHR,
+                  "CEglSyncExtension::EglCreateSyncKHR invalid attribute list");
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    CHECK_AND_RET(lockErr == EGL_SUCCESS,
+                      lockErr,
+                      EGL_NO_SYNC_KHR,
+                      "CEglSyncExtension::EglCreateSyncKHR couldn't find and lock display");
+
+
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    EGLSyncKHR dispRet = CreateSync(aDisplay, aType);
+
+    iEglSyncMapLock.Signal();
+
+    EGL_TRACE("CEglSyncExtension::EglCreateSyncKHR EXIT aDisplay=%d, sync=%d", aDisplay, dispRet);
+    return dispRet;
+    }
+
+EGLBoolean CEglSyncExtension::EglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync)
+    {
+    EGL_TRACE("CEglSyncExtension::EglDestroySyncKHR aDisplay=%d, aSync=%d", aDisplay, aSync);
+
+    RESET_EGL_ERROR();
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    CHECK_AND_RET(lockErr == EGL_SUCCESS,
+                      lockErr,
+                      EGL_FALSE,
+                      "CEglSyncExtension::EglDestroySyncKHR couldn't find and lock display");
+
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    CEglSync** sync = iEglSyncMap.Find((EGLint)aSync);
+    CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display() == aDisplay),
+                      EGL_BAD_PARAMETER,
+                      EGL_FALSE,
+                      iEglSyncMapLock.Signal(),
+                      "CEglSyncDisplayMap::EglDestroySyncKHR cannot find the sync");
+
+    if (KErrNone != iEglSyncMap.Remove((EGLint)aSync))
+        {
+		SyncPanic(__LINE__);
+        }
+
+    if ((*sync)->DestroySyncReady())
+        {
+        delete *sync;
+        }
+
+    iEglSyncMapLock.Signal();
+
+
+    EGL_TRACE("CEglSyncExtension::EglDestroySyncKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, "EGL_TRUE");
+    return EGL_TRUE;
+    }
+
+EGLBoolean CEglSyncExtension::EglSignalSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
+    {
+    EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR aDisplay=%d, aSync=%d aMode=%d", aDisplay, aSync, aMode);
+    EGLBoolean ret = EGL_FALSE;
+
+    RESET_EGL_ERROR();
+
+    CHECK_AND_RET((aMode == EGL_SIGNALED_KHR) || (aMode == EGL_UNSIGNALED_KHR),
+                   EGL_BAD_PARAMETER,
+                   ret,
+                   "CEglSyncExtension::EglSignalSyncKHR unsupported sync mode");
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    CHECK_AND_RET(lockErr == EGL_SUCCESS,
+                      lockErr,
+                      EGL_FALSE,
+                      "CEglSyncExtension::EglSignalSyncKHR couldn't find and lock display");
+
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
+
+    CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
+                      EGL_BAD_PARAMETER,
+                      EGL_FALSE,
+                      iEglSyncMapLock.Signal(),
+                      "CEglSyncExtension::EglSignalSyncKHR cannot find the lock");
+
+    TEST_CLEANUP_RET((*sync)->Display() == EGL_SYNC_REUSABLE_KHR,
+                     EGL_BAD_MATCH,
+                     iEglSyncMapLock.Signal(),
+                     "CEglSyncExtension::EglSignalSyncKHR bad sync type");
+
+    EGLint signalRet = (*sync)->SignalSync(aMode);
+
+    if (signalRet != EGL_SUCCESS)
+        {
+        EGL_SET_ERROR(ret);
+        EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR failed (%d)", ret);
+        ret = EGL_FALSE;
+        }
+    else
+        {
+        ret = EGL_TRUE;
+        }
+
+    iEglSyncMapLock.Signal();
+
+    EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, ret ? "EGL_TRUE":"EGL_FALSE");
+    return ret;
+    }
+
+EGLint CEglSyncExtension::Egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
+    {
+    EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR aDisplay=%d, aSync=%d aMode=%d", aDisplay, aSync, aMode);
+
+    TEST_AND_RET((aMode == EGL_SIGNALED_KHR) || (aMode == EGL_UNSIGNALED_KHR),
+                 EGL_BAD_PARAMETER,
+                 "CEglSyncExtension::EglPrivateSignalSyncKHR unsupported sync mode");
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    TEST_AND_RET(lockErr == EGL_SUCCESS,
+                     lockErr,
+                     "CEglSyncExtension::EglPrivateSignalSyncKHR couldn't find and lock display");
+
+
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
+
+    TEST_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
+                     EGL_BAD_PARAMETER,
+                     iEglSyncMapLock.Signal(),
+                     "CEglSyncExtension::EglPrivateSignalSyncKHR cannot find the lock");
+
+    EGLint ret = (*sync)->SignalSync(aMode);
+
+    if (ret != EGL_SUCCESS)
+        {
+        EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR failed (%d)", ret);
+        }
+
+    iEglSyncMapLock.Signal();
+
+    EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR EXIT aDisplay=%d, aSync=%d ret=%d", aDisplay, aSync, ret);
+    return ret;
+    }
+
+EGLint CEglSyncExtension::EglClientWaitSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aFlags, EGLTimeKHR aTimeout)
+    {
+    EGL_TRACE("CEglSyncExtension::EglClientWaitSyncKHR aDisplay=%d, aSync=%d aFlags=0x%x, aTimeout=%ld", aDisplay, aSync, aFlags, aTimeout);
+
+    RESET_EGL_ERROR();
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    CHECK_AND_RET(lockErr == EGL_SUCCESS,
+                      lockErr,
+                      EGL_FALSE,
+                      "CEglSyncExtension::EglClientWaitSyncKHR couldn't find and lock display");
+
+    
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
+
+    CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
+                      EGL_BAD_PARAMETER,
+                      EGL_FALSE,
+                      iEglSyncMapLock.Signal(),
+                      "CEglSyncExtension::EglClientWaitSyncKHR cannot find the sync");
+
+    EGLint ret = (*sync)->ClientWaitSync(aFlags, aTimeout);
+
+
+    EGL_TRACE("CEglSyncExtension::EglClientWaitSyncKHR EXIT aDisplay=%d, aSync=%d ret=%d", aDisplay, aSync, ret);
+    return ret;
+    }
+
+EGLBoolean CEglSyncExtension::EglGetSyncAttribKHR(EGLDisplay aDisplay,
+                                                  EGLSyncKHR aSync,
+                                                  EGLint aAttribute,
+                                                  EGLint* aValue)
+    {
+    EGL_TRACE("CEglSyncExtension::EglGetSyncAttribKHR aDisplay=%d, aSync=%d aAttribute=0x%x, aValue=0x%x", aDisplay,
+                                                                                                           aSync,
+                                                                                                           aAttribute,
+                                                                                                           aValue);
+    RESET_EGL_ERROR();
+
+    EGLint lockErr = FindAndLockDisplay(aDisplay);
+
+    CHECK_AND_RET(lockErr == EGL_SUCCESS,
+                      lockErr,
+                      EGL_FALSE,
+                      "CEglSyncExtension::EglGetSyncAttribKHR couldn't find and lock display");
+
+
+    iEglSyncMapLock.Wait();
+    ReleaseDisplayLock(aDisplay);
+
+    CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
+
+    CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
+                      EGL_BAD_PARAMETER,
+                      EGL_FALSE,
+                      iEglSyncMapLock.Signal(),
+                      "CEglSyncExtension::EglGetSyncAttribKHR cannot find the lock");
+
+
+    EGLint ret = (*sync)->GetSyncAttrib(aAttribute, aValue);
+
+    iEglSyncMapLock.Signal();
+
+
+
+    EGL_TRACE("CEglSyncExtension::EglGetSyncAttribKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, ret ? "EGL_TRUE":"EGL_FALSE");
+    return ret;
+    }
+
+EGLint CEglSyncExtension::FindAndLockDisplay(EGLDisplay aDisplay)
+    {
+    return OpenVGRI::getEGL()->FindAndLockDisplay(aDisplay);
+    }
+
+void CEglSyncExtension::ReleaseDisplayLock(EGLDisplay aDisplay)
+    {
+	OpenVGRI::getEGL()->ReleaseDisplayLock(aDisplay);
+    }
+
+EGLSyncKHR CEglSyncExtension::CreateSync(EGLDisplay aDisplay, EGLenum aType)
+    {
+    CEglSync* sync = CEglSync::Create(iEglSyncMapLock,
+                                      (EGLSyncKHR)(++iEglSyncId),
+                                      aDisplay,
+                                      aType);
+
+    CHECK_AND_RET(sync != NULL,
+                  EGL_BAD_ALLOC,
+                  EGL_NO_SYNC_KHR,
+                  "CEglSyncDisplayMap::CreateSync failed to create sync");
+
+    TInt err = KErrNone;
+    err = iEglSyncMap.Insert(iEglSyncId, sync);
+
+    CHECK_CLEANUP_RET(err == KErrNone,
+                      EGL_BAD_ALLOC,
+                      EGL_NO_SYNC_KHR,
+                      delete sync,
+                      "CEglSyncDisplayMap::CreateSync insert failed");
+
+    return (EGLSyncKHR)iEglSyncId;
+    }
+
+EGLSyncKHR CEglSyncExtension::eglCreateSyncKHR(EGLDisplay aDisplay, EGLenum aType, const EGLint* aAttribList)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_NO_SYNC_KHR,
+                  "CEglSyncExtension::eglCreateSyncKHR extension instance not created");
+
+    return eglSyncInstance->EglCreateSyncKHR(aDisplay, aType, aAttribList);
+    }
+
+EGLBoolean CEglSyncExtension::eglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_FALSE,
+                 "CEglSyncExtension::eglDestroySyncKHR extension instance not created");
+
+    return eglSyncInstance->EglDestroySyncKHR(aDisplay, aSync);
+    }
+
+EGLint CEglSyncExtension::eglClientWaitSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aFlags, EGLTimeKHR aTimeout)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_FALSE,
+                 "CEglSyncExtension::eglGetSyncAttribKHR extension instance not created");
+
+    return eglSyncInstance->EglClientWaitSyncKHR(aDisplay, aSync, aFlags, aTimeout);
+    }
+
+EGLBoolean CEglSyncExtension::eglSignalSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_FALSE,
+                 "CEglSyncExtension::eglSignalSyncKHR extension instance not created");
+
+    return eglSyncInstance->EglSignalSyncKHR(aDisplay, aSync, aMode);
+    }
+
+
+EGLBoolean CEglSyncExtension::eglGetSyncAttribKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aAttribute, EGLint* aValue)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_FALSE,
+                 "CEglSyncExtension::eglGetSyncAttribKHR extension instance not created");
+
+    return eglSyncInstance->EglGetSyncAttribKHR(aDisplay, aSync, aAttribute, aValue);
+    }
+
+EGLint CEglSyncExtension::egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
+    {
+    CEglSyncExtension* eglSyncInstance = (CEglSyncExtension*)OpenVGRI::getEGL()->EGLSyncExtension();
+    CHECK_AND_RET(eglSyncInstance,
+                  EGL_NOT_INITIALIZED,
+                  EGL_NOT_INITIALIZED,
+                  "CEglSyncExtension::egl_Private_SignalSyncNOK extension instance not created");
+
+    return eglSyncInstance->Egl_Private_SignalSyncNOK(aDisplay, aSync, aMode);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/eglapi.h	Thu Nov 18 23:28:27 2010 +0000
@@ -0,0 +1,127 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "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:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// Header file for guest egl implementation
+
+#ifndef EGLAPI_H_
+#define EGLAPI_H_
+
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32hashtab.h>
+#include <w32std.h>
+#include <graphics/surface.h>
+#include <graphics/surfaceupdateclient.h>
+#include <pixelformats.h>
+#include <e32cmn.h>
+
+#ifdef FAISALMEMON_S4_SGIMAGE
+#include <sgresource/sgimage.h>
+#endif
+
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+
+class CEglSyncExtension;
+
+
+
+/*
+ Change value to control how much tracing is generated in UDEB builds
+ 0 = API traces only
+ 1 = API traces and parameter validation diagnostics
+ 2 = API traces, param validation, extra diagnostics
+ */
+#define EGL_TRACE_LEVEL 0
+
+/*
+EGL version info
+*/
+#define EGL_VERSION_MAJOR 1
+#define EGL_VERSION_MINOR 4
+#define MAKE_VERSION_STRING(major, minor) #major "." #minor
+
+// tracing
+#include <e32debug.h>
+#ifdef _DEBUG
+	#define EGL_TRACE(fmt, args...)                   RDebug::Printf(fmt, ##args)
+	#define EGL_TRACE_DETAIL(level, fmt, args...)     if (level <= EGL_TRACE_LEVEL) RDebug::Printf(fmt, ##args)
+	#define EGLPANIC_ASSERT(condition, panic)         if (!(condition)) { EglPanic(panic, #panic, #condition, __FILE__, __LINE__); }
+	//#define EGLPANIC_ASSERT_DEBUG(condition, panic)   if (!(condition)) { EglPanic(panic, #panic, #condition, __FILE__, __LINE__); }
+	//ToDo
+	#define EGLPANIC_ASSERT_DEBUG(condition, panic)
+	#define EGLPANIC_ALWAYS(panic)                    { EglPanic(panic, #panic, NULL, __FILE__, __LINE__); }
+	#define EGLPANIC_DEBUG(panic)                     { EglPanic(panic, #panic, NULL, __FILE__, __LINE__); }
+	#define EGL_TRACE_ATTRIB_LIST(aAttribList)        TAttribUtils::TraceAttribList(aAttribList)
+	#define EGL_TRACE_GET_ATTRIB(N, T, D, O, A, V, R) TAttribUtils::TraceGetAttrib(N, T, D, O, A, V, R)
+	#define EGL_TRACE_SET_ATTRIB(N, T, D, O, A, V)    TAttribUtils::TraceSetAttrib(N, T, D, O, A, V)
+#else
+	#define EGL_TRACE(fmt, args...)
+	#define EGL_TRACE_DETAIL(level, fmt, args...)
+	#define EGLPANIC_ASSERT(condition, panic)         if (!(condition)) { EglPanic(panic, NULL, NULL, NULL, __LINE__); }
+	#define EGLPANIC_ASSERT_DEBUG(condition, panic)
+	#define EGLPANIC_ALWAYS(panic)                    { EglPanic(panic, NULL, NULL, NULL, __LINE__); }
+	#define EGLPANIC_DEBUG(panic)
+	#define EGL_TRACE_ATTRIB_LIST(aAttribList)
+	#define EGL_TRACE_GET_ATTRIB(N, T, D, O, A, V, R)
+	#define EGL_TRACE_SET_ATTRIB(N, T, D, O, A, V)
+#endif
+
+
+// Guest EGL panic codes
+typedef enum
+	{
+	EEglPanicCGuestEGLAllocFailed=1,
+	EEglPanicDisplayMapLockCreateLocalFailed,
+	EEglPanicGuestGraphicsAllocFailed,
+	EEglPanicSgImageHandleInvalid,
+	EEglPanicExtensionListAllocFailed,
+	EEglPanicExtensionListCreationError,
+	EEglPanicHostAndClientBoundApiOutOfSync,
+	EEglPanicUnexpectedBoundApi,
+	EEglPanicSymbianPixmapNotSetInSurface,
+	EEglPanicSymbianWindowNotSetInSurface,           // 10
+	EEglPanicHostAndClientEglInitOutOfSync,
+	EEglPanicHostAndClientEglTerminateOutOfSync,
+	EEglPanicErrorNotSet,
+	EEglPanicThreadStateNotValidInInternalFunction,
+	EEglPanicNotReplyOpcode,
+	EEglPanicDisplayMapInsertFailed,
+	EEglPanicEglSyncDisplayCreateFailed,
+	EEglPanicReleaseInvalidDisplay,
+	EEglPanicNullDisplayPointerInMap,
+	EEglPanicLockedDisplayNotFound,                  // 20
+	EEglPanicStrayDisplayUnlock,
+	EEglPanicDisplayNotLockedForWriting,
+	EEglPanicDisplayAlreadyLocked,
+	EEglPanicReadLockExpected,
+	EEglPanicReadFromUnlockedDisplay,
+	EEglPanicDisplayAlreadyInMap,
+	EEglPanicDisplayNotFound,
+	EEglPanicSgDriverCreateLocalFailed,
+	EEglPanicInvalidNativePixmap,
+	EEglPanicEglImageLockCreateLocalFailed,          // 30
+	EEglPanicBadSgDriverVersion,
+	EEglPanicEglImageRefCountNonZero,
+	EEglPanicEglImageIsDestroyed,
+	EEglPanicAtribListLengthTooLong,
+	EEglPanicTemp,							// temporary panic in development code
+	} TEglPanic;
+
+void EglPanic(TEglPanic aPanicCode, char* aPanicName, char* aCondition, char* aFile, TInt aLine);
+
+
+
+#endif /* EGLAPI_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/include/eglsync.h	Thu Nov 18 23:28:27 2010 +0000
@@ -0,0 +1,415 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "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:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// The API provides functionality which allows waiting on the aSync object 
+// to become signaled and to change status from signaled to unsignaled or vice
+// versa.
+
+/**
+ @file
+ @internalTechnology 
+*/
+
+#ifndef __EGL_SYNC_H_
+#define __EGL_SYNC_H_
+
+#include <e32hashtab.h>
+#include <e32base.h>
+
+#include "riMiniEGL.h"
+
+
+
+NONSHARABLE_CLASS(CEglSync): public CBase 
+{
+public:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Factory function used to create a CEglSync instance
+     * \ingroup eglSync
+     * \param   aFrontLock Reference to the lock protecting the sync map
+     *          aHeap Reference to the Heap to be used by EGL Sync extension
+     * \param   aSync the sync id for the new sync to be created
+     * \param   aDisplay the display id of the associated display
+     * \param   aType the sync type
+     * \return  a pointer to the extension instance if successful or NULL otherwise 
+     *//*-------------------------------------------------------------------*/
+    static CEglSync* Create(RFastLock& aFrontLock, 
+                            EGLSyncKHR aSync, 
+                            EGLDisplay aDisplay, 
+                            EGLenum aType);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Public destructor
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    ~CEglSync();
+    
+private:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private constructor
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    CEglSync(RFastLock& aFrontLock,
+             EGLSyncKHR aSync, 
+             EGLDisplay aDisplay, 
+             EGLenum aType);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private initialisation method to be used by the factory method
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    TInt Initialize();
+    
+public:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Blocks the calling thread until the specified aSync object 
+     * is signaled, or until <aTimeout> nanoseconds have passed. 
+     * It is supposed that the lock protecting
+     * the sync map is already acquired. The call will release this lock. 
+     * \ingroup eglSync
+     * \param   aFlags   If the EGL_FLUSH_COMMANDS_BIT_KHR bit is set in <aFlags>
+     * and <aSync> is unsignaled when the function is called, then the equivalent
+     * of Flush() will be performed for the current API context.   
+     * \param   aTimeout The thread will be unblocked when <aTimeout> is expired.
+     * If the <aTimeout> is to zero, the function just test the current status 
+     * of the aSync object. If the <aTimeout> is set to EGL_FOREVER_KHR, then the 
+     * function does not time out. For all other values, <aTimeout> is adjusted to 
+     * the closest aValue which may be substantially longer than one nanosecond. 
+     * \return  EGL_CONDITION_SATISFIED if <aSync> was signaled before
+     * the timeout expired, which includes the case when <aSync> was already 
+     * signaled when eglClientWaitSyncKHR was called; EGL_TIMEOUT_EXPIRED_KHR if the 
+     * specified timeout period expired before <aSync> was signaled; 
+     * EGL_FALSE if an error occurs.
+     * \error  EGL_BAD_PARAMETER if <aFlags> does not equal
+     * to 0 or EGL_SYNC_FLUSH_COMMAND_BIT_KHR
+     *//*-------------------------------------------------------------------*/
+    EGLint ClientWaitSync(EGLint aFlags, EGLTimeKHR aTimeout);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Signals or unsignals the reusable aSync object.  
+     * \ingroup eglSync
+     * \param   aMode    Status of the aSync object. There are two possible states: 
+     *  EGL_SIGNALED_KHR and EGL_UNSIGNALED_KHR. 
+     * \return  EGL_SUCCESS if an operation was successful; 
+     * EGL_BAD_MATCH if the type of <aSync> is not EGL_SYNC_REUSABLE_KHR
+     *//*-------------------------------------------------------------------*/
+    EGLint SignalSync(EGLenum aMode);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Preapares the sync object for destruction.  
+     * \ingroup eglSync
+     * \return  EGL_TRUE if the object can be destroyed immediately (the sync lock is not released)
+     *          EGL_FALSE if the object cannot be deleted (the sync lock is released) 
+     *//*-------------------------------------------------------------------*/
+    EGLBoolean DestroySyncReady();
+    
+    /*-------------------------------------------------------------------*//*!
+    * \brief   Query an aAttribute of the aSync object  
+     * \ingroup eglSync
+    * \param   aDisplay     Identifier of the display which owns the aSync object
+    * \param   aValue   Pointer to the aValue for the 
+    *           requested aAttribute which will be filled on function return. 
+    * \return  EGL_TRUE if an operation was successful and EGL_FALSE otherwise
+    * \error   EGL_BAD_ATTRIBUTE if <aAttribute>  does not lie within expected range;
+    * EGL_BAD_MATCH if <aAttribute> is not supported 
+    * for the type of aSync object passed in <aSync>
+    *//*-------------------------------------------------------------------*/
+    EGLBoolean GetSyncAttrib(EGLint aAttribute, EGLint *aValue);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Returns the associated display Id  
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLDisplay Display() const { return iDisplay; }
+    
+    /*-------------------------------------------------------------------*//*!
+    * \brief   Returns the sync type  
+    * \ingroup eglSync
+    *//*-------------------------------------------------------------------*/
+    EGLenum Type() const { return iSyncType; }
+private:
+    const EGLSyncKHR  iEglSync;
+    const EGLDisplay  iDisplay;
+    const EGLenum     iSyncType;
+    EGLenum     iSyncState;
+    EGLBoolean  iDestroyed;
+    EGLint      iWaiters;
+    RMutex      iSyncMutex;
+    RCondVar    iSyncCondVar;
+    RFastLock&  iFrontLock;
+    
+    static const EGLint KSupportedFlags;
+};
+
+
+NONSHARABLE_CLASS(CEglSyncExtension): public CBase
+    {
+public:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Factory function used to create a CEglSyncExtension instance
+     * \ingroup eglSync
+     * \param   aEglInstance Reference to the Egl Instance implementation object
+     * \return  a pointer to the extension instance if successful or NUL otherwise 
+     *//*-------------------------------------------------------------------*/
+    static CEglSyncExtension* Create(OpenVGRI::EGL& aEglInstance);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Public destructor
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    ~CEglSyncExtension();
+private:
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private initialisation method to be used by the factory method
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLBoolean Construct();
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private constructor
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    CEglSyncExtension(OpenVGRI::EGL& aEglInstance);
+    
+public:    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Create a aSync object for the specified display.
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which will own the aSync object
+     * \param   type    Type of the aSync object. EGL_SYNC_REUSABLE_KHR is only supported
+     * \param   attrib_list Attribute-aValue list specifying attributes of the aSync 
+     * object, terminated by an aAttribute entry EGL_NONE
+     * \return  Handle for the created aSync object if successful, EGL_NO_SYNC_KHR otherwise
+     * \error   EGL_BAD_DISPLAY if <aDisplay> is not a name of a valid EGLDisplay;
+     * EGL_NOT_INITIALIZED if the display object associated 
+     * with the <aDisplay> has not been initialized;
+     * EGL_BAD_ATTRIBUTE if <attrib_list> is neither NULL nor empty (containing only EGL_NONE) or 
+     * if <type> is not a supported type of aSync object;
+     * EGL_BAD_ALLOC if the memory allocation related to aSync object is not successful
+     * \note    If <type> is EGL_SYNC_REUSABLE_KHR, a reusable aSync object is created. 
+     * In this case <attrib_list> must be NULL or empty (containing only EGL_NONE).
+     *  *//*-------------------------------------------------------------------*/
+    static EGLSyncKHR eglCreateSyncKHR(EGLDisplay aDisplay, 
+                                       EGLenum aType, 
+                                       const EGLint* aAttribList);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Destroy a aSync object and free memory associated with it
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which owns the aSync object
+     * \param   aSync    Sync object handle. 
+     * \return  EGL_TRUE if deletion was successful and EGL_FALSE otherwise
+     * \error   EGL_BAD_DISPLAY if <aDisplay> is not a name of a valid EGLDisplay;
+     * EGL_NOT_INITIALIZED if the display object associated 
+     * with the <aDisplay> has not been initialized;
+     * EGL_BAD_PARAMETER if <aSync> is not a valid aSync object for <aDisplay>
+     * \note    If any eglClientWaitSyncKHR commands are blocking on <aSync> when 
+     * eglDestroySyncKHR is called, they will be woken up, as if <aSync> were signaled. 
+     * If no errors are generated, <aSync> will no longer be the handle of a valid aSync object.
+     *//*-------------------------------------------------------------------*/
+    static EGLBoolean eglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Blocks the calling thread until the specified aSync object 
+     * is signaled, or until <aTimeout> nanoseconds have passed.  
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which owns the aSync object.
+     * \param   aSync    Sync object handle. 
+     * \param   aFlags   If the EGL_FLUSH_COMMANDS_BIT_KHR bit is set in <aFlags>
+     * and <aSync> is unsignaled when the function is called, then the equivalent
+     * of Flush() will be performed for the current API context.   
+     * \param   aTimeout The thread will be unblocked when <aTimeout> is expired.
+     * If the <aTimeout> is to zero, the function just test the current status 
+     * of the aSync object. If the <aTimeout> is set to EGL_FOREVER_KHR, then the 
+     * function does not time out. For all other values, <aTimeout> is adjusted to 
+     * the closest aValue which may be substantially longer than one nanosecond. 
+     * \return  EGL_CONDITION_SATISFIED if <aSync> was signaled before
+     * the timeout expired, which includes the case when <aSync> was already 
+     * signaled when eglClientWaitSyncKHR was called; EGL_TIMEOUT_EXPIRED_KHR if the 
+     * specified timeout period expired before <aSync> was signaled; 
+     * EGL_FALSE if an error occurs.
+     * \error   EGL_BAD_DISPLAY if <aDisplay> is not a name of a valid EGLDisplay;
+     * EGL_NOT_INITIALIZED if the display object associated w
+     * ith the <aDisplay> has not been initialized;
+     * EGL_BAD_PARAMETER if <aSync> is not a valid aSync object for <aDisplay> or 
+     * if <aFlags> does not equal to 0 or EGL_SYNC_FLUSH_COMMAND_BIT_KHR
+     * Note\    More than one eglClientWaitSyncKHR may 
+     * be outstanding on the same <aSync> at any given time. 
+     * When there are multiple threads blocked on the same <aSync> and the aSync object is signaled, 
+     * all such threads are released, but the order in which they are released is not defined.
+     * If a aSync object is destroyed while an eglClientWaitSyncKHR is blocking on that object, 
+     * eglClientWaitSyncKHR will unblock and return immediately, just as if the aSync object 
+     * had been signaled prior to being destroyed.
+     *//*-------------------------------------------------------------------*/
+    static EGLint eglClientWaitSyncKHR(EGLDisplay aDisplay, 
+                                       EGLSyncKHR aSync, 
+                                       EGLint aFlags, 
+                                       EGLTimeKHR aTimeout);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Signals or unsignals the reusable aSync object.  
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which owns the aSync object.
+     * \param   aSync    Sync object handle. 
+     * \param   aMode    Status of the aSync object. There are two possible states: 
+     *  EGL_SIGNALED_KHR and EGL_UNSIGNALED_KHR. 
+     * \return  EGL_TRUE if an operation was successful and EGL_FALSE otherwise.
+     *//*-------------------------------------------------------------------*/
+    static EGLBoolean eglSignalSyncKHR(EGLDisplay aDisplay, 
+                                       EGLSyncKHR aSync, 
+                                       EGLenum aMode);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Query an aAttribute of the aSync object  
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which owns the aSync object
+     * \param   aSync    Sync object handle. 
+     * \param   aAttribute   An aAttribute to be retrieved. 
+     * \param   aValue   Pointer to the aValue for the requested aAttribute 
+     *          which will be filled on function return. 
+     * \return  EGL_TRUE if an operation was successful and EGL_FALSE otherwise
+     * \error   EGL_BAD_DISPLAY if <aDisplay> is not a name of a valid EGLDisplay;
+     * EGL_NOT_INITIALIZED if the display object associated 
+     * with the <aDisplay> has not been initialized;
+     * EGL_BAD_PARAMETER if <aSync> is not a valid aSync object for <aDisplay> or if <aValue> is not 
+     * a valid pointer; EGL_BAD_ATTRIBUTE if <aAttribute>  does not lie within expected range;
+     * EGL_BAD_MATCH if <aAttribute> is not supported for the type of aSync object passed in <aSync>
+     *//*-------------------------------------------------------------------*/
+    static EGLBoolean eglGetSyncAttribKHR(EGLDisplay aDisplay, 
+                                          EGLSyncKHR aSync, 
+                                          EGLint aAttribute, 
+                                          EGLint* aValue);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Signals or unsignals the reusable aSync object.  
+     * \ingroup api
+     * \param   aDisplay     Identifier of the display which owns the aSync object.
+     * \param   aSync    Sync object handle. 
+     * \param   aSync    Status of the aSync object. There are two possible states: 
+     *  EGL_SIGNALED_KHR and EGL_UNSIGNALED_KHR. 
+     * \return  EGL_SUCCESS if an operation was successful; 
+     * EGL_BAD_DISPLAY if <aDisplay> is not a name of a valid EGLDisplay; 
+     * EGL_NOT_INITIALIZED if the display object associated with the <aDisplay> has not 
+     * been initialized; EGL_BAD_PARAMETER if <aSync> is not a valid aSync object for <aDisplay> 
+     * or if <aSync> does not lie within expected range;
+     * EGL_BAD_MATCH if the type of <aSync> is not EGL_SYNC_REUSABLE_KHR
+     * \note    This function does not generate an error.
+     *//*-------------------------------------------------------------------*/
+    static EGLint egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode);
+    
+public:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Initialisation request when a new display is created  
+     * \ingroup eglSync
+     * \param  aEglDisplay a display identifier 
+     * \return  EGL_SUCCESS if successful; 
+     *//*-------------------------------------------------------------------*/
+    IMPORT_C TInt EglSyncDisplayCreate(EGLDisplay aDisplay);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Request to destroy all syncs associated with a display as preamble
+     *          of destroying the specified display  
+     * \ingroup eglSync
+     * \param  aEglDisplay a display identifier 
+     *//*-------------------------------------------------------------------*/
+    void EglSyncDisplayDestroy(EGLDisplay aDisplay);
+    
+private:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Query and request to lock a specified display   
+     * \ingroup eglSync
+     * \param   aEglDisplay a display identifier 
+     * \return  EGL_SUCCESS if successful;
+     *          EGL_BAD_DISPLAY is not a name of a valid EGLDisplay
+     *          EGL_NOT_INITIALIZED if the display object associated 
+     *          with the <aEglDisplay> has not been initialized 
+     *//*-------------------------------------------------------------------*/
+    EGLint FindAndLockDisplay(EGLDisplay aDisplay);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Releases the lock associated with a valid EGLDisplay   
+     * \ingroup eglSync
+     * \param   aEglDisplay a display identifier 
+     *//*-------------------------------------------------------------------*/
+    void ReleaseDisplayLock(EGLDisplay aDisplay);
+    
+private:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <eglCreateSyncKHR> public static interface   
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLSyncKHR EglCreateSyncKHR(EGLDisplay aDisplay, EGLenum aType, const EGLint* aAttribList);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <eglDestroySyncKHR> public static interface   
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLBoolean EglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <eglClientWaitSyncKHR> public static interface   
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLint EglClientWaitSyncKHR(EGLDisplay aDisplay, 
+                                EGLSyncKHR aSync, 
+                                EGLint aFlags, 
+                                EGLTimeKHR aTimeout);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <eglSignalSyncKHR> public static interface
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLBoolean EglSignalSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <eglGetSyncAttribKHR> public static interface
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLBoolean EglGetSyncAttribKHR(EGLDisplay aDisplay, 
+                                   EGLSyncKHR aSync, 
+                                   EGLint aAttribute, 
+                                   EGLint* aValue);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Private implementation for <egl_Private_SignalSyncNOK> public static interface
+     * \ingroup eglSync
+     *//*-------------------------------------------------------------------*/
+    EGLint Egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode);
+    
+private:
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Creates a sync and inserts it in the sync map   
+     * \ingroup eglSync
+     * \param   aEglDisplay the id of the associated display 
+     * \param   aType The sync type 
+     * \return  the id of the sync created
+     *//*-------------------------------------------------------------------*/
+    EGLSyncKHR CreateSync(EGLDisplay aDisplay, EGLenum aType);
+    
+    /*-------------------------------------------------------------------*//*!
+     * \brief   Destroy a sync associated with a display   
+     * \ingroup eglSync
+     * \param   aEglDisplay the id of the associated display 
+     *//*-------------------------------------------------------------------*/
+    void EglDestroySync(EGLDisplay aDisplay);
+    
+private:
+    typedef RHashMap<EGLint,CEglSync*> REglSyncHashMap;
+    
+    REglSyncHashMap iEglSyncMap;
+    RFastLock       iEglSyncMapLock;
+    EGLint          iEglSyncId;
+    };
+
+#endif /* __EGL_SYNC_H_ */
--- a/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.cpp	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.cpp	Thu Nov 18 23:28:27 2010 +0000
@@ -35,6 +35,7 @@
  * \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 "eglapi.h"
 
 #include "egl.h"
 #include "openvg.h"
@@ -42,6 +43,8 @@
 #include "riMath.h"
 #include "riContext.h"
 #include "riImage.h"
+#include "riMiniEGL.h"
+#include "riDefs.h"
 
 #ifdef BUILD_WITH_PRIVATE_EGL 
 #include "eglinternal.h"
@@ -51,24 +54,329 @@
 #include "openvginternal.h"
 #endif
 
-//==============================================================================================
+#ifdef EGL_COMPOSITION
+#include "eglsync.h"
+//
+#include <w32std.h>
+#include <graphics/surfacemanager.h>
+#include <graphics/surfaceconfiguration.h>
+#include <graphics/suerror.h>
+#include <graphics/surface_hints.h>
+#include <graphics/surfaceupdateclient.h>
+#include <e32hashtab.h>
+#endif
 
+using namespace OpenVGRI;
+//// class EGL
+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		
+*//*-------------------------------------------------------------------*/
 namespace OpenVGRI
 {
+EGL* getEGL()
+{
 
-void* OSGetCurrentThreadID(void);
-void OSAcquireMutex(void);
-void OSReleaseMutex(void);
-void OSDeinitMutex(void);
+
+	//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()
+{
+	EGL* pEgl = static_cast<EGL*>(Dll::Tls());
+	if (pEgl)
+		delete pEgl; 
+	Dll::SetTls(NULL);
+
+}
+//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
+/*-------------------------------------------------------------------*//*!
+* \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(const EGLDisplay displayID)
+{
+	for(int i=0;i<m_displays.size();i++)
+	{
+		if(displayID == m_displays[i]->getID())
+		{
+			if (CreateDisplayInfo(displayID))
+			{
+				return m_displays[i];		
+			}
+		}
+	}
+	return NULL;		//error: the display hasn't been eglInitialized
+}
+
+/*
+  Create an information object for an opened Display.
+ */
+TBool EGL::CreateDisplayInfo(const EGLDisplay aDisplayID)
+{
+	TBool result = EFalse;
+	EGL_TRACE("EGL::CreateDisplayInfo begin aDisplay=%d", aDisplayID);
+	iDisplayMapLock.WriteLock();
+	
+	if (NULL != iDisplayMap.Find( aDisplayID))
+	{
+		result = ETrue;
+	}
+	else
+	{
+		TInt err = KErrNoMemory; 
+		CEglDisplayInfo* dispInfo = new CEglDisplayInfo;
+
+		if (dispInfo)
+		{
+			err = iDisplayMap.Insert(aDisplayID, dispInfo);
+			EGL_TRACE("EGL::CreateDisplayInfo - DisplayMap insert error %d", err);
+			EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicDisplayMapInsertFailed);
+	
+			//added for egl sync extension benefit
+			if (iEglSyncExtension)
+			{
+				err = iEglSyncExtension->EglSyncDisplayCreate(aDisplayID);
+				EGL_TRACE("EGL::CreateDisplayInfo - EglSyncDisplayCreate error %d", err);
+				EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicEglSyncDisplayCreateFailed);
+	
+				if (err)
+				{
+					iDisplayMap.Remove(aDisplayID);
+				}
+			}
+		}
+
+		if (err == KErrNone)
+		{
+			result = ETrue;
+		}
+	}
+	iDisplayMapLock.Unlock();
+
+	EGL_TRACE("EGL::CreateDisplayInfo end, result=%d", result);
+	return result;
+}
+
+/*-------------------------------------------------------------------*//*!
+ * \brief   Creates the EGL sync instance
+ * \ingroup eglSync
+*//*-------------------------------------------------------------------*/
+
+EGLint EGL::InitialiseExtensions()
+{
+	iEglSyncExtension = CEglSyncExtension::Create(*this);
+	return EGL_SUCCESS;
+}
 
-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);
+// API supporting EGL sync extension
+/*-------------------------------------------------------------------*//*!
+ * \brief   Query and request to lock a specified display
+ * \ingroup eglSync
+ * \param   aEglDisplay a display identifier
+ * \return  EGL_SUCCESS if successful;
+ *          EGL_BAD_DISPLAY is not a name of a valid EGLDisplay
+ *          EGL_NOT_INITIALIZED if the display object associated
+ *          with the <aEglDisplay> has not been initialized
+*//*-------------------------------------------------------------------*/
+
+EGLint EGL::FindAndLockDisplay(EGLDisplay aDisplayID)
+{
+	EGLint result = EGL_BAD_DISPLAY;
+	EGL_TRACE("EGL::FindAndLockDisplay aDisplay=%d", aDisplayID);
+	iDisplayMapLock.ReadLock();
+	CEglDisplayInfo** pDisp = iDisplayMap.Find(aDisplayID);
+	if (pDisp && *pDisp)
+		{
+		CEglDisplayInfo* disp = *pDisp;
+		if (disp->iInitialized)
+			{
+			EGL_TRACE("EGL::FindAndLockDisplay display found");
+			result = EGL_SUCCESS;
+			}
+		else
+			{
+			EGL_TRACE("EGL::FindAndLockDisplay display not initialized");
+			result = EGL_NOT_INITIALIZED;
+			}
+		}
+	else
+		{
+		EGL_TRACE("EGL::FindAndLockDisplay cannot find display");
+		}
+	if (result != EGL_SUCCESS)
+		{
+		iDisplayMapLock.Unlock();
+		}
+	return result;
+}
+
+/*-------------------------------------------------------------------*//*!
+ * \brief   Releases the lock associated with a valid EGLDisplay
+ * \ingroup eglSync
+ * \param   aEglDisplay a display identifier
+*//*-------------------------------------------------------------------*/
+
+void EGL::ReleaseDisplayLock(EGLDisplay aDisplayID)
+{
+	EGL_TRACE("EGL::ReleaseDisplayLock aDisplay=%d", aDisplayID);
+	iDisplayMapLock.Unlock();
+}
+
+/*-------------------------------------------------------------------*//*!
+* \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	
@@ -77,108 +385,17 @@
 * \note		
 *//*-------------------------------------------------------------------*/
 
-class RIEGLConfig
+bool EGL::isInUse(const void* image) const
 {
-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
+    for(int i=0;i<m_currentThreads.size();i++)
     {
-        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;
+        RIEGLSurface* s = m_currentThreads[i]->getCurrentSurface();
+        if(s && s->getDrawable() && s->getDrawable()->isInUse((Image*)image))
+            return true;
     }
-
-	//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);
-
+    return false;
+}
+//
 RIEGLContext::RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config) :
 	m_vgContext(vgctx),
 	m_config(config),
@@ -191,41 +408,6 @@
 	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),
@@ -249,49 +431,6 @@
 	}
 }
 
-/*-------------------------------------------------------------------*//*!
-* \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(),
@@ -421,6 +560,24 @@
 	return EGL_FALSE;
 }
 
+RIEGLSurface* RIEGLDisplay::getSurface(const EGLSurface surf) const
+{
+	/*
+	CEGLSurface* ret = FindObjectByPointer<CEGLSurface>( m_surfaces, surfaceId, NULL );
+    if( ret && ret->IsTerminated() ) ret = NULL;
+    return ret;
+    */
+    RIEGLSurface* ret = NULL;
+    for(int i = 0; i < m_surfaces.size(); i++ )
+    {
+		if( m_surfaces[i] == CastToRIEGLSurface(surf) )
+        {
+			ret = m_surfaces[i];
+        }
+    }
+    return ret;
+}
+
 EGLBoolean RIEGLDisplay::configExists(const EGLConfig config) const
 {
     for(int i=0;i<EGL_NUMCONFIGS;i++)
@@ -431,42 +588,6 @@
 	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),
@@ -480,297 +601,12 @@
 {
 }
 
-
-
-
-
-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
+namespace OpenVGRI
 {
-	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)
+//static void eglSetError(EGL* egl, EGLint error)
+void eglSetError(EGL* egl, EGLint error)
 {
 	RIEGLThread* thread = egl->getThread();
 	if(thread)
@@ -786,7 +622,7 @@
 
 void* eglvgGetCurrentVGContext(void)
 {
-	EGL* egl = getEGL();
+	EGL* egl = OpenVGRI::getEGL();
     if(egl)
     {
         RIEGLThread* thread = egl->getCurrentThread();
@@ -808,7 +644,7 @@
 
 bool eglvgIsInUse(void* image)
 {
-	EGL* egl = getEGL();
+	EGL* egl = OpenVGRI::getEGL();
     if(egl)
     {
         return egl->isInUse(image);
@@ -816,43 +652,7 @@
 	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;
-
-
-
+} // namespace OpenVGRI
 
 
 /*-------------------------------------------------------------------*//*!
@@ -863,14 +663,14 @@
 *//*-------------------------------------------------------------------*/
 
 #ifdef BUILD_WITH_PRIVATE_EGL
-RI_APIENTRY EGLint do_eglGetError()
+RI_APIENTRY EGLint do_eglGetError(void)
 #else
 EGLint eglGetError()
 #endif
 {
     OSAcquireMutex();
     EGLint ret = EGL_SUCCESS;
-	EGL* egl = getEGL();
+	EGL* egl = OpenVGRI::getEGL();
     if(egl)
     {
         RIEGLThread* thread = egl->getThread();
@@ -971,10 +771,10 @@
 	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";
+	static const char apis[] = "OpenVG OpenGL_ES OpenGL_ES2";
+	static const char extensions[] = "KHR_reusable_sync EGL_SYMBIAN_COMPOSITION";
+	static const char vendor[] = "Symbian Foundation";
+	static const char version[] = "1.4 mergeegl";
 
 	const char* ret = NULL;
 	switch(name)
@@ -1460,9 +1260,9 @@
 
 	//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;
+	// 
+	void* wc = NULL;
+	Drawable* d = NULL;
 	RIEGLSurface* s = NULL;
 	try
 	{
@@ -1492,9 +1292,268 @@
         RI_DELETE(s);
 		EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE);
 	}
+#ifdef EGL_COMPOSITION
+	RIEGLThread* thread = egl->getThread();
+	RI_ASSERT(thread);
+	
+    
+	//egl->iDisplayMapLock.WriteLock();
+	CEglDisplayInfo** pDispInfo;
+	pDispInfo = egl->iDisplayMap.Find(dpy); // make sure iDisplayInfo is populated in CreateDisplay!!
+	
+	if (pDispInfo && *pDispInfo)
+	{
+		TSurfaceInfo& surfaceInfo = egl->GetSurfaceInfo();
+		// so we don't have to pass alphaFormat to CreateSurface we set it here... not sure if needed anyway
+		surfaceInfo.iAlphaFormat = alphaFormat;
+		
+		if(EGL_TRUE != egl->EglInternalFunction_CreateSurface(/*aThreadState,*/ dpy, (EGLSurface)s, config, win, surfaceInfo))
+			EGL_RETURN(EGL_BAD_SURFACE, NULL);
+			
+		(*pDispInfo)->iSurfaceMap.Insert(surfaceInfo.iSurface, &surfaceInfo);		
+		
+		TSurfaceConfiguration surfaceConfig;
+		surfaceConfig.SetSurfaceId(surfaceInfo.iSurfaceId);
+			
+		if(surfaceInfo.iNativeWindow.IsWindow())
+		{
+			RWindow* window = (RWindow*)(win);				
+			RWsSession& session = *window->Session();
+			session.RegisterSurface(surfaceInfo.iScreenNumber, surfaceInfo.iSurfaceId);
+			window->SetBackgroundSurface(surfaceConfig, ETrue);
+		}
+		else
+		{
+			// Now what?? Nothing is good enough?
+			// Simply no composition if not RWindow?
+			EGL_TRACE("eglCreateWindowSurface - Native Window NOT RWindow - no composition");
+		}
+		
+		TRequestStatus status = KRequestPending;
+		TTimeStamp timestampLocalToThread;
+		// session needs to be established... and it is in InternalFunction_CreateSurface
+		/*
+		 * When double-buffering is used, the client renders to one buffer (called A in this example) while the other buffer (B) is on the screen and vice versa. In order for this to work correctly and to be free of tearing artefacts, the client must use the following sequence:
+
+		   1. Render the graphics content to buffer A, and call NotifyWhenAvailable() followed by SubmitUpdate() for buffer A.
+		   2. Render the graphics content to buffer B, and call NotifyWhenAvailable() followed by SubmitUpdate() for buffer B.
+		   3. Wait for notification that buffer A is available. When it becomes available, render further content to it and call NotifyWhenAvailable() followed by SubmitUpdate() for buffer A.
+		   4. Wait for notification that buffer B is available. When it becomes available, render further content to it and call NotifyWhenAvailable() followed by SubmitUpdate() for buffer B.
+		   5. Repeat steps 3 and 4 for as long as required.
+
+		After sending the first two buffers to the composition engine, the client waits for notification before sending a further buffer. The composition engine always returns notification after receiving a new buffer even if an error condition is detected. 
+		*/
+		surfaceInfo.iSurfaceUpdateSession.NotifyWhenDisplayed(status, timestampLocalToThread);
+		surfaceInfo.iSurfaceUpdateSession.SubmitUpdate(surfaceInfo.iScreenNumber,surfaceInfo.iSurfaceId, 0);
+		surfaceInfo.iSurfaceUpdateSession.SubmitUpdate(surfaceInfo.iScreenNumber,surfaceInfo.iSurfaceId, 1);
+		User::WaitForRequest(status);
+	}
+	
+	
+	
+	//egl->iDisplayMapLock.Unlock();
+		
+	//thread->setError(EGL_SUCCESS); // done by EGL_RETURN macro?
+#endif
 	EGL_RETURN(EGL_SUCCESS, (EGLSurface)s);
 }
 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool EGL::EglInternalFunction_CreateSurface(/*TEglThreadState& aThreadState,*/ EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, 
+		EGLNativeWindowType aNativeWindow, TSurfaceInfo& aSurfaceInfo)
+{
+	
+	aSurfaceInfo.iNativeWindow.SetNativeWindow(aNativeWindow);    
+	aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow;
+	aSurfaceInfo.iSize = aSurfaceInfo.iNativeWindow.SizeInPixels();
+	
+	aSurfaceInfo.iConfigId = aConfig;    
+	aSurfaceInfo.iSurface = aSurface;
+	
+	aSurfaceInfo.iStride = 4 * aSurfaceInfo.iSize.iWidth;          // Number of bytes between start of one line and start of next   
+	    
+	
+	RSurfaceManager::TSurfaceCreationAttributesBuf buf;
+	RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
+	// Set surafce attributes
+    attributes.iSize = aSurfaceInfo.iSize;
+    attributes.iBuffers = 2;           // double-buffering is used
+    attributes.iPixelFormat = EUidPixelFormatARGB_8888;  // this is a guess; either query or hardcode to match syborg
+    //attributes.iPixelFormat = EUidPixelFormatARGB_8888_PRE;  // this is a guess; either query or hardcode
+    /** Minimum or required number of bytes between start of one line andstart of next. */
+    attributes.iStride = aSurfaceInfo.iStride;
+    /** Minimum or required offset to the first buffer from the base of the chunk. 
+     * Typically this will be set to 0. The value specified for the offset must comply with the alignment specified in iAlignment.
+     * If iAlignment is page aligned, this value will be rounded up to a multiple of the page size when the surface is created, 
+     * therefore the surface info must be queried for the actual value used. */
+    attributes.iOffsetToFirstBuffer = 0;
+    /** Alignment applied to the base address of each buffer in the surface:
+     * 1, 2, 4, 8 ,16, 32, 64 bytes or EPageAligned. */
+    attributes.iAlignment = RSurfaceManager::EPageAligned;                      // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned
+    /** Number of hints in the array iSurfaceHints. 
+     * The number should not exceed the maximum number supported by the surface manager, 
+     * see GetSurfaceManagerAttrib(EMaxNumberOfHints). */
+    attributes.iHintCount=0;
+    /** Array of hints which should be associated with the surface. 
+     * This array must not contain duplicate hint keys. */
+     attributes.iSurfaceHints = NULL;
+    /** Minimum or required offset between the start of one buffer and the
+	start of the next one in bytes. When set to 0 the surface manager will
+	choose how buffers are laid out within the chunk. If it is too small
+	and doesn't fit with the alignment, CreateSurface() will return KErrArgument. */
+    attributes.iOffsetBetweenBuffers = 0;
+    /** Require physically contiguous memory. 
+     * This value will be ignored if using a chunk which already exists. */
+    attributes.iContiguous = ETrue;
+    /** Caching attribute to create chunk memory. 
+     * This value will be ignored if using a chunk which already exists. */
+    attributes.iCacheAttrib = RSurfaceManager::ECached;      // Cache attributes
+    /** Should the surface be mappable. 
+     * If EFalse any call to MapSurface() will fail with KErrNotSupported
+     * Note, some architectures may not support mappable surfaces. */
+    attributes.iMappable = ETrue;	
+	//
+    aSurfaceInfo.iScreenNumber = aSurfaceInfo.iNativeWindow.ScreenNumber();
+				
+	// Create the surface
+	
+	aSurfaceInfo.iSurfaceManager.Open();
+	aSurfaceInfo.iSurfaceManager.CreateSurface(buf, aSurfaceInfo.iSurfaceId);
+	
+	TInt err =  aSurfaceInfo.iSurfaceManager.MapSurface(aSurfaceInfo.iSurfaceId, aSurfaceInfo.iChunk);
+		
+	EGL_TRACE("EGL::EglInternalFunction_CreateSurface surface manager returned chunk %x and ret val %d", aSurfaceInfo.iChunk, err);
+				
+
+
+    if ( !EglInternalFunction_CallSetSurfaceParams(/*aThreadState,*/ aDisplay, aSurface, aSurfaceInfo) )
+        {
+        EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end failure");
+
+        return EGL_FALSE;
+        }
+    aSurfaceInfo.iSurfaceUpdateSession.Connect();
+    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end success");
+
+    return EGL_TRUE;
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TBool EGL::EglInternalFunction_CallSetSurfaceParams(/*aThreadState,*/EGLDisplay aDisplay,EGLSurface aSurface,TSurfaceInfo& aSurfaceInfo)
+{
+	EGL_GET_EGL(EGL_FALSE);
+/*
+    EGL_GET_DISPLAY(aDisplay, EGL_NO_SURFACE);
+    EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
+    //RI_ASSERT( display->ProcessId() == process->Id() );
+    RIEGLSurface* surface = display->getSurface( aSurface );
+    EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_BAD_SURFACE);
+ */
+    RI_ASSERT( aSurfaceInfo.iSurfaceType == ESurfaceTypeWindow );
+    
+    //TODO: resizing?
+    
+#ifdef BUILD_WITH_PRIVATE_EGL
+	if(!do_eglQuerySurface(aDisplay, aSurface, EGL_VG_ALPHA_FORMAT, &aSurfaceInfo.iAlphaFormat))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!do_eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_BUFFER_SIZE, &aSurfaceInfo.iColorBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!do_eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_RED_SIZE, &aSurfaceInfo.iRedBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!do_eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_GREEN_SIZE, &aSurfaceInfo.iGreenBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!do_eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_BLUE_SIZE, &aSurfaceInfo.iBlueBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!do_eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_ALPHA_SIZE, &aSurfaceInfo.iAlphaBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+#else
+	if(!eglQuerySurface(aDisplay, aSurface, EGL_VG_ALPHA_FORMAT, &aSurfaceInfo.iAlphaFormat))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_BUFFER_SIZE, &aSurfaceInfo.iColorBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_RED_SIZE, &aSurfaceInfo.iRedBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_GREEN_SIZE, &aSurfaceInfo.iGreenBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_BLUE_SIZE, &aSurfaceInfo.iBlueBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	if(!eglGetConfigAttrib(aDisplay, aSurfaceInfo.iConfigId, EGL_ALPHA_SIZE, &aSurfaceInfo.iAlphaBits))
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+#endif
+
+    
+    EGL_TRACE("EGL::EglInternalFunction_CallSetSurfaceParams  Win surface details: width=%d height=%d colorbits=%d red=%d green=%d blue=%d alpha=%d alphaformat=0x%x",
+    		aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight, aSurfaceInfo.iColorBits, aSurfaceInfo.iRedBits,
+    		aSurfaceInfo.iGreenBits, aSurfaceInfo.iBlueBits, aSurfaceInfo.iAlphaBits, aSurfaceInfo.iAlphaFormat);
+    TInt err;
+    TSize size;
+
+    TInt offsetToFirstBuffer = -1;
+    TInt offsetToSecondBuffer = -1;
+	err = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,0,offsetToFirstBuffer);
+	if(err!=KErrNone)
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+	err = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,1,offsetToSecondBuffer);
+	if(err!=KErrNone)
+		EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE );
+    EGL_TRACE("EGL::EglInternalFunction_CallSetSurfaceParams offsetToFirstBuffer=0x%x offsetToSecondBuffer=0x%x",
+    		offsetToFirstBuffer,offsetToSecondBuffer);
+
+   
+    /* Store the pointer to the pixel data */
+    aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk.Base() + offsetToFirstBuffer;
+    aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk.Base() + offsetToSecondBuffer;
+    
+    aSurfaceInfo.iFrontBuffer = 0; // start rendering buffer 0 as a front buffer
+    
+    //TODO: what else? 
+    EGL_RETURN(EGL_SUCCESS,EGL_TRUE);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+TSurfaceInfo* EGL::EglInternalFunction_GetPlatformSurface( EGLDisplay display, EGLSurface surface )
+{
+	EGL_TRACE( "EGL::EglInternalFunction_GetPlatformSurface");
+	TSurfaceInfo* result = NULL;
+
+	iDisplayMapLock.ReadLock();
+
+	CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display );
+	if (pDispInfo && *pDispInfo)
+		{
+		TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface );
+		if (pSurfaceInfo)
+			{
+			result = *pSurfaceInfo;
+			}
+		}
+
+	// TODO on success should probably Unlock() the surface in the caller
+	iDisplayMapLock.Unlock();
+
+	/* TODO review calling code, to see if this suggestion makes sense
+	if (result == NULL)
+		{
+		EGL_RAISE_ERROR( EGL_BAD_SURFACE, NULL); //Enable this when all surfaces are in surface map
+		}
+		*/
+	return result;
+}
+
+EGLBoolean EGL::EglInternalFunction_SurfaceResized(/*TEglThreadState&,*/ TSurfaceInfo&, int, int) 
+	{
+	return EFalse; // stub code
+	}
+
 /*-------------------------------------------------------------------*//*!
 * \brief	
 * \param	
@@ -1894,6 +1953,104 @@
 #endif
 {
 	EGL_GET_DISPLAY(dpy, EGL_FALSE);
+	// From guestEGL - eglMakeCurrent
+	if (ctx == EGL_NO_CONTEXT)
+	{
+		// what now??
+		EGL_TRACE("eglMakeCurrent context NO_CONTEXT");
+		if ( (draw != EGL_NO_SURFACE) || (read != EGL_NO_SURFACE) )
+		{
+			EGL_RETURN(EGL_BAD_SURFACE, EGL_FALSE);
+		}	
+	}
+	else
+	{
+		if ( (draw == EGL_NO_SURFACE) || (read == EGL_NO_SURFACE) )
+		{
+			EGL_RETURN(EGL_BAD_SURFACE, EGL_FALSE);
+		
+		}
+		// ToDo use new CEglContext code
+		const TInt KMaxSurfaces( 2 );
+		EGLSurface surfaces[KMaxSurfaces];
+		TSurfaceInfo* surfaceInfo[KMaxSurfaces] = {NULL, NULL};
+		surfaces[0] = draw;
+		if (draw != read)
+		{
+			surfaces[1] = read;
+		}
+		else
+		{
+			surfaces[1] = EGL_NO_SURFACE;
+		}
+
+		for ( TInt i = 0; i < KMaxSurfaces; i++ )
+		{
+			if ( EGL_NO_SURFACE != surfaces[i] )
+			{
+				EGL_TRACE("eglMakeCurrent check surface %d", surfaces[i] );
+				surfaceInfo[i] = getEGL()->EglInternalFunction_GetPlatformSurface( dpy, surfaces[i] );
+				EGL_TRACE("eglMakeCurrent surfaces[%d] is %x", i, surfaces[i]);
+				//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE );
+				if ( surfaceInfo[i] )
+				{
+					TSize newSize;
+					switch (surfaceInfo[i]->iSurfaceType)
+					{
+						case ESurfaceTypePixmapFbsBitmap:
+							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iFbsBitmap, EEglPanicTemp);
+							newSize = surfaceInfo[i]->iFbsBitmap->SizeInPixels();
+							break;
+						case ESurfaceTypeWindow:
+							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iNativeWindow, EEglPanicTemp);
+							newSize = surfaceInfo[i]->iNativeWindow.SizeInPixels();
+							break;
+						default:
+							// size cannot change for other surface types
+							newSize = surfaceInfo[i]->iSize;
+							break;
+					}
+					if (newSize != surfaceInfo[i]->iSize)
+					{
+						EGL_TRACE("eglMakeCurrent resize surface");
+						if ( !getEGL()->EglInternalFunction_SurfaceResized(/*aThreadState,*/ *surfaceInfo[i], dpy, surfaces[i] ) )
+						{
+							return EGL_FALSE;
+						}
+						surfaceInfo[i]->iSize = newSize;
+					}
+				}
+			}
+		}
+
+		// adapt to only some surfaces having CEglSurfaceInfo objects so far 
+		EGLSurface drawId = surfaceInfo[0] ? surfaceInfo[0]->iSurface : draw;
+		EGLSurface readId = read;
+		if ((read == draw) && surfaceInfo[0])
+		{
+			readId = surfaceInfo[0]->iSurface;
+		}
+		else if (surfaceInfo[1])
+		{
+			readId = surfaceInfo[1]->iSurface;
+		}
+
+		EGL_TRACE("  eglMakeCurrent surfaces[0]=0x%x, surfaces[1]=0x%x", surfaces[0], surfaces[1]);
+		EGL_TRACE("  eglMakeCurrent surfacesInfo[0]=0x%x, surfacesInfo[0].iSurface=0x%x",
+					surfaceInfo[0], surfaceInfo[0] ? surfaceInfo[0]->iSurface : NULL);
+		EGL_TRACE("  eglMakeCurrent surfacesInfo[1]=0x%x, surfacesInfo[1].iSurface=0x%x",
+					surfaceInfo[1], surfaceInfo[1] ? surfaceInfo[1]->iSurface : NULL);
+
+		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
+		// now we need to use readId and drawId
+		draw = drawId;
+		read = readId;
+	}
+	// end from guestEGL
+	/* following is original EGL... very much different to hostEGL!
+	 * is that an issue?
+	 * Works only with one buffer... draw only used from now on?
+	 */
 	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);
@@ -1976,6 +2133,7 @@
 		c->addReference();
 		s->addReference();
 	}
+	
 	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
 }
 
@@ -2182,7 +2340,18 @@
 * \return	
 * \note		
 *//*-------------------------------------------------------------------*/
+/*
+ * guestEGL swap buffers
+ * 
 
+	 * PSEUDO CODE
+	 * serialization.eglSwapBuffers
+	 * (maybe finish currently bound api)
+	 * surfaceupdatesession.notifywhenavailable
+	 *   .whendisplayed()  (alternative choice from above)
+	 * surfaceupdatesession.submitupdated()
+	 * user:waitforrequestl
+ */
 #ifdef BUILD_WITH_PRIVATE_EGL
 RI_APIENTRY EGLBoolean do_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
 #else
@@ -2193,6 +2362,10 @@
 	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE);
 	EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE);
 
+	
+	TSurfaceInfo* surfaceInfo = egl->EglInternalFunction_GetPlatformSurface( dpy, surface );
+	EGL_IF_ERROR(!surfaceInfo, EGL_BAD_SURFACE, EGL_FALSE);
+	
 	RIEGLSurface* s = (RIEGLSurface*)surface;
 
 	RIEGLThread* currentThread = egl->getCurrentThread();
@@ -2204,19 +2377,67 @@
 #else
 	vgFlush();
 #endif
-
+	
+	EGLint currentApi = currentThread->getBoundAPI();
+	RIEGLContext* context = currentThread->getCurrentContext();
+	switch( currentApi )
+	{
+		case EGL_OPENVG_API:
+	    {
+			//if( thread->CurrentVGContext() != surface->BoundContext() )
+			if( currentThread->getCurrentContext()->getVGContext() != s->getOSWindowContext() ) // getOSWindowContext??
+			{
+				//EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_SURFACE );
+				EGL_TRACE("eglSwapBuffers EGL_BAD_SURFACE for EGL_OPENVG_API ");
+				//EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE); // commnted out as the check against OSWindowContext seems wrong
+			}
+			break;
+	    }
+	    case EGL_OPENGL_ES_API:
+	    {
+			/*
+	        if( thread->CurrentGLESContext() != surface->BoundContext() )
+	        {
+				 EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_SURFACE );
+	        }
+	        */
+	        EGL_RETURN(EGL_BAD_SURFACE,EGL_FALSE);
+	        // \todo other GLES stuff?
+	     }
+	}
+	
+	
+	
+	/*
+	 * ToDo
+	 * from hostegl
+	 if( !(CEGLOs::IsValidNativeWindow(((CEGLWindowSurface*)surface)->NativeType())) )
+	 */
 	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);
 	}
-
+	if( surfaceInfo->iSurfaceType != ESurfaceTypeWindow || s->getRenderBuffer() == EGL_SINGLE_BUFFER )
+	{
+		EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+	}
+	
 	int windowWidth = 0, windowHeight = 0;
     OSGetWindowSize(s->getOSWindowContext(), windowWidth, windowHeight);
-
+    /*
+    * TODO
+    * what we need to do for resize to work?
+    */
 	if(windowWidth != s->getDrawable()->getWidth() || windowHeight != s->getDrawable()->getHeight())
 	{	//resize the back buffer
 		RIEGLContext* c = currentThread->getCurrentContext();
 		RI_ASSERT(c);
+		/* from hostEGL
+		if( !(surface->Resize(w, h)) )
+		{
+			EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_ALLOC );
+		}
+		*/
 		try
 		{
 			s->getDrawable()->resize(windowWidth, windowHeight);	//throws bad_alloc
@@ -2226,11 +2447,98 @@
 			c->getVGContext()->setDefaultDrawable(NULL);
 			EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE);
 		}
+		if( windowWidth <= 0 || windowHeight <= 0 )
+		{
+			// invisible window => do nothing
+			EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+		}
+		/*
+		 * what is this for? From hostEgl...
+		 
+		if( surface->VGClientSurface() && state->VGInterface() )
+		{
+			if( !(state->VGInterface()->ResizeSurface(thread->CurrentVGContext()->ClientContext(),
+					surface->VGClientSurface(), w, h, surface->VGBuffers())) )
+		    {
+				EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_ALLOC );
+		    }
+		}
+		*/
 	}
-
+	
+	
+	//
+	
+	void* buf = NULL;
+	if (surfaceInfo->iFrontBuffer == 0)
+	{
+		buf = surfaceInfo->iBuffer1;
+	}
+	else
+	{
+		buf = surfaceInfo->iBuffer0;
+	}
+	
+	//
+	switch( currentApi )
+	{
+		case EGL_OPENVG_API:
+		{
+			//VGImageFormat format = VG_sARGB_8888_PRE; // hack!!
+			VGImageFormat format = VG_sARGB_8888; // hack!!
+			//VGImageFormat format = VG_sRGBA_8888; // hack!!
+			//
+			vgReadPixels(buf,surfaceInfo->iStride,format,0,0,windowWidth,windowHeight);
+		    break;
+		}
+		case EGL_OPENGL_ES_API:
+		{
+		/*
+			if( surface->BoundContext() && !(state->GLESInterface(surface->BoundContext()->ClientVersion())) )
+			{
+				// \todo error code?
+				EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_ACCESS );
+			}
+			*/
+			EGL_RETURN(EGL_BAD_ACCESS, EGL_FALSE);
+		}
+	}
+	//
     OSBlitToWindow(s->getOSWindowContext(), s->getDrawable());
+    getEGL()->EglInternalFunction_SwapBuffers(dpy, surface);
+    
+	
+    EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+}
 
-	EGL_RETURN(EGL_SUCCESS, EGL_TRUE);
+TBool EGL::EglInternalFunction_SwapBuffers(EGLDisplay aDisplay, EGLSurface aSurface)
+{
+	TSize size = iSurfaceInfo.iNativeWindow.SizeInPixels();
+	
+	TRequestStatus status;
+	TTimeStamp timestampLocalToThread;
+	// session needs to be established
+	iSurfaceInfo.iSurfaceUpdateSession.NotifyWhenDisplayed(status, timestampLocalToThread);
+	// what to do if native window is not RWindow???
+	if (iSurfaceInfo.iFrontBuffer == 0)
+	{
+		iSurfaceInfo.iFrontBuffer = 1;
+	}
+	else
+	{
+		iSurfaceInfo.iFrontBuffer = 0;
+	}
+	iSurfaceInfo.iSurfaceUpdateSession.SubmitUpdate(iSurfaceInfo.iScreenNumber,iSurfaceInfo.iSurfaceId, iSurfaceInfo.iFrontBuffer);
+	User::WaitForRequest(status);
+	    
+	if (size != iSurfaceInfo.iSize)
+	{
+		EGL_TRACE("EGL::EglInternalFunction_SwapBuffers Surface Resized size=%d,%d, iSurfaceInfo.iSize=%d,%d",
+	    			size.iHeight, size.iWidth, iSurfaceInfo.iSize.iHeight, iSurfaceInfo.iSize.iWidth);
+	    			
+	    return EglInternalFunction_SurfaceResized(/*aThreadState,*/ iSurfaceInfo, aDisplay, aSurface); // TODO handling of resize
+	}
+	return EGL_TRUE;
 }
 
 /*-------------------------------------------------------------------*//*!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.h	Thu Nov 18 23:28:27 2010 +0000
@@ -0,0 +1,519 @@
+/*------------------------------------------------------------------------
+ *
+ * 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.
+ *//*-------------------------------------------------------------------*/
+#ifndef __MINI_EGL_H_
+#define __MINI_EGL_H_
+
+#include "egl.h"
+#include "openvg.h"
+#include "riArray.h"
+#include "riMath.h"
+#include "riContext.h"
+#include "riImage.h"
+
+#include "eglosnativewindowtype.h"
+
+#ifdef BUILD_WITH_PRIVATE_EGL 
+#include "eglinternal.h"
+#endif
+
+#ifdef BUILD_WITH_PRIVATE_OPENVG
+#include "openvginternal.h"
+#endif
+
+#ifdef EGL_COMPOSITION
+// Surface Manager and Update
+#include <w32std.h>
+#include <graphics/surfacemanager.h>
+#include <graphics/surfaceconfiguration.h>
+#include <graphics/suerror.h>
+#include <graphics/surface_hints.h>
+#include <graphics/surfaceupdateclient.h>
+#include <e32hashtab.h>
+#endif
+
+
+//==============================================================================================
+// EGL header
+typedef enum
+	{
+	ESurfaceTypeWindow = 0,
+	ESurfaceTypePbuffer = 1,
+	ESurfaceTypePixmapFbsBitmap = 2,
+	ESurfaceTypePixmapSgImage = 3,
+	} TEglSurfaceType;
+
+#define KDefaultScreenNumber 0
+	
+class CEglContext;
+
+// client side info about a surface
+struct TSurfaceInfo
+    {
+	//TSurfaceInfo& operator=( TSurfaceInfo& aRhs );
+    TSize                   iSize;
+    TEglSurfaceType         iSurfaceType; //Surface type
+    EGLConfig               iConfigId;
+    CFbsBitmap*             iFbsBitmap;       // Handle for CFbsBitmap
+
+    EGLSurface              iSurface; 			// insted of HostSurfaceId
+	// Note: most member data is only used by Window surfaces
+    TSurfaceId              iSurfaceId;        /*<! Target system surface allocated by EGL.                                              */
+    //
+    RSurfaceManager			iSurfaceManager;
+    RSurfaceUpdateSession	iSurfaceUpdateSession;
+    void*                   iBuffer0;          /*<! Pointer to the first buffer pixels                                                   */
+    void*                   iBuffer1;          /*<! Pointer to the second buffer pixels                                                  */
+    //TInt                    iBuffer0Index;          /*<! Pointer to the first buffer pixels                                                   */
+    //TInt                    iBuffer1Index;          /*<! Pointer to the second buffer pixels                                                  */
+    RChunk                  iChunk;            /*<! chunk of the backbuffer surface memory                                               */
+    TInt					iFrontBuffer;		// We assume zero based index, 0 -> iBuffer0, 1 -> iBuffer1 should be display
+    TNativeWindowType		iNativeWindow;		// TNativeWindowType used now instead of RWindow directly
+    TInt					iScreenNumber; 		// either provided by RWindow or default screen(0)
+    EGLint                  iRedBits;
+    EGLint                  iGreenBits;
+    EGLint                  iBlueBits;
+    EGLint                  iAlphaBits;
+    EGLenum                 iAlphaFormat;
+    EGLint                  iColorBits;
+    EGLint                  iStride;
+    //
+    };
+
+
+// Container for Symbian client side information about an EGL Display
+NONSHARABLE_CLASS(CEglDisplayInfo) : public CBase
+	{
+public:
+	TBool                              iInitialized;
+//	RMutex                             iSurfaceMapLock;
+    RHashMap<TInt, TSurfaceInfo*>      iSurfaceMap;
+//private:
+//	RMutex                             iContextMapLock;
+    RHashMap<EGLContext, CEglContext*> iContextMap;
+    };
+//==============================================================================================
+
+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)	{} //why VG_sRGBA_8888 and not VG_sARGB_8888 by default?
+	~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);
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \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);
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \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;
+
+    RIEGLSurface* 	  getSurface(const EGLSurface surf) 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];
+};
+
+
+
+/*-------------------------------------------------------------------*//*!
+* \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;
+};
+
+
+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);
+    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;
+    
+    // Following functions ported from guestEGL
+    TBool 				CreateDisplayInfo(const EGLDisplay aDisplayID);
+	TBool 				InitializeDisplayInfo(EGLDisplay aDisplay);
+	TBool 				IsDisplayInitialized(EGLDisplay aDisplay);
+	TBool 				DestroyDisplayInfo(EGLDisplay aDisplay);
+	
+    // API supporting EGL sync extension
+    EGLint FindAndLockDisplay(EGLDisplay aDisplayID);
+    void ReleaseDisplayLock(EGLDisplay aDisplayID);
+    EGLint InitialiseExtensions();
+    CEglSyncExtension* 	EGLSyncExtension() {return iEglSyncExtension;};
+    //
+    TSurfaceInfo&	GetSurfaceInfo() {return iSurfaceInfo;};
+// Following should be really private... if there were 'external' equivalents defined in EGL class...
+//private:
+public:
+    TBool EglInternalFunction_CreateSurface(EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, EGLNativeWindowType aNativeWindow,
+    		TSurfaceInfo& aSurfaceInfo);
+    TBool EglInternalFunction_CallSetSurfaceParams(EGLDisplay aDisplay, EGLSurface aSurface,TSurfaceInfo& aSurfaceInfo);
+    TBool EglInternalFunction_SwapBuffers(EGLDisplay aDisplay, EGLSurface aSurface);
+    TSurfaceInfo* EglInternalFunction_GetPlatformSurface( EGLDisplay display, EGLSurface surface );
+    EGLBoolean EglInternalFunction_SurfaceResized(TSurfaceInfo&, int, int);
+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;
+	
+	//data members supporting EGL Sync extension
+	CEglSyncExtension* 		iEglSyncExtension;
+	TSurfaceInfo 			iSurfaceInfo;
+	// public for now
+public:
+	RReadWriteLock			iDisplayMapLock; // protects the iDisplayMap for multi-threaded clients
+	RHashMap<TInt, CEglDisplayInfo*> iDisplayMap;
+};
+
+// 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);
+
+EGL* getEGL();
+
+/*-------------------------------------------------------------------*//*!
+* \brief	
+* \param	
+* \return	
+* \note		
+*//*-------------------------------------------------------------------*/
+
+#define EGL_GET_DISPLAY(DISPLAY, RETVAL) \
+	OSAcquireMutex(); \
+	EGL* egl = OpenVGRI::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) { OpenVGRI::eglSetError(egl, ERRORCODE); OSReleaseMutex(); return RETVAL; } \
+
+#define EGL_RETURN(ERRORCODE, RETVAL) \
+	{ \
+		OpenVGRI::eglSetError(egl, ERRORCODE); \
+		OSReleaseMutex(); \
+		return RETVAL; \
+	}
+
+/*-------------------------------------------------------------------*//*!
+* \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);
+
+/*-------------------------------------------------------------------*//*!
+* \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);
+
+
+//==============================================================================================
+
+}	//namespace OpenVGRI
+
+#endif //__MINI_EGL_H_
--- a/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/eglosnativewindowtype.h	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/eglosnativewindowtype.h	Thu Nov 18 23:28:27 2010 +0000
@@ -20,34 +20,43 @@
 #ifndef EGLOSNATVIEWINDOWTYPE_H
 #define EGLOSNATVIEWINDOWTYPE_H
 
+#define KDefaultScreenNumber 0
+
 class REglWindowBase
 	{
 public:
-	TBool IsWindow()
-		{
-		if(*(TInt32*)iOffset == 0xFFFFFFFF)
-			{
-			return EFalse;
-			}
-		}
+	//virtual TBool IsValid() const = 0;
+	//virtual TSize SizeInPixels() const = 0;
+	//virtual TSize SizeInTwips() const = 0;
+	//virtual TInt ScreenNumber() const = 0;
 protected:
-	REglWindowBase():iOffsetVal(0xFFFFFFFF)
-		{
-		iOffset= &iOffsetVal;
-		}
-	TInt32 iOffsetVal;
-	void* iOffset;
+	REglWindowBase();
+private:
+	friend class TNativeWindowType;
+	TBool IsRWindow() const;
+private:
+	TInt32 iFourByteOffset;
+	TAny* iIsRWindow;
 	};
 
-struct TNativeWindowType:public REglWindowBase
+
+class TNativeWindowType
 	{
 public:
-	TNativeWindowType() :
-	iSize(0,0),
-	iBitmap(NULL)
-	{};
+	IMPORT_C TNativeWindowType(EGLNativeWindowType aNativeWindow);
+	IMPORT_C TNativeWindowType();
+	IMPORT_C void SetNativeWindow(EGLNativeWindowType aNativeWindow);
+	IMPORT_C TBool IsValid() const;
+	IMPORT_C TSize SizeInPixels() const;
+	//virtual TSize SizeInTwips() const = 0;
+	IMPORT_C TInt ScreenNumber() const;
+	IMPORT_C TBool IsWindow() const;
+	
 	TSize				iSize; //to keep
 	CFbsBitmap* 		iBitmap; //to keep
+private:
+	REglWindowBase*		iEglWindow;
+	TBool 				iIsValid;
 	};
 
 #endif //EGLOSCALLBACK_H
--- a/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/riEGLOS.cpp	Tue Nov 02 08:37:41 2010 +0000
+++ b/openvg/openvgrefimplementation/sfopenvg/sfopenvg/symbian/riEGLOS.cpp	Thu Nov 18 23:28:27 2010 +0000
@@ -36,7 +36,78 @@
 
 #include <e32std.h>
 #include <w32std.h>
-#include <eglosnativewindowtype.h>
+#include "eglosnativewindowtype.h"
+
+
+REglWindowBase::REglWindowBase()
+{
+	iIsRWindow = (TAny*)0xFFFFFFFF;
+}
+
+TBool REglWindowBase::IsRWindow() const
+{
+	if((TAny*)0xFFFFFFFF == iIsRWindow)
+	{
+		return EFalse;
+	}
+	return ETrue;
+}
+
+EXPORT_C TNativeWindowType::TNativeWindowType(EGLNativeWindowType aNativeWindow) : iSize(0,0),iBitmap(NULL)
+{
+	iEglWindow = (REglWindowBase*)aNativeWindow;
+	iIsValid = ETrue;
+}
+
+EXPORT_C TNativeWindowType::TNativeWindowType() : iSize(0,0),iBitmap(NULL),iEglWindow(NULL),iIsValid(EFalse)
+{
+
+}
+
+EXPORT_C void TNativeWindowType::SetNativeWindow(EGLNativeWindowType aNativeWindow)
+{
+	iEglWindow = (REglWindowBase*)aNativeWindow;
+	iIsValid = ETrue;
+}
+
+EXPORT_C TBool TNativeWindowType::IsValid() const
+{
+	return iIsValid;
+}
+
+EXPORT_C TSize TNativeWindowType::SizeInPixels() const
+{
+	if(iEglWindow && iEglWindow->IsRWindow())
+	{
+		return ((RWindow*)(iEglWindow))->Size();
+	}
+	else
+	{
+		return iSize;
+	}
+}
+
+EXPORT_C TInt TNativeWindowType::ScreenNumber() const
+{
+	if(iEglWindow && iEglWindow->IsRWindow())
+	{
+		return ((RWindow*)(iEglWindow))->ScreenNumber();
+	}
+	else
+	{
+		return KDefaultScreenNumber;
+	}
+}
+
+EXPORT_C TBool TNativeWindowType::IsWindow() const
+{
+	if(iEglWindow)
+	{
+		return iEglWindow->IsRWindow();
+	}
+	else
+		return EFalse;
+}
 
 namespace OpenVGRI
 {
@@ -101,19 +172,13 @@
 		return NULL;
 	}
 	
-	REglWindowBase* winbase = (REglWindowBase*)window;
-	if(winbase->IsWindow() == EFalse)
-		{
-		ctx->iNativeWindowType = (TNativeWindowType*)window;
-		}
-	else
-		{
-		RDrawableWindow* drawableWindow = (RDrawableWindow*)window;
-		ctx->iNativeWindowType = new TNativeWindowType;
-		ctx->iNativeWindowType->iSize.iHeight = drawableWindow->Size().iHeight;
-		ctx->iNativeWindowType->iSize.iWidth = drawableWindow->Size().iWidth;
-		}
+	ctx->iNativeWindowType = new TNativeWindowType(window);
 	
+	if(ctx->iNativeWindowType->IsWindow())
+	{
+		ctx->iNativeWindowType->iSize.iHeight = ctx->iNativeWindowType->SizeInPixels().iHeight;
+		ctx->iNativeWindowType->iSize.iWidth = ctx->iNativeWindowType->SizeInPixels().iWidth;
+	}
 return ctx;
 }
 
@@ -122,6 +187,7 @@
     OSWindowContext* ctx = (OSWindowContext*)context;
     if(ctx)
     {
+		delete ctx->iNativeWindowType;
         RI_DELETE(ctx);
     }
 }
@@ -131,6 +197,10 @@
     OSWindowContext* ctx = (OSWindowContext*)context;
     if(ctx)
     {
+		/* stub!
+		 * ToDo at least attempt to check if IsWindow:o
+		 * or what was the idea here?
+		 */
         return true;
     }
     return false;
@@ -175,6 +245,7 @@
         	ReadPixelsToCFbsBitmap(*bitmap, w, h);        	
         	}
     }
+	// do we need to do anything for OpenVG/GL??
 }
 
 void ReadPixelsToCFbsBitmap(CFbsBitmap& aBitmap, TUint aW, TUint aH)