os/graphics/egl/eglrefimpl/src/entrypoints.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2009 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 // Reference EGL implementation to support EGL sync objects and OpenWF extensions
    15 
    16 #include "eglprivate.h"
    17 
    18 // Helper macros
    19 //
    20 #define GET_THREAD_SESSION(s,r) CEglThreadSession* s = CEglThreadSession::Static(); \
    21                                 if (!s) \
    22                                     { \
    23                                     return r; \
    24                                     }
    25 
    26 #define PANIC_NOT_SUPPORTED     User::Panic(KEglPanicCategory, EEglPanicNotSupported); \
    27                                 return 0;
    28 
    29 // EGL API entrypoints
    30 //
    31 EXPORT_C EGLDisplay eglGetDisplay(NativeDisplayType display_id)
    32 	{
    33 	GET_THREAD_SESSION(session, EGL_NO_DISPLAY)
    34 	return session->EglGetDisplay(display_id);
    35 	}
    36 
    37 EXPORT_C EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
    38 	{
    39 	GET_THREAD_SESSION(session, EGL_FALSE)
    40 	return session->EglInitialize(dpy, major, minor);
    41 	}
    42 
    43 EXPORT_C EGLBoolean eglTerminate(EGLDisplay dpy)
    44 	{
    45 	GET_THREAD_SESSION(session, EGL_FALSE)
    46 	return session->EglTerminate(dpy);
    47 	}
    48 
    49 EXPORT_C EGLBoolean eglReleaseThread(void)
    50 	{
    51 	// do not call CEglThreadSession::Static() here as it may create thread state if it does not exist
    52 	//
    53 	CEglThreadSession* session = reinterpret_cast<CEglThreadSession*>(Dll::Tls());
    54 	if (session)
    55 		{
    56 		delete session;
    57 		Dll::FreeTls();
    58 		}
    59 
    60 	return EGL_TRUE;
    61 	}
    62 
    63 EXPORT_C EGLint eglGetError(void)
    64 	{
    65 	// EGL spec section 3.11: GetError will create thread state object, 
    66 	// it is recommended not to call this API immediately after calling ReleaseThread
    67 	// for that reason.
    68 	// If session creation fails, we returns BAD_ALLOC
    69 	//
    70 	GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
    71 	return session->EglGetError();
    72 	}
    73 
    74 EXPORT_C const char* eglQueryString(EGLDisplay dpy, EGLint name)
    75 	{
    76 	GET_THREAD_SESSION(session, NULL)
    77 	return session->EglQueryString(dpy, name);
    78 	}
    79 
    80 EXPORT_C TFuncPtrEglProc eglGetProcAddress (const char *procname)
    81 	{
    82 	GET_THREAD_SESSION(session, NULL)
    83 	return session->EglGetProcAddress(procname);
    84 	}
    85 
    86 // Unsupported EGL APIs
    87 //
    88 EXPORT_C EGLBoolean eglGetConfigs(EGLDisplay /*dpy*/, EGLConfig */*configs*/,
    89 			 EGLint /*config_size*/, EGLint */*num_config*/)
    90 	{
    91 	PANIC_NOT_SUPPORTED
    92 	}
    93 
    94 EXPORT_C EGLBoolean eglChooseConfig(EGLDisplay /*dpy*/, const EGLint */*attrib_list*/,
    95 			   EGLConfig */*configs*/, EGLint /*config_size*/,
    96 			   EGLint */*num_config*/)
    97 	{
    98 	PANIC_NOT_SUPPORTED
    99 	}
   100 	
   101 EXPORT_C EGLBoolean eglGetConfigAttrib(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   102 			      EGLint /*attribute*/, EGLint */*value*/)
   103 	{
   104 	PANIC_NOT_SUPPORTED	
   105 	}
   106 
   107 EXPORT_C EGLSurface eglCreateWindowSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   108 				  EGLNativeWindowType /*win*/,
   109 				  const EGLint */*attrib_list*/)
   110 	{
   111 	PANIC_NOT_SUPPORTED	
   112 	}
   113 
   114 EXPORT_C EGLSurface eglCreatePbufferSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   115 				   const EGLint */*attrib_list*/)
   116 	{
   117 	PANIC_NOT_SUPPORTED
   118 	}
   119 
   120 EXPORT_C EGLSurface eglCreatePixmapSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   121 				  EGLNativePixmapType /*pixmap*/,
   122 				  const EGLint */*attrib_list*/)
   123 	{
   124 	PANIC_NOT_SUPPORTED
   125 	}
   126 
   127 EXPORT_C EGLBoolean eglDestroySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
   128 	{
   129 	PANIC_NOT_SUPPORTED
   130 	}
   131 
   132 EXPORT_C EGLBoolean eglQuerySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   133 			   EGLint /*attribute*/, EGLint */*value*/)
   134 	{
   135 	PANIC_NOT_SUPPORTED
   136 	}
   137 
   138 EXPORT_C EGLBoolean eglBindAPI(EGLenum /*api*/)
   139 	{
   140 	PANIC_NOT_SUPPORTED
   141 	}
   142 
   143 EXPORT_C EGLenum eglQueryAPI(void)
   144 	{
   145 	PANIC_NOT_SUPPORTED	
   146 	}
   147 
   148 EXPORT_C EGLBoolean eglWaitClient(void)
   149 	{
   150 	PANIC_NOT_SUPPORTED	
   151 	}
   152 
   153 EXPORT_C EGLSurface eglCreatePbufferFromClientBuffer(
   154 	      EGLDisplay /*dpy*/, EGLenum /*buftype*/, EGLClientBuffer /*buffer*/,
   155 	      EGLConfig /*config*/, const EGLint */*attrib_list*/)
   156 	{
   157 	PANIC_NOT_SUPPORTED
   158 	}
   159 
   160 EXPORT_C EGLBoolean eglSurfaceAttrib(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   161 			    EGLint /*attribute*/, EGLint /*value*/)
   162 	{
   163 	PANIC_NOT_SUPPORTED	
   164 	}
   165 
   166 EXPORT_C EGLBoolean eglBindTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
   167 	{
   168 	PANIC_NOT_SUPPORTED
   169 	}
   170 
   171 EXPORT_C EGLBoolean eglReleaseTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
   172 	{
   173 	PANIC_NOT_SUPPORTED
   174 	}
   175 
   176 EXPORT_C EGLBoolean eglSwapInterval(EGLDisplay /*dpy*/, EGLint /*interval*/)
   177 	{
   178 	PANIC_NOT_SUPPORTED
   179 	}
   180 
   181 EXPORT_C EGLContext eglCreateContext(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   182 			    EGLContext /*share_context*/,
   183 			    const EGLint */*attrib_list*/)
   184 	{
   185 	PANIC_NOT_SUPPORTED
   186 	}
   187 
   188 EXPORT_C EGLBoolean eglDestroyContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/)
   189 	{
   190 	PANIC_NOT_SUPPORTED	
   191 	}
   192 
   193 EXPORT_C EGLBoolean eglMakeCurrent(EGLDisplay /*dpy*/, EGLSurface /*draw*/,
   194 			  EGLSurface /*read*/, EGLContext /*ctx*/)
   195 	{
   196 	PANIC_NOT_SUPPORTED	
   197 	}
   198 
   199 EXPORT_C EGLContext eglGetCurrentContext(void)
   200 	{
   201 	PANIC_NOT_SUPPORTED
   202 	}
   203 
   204 EXPORT_C EGLSurface eglGetCurrentSurface(EGLint /*readdraw*/)
   205 	{
   206 	PANIC_NOT_SUPPORTED
   207 	}
   208 
   209 EXPORT_C EGLDisplay eglGetCurrentDisplay(void)
   210 	{
   211 	PANIC_NOT_SUPPORTED
   212 	}
   213 
   214 EXPORT_C EGLBoolean eglQueryContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/,
   215 			   EGLint /*attribute*/, EGLint */*value*/)
   216 	{
   217 	PANIC_NOT_SUPPORTED
   218 	}
   219 
   220 EXPORT_C EGLBoolean eglWaitGL(void)
   221 	{
   222 	PANIC_NOT_SUPPORTED
   223 	}
   224 
   225 EXPORT_C EGLBoolean eglWaitNative(EGLint /*engine*/)
   226 	{
   227 	PANIC_NOT_SUPPORTED
   228 	}
   229 
   230 EXPORT_C EGLBoolean eglSwapBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
   231 	{
   232 	PANIC_NOT_SUPPORTED
   233 	}
   234 
   235 EXPORT_C EGLBoolean eglCopyBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   236 			  EGLNativePixmapType /*target*/)
   237 	{
   238 	PANIC_NOT_SUPPORTED
   239 	}
   240 
   241 // EGL_KHR_reusable_sync APIs
   242 //
   243 EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
   244     {
   245     GET_THREAD_SESSION(session, EGL_NO_SYNC_KHR)
   246     return session->EglCreateSyncKhr(dpy, type, attrib_list);
   247     }
   248 
   249 EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
   250     {
   251     GET_THREAD_SESSION(session, EGL_FALSE)
   252     return session->EglDestroySyncKhr(dpy, sync);
   253     }
   254 
   255 EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
   256     {
   257     GET_THREAD_SESSION(session, EGL_FALSE)
   258     return session->EglClientWaitSyncKhr(dpy, sync, flags, timeout);
   259     }
   260 
   261 EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
   262     {
   263     GET_THREAD_SESSION(session, EGL_FALSE)
   264     return session->EglSignalSyncKhr(dpy, sync, mode);
   265     }
   266 
   267 EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
   268     {
   269     GET_THREAD_SESSION(session, EGL_FALSE)
   270     return session->EglGetSyncAttribKhr(dpy, sync, attribute, value);
   271     }
   272 
   273 // Private extensions
   274 //
   275 EGLint egl_Private_SignalSyncNOK(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
   276     {
   277     GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
   278     return session->EglSignalSyncInternal(dpy, sync, mode);
   279     }
   280 
   281 // Debug APIs
   282 //
   283 #ifdef _DEBUG
   284 
   285 #define GET_THREAD_SESSION_ASSERT(s)    CEglThreadSession* s = CEglThreadSession::Static(); \
   286                                         __ASSERT_DEBUG(s, User::Panic(KEglPanicCategory, EEglPanicInvalidSession));
   287 
   288 void egliDebugHeapMarkStart()
   289     {
   290     GET_THREAD_SESSION_ASSERT(session)
   291     session->EglHeapMarkStart();
   292     }
   293 
   294 EGLint egliDebugHeapMarkEnd(EGLint count)
   295     {
   296     GET_THREAD_SESSION_ASSERT(session)    
   297     return session->EglHeapMarkEnd(count);
   298     }
   299 
   300 void egliDebugSetBurstAllocFail(EGLenum type, EGLint rate, EGLint burst)
   301     {
   302     GET_THREAD_SESSION_ASSERT(session)
   303     session->EglHeapSetBurstAllocFail(type, rate, burst);
   304 }
   305 #endif //_DEBUG