os/graphics/egl/eglrefimpl/src/entrypoints.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/eglrefimpl/src/entrypoints.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,305 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Reference EGL implementation to support EGL sync objects and OpenWF extensions
    1.18 +
    1.19 +#include "eglprivate.h"
    1.20 +
    1.21 +// Helper macros
    1.22 +//
    1.23 +#define GET_THREAD_SESSION(s,r) CEglThreadSession* s = CEglThreadSession::Static(); \
    1.24 +                                if (!s) \
    1.25 +                                    { \
    1.26 +                                    return r; \
    1.27 +                                    }
    1.28 +
    1.29 +#define PANIC_NOT_SUPPORTED     User::Panic(KEglPanicCategory, EEglPanicNotSupported); \
    1.30 +                                return 0;
    1.31 +
    1.32 +// EGL API entrypoints
    1.33 +//
    1.34 +EXPORT_C EGLDisplay eglGetDisplay(NativeDisplayType display_id)
    1.35 +	{
    1.36 +	GET_THREAD_SESSION(session, EGL_NO_DISPLAY)
    1.37 +	return session->EglGetDisplay(display_id);
    1.38 +	}
    1.39 +
    1.40 +EXPORT_C EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
    1.41 +	{
    1.42 +	GET_THREAD_SESSION(session, EGL_FALSE)
    1.43 +	return session->EglInitialize(dpy, major, minor);
    1.44 +	}
    1.45 +
    1.46 +EXPORT_C EGLBoolean eglTerminate(EGLDisplay dpy)
    1.47 +	{
    1.48 +	GET_THREAD_SESSION(session, EGL_FALSE)
    1.49 +	return session->EglTerminate(dpy);
    1.50 +	}
    1.51 +
    1.52 +EXPORT_C EGLBoolean eglReleaseThread(void)
    1.53 +	{
    1.54 +	// do not call CEglThreadSession::Static() here as it may create thread state if it does not exist
    1.55 +	//
    1.56 +	CEglThreadSession* session = reinterpret_cast<CEglThreadSession*>(Dll::Tls());
    1.57 +	if (session)
    1.58 +		{
    1.59 +		delete session;
    1.60 +		Dll::FreeTls();
    1.61 +		}
    1.62 +
    1.63 +	return EGL_TRUE;
    1.64 +	}
    1.65 +
    1.66 +EXPORT_C EGLint eglGetError(void)
    1.67 +	{
    1.68 +	// EGL spec section 3.11: GetError will create thread state object, 
    1.69 +	// it is recommended not to call this API immediately after calling ReleaseThread
    1.70 +	// for that reason.
    1.71 +	// If session creation fails, we returns BAD_ALLOC
    1.72 +	//
    1.73 +	GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
    1.74 +	return session->EglGetError();
    1.75 +	}
    1.76 +
    1.77 +EXPORT_C const char* eglQueryString(EGLDisplay dpy, EGLint name)
    1.78 +	{
    1.79 +	GET_THREAD_SESSION(session, NULL)
    1.80 +	return session->EglQueryString(dpy, name);
    1.81 +	}
    1.82 +
    1.83 +EXPORT_C TFuncPtrEglProc eglGetProcAddress (const char *procname)
    1.84 +	{
    1.85 +	GET_THREAD_SESSION(session, NULL)
    1.86 +	return session->EglGetProcAddress(procname);
    1.87 +	}
    1.88 +
    1.89 +// Unsupported EGL APIs
    1.90 +//
    1.91 +EXPORT_C EGLBoolean eglGetConfigs(EGLDisplay /*dpy*/, EGLConfig */*configs*/,
    1.92 +			 EGLint /*config_size*/, EGLint */*num_config*/)
    1.93 +	{
    1.94 +	PANIC_NOT_SUPPORTED
    1.95 +	}
    1.96 +
    1.97 +EXPORT_C EGLBoolean eglChooseConfig(EGLDisplay /*dpy*/, const EGLint */*attrib_list*/,
    1.98 +			   EGLConfig */*configs*/, EGLint /*config_size*/,
    1.99 +			   EGLint */*num_config*/)
   1.100 +	{
   1.101 +	PANIC_NOT_SUPPORTED
   1.102 +	}
   1.103 +	
   1.104 +EXPORT_C EGLBoolean eglGetConfigAttrib(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   1.105 +			      EGLint /*attribute*/, EGLint */*value*/)
   1.106 +	{
   1.107 +	PANIC_NOT_SUPPORTED	
   1.108 +	}
   1.109 +
   1.110 +EXPORT_C EGLSurface eglCreateWindowSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   1.111 +				  EGLNativeWindowType /*win*/,
   1.112 +				  const EGLint */*attrib_list*/)
   1.113 +	{
   1.114 +	PANIC_NOT_SUPPORTED	
   1.115 +	}
   1.116 +
   1.117 +EXPORT_C EGLSurface eglCreatePbufferSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   1.118 +				   const EGLint */*attrib_list*/)
   1.119 +	{
   1.120 +	PANIC_NOT_SUPPORTED
   1.121 +	}
   1.122 +
   1.123 +EXPORT_C EGLSurface eglCreatePixmapSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   1.124 +				  EGLNativePixmapType /*pixmap*/,
   1.125 +				  const EGLint */*attrib_list*/)
   1.126 +	{
   1.127 +	PANIC_NOT_SUPPORTED
   1.128 +	}
   1.129 +
   1.130 +EXPORT_C EGLBoolean eglDestroySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
   1.131 +	{
   1.132 +	PANIC_NOT_SUPPORTED
   1.133 +	}
   1.134 +
   1.135 +EXPORT_C EGLBoolean eglQuerySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   1.136 +			   EGLint /*attribute*/, EGLint */*value*/)
   1.137 +	{
   1.138 +	PANIC_NOT_SUPPORTED
   1.139 +	}
   1.140 +
   1.141 +EXPORT_C EGLBoolean eglBindAPI(EGLenum /*api*/)
   1.142 +	{
   1.143 +	PANIC_NOT_SUPPORTED
   1.144 +	}
   1.145 +
   1.146 +EXPORT_C EGLenum eglQueryAPI(void)
   1.147 +	{
   1.148 +	PANIC_NOT_SUPPORTED	
   1.149 +	}
   1.150 +
   1.151 +EXPORT_C EGLBoolean eglWaitClient(void)
   1.152 +	{
   1.153 +	PANIC_NOT_SUPPORTED	
   1.154 +	}
   1.155 +
   1.156 +EXPORT_C EGLSurface eglCreatePbufferFromClientBuffer(
   1.157 +	      EGLDisplay /*dpy*/, EGLenum /*buftype*/, EGLClientBuffer /*buffer*/,
   1.158 +	      EGLConfig /*config*/, const EGLint */*attrib_list*/)
   1.159 +	{
   1.160 +	PANIC_NOT_SUPPORTED
   1.161 +	}
   1.162 +
   1.163 +EXPORT_C EGLBoolean eglSurfaceAttrib(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   1.164 +			    EGLint /*attribute*/, EGLint /*value*/)
   1.165 +	{
   1.166 +	PANIC_NOT_SUPPORTED	
   1.167 +	}
   1.168 +
   1.169 +EXPORT_C EGLBoolean eglBindTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
   1.170 +	{
   1.171 +	PANIC_NOT_SUPPORTED
   1.172 +	}
   1.173 +
   1.174 +EXPORT_C EGLBoolean eglReleaseTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
   1.175 +	{
   1.176 +	PANIC_NOT_SUPPORTED
   1.177 +	}
   1.178 +
   1.179 +EXPORT_C EGLBoolean eglSwapInterval(EGLDisplay /*dpy*/, EGLint /*interval*/)
   1.180 +	{
   1.181 +	PANIC_NOT_SUPPORTED
   1.182 +	}
   1.183 +
   1.184 +EXPORT_C EGLContext eglCreateContext(EGLDisplay /*dpy*/, EGLConfig /*config*/,
   1.185 +			    EGLContext /*share_context*/,
   1.186 +			    const EGLint */*attrib_list*/)
   1.187 +	{
   1.188 +	PANIC_NOT_SUPPORTED
   1.189 +	}
   1.190 +
   1.191 +EXPORT_C EGLBoolean eglDestroyContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/)
   1.192 +	{
   1.193 +	PANIC_NOT_SUPPORTED	
   1.194 +	}
   1.195 +
   1.196 +EXPORT_C EGLBoolean eglMakeCurrent(EGLDisplay /*dpy*/, EGLSurface /*draw*/,
   1.197 +			  EGLSurface /*read*/, EGLContext /*ctx*/)
   1.198 +	{
   1.199 +	PANIC_NOT_SUPPORTED	
   1.200 +	}
   1.201 +
   1.202 +EXPORT_C EGLContext eglGetCurrentContext(void)
   1.203 +	{
   1.204 +	PANIC_NOT_SUPPORTED
   1.205 +	}
   1.206 +
   1.207 +EXPORT_C EGLSurface eglGetCurrentSurface(EGLint /*readdraw*/)
   1.208 +	{
   1.209 +	PANIC_NOT_SUPPORTED
   1.210 +	}
   1.211 +
   1.212 +EXPORT_C EGLDisplay eglGetCurrentDisplay(void)
   1.213 +	{
   1.214 +	PANIC_NOT_SUPPORTED
   1.215 +	}
   1.216 +
   1.217 +EXPORT_C EGLBoolean eglQueryContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/,
   1.218 +			   EGLint /*attribute*/, EGLint */*value*/)
   1.219 +	{
   1.220 +	PANIC_NOT_SUPPORTED
   1.221 +	}
   1.222 +
   1.223 +EXPORT_C EGLBoolean eglWaitGL(void)
   1.224 +	{
   1.225 +	PANIC_NOT_SUPPORTED
   1.226 +	}
   1.227 +
   1.228 +EXPORT_C EGLBoolean eglWaitNative(EGLint /*engine*/)
   1.229 +	{
   1.230 +	PANIC_NOT_SUPPORTED
   1.231 +	}
   1.232 +
   1.233 +EXPORT_C EGLBoolean eglSwapBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
   1.234 +	{
   1.235 +	PANIC_NOT_SUPPORTED
   1.236 +	}
   1.237 +
   1.238 +EXPORT_C EGLBoolean eglCopyBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
   1.239 +			  EGLNativePixmapType /*target*/)
   1.240 +	{
   1.241 +	PANIC_NOT_SUPPORTED
   1.242 +	}
   1.243 +
   1.244 +// EGL_KHR_reusable_sync APIs
   1.245 +//
   1.246 +EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
   1.247 +    {
   1.248 +    GET_THREAD_SESSION(session, EGL_NO_SYNC_KHR)
   1.249 +    return session->EglCreateSyncKhr(dpy, type, attrib_list);
   1.250 +    }
   1.251 +
   1.252 +EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
   1.253 +    {
   1.254 +    GET_THREAD_SESSION(session, EGL_FALSE)
   1.255 +    return session->EglDestroySyncKhr(dpy, sync);
   1.256 +    }
   1.257 +
   1.258 +EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
   1.259 +    {
   1.260 +    GET_THREAD_SESSION(session, EGL_FALSE)
   1.261 +    return session->EglClientWaitSyncKhr(dpy, sync, flags, timeout);
   1.262 +    }
   1.263 +
   1.264 +EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
   1.265 +    {
   1.266 +    GET_THREAD_SESSION(session, EGL_FALSE)
   1.267 +    return session->EglSignalSyncKhr(dpy, sync, mode);
   1.268 +    }
   1.269 +
   1.270 +EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
   1.271 +    {
   1.272 +    GET_THREAD_SESSION(session, EGL_FALSE)
   1.273 +    return session->EglGetSyncAttribKhr(dpy, sync, attribute, value);
   1.274 +    }
   1.275 +
   1.276 +// Private extensions
   1.277 +//
   1.278 +EGLint egl_Private_SignalSyncNOK(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
   1.279 +    {
   1.280 +    GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
   1.281 +    return session->EglSignalSyncInternal(dpy, sync, mode);
   1.282 +    }
   1.283 +
   1.284 +// Debug APIs
   1.285 +//
   1.286 +#ifdef _DEBUG
   1.287 +
   1.288 +#define GET_THREAD_SESSION_ASSERT(s)    CEglThreadSession* s = CEglThreadSession::Static(); \
   1.289 +                                        __ASSERT_DEBUG(s, User::Panic(KEglPanicCategory, EEglPanicInvalidSession));
   1.290 +
   1.291 +void egliDebugHeapMarkStart()
   1.292 +    {
   1.293 +    GET_THREAD_SESSION_ASSERT(session)
   1.294 +    session->EglHeapMarkStart();
   1.295 +    }
   1.296 +
   1.297 +EGLint egliDebugHeapMarkEnd(EGLint count)
   1.298 +    {
   1.299 +    GET_THREAD_SESSION_ASSERT(session)    
   1.300 +    return session->EglHeapMarkEnd(count);
   1.301 +    }
   1.302 +
   1.303 +void egliDebugSetBurstAllocFail(EGLenum type, EGLint rate, EGLint burst)
   1.304 +    {
   1.305 +    GET_THREAD_SESSION_ASSERT(session)
   1.306 +    session->EglHeapSetBurstAllocFail(type, rate, burst);
   1.307 +}
   1.308 +#endif //_DEBUG