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