vghwinterface/vghwapiwrapper/src/eglapiwrapper.cpp
branchbug235_bringup_0
changeset 53 c2ef9095503a
parent 30 f204b762818d
child 56 40cc73c24bf8
equal deleted inserted replaced
52:39e5f73667ba 53:c2ef9095503a
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // 
       
    15 
       
    16 #ifdef WIN32
       
    17 #define WIN32_LEAN_AND_MEAN                       // Exclude rarely-used stuff from Windows headers
       
    18 #include <windows.h>
       
    19 #endif
       
    20 
       
    21 
       
    22 #include <stdio.h>
       
    23 #include <stdlib.h>
       
    24 #include <EGL/egl.h>
       
    25 #include "eglapiwrapper.h"
       
    26 #include "serializedfunctioncall.h"
       
    27 #include "remotefunctioncall.h"
       
    28 #include "khronosapiwrapperdefs.h"
       
    29 #include "KhronosAPIWrapper.h"
       
    30 #include "DriverAPIWrapper.h"
       
    31 
       
    32 
       
    33 EGLAPIWrapper::EGLAPIWrapper( RemoteFunctionCallData& currentFunctionCallData, 
       
    34 	APIWrapperStack* stack, 
       
    35 	void* result, 
       
    36 	MGraphicsVHWCallback* serviceIf, 
       
    37 	void* surfacebuffer,
       
    38 	KhronosAPIWrapper* aAPIWrapper ):
       
    39 	APIWrapper( currentFunctionCallData, stack, result, serviceIf ),
       
    40 	m_currentFunctionCall( m_currentFunctionCallData ),
       
    41 	m_surfaceBuffer( surfacebuffer ),
       
    42 	m_APIWrapper( aAPIWrapper )
       
    43 {
       
    44     TRACE("EGLAPIWrapper::EGLAPIWrapper()\n");
       
    45 }
       
    46 
       
    47 void EGLAPIWrapper::SetProcessInformation( TUint32 aProcess, TUint32 aThread )
       
    48 {
       
    49     TRACE("EGLAPIWrapper::SetProcessInformation()\n");
       
    50 	::eglPlatsimSetProcessInformation( aProcess, aThread );
       
    51 }
       
    52 
       
    53 void EGLAPIWrapper::Cleanup( TUint32 aProcess, TUint32 aThread )
       
    54 {
       
    55     TRACE("EGLAPIWrapper::Cleanup()\n");
       
    56 	::eglPlatsimSetProcessInformation( aProcess, aThread );
       
    57 	::eglReleaseThread();
       
    58 }
       
    59 
       
    60 int EGLAPIWrapper::WriteReply()
       
    61 {
       
    62     TRACE("EGLAPIWrapper::WriteReply()\n");
       
    63 #ifdef LOG_ERROR
       
    64 	int operationid = (int)m_currentFunctionCall.Data().Header().iOpCode;
       
    65 	int eglerror = ::eglPlatsimGetError();
       
    66 	if ( m_lastEglError != eglerror )
       
    67 	{
       
    68 		if ( EGL_SUCCESS != eglerror )
       
    69 			{
       
    70 			TRACE("EGL error 0x%X, for request %d\n", eglerror, operationid );
       
    71 			}
       
    72 		m_lastEglError = eglerror;
       
    73 	}
       
    74 #endif
       
    75 	return APIWrapper::WriteReply();
       
    76 }
       
    77 
       
    78 int EGLAPIWrapper::eglGetError()
       
    79 {
       
    80     TRACE("EGLAPIWrapper::eglGetError()\n");
       
    81     EGLint error = ::eglGetError();
       
    82     m_currentFunctionCall.SetReturnValue( error );
       
    83     return WriteReply();
       
    84 }
       
    85 
       
    86 
       
    87 int EGLAPIWrapper::eglGetDisplay()
       
    88 {
       
    89     TRACE("EGLAPIWrapper::eglGetDisplay() ->\n");
       
    90     EGLNativeDisplayType display_id;
       
    91     m_currentFunctionCall.GetEGLNativeDisplayType( display_id, 0 );
       
    92     /*EGLint display*/EGLDisplay display = ::eglGetDisplay( display_id );
       
    93     m_currentFunctionCall.SetReturnValue( (TUint32)display );
       
    94     TRACE("EGLAPIWrapper::eglGetDisplay() <-\n");
       
    95     return WriteReply();
       
    96 }
       
    97 
       
    98 
       
    99 int EGLAPIWrapper::eglInitialize()
       
   100 {
       
   101     TRACE("EGLAPIWrapper::eglInitialize() ->\n");
       
   102     EGLDisplay dpy;
       
   103     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   104     // The major and minor version numbers are set from the host side
       
   105     EGLBoolean ret = ::eglInitialize( dpy, NULL, NULL);
       
   106     m_currentFunctionCall.SetReturnValue(ret);
       
   107     TRACE("EGLAPIWrapper::eglInitialize() <-\n");
       
   108     return WriteReply();
       
   109 }
       
   110 
       
   111 
       
   112 int EGLAPIWrapper::eglTerminate()
       
   113 {
       
   114     TRACE("EGLAPIWrapper::eglTerminate ->()\n");
       
   115     EGLDisplay dpy;
       
   116     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   117     EGLBoolean result = ::eglTerminate( dpy );
       
   118     m_currentFunctionCall.SetReturnValue( result );
       
   119     TRACE("EGLAPIWrapper::eglTerminate <-()\n");
       
   120     return WriteReply();
       
   121 }
       
   122 
       
   123 
       
   124 int EGLAPIWrapper::eglQueryString()
       
   125 {
       
   126     TRACE("EGLAPIWrapper::eglQueryString() ->\n");
       
   127     EGLDisplay dpy;
       
   128     EGLint name;
       
   129 
       
   130     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   131     m_currentFunctionCall.GetEGLint( name, 1 );
       
   132     const char* result = ::eglQueryString( dpy, name );
       
   133     m_currentFunctionCall.SetReturnValue( result ? 1 : 0 );
       
   134     TRACE("EGLAPIWrapper::eglQueryString() <-\n");
       
   135     return WriteReply();
       
   136 }
       
   137 
       
   138 
       
   139 int EGLAPIWrapper::eglGetConfigs()
       
   140 {
       
   141     TRACE("EGLAPIWrapper::eglGetConfigs() ->\n");
       
   142     EGLDisplay dpy;
       
   143     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   144 
       
   145     EGLint num_config = 0;
       
   146     EGLint config_size = 0;
       
   147     EGLint config_limit = 0;
       
   148     EGLConfig* configs = 0;
       
   149     EGLint* num_config_data = 0;
       
   150     EGLint num_config_size = 0;
       
   151 
       
   152     m_currentFunctionCall.GetEGLConfigVectorData( configs, config_size, 1 );
       
   153     if ( config_size )
       
   154     {
       
   155         configs = (EGLConfig*)iStack->AllocFromStack( config_size*m_currentFunctionCall.GetTypeSize( EglRFC::EEGLConfig),
       
   156             m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLConfig) );
       
   157     }
       
   158     m_currentFunctionCall.GetEGLint( config_limit, 2 );
       
   159     m_currentFunctionCall.GetEGLintVectorData( num_config_data, num_config_size, 3 );
       
   160     EGLBoolean result = ::eglGetConfigs( dpy, configs, config_limit, num_config_size ? &num_config : NULL);
       
   161     
       
   162     if(configs)
       
   163     {
       
   164         m_currentFunctionCall.SetEGLConfigVectorData( configs, config_limit, 1 );
       
   165     }
       
   166     if (num_config_size)
       
   167     {
       
   168         if (config_size && num_config > config_limit)
       
   169             num_config = config_limit;
       
   170         m_currentFunctionCall.SetEGLintVectorData( &num_config, 1, 3 );
       
   171     }
       
   172 
       
   173     m_currentFunctionCall.SetReturnValue( result );
       
   174     int reply = WriteReply();
       
   175 
       
   176     iStack->ClearStack();
       
   177     configs = NULL;
       
   178     TRACE("EGLAPIWrapper::eglGetConfigs() <-\n");
       
   179     return reply;
       
   180 }
       
   181 
       
   182 
       
   183 int EGLAPIWrapper::eglChooseConfig()
       
   184 {
       
   185     TRACE("EGLAPIWrapper::eglChooseConfig() ->\n");
       
   186     EGLDisplay dpy;
       
   187     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   188 
       
   189     EGLint num_config = 0;
       
   190     EGLint config_size = 0;
       
   191     EGLint config_limit = 0;
       
   192     EGLConfig* configs = 0;
       
   193     EGLint* attribs = 0;
       
   194     EGLint attrib_size = 0;
       
   195     EGLint* num_config_data = 0;
       
   196     EGLint num_config_size = 0;
       
   197 
       
   198     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 1 );
       
   199     m_currentFunctionCall.GetEGLConfigVectorData( configs, config_size, 2 );
       
   200     if ( config_size )
       
   201     {
       
   202         configs = (EGLConfig*)iStack->AllocFromStack( config_size*m_currentFunctionCall.GetTypeSize( EglRFC::EEGLConfig),
       
   203             m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLConfig) );
       
   204     }
       
   205     m_currentFunctionCall.GetEGLint( config_limit, 3 );
       
   206     m_currentFunctionCall.GetEGLintVectorData( num_config_data, num_config_size, 4 );
       
   207     EGLBoolean result = ::eglChooseConfig( dpy, attribs, configs, config_limit, num_config_size ? &num_config : NULL );
       
   208     if(configs)
       
   209     {
       
   210         m_currentFunctionCall.SetEGLConfigVectorData( configs, config_limit, 2 );
       
   211     }
       
   212     if (num_config_size)
       
   213     {
       
   214         if (config_size && num_config > config_limit)
       
   215             num_config = config_limit;
       
   216         m_currentFunctionCall.SetEGLintVectorData( &num_config, 1, 4 );
       
   217     }
       
   218 
       
   219     m_currentFunctionCall.SetReturnValue( result );
       
   220     int reply = WriteReply();
       
   221 
       
   222     iStack->ClearStack();
       
   223     configs = NULL;
       
   224     TRACE("EGLAPIWrapper::eglChooseConfig() <-\n");
       
   225     return reply;
       
   226 }
       
   227 
       
   228 
       
   229 int EGLAPIWrapper::eglGetConfigAttrib()
       
   230 {
       
   231     TRACE("EGLAPIWrapper::eglGetConfigAttrib() ->\n");
       
   232     EGLDisplay dpy;
       
   233     EGLConfig config;
       
   234     EGLint attrib;
       
   235     EGLint value = 0;
       
   236     EGLint* value_data;
       
   237     EGLint value_size;
       
   238 
       
   239     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   240     m_currentFunctionCall.GetEGLConfig( config, 1 );
       
   241     m_currentFunctionCall.GetEGLint( attrib, 2 );
       
   242     m_currentFunctionCall.GetEGLintVectorData( value_data, value_size, 3 );
       
   243     EGLBoolean result = ::eglGetConfigAttrib( dpy, config, attrib, value_size ? &value : NULL);
       
   244     
       
   245 	if (value_size)
       
   246 	{
       
   247         m_currentFunctionCall.SetEGLintVectorData( &value, 1, 3 );
       
   248 	}
       
   249 
       
   250     m_currentFunctionCall.SetReturnValue( result );
       
   251     TRACE("EGLAPIWrapper::eglGetConfigAttrib() <-\n");
       
   252     return WriteReply();
       
   253 }
       
   254 
       
   255 
       
   256 int EGLAPIWrapper::eglCreateWindowSurface()
       
   257 {
       
   258     TRACE("EGLAPIWrapper::eglCreateWindowSurface() ->\n");
       
   259     EGLDisplay dpy;
       
   260     EGLConfig config;
       
   261     EGLNativeWindowType window;
       
   262 
       
   263     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   264     m_currentFunctionCall.GetEGLConfig( config, 1 );
       
   265     m_currentFunctionCall.GetEGLNativeWindowType( window, 2 );
       
   266 
       
   267     EGLint* attribs;
       
   268     EGLint attrib_size;
       
   269 
       
   270     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 3 );
       
   271 
       
   272 	int width;
       
   273 	int height;
       
   274 	int horizontalPitch;
       
   275     int verticalPitch;
       
   276 	m_currentFunctionCall.GetEGLint( width, 4);
       
   277 	m_currentFunctionCall.GetEGLint( height, 5);
       
   278 	m_currentFunctionCall.GetEGLint( horizontalPitch, 6);
       
   279 	m_currentFunctionCall.GetEGLint( verticalPitch, 7);
       
   280 
       
   281 	SymbianWindow* nativeWindow = new SymbianWindow;
       
   282 	nativeWindow->id = (int)window;
       
   283 	nativeWindow->width = width;
       
   284 	nativeWindow->height = height;
       
   285 	nativeWindow->horizontalPitch = horizontalPitch;
       
   286     nativeWindow->verticalPitch = verticalPitch;
       
   287 
       
   288     EGLSurface surface = ::eglCreateWindowSurface( dpy, config, (EGLNativeWindowType)nativeWindow, attribs );
       
   289 
       
   290 	if ( EGL_NO_SURFACE != surface )
       
   291 	{
       
   292 		//Takes ownership of nativeWindow
       
   293 		//m_windowMap.insert( std::pair<std::pair<int,int>,SymbianWindow*>( std::pair<int,int>(dpy, surface), nativeWindow ) );
       
   294 		m_windowMap.insert( std::pair<TSurfaceKey,TSurfaceData>( TSurfaceKey((int)dpy, (int)surface, m_currentFunctionCall.Data().Header().iProcessId ), TSurfaceData( nativeWindow ) ) );
       
   295 	}
       
   296 	else
       
   297 	{
       
   298 		delete nativeWindow;
       
   299 	}
       
   300 
       
   301     m_currentFunctionCall.SetReturnValue( (TUint32)surface );
       
   302     TRACE("EGLAPIWrapper::eglCreateWindowSurface() <-\n");
       
   303     return WriteReply();
       
   304 }
       
   305 
       
   306 
       
   307 int EGLAPIWrapper::eglCreatePbufferSurface()
       
   308 {
       
   309     TRACE("EGLAPIWrapper::eglCreatePbufferSurface() ->\n");
       
   310     EGLDisplay dpy;
       
   311     EGLConfig config;
       
   312 
       
   313     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   314     m_currentFunctionCall.GetEGLConfig( config, 1 );
       
   315 
       
   316     EGLint* attribs;
       
   317     EGLint attrib_size;
       
   318 
       
   319     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 2 );
       
   320 
       
   321     EGLSurface surface = ::eglCreatePbufferSurface( dpy, config, attribs );
       
   322     m_currentFunctionCall.SetReturnValue( (TUint32)surface );
       
   323     TRACE("EGLAPIWrapper::eglCreatePbufferSurface() <-\n");
       
   324     return WriteReply();
       
   325 }
       
   326 
       
   327 
       
   328 int EGLAPIWrapper::eglCreatePixmapSurface()
       
   329 {
       
   330     TRACE("EGLAPIWrapper::eglCreatePixmapSurface() ->\n");
       
   331     EGLDisplay display;
       
   332     EGLConfig config;
       
   333     EGLNativePixmapType pixmap;
       
   334     EGLint format;
       
   335     EGLint width;
       
   336     EGLint height;
       
   337     EGLint stride;
       
   338     EGLint pixmapType;
       
   339 
       
   340 	m_currentFunctionCall.GetEGLDisplay( display, 0 );
       
   341     m_currentFunctionCall.GetEGLConfig( config, 1 );
       
   342     m_currentFunctionCall.GetEGLNativePixmapType( pixmap, 2 );
       
   343     m_currentFunctionCall.GetEGLint( format, 3 );
       
   344     m_currentFunctionCall.GetEGLint( width, 4 );
       
   345     m_currentFunctionCall.GetEGLint( height, 5 );
       
   346     m_currentFunctionCall.GetEGLint( stride, 6 );
       
   347     m_currentFunctionCall.GetEGLint( pixmapType, 7 );
       
   348 
       
   349 	SymbianPixmap* nativeBitmap = new SymbianPixmap;
       
   350 	nativeBitmap->data = new unsigned long[(stride*height+3)/4];
       
   351 	nativeBitmap->format = (TDisplayMode)format;
       
   352 	nativeBitmap->width = width;
       
   353 	nativeBitmap->height = height;
       
   354 	nativeBitmap->stride = stride;
       
   355 	nativeBitmap->type = pixmapType;
       
   356 
       
   357     EGLint* attribs;
       
   358     EGLint attrib_size;
       
   359 
       
   360     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 8 );
       
   361 
       
   362 	//Takes ownership of nativeBitmap 
       
   363     EGLSurface surface = ::eglCreatePixmapSurface( display, config, (EGLNativePixmapType)nativeBitmap, attribs );
       
   364     m_currentFunctionCall.SetReturnValue( (TUint32)surface );
       
   365     TRACE("EGLAPIWrapper::eglCreatePixmapSurface() <-\n");
       
   366 	return WriteReply();
       
   367 }
       
   368 
       
   369 
       
   370 int EGLAPIWrapper::eglDestroySurface()
       
   371 {
       
   372     TRACE("EGLAPIWrapper::eglDestroySurface() ->\n");
       
   373     EGLDisplay dpy;
       
   374     EGLConfig surface;
       
   375 
       
   376     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   377     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   378 
       
   379     EGLBoolean result = ::eglDestroySurface( dpy, surface );
       
   380 
       
   381 	if ( result )
       
   382 	{
       
   383 		if ( EGL_NO_SURFACE != surface )
       
   384 		{
       
   385 			TSurfaceMap::iterator cur = m_windowMap.find( TSurfaceKey((int)dpy, (int)surface, m_currentFunctionCall.Data().Header().iProcessId ) );
       
   386 			if ( m_windowMap.end() != cur )
       
   387 			{
       
   388 				SymbianWindow* nativeWindow( cur->second.iWindow );
       
   389 				m_windowMap.erase(cur);
       
   390 				delete nativeWindow;
       
   391 			}
       
   392 		}
       
   393 	}
       
   394 
       
   395     m_currentFunctionCall.SetReturnValue( result );
       
   396     TRACE("EGLAPIWrapper::eglDestroySurface() <-\n");
       
   397     return WriteReply();
       
   398 }
       
   399 
       
   400 
       
   401 int EGLAPIWrapper::eglQuerySurface()
       
   402 {
       
   403     TRACE("EGLAPIWrapper::eglQuerySurface() ->\n");
       
   404     EGLDisplay dpy;
       
   405     EGLConfig surface;
       
   406     EGLint attrib;
       
   407     EGLint value = 0;
       
   408     EGLint* value_data;
       
   409     EGLint value_size;
       
   410 
       
   411     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   412     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   413     m_currentFunctionCall.GetEGLint( attrib, 2 );
       
   414     m_currentFunctionCall.GetEGLintVectorData( value_data, value_size, 3 );
       
   415     EGLBoolean result = ::eglQuerySurface( dpy, surface, attrib, value_size ? &value : NULL);
       
   416     if (value_size)
       
   417         m_currentFunctionCall.SetEGLintVectorData( &value, 1, 3 );
       
   418 
       
   419     m_currentFunctionCall.SetReturnValue( result );
       
   420     TRACE("EGLAPIWrapper::eglQuerySurface() <-\n");
       
   421     return WriteReply();
       
   422 }
       
   423 
       
   424 
       
   425 int EGLAPIWrapper::eglBindAPI()
       
   426 {
       
   427     TRACE("EGLAPIWrapper::eglBindAPI() ->\n");
       
   428     EGLenum api;
       
   429     m_currentFunctionCall.GetEGLenum( api, 0 );
       
   430     EGLBoolean result = ::eglBindAPI( api );
       
   431     m_currentFunctionCall.SetReturnValue( result );
       
   432     TRACE("EGLAPIWrapper::eglBindAPI() <-\n");
       
   433     return WriteReply();
       
   434 }
       
   435 
       
   436 
       
   437 int EGLAPIWrapper::eglQueryAPI()
       
   438 {
       
   439     TRACE("EGLAPIWrapper::eglQueryAPI() ->\n");
       
   440     EGLenum result = ::eglQueryAPI();
       
   441     m_currentFunctionCall.SetReturnValue( result );
       
   442     TRACE("EGLAPIWrapper::eglQueryAPI() <-\n");
       
   443     return WriteReply();
       
   444 }
       
   445 
       
   446 
       
   447 int EGLAPIWrapper::eglWaitClient()
       
   448 {
       
   449     TRACE("EGLAPIWrapper::eglWaitClient() ->\n");
       
   450     EGLBoolean result = ::eglWaitClient();
       
   451     m_currentFunctionCall.SetReturnValue( result );
       
   452     TRACE("EGLAPIWrapper::eglWaitClient() <-\n");
       
   453     return WriteReply();
       
   454 }
       
   455 
       
   456 
       
   457 int EGLAPIWrapper::eglReleaseThread()
       
   458 {
       
   459     TRACE("EGLAPIWrapper::eglReleaseThread() ->\n");
       
   460     EGLBoolean result = ::eglReleaseThread();
       
   461     m_currentFunctionCall.SetReturnValue( result );
       
   462     TRACE("EGLAPIWrapper::eglReleaseThread() <-\n");
       
   463     return WriteReply();
       
   464 }
       
   465 
       
   466 
       
   467 int EGLAPIWrapper::eglCreatePbufferFromClientBuffer()
       
   468 {
       
   469     TRACE("EGLAPIWrapper::eglCreatePbufferFromClientBuffer() ->\n");
       
   470     EGLDisplay dpy;
       
   471     EGLenum buftype;
       
   472     EGLClientBuffer buffer;
       
   473     EGLConfig config;
       
   474 	
       
   475     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   476     m_currentFunctionCall.GetEGLenum( buftype, 1 );
       
   477     m_currentFunctionCall.GetEGLClientBuffer( buffer, 2 );
       
   478     m_currentFunctionCall.GetEGLConfig( config, 3 );
       
   479 
       
   480 	if( buftype == EGL_OPENVG_IMAGE &&
       
   481 		m_APIWrapper->GetDriverWrapper()->IsSgBackingVGImage( (VGImage)buffer ) )
       
   482 	{
       
   483 		//TODO EGL_BAD_ADDRESS
       
   484 	}
       
   485 
       
   486     EGLint* attribs;
       
   487     EGLint attrib_size;
       
   488 
       
   489     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 4 );
       
   490 
       
   491     EGLSurface surface = ::eglCreatePbufferFromClientBuffer( dpy, buftype, buffer, config, attribs );
       
   492     m_currentFunctionCall.SetReturnValue( (TUint32)surface );
       
   493     TRACE("EGLAPIWrapper::eglCreateBufferFromClientBuffer() <-\n");
       
   494     return WriteReply();
       
   495 }
       
   496 
       
   497 
       
   498 int EGLAPIWrapper::eglSurfaceAttrib()
       
   499 {
       
   500     TRACE("EGLAPIWrapper::eglSurfaceAttrib() ->\n");
       
   501     EGLDisplay dpy;
       
   502     EGLSurface surface;
       
   503     EGLint attrib;
       
   504     EGLint value;
       
   505 
       
   506     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   507     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   508     m_currentFunctionCall.GetEGLint( attrib, 2 );
       
   509     m_currentFunctionCall.GetEGLint( value, 3 );
       
   510 
       
   511     EGLBoolean result = ::eglSurfaceAttrib( dpy, surface, attrib, value );
       
   512     m_currentFunctionCall.SetReturnValue( result );
       
   513     TRACE("EGLAPIWrapper::eglSurfaceAttrib() <-\n");
       
   514     return WriteReply();
       
   515 }
       
   516 
       
   517 
       
   518 int EGLAPIWrapper::eglBindTexImage()
       
   519 {
       
   520     TRACE("EGLAPIWrapper::eglBindTexImage() ->\n");
       
   521     EGLDisplay dpy;
       
   522     EGLSurface surface;
       
   523     EGLint buffer;
       
   524 
       
   525     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   526     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   527     m_currentFunctionCall.GetEGLint( buffer, 2 );
       
   528 
       
   529     EGLBoolean result = ::eglBindTexImage( dpy, surface, buffer );
       
   530     m_currentFunctionCall.SetReturnValue( result );
       
   531     TRACE("EGLAPIWrapper::eglBindTexImage() <-\n");
       
   532     return WriteReply();
       
   533 }
       
   534 
       
   535 
       
   536 int EGLAPIWrapper::eglReleaseTexImage()
       
   537 {
       
   538     TRACE("EGLAPIWrapper::eglReleaseTexImage() ->\n");
       
   539     EGLDisplay dpy;
       
   540     EGLSurface surface;
       
   541     EGLint buffer;
       
   542 
       
   543     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   544     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   545     m_currentFunctionCall.GetEGLint( buffer, 2 );
       
   546 
       
   547     EGLBoolean result = ::eglReleaseTexImage( dpy, surface, buffer );
       
   548     m_currentFunctionCall.SetReturnValue( result );
       
   549     TRACE("EGLAPIWrapper::eglReleaseTexImage() <-\n");
       
   550     return WriteReply();
       
   551 }
       
   552 
       
   553 
       
   554 int EGLAPIWrapper::eglSwapInterval()
       
   555 {
       
   556     TRACE("EGLAPIWrapper::eglSwapInterval() ->\n");
       
   557     EGLDisplay dpy;
       
   558     EGLint interval;
       
   559 
       
   560     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   561     m_currentFunctionCall.GetEGLint( interval, 1 );
       
   562 
       
   563     EGLBoolean result = ::eglSwapInterval( dpy, interval );
       
   564     m_currentFunctionCall.SetReturnValue( result );
       
   565     TRACE("EGLAPIWrapper::eglSwapInterval() <-\n");
       
   566     return WriteReply();
       
   567 }
       
   568 
       
   569 
       
   570 int EGLAPIWrapper::eglCreateContext()
       
   571 {
       
   572     TRACE("EGLAPIWrapper::eglCreateContext() ->\n");
       
   573     EGLDisplay dpy;
       
   574     EGLConfig config;
       
   575     EGLContext share_context;
       
   576 	EGLBoolean sgSupporting(EGL_FALSE);
       
   577 
       
   578     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   579     m_currentFunctionCall.GetEGLConfig( config, 1 );
       
   580     m_currentFunctionCall.GetEGLContext( share_context, 2 );
       
   581 
       
   582 	if( share_context == EGL_NO_CONTEXT )
       
   583 	{
       
   584 		share_context = m_APIWrapper->GetDriverWrapper()->GetPoolContext();
       
   585 	}
       
   586 
       
   587     EGLint* attribs;
       
   588     EGLint attrib_size;
       
   589 
       
   590     m_currentFunctionCall.GetEGLintVectorData( attribs, attrib_size, 3 );
       
   591 
       
   592     EGLContext context = ::eglCreateContext( dpy, config, share_context, attribs );
       
   593     m_currentFunctionCall.SetReturnValue( (TUint32)context );
       
   594     TRACE("EGLAPIWrapper::eglCreateContext() <-\n");
       
   595     return WriteReply();
       
   596 }
       
   597 
       
   598 
       
   599 int EGLAPIWrapper::eglDestroyContext()
       
   600 {
       
   601     TRACE("EGLAPIWrapper::eglDestroyContext() ->\n");
       
   602     EGLDisplay dpy;
       
   603     EGLContext context;
       
   604 
       
   605     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   606     m_currentFunctionCall.GetEGLContext( context, 1 );
       
   607 
       
   608     EGLBoolean result = ::eglDestroyContext( dpy, context );
       
   609     m_currentFunctionCall.SetReturnValue( result );
       
   610     TRACE("EGLAPIWrapper::eglDestroyContext() <-\n");
       
   611     return WriteReply();
       
   612 }
       
   613 
       
   614 
       
   615 int EGLAPIWrapper::eglMakeCurrent()
       
   616 {
       
   617     TRACE("EGLAPIWrapper::eglMakeCurrent() ->\n");
       
   618     EGLDisplay dpy;
       
   619     EGLSurface draw;
       
   620     EGLSurface read;
       
   621     EGLContext context;
       
   622 	EGLint syncNeed(0);
       
   623 	EGLint src(0);
       
   624 
       
   625     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   626     m_currentFunctionCall.GetEGLSurface( draw, 1 );
       
   627     m_currentFunctionCall.GetEGLSurface( read, 2 );
       
   628     m_currentFunctionCall.GetEGLContext( context, 3 );
       
   629 	if( m_currentFunctionCall.Data().Header().iParameterCount > 4 )
       
   630 	{
       
   631 		m_currentFunctionCall.GetEGLint( syncNeed, 4 );
       
   632 		m_currentFunctionCall.GetEGLint( src, 5 );
       
   633 	}
       
   634 
       
   635 	//Call eglMakeCurrent first
       
   636 	EGLBoolean result = ::eglMakeCurrent( dpy, draw, read, context );
       
   637 
       
   638 	//If the surface is "dirty", then it needs to be drawn the vgImage onto
       
   639 	if( syncNeed & KSyncReadSurface )
       
   640 	{
       
   641 		int width;
       
   642 		int height;
       
   643 		::eglQuerySurface(dpy, read, EGL_WIDTH, &width );
       
   644 		::eglQuerySurface(dpy, read, EGL_HEIGHT, &height );		
       
   645 		m_APIWrapper->GetDriverWrapper()->SyncPBufferFromVGImage( (int)src, width, height );
       
   646 	}
       
   647 	if( syncNeed & KSyncDrawSurface )
       
   648 	{
       
   649 		int width;
       
   650 		int height;
       
   651 		::eglQuerySurface(dpy, draw, EGL_WIDTH, &width );
       
   652 		::eglQuerySurface(dpy, draw, EGL_HEIGHT, &height );
       
   653 		m_APIWrapper->GetDriverWrapper()->SyncPBufferFromVGImage( (int)src, width, height );
       
   654 	}
       
   655     
       
   656     m_currentFunctionCall.SetReturnValue( result );
       
   657     TRACE("EGLAPIWrapper::eglMakeCurrent() <-\n");
       
   658     return WriteReply();
       
   659 }
       
   660 
       
   661 
       
   662 int EGLAPIWrapper::eglGetCurrentContext()
       
   663 {
       
   664     TRACE("EGLAPIWrapper::eglGetCurrentContext() ->\n");
       
   665     EGLContext context = ::eglGetCurrentContext();
       
   666     m_currentFunctionCall.SetReturnValue( (TUint32)context );
       
   667     TRACE("EGLAPIWrapper::eglGetCurrentContext() <-\n");
       
   668     return WriteReply();
       
   669 }
       
   670 
       
   671 
       
   672 int EGLAPIWrapper::eglGetCurrentSurface()
       
   673 {
       
   674     TRACE("EGLAPIWrapper::eglGetCurrentSurface() ->\n");
       
   675     EGLint readdraw;
       
   676 
       
   677     m_currentFunctionCall.GetEGLint( readdraw, 0 );
       
   678 
       
   679     EGLSurface surface = ::eglGetCurrentSurface( readdraw );
       
   680     m_currentFunctionCall.SetReturnValue( (TUint32)surface );
       
   681     TRACE("EGLAPIWrapper::eglGetCurrentSurface() <-\n");
       
   682     return WriteReply();
       
   683 }
       
   684 
       
   685 
       
   686 int EGLAPIWrapper::eglGetCurrentDisplay()
       
   687 {
       
   688     TRACE("EGLAPIWrapper::eglGetCurrentDisplay() ->\n");
       
   689     EGLDisplay display = ::eglGetCurrentDisplay();
       
   690     m_currentFunctionCall.SetReturnValue( (TUint32)display );
       
   691     TRACE("EGLAPIWrapper::eglGetCurrentDisplay() <-\n");
       
   692     return WriteReply();
       
   693 }
       
   694 
       
   695 
       
   696 int EGLAPIWrapper::eglQueryContext()
       
   697 {
       
   698     TRACE("EGLAPIWrapper::eglQueryContext() ->\n");
       
   699     EGLDisplay dpy;
       
   700     EGLContext context;
       
   701     EGLint attrib;
       
   702     EGLint value = 0;
       
   703     EGLint* value_data;
       
   704     EGLint value_size;
       
   705 
       
   706     m_currentFunctionCall.GetEGLDisplay( dpy, 0 );
       
   707     m_currentFunctionCall.GetEGLContext( context, 1 );
       
   708     m_currentFunctionCall.GetEGLint( attrib, 2 );
       
   709     m_currentFunctionCall.GetEGLintVectorData( value_data, value_size, 3 );
       
   710     EGLBoolean result = ::eglQueryContext( dpy, context, attrib, value_size ? &value : NULL);
       
   711     if (value_size)
       
   712         m_currentFunctionCall.SetEGLintVectorData( &value, 1, 3 );
       
   713     m_currentFunctionCall.SetReturnValue( result );
       
   714     TRACE("EGLAPIWrapper::eglQueryContext() <-\n");
       
   715     return WriteReply();
       
   716 }
       
   717 
       
   718 
       
   719 int EGLAPIWrapper::eglWaitGL()
       
   720 {
       
   721     TRACE("EGLAPIWrapper::eglWaitGL() ->\n");
       
   722     EGLBoolean result = ::eglWaitGL();
       
   723     m_currentFunctionCall.SetReturnValue( result );
       
   724     TRACE("EGLAPIWrapper::() <-\n");
       
   725     return WriteReply();
       
   726 }
       
   727 
       
   728 
       
   729 int EGLAPIWrapper::eglWaitNative()
       
   730 {
       
   731     TRACE("EGLAPIWrapper::eglWaitNative() ->\n");
       
   732     EGLint engine;
       
   733 
       
   734     m_currentFunctionCall.GetEGLint( engine, 0 );
       
   735 
       
   736     EGLBoolean result = ::eglWaitNative( engine );
       
   737     m_currentFunctionCall.SetReturnValue( result );
       
   738     TRACE("EGLAPIWrapper::eglWaitNative() <-\n");
       
   739     return WriteReply();
       
   740 }
       
   741 
       
   742 
       
   743 int EGLAPIWrapper::eglSwapBuffers()
       
   744 {
       
   745     TRACE("EGLAPIWrapper::eglSwapBuffers() ->\n");
       
   746     EGLDisplay display;
       
   747     EGLSurface surface;
       
   748 	int width;
       
   749 	int height;
       
   750     m_currentFunctionCall.GetEGLDisplay( display, 0 );
       
   751     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   752     m_currentFunctionCall.GetEGLint( width, 2 );
       
   753     m_currentFunctionCall.GetEGLint( height, 3 );
       
   754 	//TWindowMap::const_iterator cur  = m_windowMap.find(std::pair<int,int>( display, surface ));
       
   755 	TSurfaceMap::const_iterator cur  = m_windowMap.find(TSurfaceKey( (int)display, (int)surface, m_currentFunctionCall.Data().Header().iProcessId ));
       
   756 
       
   757 	//Only found for windows surfaces
       
   758 	if ( m_windowMap.end() != cur )
       
   759 	{
       
   760 		cur->second.iWindow->width = width;
       
   761 		cur->second.iWindow->height = height;
       
   762 	}
       
   763 
       
   764     EGLBoolean result = ::eglSwapBuffers( display, surface );
       
   765 
       
   766     m_currentFunctionCall.SetReturnValue( (TUint32)result );
       
   767     TRACE("EGLAPIWrapper::eglSwapBuffers() <-\n");
       
   768     return WriteReply();
       
   769 }
       
   770 
       
   771 
       
   772 int EGLAPIWrapper::eglCopyBuffers()
       
   773 {
       
   774     TRACE("EGLAPIWrapper::eglCopyBuffers() ->\n");
       
   775     EGLDisplay display(0);
       
   776     EGLSurface surface(0);
       
   777 
       
   778     m_currentFunctionCall.GetEGLDisplay( display, 0 );
       
   779     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   780 
       
   781 	void* data(NULL);
       
   782     int size(0);
       
   783     m_currentFunctionCall.GetVectorData( data, size, 2 );
       
   784 
       
   785 	SymbianPixmap* bitmap(NULL);
       
   786 	if ( size )
       
   787 	{
       
   788 		bitmap = (SymbianPixmap*)iStack->AllocFromStack( sizeof(SymbianPixmap),
       
   789             m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLVoid ) );
       
   790 		bitmap->data = (unsigned long*)iStack->AllocFromStack( size,
       
   791             m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLVoid ) );
       
   792 		EGLint format;
       
   793 		m_currentFunctionCall.GetEGLint( format, 3 );
       
   794 		bitmap->format = (TDisplayMode)format;
       
   795 		m_currentFunctionCall.GetEGLint( bitmap->width, 4 );
       
   796 		m_currentFunctionCall.GetEGLint( bitmap->height, 5 );
       
   797 		m_currentFunctionCall.GetEGLint( bitmap->stride, 6 );
       
   798 		m_currentFunctionCall.GetEGLint( bitmap->type, 7 );
       
   799 	}
       
   800 	else
       
   801 	{
       
   802 		data = NULL;
       
   803 	}
       
   804 	
       
   805     EGLBoolean result = ::eglCopyBuffers( display, surface, (EGLNativePixmapType)bitmap );
       
   806     
       
   807 	if ( result )
       
   808 		{
       
   809 		m_currentFunctionCall.SetVectorData( bitmap->data, size, 2 );
       
   810 		}
       
   811 
       
   812     m_currentFunctionCall.SetReturnValue( result );
       
   813 	int ret = WriteReply();
       
   814 	iStack->ClearStack();
       
   815 	TRACE("EGLAPIWrapper::eglCopyBiffers() <-\n");
       
   816     return ret;
       
   817 }
       
   818 
       
   819 
       
   820 int EGLAPIWrapper::eglPlatsimSetSurfaceParams()
       
   821 {
       
   822     TRACE("EGLAPIWrapper::eglPlatsimSetSurfaceParams() ->\n");
       
   823     EGLDisplay display;
       
   824     EGLSurface surface;
       
   825     EGLint width;
       
   826     EGLint height;
       
   827     EGLint stride;
       
   828     EGLint buffer0Offset(0);
       
   829     EGLint buffer1Offset(0);
       
   830 	NativeWindowType win(0);
       
   831 
       
   832     m_currentFunctionCall.GetEGLDisplay( display, 0 );
       
   833     m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   834     m_currentFunctionCall.GetEGLNativeWindowType( win, 2 );
       
   835     m_currentFunctionCall.GetEGLint( width, 3 );
       
   836     m_currentFunctionCall.GetEGLint( height, 4 );
       
   837     m_currentFunctionCall.GetEGLint( stride, 5 );
       
   838     m_currentFunctionCall.GetEGLint( buffer0Offset, 6 );
       
   839     m_currentFunctionCall.GetEGLint( buffer1Offset, 7 );
       
   840 
       
   841     void* buffer0 = (void*)((EGLint)m_surfaceBuffer + buffer0Offset);
       
   842     void* buffer1 = (void*)((EGLint)m_surfaceBuffer + buffer1Offset);
       
   843 
       
   844 	::eglPlatsimSetSurfaceParams(display, surface, width, height, stride, buffer0, buffer1);
       
   845 	m_currentFunctionCall.SetReturnValue( 0 );
       
   846 	TRACE("EGLAPIWrapper::eglPlatsimSetSurfaceParams() <-\n");
       
   847     return WriteReply();
       
   848 }
       
   849 
       
   850 
       
   851 int EGLAPIWrapper::eglPlatsimCopyImageData()
       
   852 {
       
   853     TRACE("EGLAPIWrapper::eglPlatsimCopyImageData() ->\n");
       
   854     void* data(NULL);
       
   855     int size(0);
       
   856     m_currentFunctionCall.GetVectorData( data, size, 0 );
       
   857 
       
   858 	if ( size )
       
   859 		{
       
   860 		EGLDisplay display = ::eglGetCurrentDisplay();
       
   861 		EGLSurface surface = ::eglGetCurrentSurface(EGL_DRAW);
       
   862 		NativePixmapType nativePixmap = eglPlatsimGetPixmapSurfaceBitmap(display,surface);
       
   863 		SymbianPixmap* symbianBitmap = (SymbianPixmap*)nativePixmap;
       
   864 		if ( symbianBitmap )
       
   865 			{
       
   866 			m_currentFunctionCall.SetVectorData( symbianBitmap->data, size, 0 );
       
   867 			}
       
   868 		}	
       
   869     TRACE("EGLAPIWrapper::eglPlatsimCopyImageData() <-\n");
       
   870     return WriteReply();
       
   871 }
       
   872 
       
   873 int EGLAPIWrapper::eglPixmapSurfaceSizeChanged()
       
   874 {
       
   875     TRACE("EGLAPIWrapper::eglPixmapSurfaceSizeChanged() ->\n");
       
   876 	EGLDisplay display;
       
   877 	m_currentFunctionCall.GetEGLDisplay( display, 0 );
       
   878 	EGLSurface surface;
       
   879 	m_currentFunctionCall.GetEGLSurface( surface, 1 );
       
   880 	NativePixmapType dtype;
       
   881     m_currentFunctionCall.GetEGLNativePixmapType( dtype, 2);
       
   882 	EGLint format;
       
   883 	m_currentFunctionCall.GetEGLint( format, 3 );
       
   884 	EGLint width;
       
   885     m_currentFunctionCall.GetEGLint( width, 4 );
       
   886 	EGLint height;
       
   887     m_currentFunctionCall.GetEGLint( height, 5 );
       
   888 	EGLint stride;
       
   889     m_currentFunctionCall.GetEGLint( stride, 6 );
       
   890 
       
   891 	NativePixmapType nativePixmap = eglPlatsimGetPixmapSurfaceBitmap(display,surface);
       
   892 	SymbianPixmap* symbianBitmap = (SymbianPixmap*)nativePixmap;
       
   893 	if ( symbianBitmap )
       
   894 	{
       
   895 		symbianBitmap->format = (TDisplayMode)format;
       
   896 		symbianBitmap->width = width;
       
   897 		symbianBitmap->height = height;
       
   898 		symbianBitmap->stride = stride;
       
   899 		delete [] symbianBitmap->data;
       
   900 		symbianBitmap->data = new unsigned long[(stride*height+3)/4];
       
   901 	}
       
   902     TRACE("EGLAPIWrapper::eglPixmapSurfaceSizeChanged() <-\n");
       
   903     return WriteReply();
       
   904 }
       
   905 
       
   906 int EGLAPIWrapper::eglMetaGetConfigs()
       
   907 {
       
   908     TRACE("EGLAPIWrapper::eglMetaGetConfigs() ->\n");
       
   909 	bool abortOper = false;
       
   910 	int fetchMode(0);
       
   911 	m_currentFunctionCall.GetEGLint( fetchMode, 1 );//2nd parameter
       
   912 
       
   913 	EGLint* attributes;
       
   914 
       
   915 	EGLint red, green, blue, alpha;
       
   916 
       
   917 	//For storing the sg-compatible configs (for a single call to eglChooseConfig)
       
   918 	EGLConfig* sgConfigs = 0;
       
   919 	EGLint     sgConfigsSize = 0;//size of the array
       
   920 	EGLint     sgConfigsCnt = 0;//Number of actually received configurations
       
   921 
       
   922 	//The sgConfigs for returning them
       
   923 	EGLConfig* sgConfigsToReturn;
       
   924 	EGLint     sgConfigsToReturnCnt;
       
   925 	int        sgConfigsToReturnIndex = 0;
       
   926 
       
   927 	//For storing all the configs
       
   928 	EGLConfig*  allConfigs = 0;
       
   929 	EGLint      allConfigsSize = 0;//size of the array
       
   930 	EGLint      allConfigsCnt = 0;//Number of actually received configurations
       
   931 
       
   932 	//Allocate temporary storage for the attributes for each config
       
   933 	//This is actually obtained from the remote function call
       
   934 	EGLint* attributesForAllConfigs(0);
       
   935 	int     sizeAttributesForAllConfigs(0);
       
   936 	int     sizeAttributesForAllConfigsMax(0);
       
   937 
       
   938 
       
   939 	static EGLint SgPixelFormats[] =
       
   940 		{
       
   941 		EUidPixelFormatXRGB_8888,
       
   942 		EUidPixelFormatARGB_8888,
       
   943 		EUidPixelFormatARGB_8888_PRE,
       
   944 		EUidPixelFormatRGB_565,
       
   945 		EUidPixelFormatA_8
       
   946 		};
       
   947 
       
   948 	int sgPixelFormatsCnt = sizeof(SgPixelFormats)/sizeof(EGLint);
       
   949 
       
   950 	//This is for storing all the attributes. This struct's values will be queried from the configs
       
   951 	static EGLint configAttributes[] =
       
   952 	{
       
   953 		EGL_BUFFER_SIZE,
       
   954 		EGL_RED_SIZE,
       
   955 		EGL_GREEN_SIZE,
       
   956 		EGL_BLUE_SIZE,
       
   957 		EGL_LUMINANCE_SIZE,
       
   958 		EGL_ALPHA_SIZE,
       
   959 		EGL_ALPHA_MASK_SIZE,
       
   960 		EGL_BIND_TO_TEXTURE_RGB,
       
   961 		EGL_BIND_TO_TEXTURE_RGBA,
       
   962 		EGL_COLOR_BUFFER_TYPE,
       
   963 		EGL_CONFIG_CAVEAT,
       
   964 		EGL_CONFIG_ID,
       
   965 		EGL_CONFORMANT,
       
   966 		EGL_DEPTH_SIZE,
       
   967 		EGL_LEVEL,
       
   968 		EGL_MATCH_NATIVE_PIXMAP,
       
   969 		EGL_MAX_SWAP_INTERVAL,
       
   970 		EGL_MIN_SWAP_INTERVAL,
       
   971 		EGL_NATIVE_RENDERABLE,
       
   972 		EGL_NATIVE_VISUAL_TYPE,
       
   973 		EGL_RENDERABLE_TYPE,
       
   974 		EGL_SAMPLE_BUFFERS,
       
   975 		EGL_SAMPLES,
       
   976 		EGL_STENCIL_SIZE,
       
   977 		EGL_SURFACE_TYPE,
       
   978 		EGL_TRANSPARENT_TYPE,
       
   979 		EGL_TRANSPARENT_RED_VALUE,
       
   980 		EGL_TRANSPARENT_GREEN_VALUE,
       
   981 		EGL_TRANSPARENT_BLUE_VALUE
       
   982 	};
       
   983 	int cntConfigAttributes = sizeof(configAttributes) / sizeof(EGLint);
       
   984 
       
   985 	sizeAttributesForAllConfigsMax = cntConfigAttributes * KConfigsMaxCnt;
       
   986 	TRACE("\nEGLAPIWrapper::eglMetaGetConfigs get Vector datas\n" );
       
   987 	m_currentFunctionCall.GetEGLConfigVectorData( sgConfigsToReturn, sgConfigsToReturnCnt, 0 );
       
   988 	//m_currentFunctionCall.GetEGLConfigVectorData( attributesForAllConfigs, sizeAttributesForAllConfigs, 1 );
       
   989     m_currentFunctionCall.GetEGLintVectorData( attributesForAllConfigs, sizeAttributesForAllConfigs, 1 );
       
   990 	TRACE("\nEGLAPIWrapper::eglMetaGetConfigs eglGetConfigs\n" );
       
   991 	//Get the total number of all the configs
       
   992 	::eglGetConfigs( m_APIWrapper->GetDriverWrapper()->getDisplay(), NULL, 0, &allConfigsCnt );
       
   993 	TRACE("\nEGLAPIWrapper::eglMetaGetConfigs all configs count=%d\n", allConfigsCnt );
       
   994 	ASSERT( allConfigsCnt <= KConfigsMaxCnt );
       
   995 
       
   996     if ( sizeAttributesForAllConfigs <= sizeAttributesForAllConfigsMax )
       
   997     {
       
   998 		attributesForAllConfigs = (EGLint*)iStack->AllocFromStack( sizeAttributesForAllConfigs*m_currentFunctionCall.GetTypeSize( EglRFC::EEGLint ),
       
   999 					m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLint ) );
       
  1000 		//Allocate room for holding the configs
       
  1001 		TRACE("\nEGLAPIWrapper::eglMetaGetConfigs attribs cnt = %d\n", cntConfigAttributes );			
       
  1002 		switch( fetchMode )
       
  1003 		{
       
  1004 		case EMetaGetConfigsSg:
       
  1005 			{
       
  1006 			for( int i = 0; i < sgPixelFormatsCnt; ++i )//Go through all the pixel formats, fetching configs matching them
       
  1007 			{
       
  1008 				TRACE("\nEGLAPIWrapper::eglMetaGetConfigs sg pixel formats %d\n", i );
       
  1009 				//This is for temporary storage. We are only interested in picking the attribute values for each configuration
       
  1010 				sgConfigs = new EGLConfig[KConfigsMaxCnt];//(EGLConfig*)iStack->AllocFromStack( KConfigsMaxCnt*m_currentFunctionCall.GetTypeSize( EglRFC::EEGLConfig),
       
  1011 							//m_currentFunctionCall.GetTypeAlignment( EglRFC::EEGLConfig) );
       
  1012 				sgConfigsSize = KConfigsMaxCnt;
       
  1013 				attributes = m_APIWrapper->GetDriverWrapper()->getColorAttributes( SgPixelFormats[i], red, green, blue, alpha );
       
  1014 				if( ::eglChooseConfig(	m_APIWrapper->GetDriverWrapper()->getDisplay(), 
       
  1015 										attributes,
       
  1016 										sgConfigs,
       
  1017 										sgConfigsSize,
       
  1018 										&sgConfigsCnt ) )
       
  1019 				{
       
  1020 					//TRACE("\nEGLAPIWrapper::eglMetaGetConfigs sg configs cnt / size = %d / %d\n", sgConfigsCnt, sgConfigsSize );
       
  1021 					sizeAttributesForAllConfigs = sgConfigsCnt * sizeof(EGLint) * cntConfigAttributes;
       
  1022 					for( int config_i = 0; config_i < sgConfigsCnt; ++config_i )
       
  1023 					{
       
  1024 						*(sgConfigsToReturn + (sgConfigsToReturnIndex++)) = sgConfigs[config_i]; 
       
  1025 						//Go through all the configs, recording the attributes
       
  1026 						for( int attr_i = 0; attr_i < cntConfigAttributes; ++attr_i )
       
  1027 						{
       
  1028 							EGLint attribValue;
       
  1029 							if( ::eglGetConfigAttrib( m_APIWrapper->GetDriverWrapper()->getDisplay(), sgConfigs[config_i], configAttributes[attr_i], &attribValue ) )
       
  1030 							{
       
  1031 								//                           #config                          #attribute
       
  1032 								*( attributesForAllConfigs + config_i * cntConfigAttributes + attr_i ) = attribValue;
       
  1033 								//TRACE("\nEGLAPIWrapper::eglMetaGetConfigs sg pixformat %d, config %d, attr %d = %d\n", i, config_i, attr_i, attribValue );
       
  1034 							}
       
  1035 							else
       
  1036 							{
       
  1037 								//Could not obtain the config attribute, now we are going to abort everything
       
  1038 								goto ATTRIBUTESARRAYDELETE;
       
  1039 							}
       
  1040 						}//end for all attribs within a config
       
  1041 					}//end for all configs returned
       
  1042 ATTRIBUTESARRAYDELETE:
       
  1043 					//We have not been able to populate the attributes list, just abort now
       
  1044 					delete[] sgConfigs;
       
  1045 					abortOper = true;
       
  1046 				}//end if eglGetConfigs succeeded
       
  1047 				else
       
  1048 				{
       
  1049 					//Problems: can't get the configs. Maybe just abort the whole business
       
  1050 					abortOper = true;
       
  1051 					break;
       
  1052 				}
       
  1053 			}//end for all pixel formats
       
  1054 			break;
       
  1055 			}//end case EMetaGetConfigsSg
       
  1056 		}//end switch fetchMode
       
  1057 	
       
  1058 		if( !abortOper )
       
  1059 		{
       
  1060 			//Param 0:
       
  1061 			TRACE("EGLAPIWrapper::eglMetaGetConfigs sgConfigsToReturnIndex = %d", sgConfigsToReturnIndex );
       
  1062 			//m_currentFunctionCall.SetEGLintVectorData( sgConfigsToReturn, sgConfigsToReturnIndex+1, 0 );
       
  1063             m_currentFunctionCall.SetEGLConfigVectorData( sgConfigsToReturn, sgConfigsToReturnIndex+1, 0 );
       
  1064 			TRACE("EGLAPIWrapper::eglMetaGetConfigs sizeAttributesForAllConfigs = %d", sizeAttributesForAllConfigs / sizeof( EGLint ) );
       
  1065 			m_currentFunctionCall.SetEGLintVectorData( attributesForAllConfigs, sizeAttributesForAllConfigs / sizeof( EGLint ), 1 );
       
  1066 		}
       
  1067 	}//end if config_size >= KConfigsMaxCnt
       
  1068 	else
       
  1069 	{
       
  1070 		abortOper = true;
       
  1071 	}
       
  1072 	m_currentFunctionCall.SetReturnValue( abortOper?EGL_FALSE:EGL_TRUE );
       
  1073     int reply = WriteReply();
       
  1074     iStack->ClearStack();
       
  1075     sgConfigs = NULL;
       
  1076 	allConfigs = NULL;
       
  1077     TRACE("EGLAPIWrapper::eglGetConfigs() <-\n");
       
  1078     return reply;
       
  1079 }
       
  1080 
       
  1081 int EGLAPIWrapper::DispatchRequest( unsigned long aCode )
       
  1082 {
       
  1083     int ret(0);
       
  1084 
       
  1085     switch ( aCode )
       
  1086     {        
       
  1087 		case EglRFC::EeglGetError:
       
  1088         {
       
  1089             ret = eglGetError();
       
  1090             break;
       
  1091         }
       
  1092         case EglRFC::EeglGetDisplay:
       
  1093         {
       
  1094             ret = eglGetDisplay();
       
  1095             break;
       
  1096         }
       
  1097         case EglRFC::EeglInitialize:
       
  1098         {
       
  1099             ret = eglInitialize();
       
  1100             break;
       
  1101         }
       
  1102         case EglRFC::EeglTerminate:
       
  1103         {
       
  1104             ret = eglTerminate();
       
  1105             break;
       
  1106         }
       
  1107         case EglRFC::EeglQueryString:
       
  1108         {
       
  1109             ret = eglQueryString();
       
  1110             break;
       
  1111         }
       
  1112         case EglRFC::EeglGetConfigs:
       
  1113         {
       
  1114             ret = eglGetConfigs();
       
  1115             break;
       
  1116         }
       
  1117         case EglRFC::EeglChooseConfig:
       
  1118         {
       
  1119             ret = eglChooseConfig();
       
  1120             break;
       
  1121         }
       
  1122         case EglRFC::EeglGetConfigAttrib:
       
  1123         {
       
  1124             ret = eglGetConfigAttrib();
       
  1125             break;
       
  1126         }
       
  1127         case EglRFC::EeglCreateWindowSurface:
       
  1128         {
       
  1129             ret = eglCreateWindowSurface();
       
  1130             break;
       
  1131         }
       
  1132         case EglRFC::EeglCreatePbufferSurface:
       
  1133         {
       
  1134             ret = eglCreatePbufferSurface();
       
  1135             break;
       
  1136         }
       
  1137         case EglRFC::EeglCreatePixmapSurface:
       
  1138         {
       
  1139             ret = eglCreatePixmapSurface();
       
  1140             break;
       
  1141         }
       
  1142         case EglRFC::EeglDestroySurface:
       
  1143         {
       
  1144             ret = eglDestroySurface();
       
  1145             break;
       
  1146         }
       
  1147         case EglRFC::EeglQuerySurface:
       
  1148         {
       
  1149             ret = eglQuerySurface();
       
  1150             break;
       
  1151         }
       
  1152         case EglRFC::EeglBindAPI:
       
  1153         {
       
  1154             ret = eglBindAPI();
       
  1155             break;
       
  1156         }
       
  1157         case EglRFC::EeglQueryAPI:
       
  1158         {
       
  1159             ret = eglQueryAPI();
       
  1160             break;
       
  1161         }
       
  1162         case EglRFC::EeglWaitClient:
       
  1163         {
       
  1164             ret = eglWaitClient();
       
  1165             break;
       
  1166         }
       
  1167         case EglRFC::EeglReleaseThread:
       
  1168         {
       
  1169             ret = eglReleaseThread();
       
  1170             break;
       
  1171         }
       
  1172         case EglRFC::EeglCreatePbufferFromClientBuffer:
       
  1173         {
       
  1174             ret = eglCreatePbufferFromClientBuffer();
       
  1175             break;
       
  1176         }
       
  1177         case EglRFC::EeglSurfaceAttrib:
       
  1178         {
       
  1179             ret = eglSurfaceAttrib();
       
  1180             break;
       
  1181         }
       
  1182         case EglRFC::EeglBindTexImage:
       
  1183         {
       
  1184             ret = eglBindTexImage();
       
  1185             break;
       
  1186         }
       
  1187         case EglRFC::EeglReleaseTexImage:
       
  1188         {
       
  1189             ret = eglReleaseTexImage();
       
  1190             break;
       
  1191         }
       
  1192         case EglRFC::EeglSwapInterval:
       
  1193         {
       
  1194             ret = eglSwapInterval();
       
  1195             break;
       
  1196         }
       
  1197         case EglRFC::EeglCreateContext:
       
  1198         {
       
  1199             ret = eglCreateContext();
       
  1200             break;
       
  1201         }
       
  1202         case EglRFC::EeglDestroyContext:
       
  1203         {
       
  1204             ret = eglDestroyContext();
       
  1205             break;
       
  1206         }
       
  1207         case EglRFC::EeglMakeCurrent:
       
  1208         {
       
  1209             ret = eglMakeCurrent();
       
  1210             break;
       
  1211         }
       
  1212 		case EglRFC::EeglMakeCurrentSg:
       
  1213 		{
       
  1214 			break;
       
  1215 		}
       
  1216         case EglRFC::EeglGetCurrentContext:
       
  1217         {
       
  1218             ret = eglGetCurrentContext();
       
  1219             break;
       
  1220         }
       
  1221         case EglRFC::EeglGetCurrentSurface:
       
  1222         {
       
  1223             ret = eglGetCurrentSurface();
       
  1224             break;
       
  1225         }
       
  1226         case EglRFC::EeglGetCurrentDisplay:
       
  1227         {
       
  1228             ret = eglGetCurrentDisplay();
       
  1229             break;
       
  1230         }
       
  1231         case EglRFC::EeglQueryContext:
       
  1232         {
       
  1233             ret = eglQueryContext();
       
  1234             break;
       
  1235         }
       
  1236         case EglRFC::EeglWaitGL:
       
  1237         {
       
  1238             ret = eglWaitGL();
       
  1239             break;
       
  1240         }
       
  1241         case EglRFC::EeglWaitNative:
       
  1242         {
       
  1243             ret = eglWaitNative();
       
  1244             break;
       
  1245         }
       
  1246         case EglRFC::EeglSwapBuffers:
       
  1247         {
       
  1248             ret = eglSwapBuffers();
       
  1249             break;
       
  1250         }
       
  1251         case EglRFC::EeglCopyBuffers:
       
  1252         {
       
  1253             ret = eglCopyBuffers();
       
  1254             break;
       
  1255         }
       
  1256         case EglRFC::EeglSimulatorSetSurfaceParams:
       
  1257         {
       
  1258             ret = eglPlatsimSetSurfaceParams();
       
  1259             break;
       
  1260         }
       
  1261 		case EglRFC::EeglSimulatorCopyImageData:
       
  1262         {
       
  1263             ret = eglPlatsimCopyImageData();
       
  1264             break;
       
  1265         }
       
  1266 		case EglRFC::EeglPixmapSurfaceSizeChanged:
       
  1267         {
       
  1268             ret = eglPixmapSurfaceSizeChanged();
       
  1269             break;
       
  1270         }
       
  1271 		case EglRFC::EeglMetaGetConfigs:
       
  1272 		{
       
  1273 			ret = eglMetaGetConfigs();
       
  1274 			break;
       
  1275 		}
       
  1276         default:
       
  1277             TRACE("Unimplemented EGL Op code %u\n",aCode);
       
  1278             break;
       
  1279     }
       
  1280     return ret;
       
  1281 }