guestrendering/guestegl/src/guestegl.cpp
branchbug235_bringup_0
changeset 72 fd0a704154b9
parent 66 07904b9e3bd7
equal deleted inserted replaced
71:243bbc1d70db 72:fd0a704154b9
    31 // -----------------------------------------------------------------------------
    31 // -----------------------------------------------------------------------------
    32 //
    32 //
    33 
    33 
    34 // FAISALMEMON STUB CODE
    34 // FAISALMEMON STUB CODE
    35 #define EGL_CHECK_ERROR(a, b, c)      /* This does no checking; just a stub */
    35 #define EGL_CHECK_ERROR(a, b, c)      /* This does no checking; just a stub */
    36 void CGuestEGL::EglInternalFunction_DestroyWindowSurface(TSurfaceInfo&)
    36 void CGuestEGL::EglInternalFunction_DestroyWindowSurface(TSurfaceInfo& aSurfaceInfo)
    37 	{
    37 	{
       
    38 	RWindow* window = aSurfaceInfo.iNativeWindow;
       
    39 	TInt screen = window->ScreenNumber();
       
    40 	RWsSession* session = window->Session();
       
    41 	session->UnregisterSurface(screen, aSurfaceInfo.iSurfaceId);
       
    42 
    38 	return; // stub code
    43 	return; // stub code
    39 	}
    44 	}
    40 
    45 
    41 EGLBoolean CGuestEGL::EglInternalFunction_SurfaceResized(TEglThreadState&, TSurfaceInfo&, int, int) 
    46 EGLBoolean CGuestEGL::EglInternalFunction_SurfaceResized(TEglThreadState&, TSurfaceInfo&, int, int) 
    42 	{
    47 	{
   247 	RWindow* window;
   252 	RWindow* window;
   248 	window = (RWindow*) aNativeWindow;
   253 	window = (RWindow*) aNativeWindow;
   249 	TSize size = window->Size();
   254 	TSize size = window->Size();
   250 	
   255 	
   251 	TSurfaceInfo* surfaceInfo = NULL;
   256 	TSurfaceInfo* surfaceInfo = NULL;
   252 	TSurfaceId surfaceId;
       
   253 
   257 
   254     RSurfaceManager::TSurfaceCreationAttributesBuf buf;
   258     RSurfaceManager::TSurfaceCreationAttributesBuf buf;
   255     RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
   259     RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
   256 
   260 
   257     attributes.iSize = size;
   261     attributes.iSize = size;
   263     attributes.iHintCount=0;  
   267     attributes.iHintCount=0;  
   264     attributes.iSurfaceHints = NULL;
   268     attributes.iSurfaceHints = NULL;
   265     attributes.iOffsetBetweenBuffers = 0;
   269     attributes.iOffsetBetweenBuffers = 0;
   266     attributes.iContiguous = ETrue;
   270     attributes.iContiguous = ETrue;
   267     attributes.iCacheAttrib = RSurfaceManager::ENotCached;      // Cache attributes
   271     attributes.iCacheAttrib = RSurfaceManager::ENotCached;      // Cache attributes
       
   272     attributes.iMappable = ETrue;
   268 
   273 
   269 	iDisplayMapLock.WriteLock();
   274 	iDisplayMapLock.WriteLock();
   270 	CEglDisplayInfo** pDispInfo;
   275 	CEglDisplayInfo** pDispInfo;
   271 	pDispInfo = iDisplayMap.Find(aDisplay);
   276 	pDispInfo = iDisplayMap.Find(aDisplay);
   272 	
   277 	
   278 			if (surfaceInfo)
   283 			if (surfaceInfo)
   279 				{
   284 				{
   280 				surfaceInfo->iNativeWindow = (RWindow*)aNativeWindow;
   285 				surfaceInfo->iNativeWindow = (RWindow*)aNativeWindow;
   281 				surfaceInfo->iConfigId = aConfig;
   286 				surfaceInfo->iConfigId = aConfig;
   282 				surfaceInfo->iSurfaceManager.Open();
   287 				surfaceInfo->iSurfaceManager.Open();
   283 				surfaceInfo->iSurfaceManager.CreateSurface(buf, surfaceId);
   288 				surfaceInfo->iSurfaceManager.CreateSurface(buf, surfaceInfo->iSurfaceId);
   284 				(void) surfaceInfo->iSurfaceManager.MapSurface(surfaceId, surfaceInfo->iChunk);
   289 				surfaceInfo->iStride = attributes.iStride;
       
   290 
       
   291 				TInt err =  surfaceInfo->iSurfaceManager.MapSurface(surfaceInfo->iSurfaceId, surfaceInfo->iChunk);
       
   292 				EGL_TRACE("CGuestEGL::eglCreateWindowSurface surface manager returned chunk %x and ret val %d", surfaceInfo->iChunk, err);
   285 				RemoteFunctionCallData rfcdata;
   293 				RemoteFunctionCallData rfcdata;
   286 				EglRFC eglApiData( rfcdata );
   294 				EglRFC eglApiData( rfcdata );
   287 				eglApiData.Init( EglRFC::EeglCreateWindowSurface);
   295 				eglApiData.Init( EglRFC::EeglCreateWindowSurface);
   288 				eglApiData.AppendEGLDisplay(aDisplay);
   296 				eglApiData.AppendEGLDisplay(aDisplay);
   289 				eglApiData.AppendEGLConfig(aConfig);
   297 				eglApiData.AppendEGLConfig(aConfig);
   296 				surfaceInfo->iHostSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); // todo check if is valid
   304 				surfaceInfo->iHostSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); // todo check if is valid
   297 				(*pDispInfo)->iSurfaceMap.Insert(surfaceInfo->iHostSurfaceId, surfaceInfo);
   305 				(*pDispInfo)->iSurfaceMap.Insert(surfaceInfo->iHostSurfaceId, surfaceInfo);
   298 				EglInternalFunction_CreateSurface(aThreadState, aDisplay, surfaceInfo->iHostSurfaceId, aConfig, window, *surfaceInfo);
   306 				EglInternalFunction_CreateSurface(aThreadState, aDisplay, surfaceInfo->iHostSurfaceId, aConfig, window, *surfaceInfo);
   299 				surfaceInfo->iSurfaceUpdateSession.Connect();
   307 				surfaceInfo->iSurfaceUpdateSession.Connect();
   300 				TSurfaceConfiguration surfaceConfig;
   308 				TSurfaceConfiguration surfaceConfig;
   301 				surfaceConfig.SetSurfaceId(surfaceId);
   309 				surfaceConfig.SetSurfaceId(surfaceInfo->iSurfaceId);
       
   310 
       
   311 				TInt screen = window->ScreenNumber();
       
   312 				RWsSession& session = *window->Session();
       
   313 				session.RegisterSurface(screen, surfaceInfo->iSurfaceId);
       
   314 
   302 				window->SetBackgroundSurface(surfaceConfig, ETrue);
   315 				window->SetBackgroundSurface(surfaceConfig, ETrue);
   303 				}
   316 				}
   304 			CVghwUtils::SwitchFromVghwHeap(threadHeap);
   317 			CVghwUtils::SwitchFromVghwHeap(threadHeap);
   305 			}
   318 			}
   306 	
   319 	
  1114 			return EGL_FALSE;
  1127 			return EGL_FALSE;
  1115 			}
  1128 			}
  1116 		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
  1129 		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
  1117 		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
  1130 		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
  1118 		eglApiData.Init( EglRFC::EeglMakeCurrent );
  1131 		eglApiData.Init( EglRFC::EeglMakeCurrent );
  1119 		eglApiData.AppendEGLDisplay(aDisplay);
  1132 		eglApiData.AppendEGLDisplay(EGL_NO_DISPLAY);
  1120 		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
  1133 		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
  1121 		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
  1134 		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
  1122 		eglApiData.AppendEGLContext(EGL_NO_CONTEXT);
  1135 		eglApiData.AppendEGLContext(EGL_NO_CONTEXT);
  1123 
  1136 
  1124 		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
  1137 		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
  1150 			{
  1163 			{
  1151 			if ( EGL_NO_SURFACE != surfaces[i] )
  1164 			if ( EGL_NO_SURFACE != surfaces[i] )
  1152 				{
  1165 				{
  1153 				EGL_TRACE("CGuestEGL::eglMakeCurrent check surface %d", surfaces[i] );
  1166 				EGL_TRACE("CGuestEGL::eglMakeCurrent check surface %d", surfaces[i] );
  1154 				surfaceInfo[i] = EglInternalFunction_GetPlatformSurface( aDisplay, surfaces[i] );
  1167 				surfaceInfo[i] = EglInternalFunction_GetPlatformSurface( aDisplay, surfaces[i] );
       
  1168 				EGL_TRACE("CGuestEGL::eglMakeCurrent surfaces[%d] is %x", i, surfaces[i]);
  1155 				//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE );
  1169 				//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE );
  1156 				if ( surfaceInfo[i] )
  1170 				if ( surfaceInfo[i] )
  1157 					{
  1171 					{
  1158 					TSize newSize;
  1172 					TSize newSize;
  1159 					switch (surfaceInfo[i]->iSurfaceType)
  1173 					switch (surfaceInfo[i]->iSurfaceType)
  1212 		EGL_TRACE("  eglApiData.AppendEGLSurface(readId = 0x%x);", readId);
  1226 		EGL_TRACE("  eglApiData.AppendEGLSurface(readId = 0x%x);", readId);
  1213 		eglApiData.AppendEGLSurface(readId);
  1227 		eglApiData.AppendEGLSurface(readId);
  1214 
  1228 
  1215 		eglApiData.AppendEGLContext(aContext);
  1229 		eglApiData.AppendEGLContext(aContext);
  1216 		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
  1230 		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
  1217 		EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret);
  1231 		EGL_TRACE("CGuestEGL::eglMakeCurrent last end success=%d", ret);
  1218 		return (EGLBoolean)ret;
  1232 		return (EGLBoolean)ret;
  1219 		}
  1233 		}
  1220 	}
  1234 	}
  1221 
  1235 
  1222 // FAISALMEMON HOLE 0.1
  1236 // FAISALMEMON HOLE 0.1
  1229 TBool CGuestEGL::EglInternalFunction_CreateSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, RWindow* aNativeWindow,
  1243 TBool CGuestEGL::EglInternalFunction_CreateSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, RWindow* aNativeWindow,
  1230 		TSurfaceInfo& aSurfaceInfo)
  1244 		TSurfaceInfo& aSurfaceInfo)
  1231 	{
  1245 	{
  1232     RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
  1246     RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
  1233     RSurfaceManager::TInfoBuf info;
  1247     RSurfaceManager::TInfoBuf info;
       
  1248 	TInt r;
  1234 
  1249 
  1235     aSurfaceInfo.iNativeWindow = aNativeWindow;
  1250     aSurfaceInfo.iNativeWindow = aNativeWindow;
  1236     aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow;
  1251     aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow;
  1237     aSurfaceInfo.iSize = aNativeWindow->Size();
  1252     aSurfaceInfo.iSize = aNativeWindow->Size();
  1238     aSurfaceInfo.iConfigId = aConfig;
  1253     aSurfaceInfo.iConfigId = aConfig;
  1257     TSize size;
  1272     TSize size;
  1258 
  1273 
  1259     // FAISALMEMON HOLE 1
  1274     // FAISALMEMON HOLE 1
  1260 
  1275 
  1261     // FAISALMEMON STUB CODE
  1276     // FAISALMEMON STUB CODE
  1262     TUint8 offsetToFirstBuffer = 0; // This is wrong; just stub code
  1277 
  1263     TUint8 offsetToSecondBuffer = 0; // This is wrong; just stub code
  1278     TInt offsetToFirstBuffer = -1;
  1264     // FAISALMEMON END OF STUB CODE
  1279     TInt offsetToSecondBuffer = -1;
       
  1280 	r = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,0,offsetToFirstBuffer);
       
  1281 	if(r!=KErrNone)
       
  1282 		return EGL_FALSE;
       
  1283 	r = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,1,offsetToSecondBuffer);
       
  1284 	if(r!=KErrNone)
       
  1285 		return EGL_FALSE;
       
  1286     EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface offsetToFirstBuffer=0x%x offsetToSecondBuffer=0x%x",offsetToFirstBuffer,offsetToSecondBuffer);
       
  1287 
       
  1288 	// FAISALMEMON END OF STUB CODE
  1265     
  1289     
  1266     TUint32 chunkHWBase = 0;
  1290     TUint32 chunkHWBase = 0;
  1267     (void)CVghwUtils::MapToHWAddress(aSurfaceInfo.iChunk.Handle(), chunkHWBase);
  1291     TInt err = CVghwUtils::MapToHWAddress(aSurfaceInfo.iChunk.Handle(), chunkHWBase);
       
  1292     EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface MapToHWAddress returned %d", err);
  1268     // FAISALMEMON write code to handle errors in the above function
  1293     // FAISALMEMON write code to handle errors in the above function
  1269     EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface AFTER VGHWUtils::MapToHWAddress");
  1294     EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface AFTER VGHWUtils::MapToHWAddress");
  1270 
  1295 
  1271 	TUint32 surfaceBufferBaseAddress(0);
  1296 	TUint32 surfaceBufferBaseAddress(0);
  1272 	(void)CVghwUtils::GetSurfaceBufferBaseAddress(surfaceBufferBaseAddress);
  1297 	(void)CVghwUtils::GetSurfaceBufferBaseAddress(surfaceBufferBaseAddress);
  1273 	EGL_TRACE("CPlatsimEGL::egliCreateSurface AFTER VGHWUtils::MapToHWAddress");
  1298 	EGL_TRACE("CGuestEGL::egliCreateSurface AFTER VGHWUtils::MapToHWAddress");
  1274 
  1299 	EGL_TRACE("CGuestEGL::egliCreateSurface aSurfaceInfo.iChunk.Base() is %x", aSurfaceInfo.iChunk.Base());
  1275     /* Store the pointer to the pixel data */
  1300     /* Store the pointer to the pixel data */
  1276     aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk.Base() + offsetToFirstBuffer;
  1301     aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk.Base() + offsetToFirstBuffer;
  1277     aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk.Base() + offsetToSecondBuffer;
  1302     aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk.Base() + offsetToSecondBuffer;
  1278 
  1303 
  1279     aSurfaceInfo.iBuffer0Index = (chunkHWBase + offsetToFirstBuffer) -  surfaceBufferBaseAddress;
  1304     aSurfaceInfo.iBuffer0Index = (chunkHWBase + offsetToFirstBuffer) -  surfaceBufferBaseAddress;