|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Guest Egl implementation of attributes and attribute lists |
|
15 |
|
16 #include <e32debug.h> |
|
17 #include "eglapi.h" |
|
18 |
|
19 |
|
20 |
|
21 TInt TAttribUtils::AttribListLength(const EGLint* aAttribList) |
|
22 { |
|
23 int length = 0; |
|
24 if (aAttribList) |
|
25 { |
|
26 while (aAttribList[length] != EGL_NONE) |
|
27 { |
|
28 length += 2; |
|
29 EGLPANIC_ASSERT_DEBUG(length < 100, EEglPanicAtribListLengthTooLong); |
|
30 } |
|
31 ++length; |
|
32 } |
|
33 return length; |
|
34 } |
|
35 |
|
36 const EGLint* TAttribUtils::FindAttribValue(const EGLint* aAttribList, EGLint aAttrib) |
|
37 { |
|
38 EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp); |
|
39 |
|
40 if (aAttribList && (aAttrib != EGL_NONE) ) |
|
41 { |
|
42 TInt idx = 0; |
|
43 while (aAttribList[idx] != EGL_NONE) |
|
44 { |
|
45 if (aAttribList[idx] == aAttrib) |
|
46 { |
|
47 return aAttribList + idx + 1; |
|
48 } |
|
49 idx += 2; |
|
50 EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong); |
|
51 } |
|
52 } |
|
53 return NULL; |
|
54 } |
|
55 |
|
56 EGLint* TAttribUtils::FindAttribValue(EGLint* aAttribList, EGLint aAttrib) |
|
57 { |
|
58 EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp); |
|
59 |
|
60 if (aAttribList && (aAttrib != EGL_NONE) ) |
|
61 { |
|
62 TInt idx = 0; |
|
63 while (aAttribList[idx] != EGL_NONE) |
|
64 { |
|
65 if (aAttribList[idx] == aAttrib) |
|
66 { |
|
67 return aAttribList + idx + 1; |
|
68 } |
|
69 idx += 2; |
|
70 EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong); |
|
71 } |
|
72 } |
|
73 return NULL; |
|
74 } |
|
75 |
|
76 void TAttribUtils::AppendAttribValue(EGLint* aAttribList, EGLint aAttrib, EGLint aValue) |
|
77 { |
|
78 EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp); |
|
79 |
|
80 if (aAttribList && (aAttrib != EGL_NONE)) |
|
81 { |
|
82 TInt idx = 0; |
|
83 while (aAttribList[idx] != EGL_NONE) |
|
84 { |
|
85 idx += 2; |
|
86 EGLPANIC_ASSERT_DEBUG(idx < 100, EEglPanicAtribListLengthTooLong); |
|
87 } |
|
88 aAttribList[idx++] = aAttrib; |
|
89 aAttribList[idx++] = aValue; |
|
90 aAttribList[idx++] = EGL_NONE; |
|
91 } |
|
92 } |
|
93 |
|
94 void TAttribUtils::RemoveAttrib(EGLint* aAttribList, EGLint aAttrib) |
|
95 { |
|
96 EGLPANIC_ASSERT_DEBUG(aAttrib != EGL_NONE, EEglPanicTemp); |
|
97 |
|
98 if (aAttribList && (aAttrib != EGL_NONE) && (*aAttribList != EGL_NONE)) |
|
99 { |
|
100 TInt dstIdx = 0; |
|
101 |
|
102 while ( (aAttribList[dstIdx] != EGL_NONE) && (aAttribList[dstIdx] != aAttrib) ) |
|
103 { |
|
104 dstIdx += 2; |
|
105 EGLPANIC_ASSERT_DEBUG(dstIdx < 100, EEglPanicAtribListLengthTooLong); |
|
106 } |
|
107 |
|
108 if (aAttribList[dstIdx] == aAttrib) |
|
109 { // attrib found |
|
110 TInt srcIdx = dstIdx + 2; |
|
111 while (aAttribList[srcIdx] != EGL_NONE) |
|
112 { // copy up succeeding attrib / value pairs |
|
113 aAttribList[dstIdx++] = aAttribList[srcIdx++]; |
|
114 aAttribList[dstIdx++] = aAttribList[srcIdx++]; |
|
115 EGLPANIC_ASSERT_DEBUG(dstIdx < 100, EEglPanicAtribListLengthTooLong); |
|
116 } |
|
117 aAttribList[dstIdx++] = EGL_NONE; |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 // end of file eglattrib.cpp |