guestrendering/guestegl/src/eglattribs.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
// Guest Egl implementation of attributes and attribute lists
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 <e32debug.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    17
#include "eglapi.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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    21
TInt TAttribUtils::AttribListLength(const EGLint* aAttribList)
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
	int length = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    24
	if (aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    25
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    26
		while (aAttribList[length] != EGL_NONE)
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
			length += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    29
			EGLPANIC_ASSERT_DEBUG(length < 100, EEglPanicAtribListLengthTooLong);
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
		++length;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    32
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    33
	return length;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    34
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    35
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    36
const EGLint* TAttribUtils::FindAttribValue(const EGLint* aAttribList, EGLint aAttrib)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    37
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    38
	EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    39
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    40
	if (aAttribList && (aAttrib != EGL_NONE) )
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
		TInt idx = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    43
		while (aAttribList[idx] != EGL_NONE)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    44
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    45
			if (aAttribList[idx] == aAttrib)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    46
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    47
				return aAttribList + idx + 1;
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
			idx += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    50
			EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong);
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
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    54
	}
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
EGLint* TAttribUtils::FindAttribValue(EGLint* aAttribList, EGLint aAttrib)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    57
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    58
	EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    59
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    60
	if (aAttribList && (aAttrib != EGL_NONE) )
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
		TInt idx = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    63
		while (aAttribList[idx] != EGL_NONE)
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
			if (aAttribList[idx] == aAttrib)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    66
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    67
				return aAttribList + idx + 1;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    68
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    69
			idx += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    70
			EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong);
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
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    73
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    74
	}
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
void TAttribUtils::AppendAttribValue(EGLint* aAttribList, EGLint aAttrib, EGLint aValue)
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
	EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp);
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
	if (aAttribList && (aAttrib != EGL_NONE))
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
		TInt idx = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    83
		while (aAttribList[idx] != EGL_NONE)
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
			idx += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    86
			EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    87
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    88
		aAttribList[idx++] = aAttrib;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    89
		aAttribList[idx++] = aValue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    90
		aAttribList[idx++] = EGL_NONE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    91
		}
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
void TAttribUtils::RemoveAttrib(EGLint* aAttribList, EGLint aAttrib)
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
	EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp);
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
	if (aAttribList && (aAttrib != EGL_NONE) && (*aAttribList != EGL_NONE))
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
		TInt dstIdx = 0;
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
		while ( (aAttribList[dstIdx] != EGL_NONE) && (aAttribList[dstIdx] != aAttrib) )
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
			dstIdx += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   105
			EGLPANIC_ASSERT_DEBUG(dstIdx < 100, EEglPanicAtribListLengthTooLong);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   106
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   107
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   108
		if (aAttribList[dstIdx] == aAttrib)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   109
			{ // attrib found
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   110
			TInt srcIdx = dstIdx + 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   111
			while (aAttribList[srcIdx] != EGL_NONE)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   112
				{ // copy up succeeding attrib / value pairs
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   113
				aAttribList[dstIdx++] = aAttribList[srcIdx++];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   114
				aAttribList[dstIdx++] = aAttribList[srcIdx++];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   115
				EGLPANIC_ASSERT_DEBUG(dstIdx < 100, EEglPanicAtribListLengthTooLong);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   116
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   117
			aAttribList[dstIdx++] = EGL_NONE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   118
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   119
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   120
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   121
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   122
// end of file eglattrib.cpp