openvg/openvgrefimplementation/sfopenvg/sfopenvg/riMiniEGL.cpp
branchEGL_MERGE
changeset 217 205d3af68142
parent 216 b87045f2f5d7
equal deleted inserted replaced
216:b87045f2f5d7 217:205d3af68142
    86 		RI_DELETE(m_threads[i]);
    86 		RI_DELETE(m_threads[i]);
    87 	}
    87 	}
    88 	//currentThreads contain just pointers to threads we just deleted
    88 	//currentThreads contain just pointers to threads we just deleted
    89 }
    89 }
    90 
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // 2nd phase constructor
       
    93 // ported from guestEGL
       
    94 //-----------------------------------------------------------------------------
       
    95 //
       
    96 void EGL::Create()
       
    97 {
       
    98 	EGL_TRACE("  EGL::Create ");
       
    99     //OpenSgResources();
       
   100     TInt err;
       
   101 	err = iDisplayMapLock.CreateLocal();
       
   102 	EGLPANIC_ASSERT(err == KErrNone, EEglPanicDisplayMapLockCreateLocalFailed);
       
   103 
       
   104 	//err = iEglImageLock.CreateLocal();
       
   105 	//EGLPANIC_ASSERT(err == KErrNone, EEglPanicEglImageLockCreateLocalFailed);	
       
   106 
       
   107 	InitialiseExtensions();
       
   108 
       
   109 	//const char* initExtensionList = EglInternalFunction_QueryExtensionList();
       
   110 	//EGL_TRACE("  CGuestEGL::Create  initExtensionList=0x%x (\"%s\") <--",
       
   111 	//		initExtensionList, initExtensionList ? initExtensionList : "");
       
   112 }
       
   113 
    91 /*-------------------------------------------------------------------*//*!
   114 /*-------------------------------------------------------------------*//*!
    92 * \brief	
   115 * \brief	
    93 * \param	
   116 * \param	
    94 * \return	
   117 * \return	
    95 * \note		
   118 * \note		
   104 	EGL* pEgl=NULL; 
   127 	EGL* pEgl=NULL; 
   105 	if((pEgl = static_cast<EGL*>(Dll::Tls()))==NULL)
   128 	if((pEgl = static_cast<EGL*>(Dll::Tls()))==NULL)
   106 		{
   129 		{
   107 		//create TLS instance
   130 		//create TLS instance
   108 		pEgl = RI_NEW(EGL, ());
   131 		pEgl = RI_NEW(EGL, ());
       
   132 		pEgl->Create();
   109 		Dll::SetTls(pEgl);
   133 		Dll::SetTls(pEgl);
   110 		}
   134 		}
   111 	return pEgl;
   135 	return pEgl;
   112 
   136 
   113 	
   137 	
   171 		}
   195 		}
   172 	}
   196 	}
   173 	return NULL;		//error: the display hasn't been eglInitialized
   197 	return NULL;		//error: the display hasn't been eglInitialized
   174 }
   198 }
   175 
   199 
       
   200 /*-------------------------------------------------------------------*//*!
       
   201 * \brief	Creates a display given a display ID, including Display info
       
   202 * \param	
       
   203 * \return	
       
   204 * \note		if egl has been initialized for this display, the display ID can
       
   205 *			be found from egl->m_displays
       
   206 *//*-------------------------------------------------------------------*/
       
   207 void EGL::addDisplay(RIEGLDisplay* display)
       
   208 {
       
   209 	RI_ASSERT(display); 
       
   210 	m_displays.push_back(display); //throws bad alloc
       
   211 	CreateDisplayInfo(display->getID());
       
   212 }  
       
   213 
       
   214 
   176 /*
   215 /*
   177   Create an information object for an opened Display.
   216   Create an information object for an opened Display.
   178  */
   217  */
   179 TBool EGL::CreateDisplayInfo(const EGLDisplay aDisplayID)
   218 TBool EGL::CreateDisplayInfo(const EGLDisplay aDisplayID)
   180 {
   219 {
   211 			}
   250 			}
   212 		}
   251 		}
   213 
   252 
   214 		if (err == KErrNone)
   253 		if (err == KErrNone)
   215 		{
   254 		{
       
   255 			// mark as initialized here??
       
   256 			dispInfo->iInitialized = ETrue;
   216 			result = ETrue;
   257 			result = ETrue;
   217 		}
   258 		}
   218 	}
   259 	}
   219 	iDisplayMapLock.Unlock();
   260 	iDisplayMapLock.Unlock();
   220 
   261 
  1229 	EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
  1270 	EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE);
  1230 	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
  1271 	EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE);
  1231 	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
  1272 	EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE);
  1232 
  1273 
  1233 	int renderBuffer = EGL_BACK_BUFFER;
  1274 	int renderBuffer = EGL_BACK_BUFFER;
  1234 	int colorSpace = EGL_VG_COLORSPACE_sRGB;
  1275 	int colorSpace = EGL_COLORSPACE_sRGB;
  1235 	int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE;
  1276 	int alphaFormat = EGL_ALPHA_FORMAT_NONPRE;
       
  1277    
       
  1278 
  1236 	if(attrib_list)
  1279 	if(attrib_list)
  1237 	{
  1280 	{
  1238 		for(int i=0;attrib_list[i] != EGL_NONE;i+=2)
  1281 		for(int i=0;attrib_list[i] != EGL_NONE;i+=2)
  1239 		{
  1282 		{
  1240 			switch(attrib_list[i])
  1283 			switch(attrib_list[i])
  1318 		if(surfaceInfo.iNativeWindow.IsWindow())
  1361 		if(surfaceInfo.iNativeWindow.IsWindow())
  1319 		{
  1362 		{
  1320 			RWindow* window = (RWindow*)(win);				
  1363 			RWindow* window = (RWindow*)(win);				
  1321 			RWsSession& session = *window->Session();
  1364 			RWsSession& session = *window->Session();
  1322 			session.RegisterSurface(surfaceInfo.iScreenNumber, surfaceInfo.iSurfaceId);
  1365 			session.RegisterSurface(surfaceInfo.iScreenNumber, surfaceInfo.iSurfaceId);
       
  1366 			surfaceConfig.SetFlip(ETrue); // don't ask :o
  1323 			window->SetBackgroundSurface(surfaceConfig, ETrue);
  1367 			window->SetBackgroundSurface(surfaceConfig, ETrue);
  1324 		}
  1368 		}
  1325 		else
  1369 		else
  1326 		{
  1370 		{
  1327 			// Now what?? Nothing is good enough?
  1371 			// Now what?? Nothing is good enough?
  2603 * \brief	
  2647 * \brief	
  2604 * \param	
  2648 * \param	
  2605 * \return	
  2649 * \return	
  2606 * \note		
  2650 * \note		
  2607 *//*-------------------------------------------------------------------*/
  2651 *//*-------------------------------------------------------------------*/
  2608 
  2652 /**
       
  2653 	Obtain extension function pointer.
       
  2654 
       
  2655 	Provide support for the Symbian Graphics SHAI for EGL Extensions
       
  2656 	@param aName	Name of extension
       
  2657 	@return			Function pointer, or NULL if not available.
       
  2658 
       
  2659 	@note  Known extensions and their directly associated functions:
       
  2660 	   1. EGL_KHR_image 
       
  2661 			None
       
  2662 	   2. EGL_KHR_image_base 
       
  2663 			eglCreateImageKHR,
       
  2664 			eglDestroyImageKHR
       
  2665 	   3. EGL_KHR_image_pixmap
       
  2666 			None
       
  2667 	   4. EGL_KHR_vg_parent_image
       
  2668 			None
       
  2669 	   5. EGL_KHR_gl_texture_2D_image
       
  2670 			None
       
  2671 	   6. EGL_KHR_gl_texture_cubemap_image
       
  2672 			EGLImageTargetTexture2DOES,
       
  2673 			EGLImageTargetRenderbufferStorageOES
       
  2674 	   7. EGL_KHR_lock_surface2
       
  2675 			eglLockSurfaceKHR,
       
  2676 			eglUnlockSurfaceKHR
       
  2677 	   8. EGL_NOK_resource_profiling2
       
  2678 			eglQueryProfilingDataNOK
       
  2679 	   9. EGL_SYMBIAN_composition
       
  2680 			None
       
  2681 	  10. EGL_NOK_image_endpoint
       
  2682 			eglCreateEndpointNOK,
       
  2683 			eglDestroyEndpointNOK,
       
  2684 			eglGetEndpointAttribNOK,
       
  2685 			eglSetEndpointAttribNOK,
       
  2686 			eglEndpointBeginStreamingNOK,
       
  2687 			eglEndpointEndStreamingNOK,
       
  2688 			eglAcquireImageNOK,
       
  2689 			eglReleaseImageNOK,
       
  2690 			eglGetEndpointDirtyAreaNOK,
       
  2691 			eglEndpointRequestNotificationNOK,
       
  2692 			eglEndpointCancelNotificationNOK,
       
  2693 			eglCreateEndpointNOK
       
  2694 	  11. NOK_pixmap_type_rsgimage
       
  2695 			None
       
  2696 	  12. EGL_NOK_swap_region
       
  2697 			eglSwapBuffersRegionNOK
       
  2698 
       
  2699 	@see Khronos EGL 1.4 Specification, eglGetProcAddress()
       
  2700 	@author Faisal Memon Community EGL project
       
  2701 	ported to Merge EGL
       
  2702 	*/
  2609 typedef void RI_Proc();
  2703 typedef void RI_Proc();
  2610 
  2704 
  2611 //EGLAPI void (* EGLAPIENTRY      eglGetProcAddress(const char *procname))(void);
  2705 //EGLAPI void (* EGLAPIENTRY      eglGetProcAddress(const char *procname))(void);
  2612 
  2706 
  2613 #ifdef BUILD_WITH_PRIVATE_EGL
  2707 #ifdef BUILD_WITH_PRIVATE_EGL
  2614 RI_APIENTRY void (*do_eglGetProcAddress(const char *procname))(...)
  2708 RI_APIENTRY void (*do_eglGetProcAddress(const char *aName))(...)
  2615 #else
  2709 #else
  2616 void (*eglGetProcAddress(const char *procname))(...)
  2710 void (*eglGetProcAddress(const char *aName))(...)
  2617 #endif
  2711 #endif
  2618 {
  2712 {
       
  2713 	/*
  2619 	if(!procname)
  2714 	if(!procname)
  2620 		return NULL;
  2715 		return NULL;
  2621 	return NULL;
  2716 	return NULL;
       
  2717 	*/
       
  2718 	
       
  2719 /*ProcPointer CGuestEGL::eglGetProcAddress(const char* aName)*/
       
  2720 	if (strncmp("eglCreateImageKHR", aName, strlen("eglCreateImageKHR")) == 0)
       
  2721 	{
       
  2722 		return NULL;
       
  2723 	}
       
  2724 	else if (strncmp("eglDestroyImageKHR", aName, strlen("eglDestroyImageKHR")) == 0)
       
  2725 	{
       
  2726 		return NULL;
       
  2727 	}
       
  2728 	else if (strncmp("EGLImageTargetTexture2DOES", aName, strlen("EGLImageTargetTexture2DOES")) == 0)
       
  2729 	{
       
  2730 		return NULL;
       
  2731 	}
       
  2732 	else if (strncmp("EGLImageTargetRenderbufferStorageOES", aName, strlen("EGLImageTargetRenderbufferStorageOES")) == 0)
       
  2733 	{
       
  2734 		return NULL;
       
  2735 	}
       
  2736 	else if (strncmp("eglLockSurfaceKHR", aName, strlen("eglLockSurfaceKHR")) == 0)
       
  2737 	{
       
  2738 		return NULL;
       
  2739 	}
       
  2740 	else if (strncmp("eglUnlockSurfaceKHR", aName, strlen("eglUnlockSurfaceKHR")) == 0)
       
  2741 	{
       
  2742 		return NULL;
       
  2743 	}
       
  2744 	else if (strncmp("EGL_KHR_lock_surface", aName, strlen("EGL_KHR_lock_surface")) == 0)
       
  2745 	{
       
  2746 		return NULL;
       
  2747 	}
       
  2748 	else if (strncmp("eglQueryProfilingDataNOK", aName, strlen("eglQueryProfilingDataNOK")) == 0)
       
  2749 	{
       
  2750 		return NULL;
       
  2751 	}
       
  2752 	else if (strncmp("eglCreateEndpointNOK", aName, strlen("eglCreateEndpointNOK")) == 0)
       
  2753 	{
       
  2754 		return NULL;
       
  2755 	}
       
  2756 	else if (strncmp("eglDestroyEndpointNOK", aName, strlen("eglDestroyEndpointNOK")) == 0)
       
  2757 	{
       
  2758 		return NULL;
       
  2759 	}
       
  2760 	else if (strncmp("eglGetEndpointAttribNOK", aName, strlen("eglGetEndpointAttribNOK")) == 0)
       
  2761 	{
       
  2762 		return NULL;
       
  2763 	}
       
  2764 	else if (strncmp("eglEndpointBeginStreamingNOK", aName, strlen("eglEndpointBeginStreamingNOK")) == 0)
       
  2765 	{
       
  2766 		return NULL;
       
  2767 	}
       
  2768 	else if (strncmp("eglEndpointEndStreamingNOK", aName, strlen("eglEndpointEndStreamingNOK")) == 0)
       
  2769 	{
       
  2770 		return NULL;
       
  2771 	}
       
  2772 	else if (strncmp("eglAcquireImageNOK", aName, strlen("eglAcquireImageNOK")) == 0)
       
  2773 	{
       
  2774 		return NULL;
       
  2775 	}
       
  2776 	else if (strncmp("eglReleaseImageNOK", aName, strlen("eglReleaseImageNOK")) == 0)
       
  2777 	{
       
  2778 		return NULL;
       
  2779 	}
       
  2780 	else if (strncmp("eglGetEndpointDirtyAreaNOK", aName, strlen("eglGetEndpointDirtyAreaNOK")) == 0)
       
  2781 	{
       
  2782 		return NULL;
       
  2783 	}
       
  2784 	else if (strncmp("eglEndpointRequestNotificationNOK", aName, strlen("eglEndpointRequestNotificationNOK")) == 0)
       
  2785 	{
       
  2786 		return NULL;
       
  2787 	}
       
  2788 	else if (strncmp("eglEndpointCancelNotificationNOK", aName, strlen("eglEndpointCancelNotificationNOK")) == 0)
       
  2789 	{
       
  2790 		return NULL;
       
  2791 	}
       
  2792 	else if (strncmp("eglCreateEndpointNOK", aName, strlen("eglCreateEndpointNOK")) == 0)
       
  2793 	{
       
  2794 	    return NULL;
       
  2795 	}
       
  2796 	else if (strncmp("eglSwapBuffersRegionNOK", aName, strlen("eglSwapBuffersRegionNOK")) == 0)
       
  2797 	{
       
  2798 	    return NULL;
       
  2799 	}
       
  2800 	else if (strncmp("egl_Private_SignalSyncNOK", aName, strlen("egl_Private_SignalSyncNOK")) == 0)
       
  2801 	{
       
  2802 		return (ProcPointer)CEglSyncExtension::egl_Private_SignalSyncNOK;
       
  2803 	}
       
  2804 	else if (strncmp("eglCreateSyncKHR", aName, strlen("eglCreateSyncKHR")) == 0)
       
  2805 	{
       
  2806 		return (ProcPointer)CEglSyncExtension::eglCreateSyncKHR;
       
  2807 	}
       
  2808 	else if (strncmp("eglDestroySyncKHR", aName, strlen("eglDestroySyncKHR")) == 0)
       
  2809 	{
       
  2810 		return (ProcPointer)CEglSyncExtension::eglDestroySyncKHR;
       
  2811 	}
       
  2812 	else if (strncmp("eglClientWaitSyncKHR", aName, strlen("eglClientWaitSyncKHR")) == 0)
       
  2813 	{
       
  2814 		return (ProcPointer)CEglSyncExtension::eglClientWaitSyncKHR;
       
  2815 	}
       
  2816 	else if (strncmp("eglSignalSyncKHR", aName, strlen("eglSignalSyncKHR")) == 0)
       
  2817 	{
       
  2818 		return (ProcPointer)CEglSyncExtension::eglSignalSyncKHR;
       
  2819 	}
       
  2820 	else if (strncmp("eglGetSyncAttribKHR", aName, strlen("eglGetSyncAttribKHR")) == 0)
       
  2821 	{
       
  2822 		return (ProcPointer)CEglSyncExtension::eglGetSyncAttribKHR;
       
  2823 	}
       
  2824 	else
       
  2825 	{
       
  2826 		return NULL;
       
  2827 	}
       
  2828 		
  2622 }
  2829 }
  2623 
  2830 
  2624 
  2831 
  2625 
  2832 
  2626 /*-------------------------------------------------------------------*//*!
  2833 /*-------------------------------------------------------------------*//*!