guestrendering/guestegl/src/eglapi.cpp
author Faisal Memon <faisal.memon@nokia.com>
Wed, 08 Sep 2010 15:45:18 +0100
branchbug235_bringup_0
changeset 13 220791dae4c4
permissions -rwxr-xr-x
Add TPIP free guest egl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     7
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    10
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    11
// Contributors:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    12
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    13
// Description:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    14
// Implementation of guest egl stub functions
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    15
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    16
#include "eglapi.h"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    17
#include <e32atomics.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    18
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    19
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    20
 Only having the pointer as "Writeable Static Data" makes it very easy to tell if
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    21
 initialisation has been done: the pointer is not NULL!
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    22
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    23
CGuestEGL* guestEGL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    24
// Writeable Static Data - causes constructor to be called at load DLL time.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    25
XGuestEglInitialiser GuestEglInitialiser;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    26
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    27
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    28
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    29
XGuestEglInitialiser::XGuestEglInitialiser()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    30
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    31
	EGL_TRACE("XGuestEglInitialiser::XGuestEglInitialiser() - guestEGL=0x%x", guestEGL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    32
	if (!guestEGL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    33
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    34
		// ensure VGHW Memory heap is created & channel to LDD is opened
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    35
		CVghwUtils::InitStatics();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    36
		// Multi-Threading safe creation of CGuestEGL instance
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    37
		if (!guestEGL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    38
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    39
			// guarantee that initialisation of the object is flushed to memory before the pointer is published
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    40
			__e32_atomic_store_rel_ptr(&guestEGL, CGuestEGL::New());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    41
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    42
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    43
		// cast away volatile attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    44
		CGuestEGL* instance = (CGuestEGL*)guestEGL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    45
		// cannot continue if alloc failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    46
		EGLPANIC_ASSERT(guestEGL, EEglPanicCGuestEGLAllocFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    47
		CVghwUtils::SetEglManagementApi(instance);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    48
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    49
		CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    50
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    51
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    52
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    53
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    54
XGuestEglInitialiser::~XGuestEglInitialiser()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    55
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    56
	EGL_TRACE("XGuestEglInitialiser::~XGuestEglInitialiser() - guestEGL=0x%x", guestEGL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    57
	if (guestEGL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    58
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    59
		delete guestEGL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    60
		guestEGL = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    61
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    62
	CVghwUtils::DestroyStatics();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    63
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    64
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    65
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    66
_LIT(KEglPanicCategory, "Guest EGL");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    67
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    68
void EglPanic(TEglPanic aPanicCode, char* aPanicName, char* aCondition, char* aFile, TInt aLine)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    69
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    70
	if (aPanicName && aCondition && aFile)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    71
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    72
		RDebug::Printf("Guest EGL DLL Panic %s for failed Assert (%s),\n\tat %s:%d", aPanicName, aCondition, aFile, aLine);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    73
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    74
	else if (aPanicName && aFile)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    75
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    76
		RDebug::Printf("Guest EGL DLL Panic %s at %s:%d", aPanicName, aFile, aLine);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    77
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    78
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    79
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    80
		RDebug::Printf("Guest EGL DLL Panic %d (line %d)", aPanicCode, aLine);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    81
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    82
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    83
	User::Panic(KEglPanicCategory, aPanicCode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    84
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    85
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    86
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    87
extern "C" {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    88
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    89
 Note: Comments at the start of each EGL api are adapted from the Khronos EGL 1.4 specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    90
 The text has been chosen/adapted to give a helpful overview of the function, and the errors
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    91
 that it may generate.  For more details see the full Khronos EGL specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    92
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    93
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    94
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    95
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    96
 Get details of the last EGL api error in this thread.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    97
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    98
 Returns EGL_SUCCESS or an EGL_xxxx error constant.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    99
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   100
EXPORT_C EGLint eglGetError(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   101
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   102
	EGL_TRACE("eglGetError -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   103
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   104
	EGLint eglError = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   105
	// threadState is non-null if an EGL api has been called in this thread
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   106
	TEglThreadState* threadState = CVghwUtils::EglThreadState(); // do not create thread object for this API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   107
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   108
		{ // get error (may be from parameter checking in this DLL or from Host EGL) - fetching resets error to EGL_SUCCESS
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   109
		eglError = threadState->EglError();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   110
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   111
	EGL_TRACE("eglGetError returning eglError=0x%x <--", eglError);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   112
	return eglError;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   113
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   114
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   115
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   116
 Get display handle for display with requested properties.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   117
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   118
 If display id is EGL_DEFAULT_DISPLAY, a default display is returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   119
 Multiple calls made to eglGetDisplay with the same display-id will
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   120
 all return the same EGLDisplay handle.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   121
 If no display matching display id is available, EGL_NO_DISPLAY is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   122
 returned; no error condition is raised in this case.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   123
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   124
EXPORT_C EGLDisplay eglGetDisplay(EGLNativeDisplayType aDisplayId)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   125
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   126
	EGL_TRACE("eglGetDisplay Display Id=%d -->", aDisplayId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   127
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   128
	EGLDisplay display = EGL_NO_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   129
	// Most likely eglGetDisplay is the first API called, so try initialising EGL instance first
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   130
	CGuestEGL& instance = Instance();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   131
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   132
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   133
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   134
		display = instance.eglGetDisplay(*threadState, aDisplayId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   135
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   136
	EGL_TRACE("eglGetDisplay result Display=%d <--", display);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   137
	return display;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   138
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   139
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   140
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   141
 Initialize EGL on a display.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   142
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   143
 EGL_TRUE is returned on success, and major and minor are updated with the major
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   144
 and minor version numbers of the EGL implementation (for example, in an EGL
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   145
 1.2 implementation, the values of *major and *minor would be 1 and 2, respectively).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   146
 major and minor are not updated if they are specified as NULL.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   147
 EGL_FALSE is returned on failure and major and minor are not updated. An
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   148
 EGL_BAD_DISPLAY error is generated if the dpy argument does not refer to a valid
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   149
 EGLDisplay. An EGL_NOT_INITIALIZED error is generated if EGL cannot be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   150
 initialized for an otherwise valid dpy.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   151
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   152
EXPORT_C EGLBoolean eglInitialize(EGLDisplay aDisplay, EGLint *aMajor, EGLint *aMinor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   153
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   154
	EGL_TRACE("eglInitialize Display=%d, Major 0x%x, Minor 0x%x", aDisplay, aMajor, aMinor );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   155
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   156
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   157
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   158
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   159
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   160
		success = Instance().eglInitialize(*threadState, aDisplay, aMajor, aMinor);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   161
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   162
	EGL_TRACE("eglInitialize <- result=%d", success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   163
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   164
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   165
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   166
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   167
 Marks all EGL-specific resources associated with the specified display
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   168
 for deletion.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   169
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   170
 If the dpy argument does not refer to a valid EGLDisplay, EGL_FALSE is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   171
 returned, and an EGL_BAD_DISPLAY error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   172
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   173
EXPORT_C EGLBoolean eglTerminate(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   174
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   175
	EGL_TRACE("eglTerminate Display=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   176
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   177
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   178
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   179
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   180
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   181
		result = Instance().eglTerminate(*threadState, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   182
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   183
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   184
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   185
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   186
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   187
 Returns a pointer to a static, zero-terminated string describing some aspect
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   188
 of the EGL implementation running on the specified display. name may be one
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   189
 of EGL_CLIENT_APIS, EGL_EXTENSIONS, EGL_VENDOR, or EGL_VERSION.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   190
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   191
 The EGL_CLIENT_APIS string describes which client rendering APIs are
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   192
 supported. It is zero-terminated and contains a space-separated list of API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   193
 names, which must include at least one of ‘‘OpenGL’’, ‘‘OpenGL_ES’’ or
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   194
 ‘‘OpenVG’’.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   195
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   196
 The EGL_EXTENSIONS string describes which EGL extensions are supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   197
 by the EGL implementation running on the specified display, and for the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   198
 current client API context. The string is zero terminated and contains a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   199
 space-separated list of extension names;  extension names themselves do
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   200
 not contain spaces. If there are no extensions to EGL, then the empty string
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   201
 is returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   202
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   203
 The format and contents of the EGL_VENDOR string is implementation dependent.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   204
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   205
 The format of the EGL_VERSION string is:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   206
 <major version.minor version><space><vendor specific info>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   207
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   208
 On failure, NULL is returned. An EGL_NOT_INITIALIZED error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   209
 if EGL is not initialized for dpy. An EGL_BAD_PARAMETER error is generated if
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   210
 name is not one of the values described above.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   211
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   212
EXPORT_C const char* eglQueryString(EGLDisplay aDisplay, EGLint aName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   213
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   214
    EGL_TRACE("eglQueryString Display=%d, Name=0x%x", aDisplay, aName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   215
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   216
    return Instance().eglQueryString(aDisplay, aName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   217
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   218
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   219
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   220
 Get the list of all EGLConfigs that are available on the specified display.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   221
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   222
 On failure, EGL_FALSE is returned. An EGL_NOT_INITIALIZED error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   223
 if EGL is not initialized on dpy. An EGL_BAD_PARAMETER error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   224
 if num config is NULL.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   225
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   226
EXPORT_C EGLBoolean eglGetConfigs(EGLDisplay aDisplay, EGLConfig *aConfigs,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   227
			 EGLint aConfigSize, EGLint *aNumConfig)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   228
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   229
	EGL_TRACE("eglGetConfigs Display=%d, ConfigSize=%d , NumConfig=0x%x -->", aDisplay, aConfigSize, aNumConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   230
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   231
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   232
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   233
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   234
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   235
		result = Instance().eglGetConfigs(*threadState, aDisplay, aConfigs, aConfigSize, aNumConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   236
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   237
	EGL_TRACE("eglGetConfigs hostResult=%d, NumConfig-%d <--", result, aNumConfig ? *aNumConfig : 0);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   238
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   239
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   240
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   241
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   242
 Get EGLConfigs that match a list of attributes. The return value and the meaning
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   243
 of configs, config size, and num config are the same as for eglGetConfigs.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   244
 However, only configurations matching attrib list will be returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   245
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   246
 On failure, EGL_FALSE is returned. An EGL_BAD_ATTRIBUTE error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   247
 if attrib list contains an undefined EGL attribute or an attribute value that is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   248
 unrecognized or out of range.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   249
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   250
EXPORT_C EGLBoolean eglChooseConfig(EGLDisplay aDisplay, const EGLint *aAttribList,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   251
			   EGLConfig *aConfigs, EGLint aConfigSize, EGLint *aNumConfig)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   252
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   253
	EGL_TRACE("eglChooseConfig Display=%d, AttribList=0x%x, Configs=0x%x, ConfigSize=%d, NumConfig=0x%x -->",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   254
			aDisplay, aAttribList, aConfigs, aConfigSize, aNumConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   255
	EGL_TRACE_ATTRIB_LIST(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   256
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   257
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   258
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   259
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   260
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   261
		result = Instance().eglChooseConfig(*threadState, aDisplay, aAttribList, aConfigs, aConfigSize, aNumConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   262
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   263
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   264
	EGL_TRACE("eglChooseConfig Result=%s, Num configs=%d, First config=%d <--",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   265
			result ? "success" : "fail", 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   266
			aNumConfig ? *aNumConfig : 0,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   267
			(aConfigs && aNumConfig && (*aNumConfig > 0)) ? *aConfigs : -1);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   268
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   269
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   270
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   271
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   272
 Get the value of an EGLConfig attribute.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   273
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   274
 On failure returns EGL_FALSE. If attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   275
 is not a valid attribute then EGL_BAD_ATTRIBUTE is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   276
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   277
EXPORT_C EGLBoolean eglGetConfigAttrib(EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   278
			      EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   279
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   280
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   281
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   282
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   283
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   284
		result = Instance().eglGetConfigAttrib(*threadState, aDisplay, aConfig, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   285
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   286
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   287
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   288
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   289
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   290
 Creates an onscreen EGLSurface and returns a handle to it. Any EGL context created
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   291
 with a compatible EGLConfig can be used to render into this surface.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   292
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   293
 On failure returns EGL_NO_SURFACE. If the attributes of win do not correspond to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   294
 config, then an EGL_BAD_MATCH error is generated. If config does not support
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   295
 rendering to windows (the EGL_SURFACE_TYPE attribute does not contain
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   296
 EGL_WINDOW_BIT), an EGL_BAD_MATCH error is generated. If config does not support
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   297
 the colorspace or  alpha format attributes specified in attrib list (as defined
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   298
 for eglCreateWindowSurface), an EGL_BAD_MATCH error is generated. If config is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   299
 not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If win is not a valid
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   300
 native window handle, then an EGL_BAD_NATIVE_WINDOW error should be generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   301
 there is already an EGLConfig associated with win (as a result of a previous
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   302
 eglCreateWindowSurface call), then an EGL_BAD_ALLOC error is generated. Finally,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   303
 if the implementation cannot allocate resources for the new EGL window, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   304
 EGL_BAD_ALLOC error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   305
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   306
EXPORT_C EGLSurface eglCreateWindowSurface(EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   307
				  EGLNativeWindowType aWindow, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   308
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   309
	EGL_TRACE("eglCreateWindowSurface Display=%d, Config=%d, Window=0x%x -->", aDisplay, aConfig, aWindow);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   310
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   311
	EGLSurface newSurface = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   312
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   313
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   314
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   315
		newSurface = Instance().eglCreateWindowSurface(*threadState, aDisplay, aConfig, aWindow, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   316
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   317
	EGL_TRACE("eglCreateWindowSurface new Surface=0x%x <--", newSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   318
	return newSurface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   319
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   320
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   321
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   322
 Creates a single off-screen pbuffer surface and returns a handle to it.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   323
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   324
 On failure returns EGL_NO_SURFACE. If the pbuffer could not be created due
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   325
 to insufficient resources, then an EGL_BAD_ALLOC error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   326
 config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   327
 the value specified for either EGL_WIDTH or EGL_HEIGHT is less than zero,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   328
 an EGL_BAD_PARAMETER error is generated. If config does not support
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   329
 pbuffers, an EGL_BAD_MATCH error is generated. In addition, an EGL_BAD_MATCH
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   330
 error is generated if any of the following conditions are true:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   331
 * The EGL_TEXTURE_FORMAT attribute is not EGL_NO_TEXTURE, and EGL_WIDTH
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   332
   and/or EGL_HEIGHT specify an invalid size (e.g., the texture size is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   333
   not a power of two, and the underlying OpenGL ES implementation does not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   334
   support non-power-of-two textures).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   335
 * The EGL_TEXTURE_FORMAT attribute is EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   336
   is something other than EGL_NO_TEXTURE; or, EGL_TEXTURE_FORMAT is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   337
   something other than EGL_NO_TEXTURE, and EGL_TEXTURE_TARGET is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   338
   EGL_NO_TEXTURE.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   339
 Finally, an EGL_BAD_ATTRIBUTE error is generated if any of the EGL_-
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   340
 TEXTURE_FORMAT, EGL_TEXTURE_TARGET, or EGL_MIPMAP_TEXTURE attributes
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   341
 are specified, but config does not support OpenGL ES rendering (e.g.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   342
 the EGL_RENDERABLE_TYPE attribute does not include at least one of EGL_-
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   343
 OPENGL_ES_BIT or EGL_OPENGL_ES2_BIT.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   344
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   345
EXPORT_C EGLSurface eglCreatePbufferSurface(EGLDisplay aDisplay, EGLConfig aConfig, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   346
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   347
	EGL_TRACE("eglCreatePbufferSurface Display=%d, Config=%d -->", aDisplay, aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   348
	EGL_TRACE_ATTRIB_LIST(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   349
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   350
	EGLSurface newSurface = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   351
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   352
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   353
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   354
		newSurface = Instance().eglCreatePbufferSurface(*threadState, aDisplay, aConfig, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   355
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   356
	EGL_TRACE("eglCreatePbufferSurface new Surface=0x%x <--", newSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   357
	return newSurface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   358
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   359
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   360
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   361
 Creates an offscreen EGLSurface and returns a handle to it. Any EGL context
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   362
 created with a compatible EGLConfig can be used to render into this surface.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   363
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   364
 To create a pixmap rendering surface, first create a native platform pixmap,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   365
 then select an EGLConfig matching the pixel format of that pixmap (calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   366
 eglChooseConfig with an attribute list including EGL_MATCH_NATIVE_PIXMAP
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   367
 returns only EGLConfigs matching the pixmap specified in the attribute list).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   368
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   369
 Returns EGL_NO_SURFACE on failure. If the attributes of pixmap do not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   370
 correspond to config, then an EGL_BAD_MATCH error is generated. If config does
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   371
 not support rendering to pixmaps (the EGL_SURFACE_TYPE attribute does not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   372
 contain EGL_PIXMAP_BIT), an EGL_BAD_MATCH error is generated. If config does
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   373
 not support the colorspace or alpha format attributes specified in attrib list
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   374
 (as defined for eglCreateWindowSurface), an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   375
 If config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   376
 pixmap is not a valid native pixmap handle, then an EGL_BAD_NATIVE_PIXMAP
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   377
 error should be generated. If there is already an EGLSurface associated with
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   378
 pixmap (as a result of a previous eglCreatePixmapSurface call), then a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   379
 EGL_BAD_ALLOC error is generated. Finally, if the implementation cannotallocate
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   380
 resources for the new EGL pixmap, an EGL_BAD_ALLOC error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   381
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   382
EXPORT_C EGLSurface eglCreatePixmapSurface(EGLDisplay aDisplay, EGLConfig aConfig, EGLNativePixmapType aPixmap, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   383
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   384
	EGL_TRACE("eglCreatePixmapSurface Display=%d, Config=%d, Pixmap=0x%x -->", aDisplay, aConfig, aPixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   385
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   386
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   387
	EGLSurface newSurface = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   388
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   389
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   390
		newSurface = Instance().eglCreatePixmapSurface(*threadState, aDisplay, aConfig, aPixmap, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   391
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   392
	EGL_TRACE("eglCreatePixmapSurface new Surface=0x%x <--", newSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   393
	return newSurface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   394
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   395
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   396
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   397
 Destroy an EGLSurface of any type (window, pbuffer, or pixmap).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   398
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   399
 All resources associated with surface which were allocated by EGL are marked
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   400
 for deletion as soon as possible. Following eglDestroySurface, the surface
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   401
 and  the handle referring to it are treated in the same fashion as a surface
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   402
 destroyed by eglTerminate.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   403
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   404
 Resources associated with surface but not allocated by EGL, such as native
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   405
 windows, native pixmaps, or client API buffers, are not affected when the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   406
 surface is destroyed. Only storage actually allocated by EGL is marked for
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   407
 deletion. Furthermore, resources associated with a pbuffer surface are not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   408
 released until all color buffers of that pbuffer bound to a OpenGL ES texture
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   409
 object have been released.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   410
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   411
 Returns EGL_FALSE on failure. An EGL_BAD_SURFACE error is generated if surface
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   412
 is not a valid rendering surface.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   413
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   414
EXPORT_C EGLBoolean eglDestroySurface(EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   415
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   416
	EGL_TRACE("eglDestroySurface Display=%d, Surface=0x%x", aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   417
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   418
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   419
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   420
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   421
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   422
		result = Instance().eglDestroySurface(*threadState, aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   423
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   424
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   425
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   426
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   427
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   428
 Returns in value the value of attribute for surface. attribute must be set
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   429
 to one of the attributes in table 3.5 of the EGL specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   430
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   431
 Returns EGL_FALSE on failure and value is not updated. If attribute is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   432
 valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   433
 surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   434
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   435
EXPORT_C EGLBoolean eglQuerySurface(EGLDisplay aDisplay, EGLSurface aSurface, EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   436
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   437
    EGL_TRACE("eglQuerySurface display=%d, surface=%d, attribute=%d", aDisplay, aSurface, aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   438
    TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   439
    if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   440
    	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   441
		return Instance().eglQuerySurface(*threadState, aDisplay, aSurface, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   442
    	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   443
    return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   444
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   445
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   446
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   447
 Set the current rendering API, this is set on a per-thread basis.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   448
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   449
 api must specify one of the supported client APIs , either EGL_OPENVG_API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   450
 or EGL_OPENGL_ES_API. (EGL_OPENGL_API is not currently supported by Symbian.)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   451
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   452
 Returns EGL_FALSE on failure. If api is not one of the values specified
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   453
 above, or if the client API specified by api is not supported by the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   454
 implementation, an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   455
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   456
EXPORT_C EGLBoolean eglBindAPI(EGLenum aApi)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   457
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   458
	EGL_TRACE("eglBindAPI 0x%x (%s)", aApi, (aApi == EGL_OPENGL_ES_API) ? "EGL_OPENGL_ES_API" : (aApi == EGL_OPENVG_API) ? "EGL_OPENVG_API" : "???");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   459
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   460
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   461
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   462
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   463
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   464
		if ( (aApi == EGL_OPENGL_ES_API) || (aApi == EGL_OPENVG_API) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   465
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   466
			threadState->SetEglBoundApi(aApi);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   467
			result = EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   468
			RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   469
			eglApiData.Init(EglRFC::EeglBindAPI);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   470
			eglApiData.AppendEGLenum(aApi);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   471
			EGLBoolean hostResult = threadState->ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   472
			// confirm Host EGL matches what we think about the parameter
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   473
			EGLPANIC_ASSERT_DEBUG(hostResult == result, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   474
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   475
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   476
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   477
			threadState->SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   478
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   479
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   480
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   481
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   482
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   483
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   484
 Get the current rendering API, this is set on a per-thread basis.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   485
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   486
 The value returned will be one of the valid api parameters to eglBindAPI,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   487
 or EGL_NONE.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   488
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   489
 The initial value of the current rendering API is EGL_OPENGL_ES_API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   490
 Applications using multiple client APIs are responsible for ensuring
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   491
 the current rendering API is correct before calling the functions
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   492
 eglCreateContext, eglGetCurrentContext, eglGetCurrentDisplay,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   493
 eglGetCurrentSurface, eglMakeCurrent (when its ctx parameter is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   494
 EGL_NO_CONTEXT), eglWaitClient, or eglWaitNative.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   495
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   496
EXPORT_C EGLenum eglQueryAPI(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   497
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   498
	EGL_TRACE("eglQueryAPI");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   499
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   500
	EGLenum result = EGL_OPENGL_ES_API;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   501
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   502
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   503
		{ // EGL threadState exists
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   504
		result = threadState->EglBoundApi();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   505
		threadState->SetEglError(EGL_SUCCESS);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   506
#ifdef _DEBUG
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   507
		// Debug build checks that local threadState is in sync with Host EGL state
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   508
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   509
		eglApiData.Init(EglRFC::EeglQueryAPI);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   510
		threadState->ExecuteEglNeverErrorCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   511
		EGLPANIC_ASSERT(result == (EGLenum)eglApiData.ReturnValue(), EEglPanicHostAndClientBoundApiOutOfSync);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   512
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   513
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   514
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   515
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   516
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   517
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   518
 Wait for client (Open GL ES, VG, ...) rendering to complete, before
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   519
 using Symbian native rendering.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   520
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   521
 Returns EGL_TRUE on success. If there is no current context for  the current
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   522
 rendering API, the function has no effect but still returns EGL_TRUE. If the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   523
 surface associated with the calling thread’s current context is no longer valid,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   524
 EGL_FALSE is returned and an EGL_BAD_CURRENT_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   525
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   526
EXPORT_C EGLBoolean eglWaitClient(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   527
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   528
	EGL_TRACE("eglWaitClient");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   529
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   530
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   531
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   532
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   533
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   534
		result = Instance().eglWaitClient(*threadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   535
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   536
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   537
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   538
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   539
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   540
 Return EGL to its state at thread initialization.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   541
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   542
 EGL_TRUE is returned on success, and the following actions are taken:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   543
 * For each client API supported by EGL, if there is a currently bound context,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   544
   that context is released. This is equivalent to calling eglMakeCurrent
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   545
   with ctx set to EGL_NO_CONTEXT and both draw and read set to EGL_NO_SURFACE.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   546
 * The current rendering API is reset to its value at thread initialization.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   547
 * Any additional implementation-dependent per-thread state maintained by
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   548
   EGL is marked for deletion as soon as possible.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   549
 Returns EGL_FALSE on failure, there are no defined conditions under which
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   550
 failure will occur.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   551
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   552
EXPORT_C EGLBoolean eglReleaseThread(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   553
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   554
	EGL_TRACE("eglReleaseThread -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   555
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   556
	TEglThreadState* threadState = CVghwUtils::EglThreadState(); // fetching pre-existing thread state, if any
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   557
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   558
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   559
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   560
		eglApiData.Init(EglRFC::EeglReleaseThread);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   561
	    threadState->ExecuteEglNeverErrorCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   562
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   563
	    // release client side memory
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   564
		CVghwUtils::ReleaseThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   565
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   566
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   567
	EGL_TRACE("eglReleaseThread <--");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   568
	return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   569
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   570
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   571
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   572
 Creates a single pbuffer surface bound to the specified buffer for part or
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   573
 all of its buffer storage, and returns a handle to it. The width  and height
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   574
 of the pbuffer are determined by the width and height of buffer.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   575
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   576
 Currently, the only client API resources which may be bound in this fashion
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   577
 are OpenVG VGImage objects.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   578
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   579
 On failure eglCreatePbufferFromClientBuffer returns EGL_NO_SURFACE. In
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   580
 addition to the errors described eglCreatePbufferSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   581
 eglCreatePbufferFromClientBuffer may fail and generate errors for the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   582
 following reasons:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   583
 * If buftype is not a recognized client API resource type (e.g. is not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   584
   EGL_OPENVG_IMAGE), an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   585
 * If buffer is not a valid handle or name of a client API resource of the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   586
   specified buftype in the currently bound context corresponding to that
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   587
   type, an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   588
 * If the buffers contained in buffer do not correspond to a proper subset
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   589
   of the buffers described by config, and match the bit depths for those
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   590
   buffers specified in config, then an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   591
   For example, a VGImage with pixel format VG_lRGBA_8888 corresponds to an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   592
   EGLConfig with EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, and
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   593
   EGL_ALPHA_SIZE values of 8.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   594
 * If no context corresponding to the specified buftype is current, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   595
   EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   596
 * There may be additional constraints on which types of buffers may be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   597
   bound to EGL surfaces, as described in client API specifications. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   598
   those constraints are violated, then an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   599
 * If buffer is already bound to another pbuffer, or is in use by a client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   600
   API an EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   601
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   602
EXPORT_C EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay aDisplay, EGLenum aBufType, EGLClientBuffer aBuffer,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   603
			EGLConfig aConfig, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   604
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   605
	EGL_TRACE("eglCreatePbufferFromClientBuffer Display=%d, BufType=%d, Config=%d -->", aDisplay, aBufType, aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   606
	EGL_TRACE_ATTRIB_LIST(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   607
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   608
	EGLSurface newSurface = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   609
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   610
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   611
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   612
		newSurface = Instance().eglCreatePbufferFromClientBuffer(*threadState, aDisplay, aBufType, aBuffer, aConfig, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   613
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   614
	EGL_TRACE("eglCreateWindowSurface new Surface=0x%x <--", newSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   615
	return newSurface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   616
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   617
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   618
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   619
 Set an attribute for an EGLSurface.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   620
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   621
 The specified attribute of surface is set to value. Attributes that can be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   622
 specified are EGL_MIPMAP_LEVEL, EGL_MULTISAMPLE_RESOLVE, and EGL_SWAP_BEHAVIOR.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   623
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   624
 Returns EGL_FALSE on failure and value is not updated. If attribute is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   625
 valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   626
 surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   627
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   628
EXPORT_C EGLBoolean eglSurfaceAttrib(EGLDisplay aDisplay, EGLSurface aSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   629
			    EGLint aAttribute, EGLint aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   630
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   631
	EGL_TRACE("eglSurfaceAttrib Display=%d, Surface=0x%x, Attribute=0x%x, Value=%d", aDisplay, aSurface, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   632
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   633
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   634
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   635
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   636
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   637
		result = Instance().eglSurfaceAttrib(*threadState, aDisplay, aSurface, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   638
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   639
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   640
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   641
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   642
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   643
 Defines a two-dimensional texture image. The texture image consists of the image
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   644
 data in buffer for the specified surface, and need not be copied. Currently the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   645
 only value accepted for buffer is EGL_BACK_BUFFER, which indicates the buffer into
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   646
 which OpenGL ES rendering is taking place (this is true even when using a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   647
 singlebuffered surface, such as a pixmap). In future versions of EGL, additional buffer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   648
 values may be allowed to bind textures to other buffers in an EGLSurface.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   649
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   650
 eglBindTexImage is ignored if there is no current rendering context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   651
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   652
 If eglBindTexImage is called and the surface attribute EGL_TEXTURE_FORMAT is set
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   653
 to EGL_NO_TEXTURE, then an EGL_BAD_MATCH error is returned. If buffer is already
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   654
 bound to a texture then an EGL_BAD_ACCESS error is returned. If buffer is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   655
 valid buffer, then an EGL_BAD_PARAMETER error is generated. If surface is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   656
 valid EGLSurface, or is not a pbuffer surface supporting texture
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   657
 binding, then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   658
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   659
EXPORT_C EGLBoolean eglBindTexImage(EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   660
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   661
	EGL_TRACE("eglBindTexImage Display=%d, Surface=0x%x, Buffer=%d", aDisplay, aSurface, aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   662
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   663
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   664
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   665
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   666
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   667
		result = Instance().eglBindTexImage(*threadState, aDisplay, aSurface, aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   668
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   669
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   670
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   671
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   672
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   673
 The specified color buffer is released back to the surface. The surface is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   674
 made  available for reading and writing when it no longer has any color
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   675
 buffers bound as textures.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   676
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   677
 If the value of surface attribute EGL_TEXTURE_FORMAT is EGL_NO_TEXTURE,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   678
 then an EGL_BAD_MATCH error is returned. If buffer is not a valid buffer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   679
 (currently only EGL_BACK_BUFFER may  be specified), then an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   680
 EGL_BAD_PARAMETER error is generated. If surface is not a valid EGLSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   681
 or is not a bound pbuffer surface, then an EGL_BAD_SURFACE error is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   682
 returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   683
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   684
EXPORT_C EGLBoolean eglReleaseTexImage(EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   685
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   686
	EGL_TRACE("eglReleaseTexImage Display=%d, Surface=0x%x, Buffer=%d", aDisplay, aSurface, aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   687
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   688
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   689
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   690
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   691
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   692
		result = Instance().eglReleaseTexImage(*threadState, aDisplay, aSurface, aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   693
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   694
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   695
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   696
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   697
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   698
 Specifies the minimum number of video frame periods per buffer swap for
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   699
 the window associated with the current context. The interval takes effect when
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   700
 eglSwapBuffers is first called subsequent to the eglSwapInterval call.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   701
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   702
 Returns EGL_FALSE on failure. If there is no current context on the calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   703
 thread, a EGL_BAD_CONTEXT error is generated. If there is no surface bound
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   704
 to the current context, a EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   705
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   706
EXPORT_C EGLBoolean eglSwapInterval(EGLDisplay aDisplay, EGLint aInterval)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   707
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   708
	EGL_TRACE("eglSwapInterval Display=%d, Interval=%d frames", aDisplay, aInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   709
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   710
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   711
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   712
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   713
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   714
		result = Instance().eglSwapInterval(*threadState, aDisplay, aInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   715
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   716
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   717
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   718
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   719
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   720
 Create a rendering context for the current rendering API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   721
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   722
 If eglCreateContext succeeds, it initializes the context to the initial
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   723
 state defined for the current rendering API, and returns a handle to it.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   724
 The context can be used to render to any compatible EGLSurface. Although
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   725
 contexts are specific to a single client API , all contexts created in
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   726
 EGL exist in a single namespace. This allows many EGL calls which manage
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   727
 contexts to avoid use of the current rendering API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   728
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   729
 On failure returns EGL_NO_CONTEXT. If the current rendering api is EGL_NONE,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   730
 then an EGL_BAD_MATCH error is generated (this situation can only arise in
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   731
 an implementation which does not support OpenGL ES, and prior to the first
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   732
 call to eglBindAPI). If share context is neither zero nor a valid context
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   733
 of the same client API type as the newly created context, then an EGL_-
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   734
 BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   735
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   736
 If config is not a valid EGLConfig, or does not support the requested client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   737
 API , then an EGL_BAD_CONFIG error is generated (this includes requesting creation
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   738
 of an OpenGL ES 1.x context when the EGL_RENDERABLE_TYPE attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   739
 of config does not contain EGL_OPENGL_ES_BIT, or creation of an OpenGL ES
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   740
 2.x context when the attribute does not contain EGL_OPENGL_ES2_BIT).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   741
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   742
 If the OpenGL or OpenGL ES server context state for share context exists in
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   743
 an address space that cannot be shared with the newly created context, if share -
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   744
 context was created on a different display than the one referenced by config, or if
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   745
 the contexts are otherwise incompatible (for example, one context being associated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   746
 with a hardware device driver and the other with a software renderer), then an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   747
 EGL_BAD_MATCH error is generated. If the server does not have enough resources
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   748
 to allocate the new context, then an EGL_BAD_ALLOC error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   749
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   750
EXPORT_C EGLContext eglCreateContext(EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   751
				EGLContext aShareContext, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   752
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   753
	EGL_TRACE("eglCreateContext Display=%d, Config=%d, ShareContext=%d -->", aDisplay, aConfig, aShareContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   754
	EGL_TRACE_ATTRIB_LIST(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   755
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   756
	EGLContext result = EGL_NO_CONTEXT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   757
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   758
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   759
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   760
		result = Instance().eglCreateContext(*threadState, aDisplay, aConfig, aShareContext, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   761
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   762
	EGL_TRACE("eglCreateContext new context=%d <--", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   763
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   764
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   765
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   766
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   767
 Destroy a rendering context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   768
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   769
 All resources associated with ctx are marked for deletion as soon as possible.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   770
 Following eglDestroyContext, the context and the handle referring to it are
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   771
 treated in the same fashion as a context destroyed by eglTerminate.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   772
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   773
 Returns EGL_FALSE on failure. An EGL_BAD_CONTEXT error is generated if ctx is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   774
 not a valid context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   775
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   776
EXPORT_C EGLBoolean eglDestroyContext(EGLDisplay aDisplay, EGLContext aContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   777
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   778
	EGL_TRACE("eglDestroyContext Display=%d, Context=%d", aDisplay, aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   779
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   780
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   781
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   782
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   783
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   784
		result = Instance().eglDestroyContext(*threadState, aDisplay, aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   785
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   786
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   787
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   788
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   789
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   790
 Make a context current, binds ctx to the current rendering thread
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   791
 and to the draw and read surfaces.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   792
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   793
 For an OpenVG context, the same EGLSurface must be specified for both
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   794
 draw and read.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   795
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   796
 If the calling thread already has a current context of the same client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   797
 API type as ctx, then that context is flushed and marked as no longer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   798
 current. ctx is then made the current context for the calling thread.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   799
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   800
 To release the current context without assigning a new one, set ctx to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   801
 EGL_NO_CONTEXT and set draw and read to EGL_NO_SURFACE. The currently
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   802
 bound context for the client API specified by the current rendering API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   803
 is flushed and marked as no longer current, and there will be no current
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   804
 context for that client API after eglMakeCurrent returns. This is the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   805
 only case in which eglMakeCurrent respects the current rendering API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   806
 In all other cases, the client API affected is determined by ctx. This
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   807
 is the only case where an uninitialized display may be passed to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   808
 eglMakeCurrent.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   809
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   810
 Returns EGL_FALSE on failure. Errors generated may include:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   811
 * If draw or read are not compatible with ctx, then an EGL_BAD_MATCH
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   812
   error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   813
 * If ctx is current to some other thread, or if either draw or read are
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   814
   bound to contexts in another thread, an EGL_BAD_ACCESS error is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   815
   generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   816
 * If binding ctx would exceed the number of current contexts of that
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   817
   client API type supported by the implementation, an EGL_BAD_ACCESS
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   818
   error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   819
 * If either draw or read are pbuffers created with eglCreatePbufferFrom-
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   820
   ClientBuffer, and the underlying bound client API buffers are in use
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   821
   by the client API that created them, an EGL_BAD_ACCESS error is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   822
   generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   823
 * If ctx is not a valid context, an EGL_BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   824
 * If either draw or read are not valid EGL surfaces, an EGL_BAD_SURFACE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   825
   error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   826
 * If a native window underlying either draw or read is no longer valid,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   827
   an EGL_BAD_NATIVE_WINDOW error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   828
 * If draw and read cannot fit into graphics memory simultaneously, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   829
   EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   830
 * If the previous context of the calling thread has unflushed commands,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   831
   and the previous surface is no longer valid, an EGL_BAD_CURRENT_SURFACE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   832
   error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   833
 * If the ancillary buffers for draw and read cannot be allocated, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   834
   EGL_BAD_ALLOC error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   835
 * If a power management event has occurred, an EGL_CONTEXT_LOST error
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   836
   is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   837
 * As with other commands taking EGLDisplay parameters, if dpy is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   838
   valid EGLDisplay handle, an EGL_BAD_DISPLAY error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   839
 Other errors may arise when the context state is inconsistent with the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   840
 surface state, as described in the EGL specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   841
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   842
EXPORT_C EGLBoolean eglMakeCurrent(EGLDisplay aDisplay, EGLSurface aDraw, EGLSurface aRead, EGLContext aContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   843
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   844
	EGL_TRACE("eglMakeCurrent Display=%d, DrawSurface=0x%x, ReadSurface=0x%x, Context=%d", aDisplay, aDraw, aRead, aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   845
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   846
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   847
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   848
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   849
		return Instance().eglMakeCurrent(*threadState, aDisplay, aDraw, aRead, aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   850
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   851
	return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   852
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   853
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   854
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   855
 Get the current context for the current rendering API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   856
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   857
 If there is no current context for the current rendering API, or if the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   858
 current rendering API is EGL_NONE, then EGL_NO_CONTEXT is returned (this
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   859
 is not an error).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   860
 If the current context has been marked for deletion as a result of calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   861
 eglTerminate or eglDestroyContext, the handle returned by eglGetCurrentContext
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   862
 is not valid, and cannot be passed successfully to any other EGL function,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   863
 as discussed in section 3.2 of the EGL Specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   864
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   865
EXPORT_C EGLContext eglGetCurrentContext(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   866
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   867
	EGL_TRACE("eglGetCurrentContext -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   868
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   869
	EGLContext context = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   870
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   871
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   872
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   873
		context = Instance().eglGetCurrentContext(*threadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   874
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   875
	EGL_TRACE("eglGetCurrentContext context=%d <--", context);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   876
	return context;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   877
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   878
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   879
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   880
 Get the surfaces used for rendering by a current context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   881
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   882
 readdraw is either EGL_READ or EGL_DRAW, to return respectively the read or
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   883
 draw surfaces bound to the current context in the calling thread, for the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   884
 current rendering API.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   885
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   886
 If there is no current context for the current rendering API, then
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   887
 EGL_NO_SURFACE is returned (this is not an error). If readdraw is neither
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   888
 EGL_READ nor EGL_DRAW, EGL_NO_SURFACE is returned and an EGL_BAD_PARAMETER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   889
 error is generated. If a current surface has been marked for deletion as
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   890
 a result of calling eglTerminate or eglDestroySurface, the handle returned
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   891
 by eglGetCurrentSurface is not valid, and cannot be passed successfully to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   892
 any other EGL function, as discussed in section 3.2 of the EGL Specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   893
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   894
EXPORT_C EGLSurface eglGetCurrentSurface(EGLint aReadDraw)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   895
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   896
	EGL_TRACE("eglGetCurrentSurface ReadDraw=%d -->", aReadDraw);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   897
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   898
	EGLSurface surface = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   899
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   900
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   901
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   902
		surface = Instance().eglGetCurrentSurface(*threadState, aReadDraw);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   903
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   904
	EGL_TRACE("eglGetCurrentSurface surface=0x%x <--", surface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   905
	return surface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   906
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   907
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   908
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   909
 Get the display associated with a current context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   910
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   911
 The display for the current context in the calling thread, for the current
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   912
 rendering API, is returned. If there is no current context for the current
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   913
 rendering API, EGL_NO_DISPLAY is returned (this is not an error).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   914
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   915
 Note that EGL_NO_DISPLAY is used solely to represent an error condition,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   916
 and is not a valid EGLDisplay handle. Passing EGL_NO_DISPLAY to any command
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   917
 taking an EGLDisplay parameter will generate either an EGL_BAD_DISPLAY
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   918
 error if the EGL implementation validates EGLDisplay handles, or undefined
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   919
 behavior as described at the end of section 3.1 of the EGL Specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   920
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   921
EXPORT_C EGLDisplay eglGetCurrentDisplay(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   922
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   923
	EGL_TRACE("eglGetCurrentDisplay -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   924
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   925
	EGLDisplay display = EGL_NO_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   926
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   927
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   928
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   929
		display = Instance().eglGetCurrentDisplay(*threadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   930
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   931
	EGL_TRACE("eglGetCurrentDisplay Display=%d <--", display);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   932
	return display;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   933
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   934
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   935
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   936
 Obtain the value of context attributes.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   937
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   938
 Returns in value the value of attribute for ctx. attribute must be set to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   939
 EGL_CONFIG_ID, EGL_CONTEXT_CLIENT_TYPE, EGL_CONTEXT_CLIENT_VERSION, or
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   940
 EGL_RENDER_BUFFER.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   941
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   942
 Returns EGL_FALSE on failure and value is not updated. If attribute is not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   943
 a valid EGL context attribute, then an EGL_BAD_ATTRIBUTE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   944
 If ctx is invalid, an EGL_BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   945
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   946
EXPORT_C EGLBoolean eglQueryContext(EGLDisplay aDisplay, EGLContext aContext, EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   947
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   948
	EGL_TRACE("eglQueryContext Display=%d, Context=%d, Attribute=0x%x, aValue=0x%x", aDisplay, aContext, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   949
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   950
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   951
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   952
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   953
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   954
		result = Instance().eglQueryContext(*threadState, aDisplay, aContext, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   955
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   956
	EGL_TRACE_GET_ATTRIB("eglQueryContext", "context", aDisplay, aContext, aAttribute, aValue, result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   957
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   958
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   959
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   960
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   961
 EGL function is for backwards compatibility only.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   962
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   963
 Equivalent to:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   964
 EGLenum api = eglQueryAPI();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   965
 eglBindAPI(EGL_OPENGL_ES_API);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   966
 eglWaitClient();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   967
 eglBindAPI(api);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   968
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   969
EXPORT_C EGLBoolean eglWaitGL(void)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   970
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   971
	EGL_TRACE("eglWaitGL");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   972
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   973
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   974
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   975
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   976
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   977
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   978
		eglApiData.Init(EglRFC::EeglWaitGL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   979
		result = threadState->ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   980
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   981
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   982
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   983
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   984
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   985
 Wait for Symbian native rendering to complete, before performing
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   986
 client (Open GL ES, VG, ...) rendering.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   987
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   988
 Returns EGL_TRUE on success. If there is no current context,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   989
 the function has no effect but still returns EGL_TRUE. If the surface does not support
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   990
 native rendering (e.g. pbuffer and in most cases window surfaces), the function
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   991
 has no effect but still returns EGL_TRUE. If the surface associated with the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   992
 calling thread’s current context is no longer valid, EGL_FALSE is returned and an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   993
 EGL_BAD_CURRENT_SURFACE error is generated. If engine does not denote a recognized
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   994
 marking engine, EGL_FALSE is returned and an EGL_BAD_PARAMETER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   995
 error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   996
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   997
EXPORT_C EGLBoolean eglWaitNative(EGLint aEngine)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   998
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   999
	EGL_TRACE("eglWaitNative %d", aEngine);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1000
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1001
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1002
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1003
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1004
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1005
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1006
		eglApiData.Init( EglRFC::EeglWaitNative);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1007
		eglApiData.AppendEGLint(aEngine);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1008
		result = threadState->ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1009
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1010
		if ( EGL_CORE_NATIVE_ENGINE == aEngine )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1011
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1012
			//Do native draw api sync
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1013
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1014
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1015
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1016
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1017
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1018
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1019
 Post the color buffer to a window.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1020
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1021
 If surface is a back-buffered window surface, then the color buffer is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1022
 copied to the native window associated with that surface. If surface is a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1023
 single-buffered window, pixmap, or pbuffer surface, eglSwapBuffers has no
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1024
 effect.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1025
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1026
 The contents of the color buffer of surface may be affected by
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1027
 eglSwapBuffers, depending on the value of the EGL_SWAP_BEHAVIOR attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1028
 of surface. See section 3.5.6 of the EGL Specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1029
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1030
 Returns EGL_FALSE on failure. If surface is not a valid EGL surface, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1031
 EGL_BAD_SURFACE error is generated. If surface is not bound to the calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1032
 thread’s current context, an EGL_BAD_SURFACE error is generated. If target is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1033
 not a valid native pixmap handle, an EGL_BAD_NATIVE_PIXMAP error should be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1034
 generated. If the format of target is not compatible with the color buffer,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1035
 or if the size of target is not the same as the size of the color buffer, and
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1036
 there is no defined conversion between the source and target formats, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1037
 EGL_BAD_MATCH error is generated. If called after a power management event
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1038
 has occurred, a EGL_CONTEXT_LOST error is generated. If the native window
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1039
 associated with surface is no longer valid, an EGL_ BAD_NATIVE_WINDOW error
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1040
 is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1041
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1042
EXPORT_C EGLBoolean eglSwapBuffers(EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1043
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1044
	EGL_TRACE("eglSwapBuffers begin Display=%d, Surface=0x%x -->", aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1045
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1046
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1047
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1048
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1049
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1050
		result = Instance().eglSwapBuffers(*threadState, aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1051
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1052
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1053
	EGL_TRACE("eglSwapBuffers success=%d <--", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1054
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1055
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1056
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1057
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1058
 Copy the color buffer to a native pixmap.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1059
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1060
 The mapping of pixels in the color buffer to pixels in the pixmap is platform
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1061
 dependent, since the native platform pixel coordinate system may differ from
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1062
 that of client APIs.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1063
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1064
 The color buffer of surface is left unchanged after calling eglCopyBuffers.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1065
 Returns EGL_FALSE on failure. If surface is not a valid EGL surface, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1066
 EGL_BAD_SURFACE error is generated. If surface is not bound to the calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1067
 thread’s current context, an EGL_BAD_SURFACE error is generated. If target is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1068
 not a valid native pixmap handle, an EGL_BAD_NATIVE_PIXMAP error should be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1069
 generated. If the format of target is not compatible with the color buffer,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1070
 or if the size of target is not the same as the size of the color buffer, and
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1071
 there is no defined conversion between the source and target formats, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1072
 EGL_BAD_MATCH error is generated. If called after a power management event
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1073
 has occurred, a EGL_CONTEXT_LOST error is generated. If the egl
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1074
 implementation does not support native pixmaps, an EGL_BAD_NATIVE_PIXMAP
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1075
 error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1076
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1077
EXPORT_C EGLBoolean eglCopyBuffers(EGLDisplay aDisplay, EGLSurface aSurface, EGLNativePixmapType aTarget)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1078
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1079
	// Note: API supports CFbsBitmap native pixmap but not SgImage
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1080
	EGL_TRACE("eglCopyBuffers Display=%d, Surface=0x%x, Target=0x%x", aDisplay, aSurface, aTarget);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1081
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1082
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1083
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1084
		{ // EGL is initialized for thread
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1085
		return Instance().eglCopyBuffers(*threadState, aDisplay, aSurface, aTarget);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1086
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1087
	return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1088
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1089
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1090
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1091
 * eglCreateImageKHR supports Khronos EGL extension #8, "KHR_image_base"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1092
 *
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1093
 * Supported values for target parameter:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1094
 * EGL_NATIVE_PIXMAP_KHR for Khronos EGL extension #9, "KHR_image_pixmap"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1095
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1096
EGLImageKHR eglCreateImageKHR(EGLDisplay aDisplay, EGLContext aContext, EGLenum aTarget, EGLClientBuffer aBuffer, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1097
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1098
	EGL_TRACE("eglCreateImageKHR Display=%d, Context=%d, Target=0x%x, Buffer=0x%x, AttribList=0x%x -->",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1099
			aDisplay, aContext, aTarget, aBuffer, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1100
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1101
	EGLImageKHR image = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1102
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1103
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1104
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1105
		image = Instance().eglCreateImageKHR(*threadState, aDisplay, aContext, aTarget, aBuffer, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1106
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1107
	EGL_TRACE("eglCreateImageKHR image=0x%x <--", image);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1108
	return image;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1109
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1110
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1111
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1112
 * eglDestroyImageKHR supports Khronos EGL extension #8, "KHR_image_base"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1113
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1114
EGLBoolean eglDestroyImageKHR(EGLDisplay aDisplay, EGLImageKHR aImage)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1115
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1116
	EGL_TRACE("eglDestroyImageKHR Display=%d, Image=0x%x -->", aDisplay, aImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1117
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1118
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1119
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1120
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1121
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1122
		success = Instance().eglDestroyImageKHR(*threadState, aDisplay, aImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1123
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1124
	EGL_TRACE("eglDestroyImageKHR success=%d <--", success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1125
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1126
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1127
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1128
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1129
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1130
 Returns the address of the extension function named by procName. procName
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1131
 must be a NULL-terminated string. The pointer returned should be cast to
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1132
 a function pointer type matching the extension function’s definition in
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1133
 that extension specification.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1134
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1135
 A return value of NULL indicates that the specified function does not exist
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1136
 for the implementation.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1137
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1138
 A non-NULL return value for eglGetProcAddress does not guarantee that an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1139
 extension function is actually supported at runtime. The client must also make
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1140
 a corresponding query, such as glGetString(GL_EXTENSIONS) for OpenGL and
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1141
 OpenGL ES extensions; vgGetString(VG_EXTENSIONS) for OpenVG extensions;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1142
 or eglQueryString(dpy, EGL_EXTENSIONS) for EGL extensions, to determine if
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1143
 an extension is supported by a particular client API context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1144
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1145
 Function pointers returned by eglGetProcAddress are independent of the display
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1146
 and the currently bound context, and may be used by any context which supports
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1147
 the extension.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1148
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1149
 eglGetProcAddress may be queried for all of the following functions:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1150
 * All EGL and client API extension functions supported by the implementation
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1151
   (whether those extensions are supported by the current context or not).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1152
   This includes any mandatory OpenGL ES extensions.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1153
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1154
EXPORT_C void (*eglGetProcAddress (const char *aProcname))(...)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1155
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1156
	EGL_TRACE("eglGetProcAddress");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1157
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1158
	if (aProcname)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1159
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1160
		return Instance().eglGetProcAddress(aProcname);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1161
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1162
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1163
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1164
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1165
} /* extern "C" */