author | Faisal Memon <faisal.memon@nokia.com> |
Thu, 09 Sep 2010 16:50:12 +0100 | |
branch | bug235_bringup_0 |
changeset 18 | 3064c37a6509 |
parent 17 | c9d1eb0bfac8 |
child 19 | da7c1a80df0d |
permissions | -rwxr-xr-x |
13 | 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 |
|
15 |
||
16 |
#include <graphics/surfacemanager.h> |
|
17 |
#include <graphics/surfaceconfiguration.h> |
|
18 |
#include <graphics/suerror.h> |
|
19 |
#include <graphics/surface_hints.h> |
|
20 |
#include <e32debug.h> |
|
21 |
#include <stdlib.h> // for malloc |
|
22 |
#include "eglapi.h" |
|
23 |
||
24 |
#include <graphics/guestvideodriverinterfaceconstants.h> |
|
25 |
||
26 |
||
27 |
// FAISALMEMON HOLE 0 |
|
28 |
||
29 |
// ----------------------------------------------------------------------------- |
|
30 |
// constructor |
|
31 |
// ----------------------------------------------------------------------------- |
|
32 |
// |
|
33 |
||
34 |
// FAISALMEMON STUB CODE |
|
35 |
#define EGL_CHECK_ERROR(a, b, c) /* This does no checking; just a stub */ |
|
36 |
void CGuestEGL::EglInternalFunction_DestroyWindowSurface(TSurfaceInfo&) |
|
37 |
{ |
|
38 |
return; // stub code |
|
39 |
} |
|
40 |
||
41 |
EGLBoolean CGuestEGL::EglInternalFunction_SurfaceResized(TEglThreadState&, TSurfaceInfo&, int, int) |
|
42 |
{ |
|
43 |
return EFalse; // stub code |
|
44 |
} |
|
45 |
||
46 |
TBool CGuestEGL::EglInternalFunction_SwapWindowSurface(TEglThreadState&, int, int) |
|
47 |
{ |
|
48 |
return EFalse; // stub code |
|
49 |
} |
|
50 |
TSymbianPixmapTypeId CGuestEGL::EglInternalFunction_GetNativePixmapType(void*) |
|
51 |
{ |
|
52 |
return EPixmapTypeNone; // stub code |
|
53 |
} |
|
54 |
TBool CGuestEGL::EglInternalFunction_IsValidNativePixmap(void*, TSymbianPixmapTypeId) |
|
55 |
{ |
|
56 |
return EFalse; // stub code |
|
57 |
} |
|
58 |
const char * CGuestEGL::EglInternalFunction_QueryExtensionList() |
|
59 |
{ |
|
60 |
return NULL; // stub code |
|
61 |
} |
|
18
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
62 |
|
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
63 |
/** |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
64 |
Obtain extension function pointer. |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
65 |
|
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
66 |
Provide support for the Symbian Graphics SHAI for EGL Extensions |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
67 |
@param aName Name of extension |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
68 |
@return Function pointer, or NULL if not available. |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
69 |
|
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
70 |
@note Known extensions: |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
71 |
1. EGL_KHR_image |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
72 |
2. EGL_KHR_image_base |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
73 |
3. EGL_KHR_image_pixmap |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
74 |
4. EGL_KHR_vg_parent_image |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
75 |
5. EGL_KHR_gl_texture_2D_image |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
76 |
6. EGL_KHR_gl_texture_cubemap_image |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
77 |
7. EGL_KHR_lock_surface |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
78 |
8. EGL_NOK_resource_profiling2 |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
79 |
9. EGL_SYMBIAN_composition |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
80 |
10. EGL_NOK_image_endpoint |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
81 |
11. NOK_pixmap_type_rsgimage |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
82 |
12. eglSwapBuffersRegionNOK |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
83 |
|
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
84 |
@see Khronos EGL 1.4 Specification, eglGetProcAddress() |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
85 |
@author Faisal Memon Community EGL project |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
86 |
|
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
87 |
*/ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
88 |
ProcPointer CGuestEGL::eglGetProcAddress(const char* aName) |
13 | 89 |
{ |
18
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
90 |
if (strncmp("EGL_KHR_image", aName, strlen("EGL_KHR_image")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
91 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
92 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
93 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
94 |
else if (strncmp("EGL_KHR_image_base", aName, strlen("EGL_KHR_image_base")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
95 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
96 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
97 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
98 |
else if (strncmp("EGL_KHR_image_pixmap", aName, strlen("EGL_KHR_image_pixmap")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
99 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
100 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
101 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
102 |
else if (strncmp("EGL_KHR_vg_parent_image", aName, strlen("EGL_KHR_vg_parent_image")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
103 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
104 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
105 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
106 |
else if (strncmp("EGL_KHR_gl_texture_2D_image", aName, strlen("EGL_KHR_gl_texture_2D_image")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
107 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
108 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
109 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
110 |
else if (strncmp("EGL_KHR_gl_texture_cubemap_image", aName, strlen("EGL_KHR_gl_texture_cubemap_image")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
111 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
112 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
113 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
114 |
else if (strncmp("EGL_KHR_lock_surface", aName, strlen("EGL_KHR_lock_surface")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
115 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
116 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
117 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
118 |
else if (strncmp("EGL_NOK_resource_profiling2", aName, strlen("EGL_NOK_resource_profiling2")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
119 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
120 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
121 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
122 |
else if (strncmp("EGL_SYMBIAN_composition", aName, strlen("EGL_SYMBIAN_composition")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
123 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
124 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
125 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
126 |
else if (strncmp("EGL_NOK_image_endpoint", aName, strlen("EGL_NOK_image_endpoint")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
127 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
128 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
129 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
130 |
else if (strncmp("NOK_pixmap_type_rsgimage", aName, strlen("NOK_pixmap_type_rsgimage")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
131 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
132 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
133 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
134 |
else if (strncmp("eglSwapBuffersRegionNOK", aName, strlen("eglSwapBuffersRegionNOK")) == 0) |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
135 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
136 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
137 |
} |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
138 |
else |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
139 |
{ |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
140 |
return NULL; |
3064c37a6509
Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents:
17
diff
changeset
|
141 |
} |
13 | 142 |
} |
143 |
||
144 |
EGLSurface CGuestEGL::eglCreateWindowSurface(TEglThreadState&, int, int, void*, const int*) |
|
145 |
{ |
|
146 |
return 0; // stub code |
|
147 |
} |
|
148 |
const char* CGuestEGL::eglQueryString(EGLDisplay aDisplay, EGLint aName) |
|
149 |
{ |
|
150 |
return NULL; // stub code |
|
151 |
} |
|
152 |
// FAISALMEMON END OF STUB CODE |
|
153 |
||
154 |
CGuestEGL::CGuestEGL() : |
|
155 |
iEglSyncExtension(NULL) |
|
156 |
{ |
|
157 |
} |
|
158 |
||
159 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
160 |
void CGuestEGL::OpenSgResources() |
|
161 |
{ |
|
162 |
// ToDo delay opening SgDriver until needed, as it force loads Open GL ES 1.1, GL ES 2 and Open VG DLLs if it finds them |
|
163 |
TInt err = iSgDriver.Open(); |
|
164 |
EGL_TRACE(" CGuestEGL::Create SgDriver.Open err=%d", err); |
|
165 |
EGLPANIC_ASSERT(err == KErrNone, EEglPanicSgDriverCreateLocalFailed); |
|
166 |
||
167 |
TVersion sgImageVer = RSgDriver::Version(); |
|
168 |
EGL_TRACE(" CGuestEGL::Create sgImageVer=%d.%d", sgImageVer.iMajor, sgImageVer.iMinor); |
|
169 |
EGLPANIC_ASSERT(sgImageVer.iMajor == 1, EEglPanicBadSgDriverVersion); |
|
170 |
||
171 |
} |
|
172 |
void CGuestEGL::CloseSgResources() |
|
173 |
{ |
|
174 |
iSgDriver.Close(); |
|
175 |
} |
|
176 |
#else |
|
177 |
void CGuestEGL::CloseSgResources() |
|
178 |
{ |
|
179 |
} |
|
180 |
||
181 |
void CGuestEGL::OpenSgResources() |
|
182 |
{ |
|
183 |
} |
|
184 |
#endif |
|
185 |
||
186 |
// ----------------------------------------------------------------------------- |
|
187 |
// destructor |
|
188 |
// ----------------------------------------------------------------------------- |
|
189 |
// |
|
190 |
CGuestEGL::~CGuestEGL() |
|
191 |
{ |
|
192 |
EGL_TRACE("CGuestEGL::~CGuestEGL"); |
|
193 |
// only expected to be called during process termination |
|
194 |
if (iEglSyncExtension) |
|
195 |
{ |
|
196 |
delete iEglSyncExtension; |
|
197 |
iEglSyncExtension = NULL; |
|
198 |
} |
|
199 |
iDisplayMapLock.Close(); |
|
200 |
CloseSgResources(); |
|
201 |
iEglImageLock.Close(); |
|
202 |
} |
|
203 |
||
204 |
// ----------------------------------------------------------------------------- |
|
205 |
// 2nd phase constructor |
|
206 |
// ----------------------------------------------------------------------------- |
|
207 |
// |
|
208 |
void CGuestEGL::Create() |
|
209 |
{ |
|
210 |
EGL_TRACE(" CGuestEGL::Create -->"); |
|
211 |
OpenSgResources(); |
|
212 |
TInt err; |
|
213 |
err = iDisplayMapLock.CreateLocal(); |
|
214 |
EGLPANIC_ASSERT(err == KErrNone, EEglPanicDisplayMapLockCreateLocalFailed); |
|
215 |
||
216 |
err = iEglImageLock.CreateLocal(); |
|
217 |
EGLPANIC_ASSERT(err == KErrNone, EEglPanicEglImageLockCreateLocalFailed); |
|
218 |
||
219 |
InitialiseExtensions(); |
|
220 |
||
221 |
const char* initExtensionList = EglInternalFunction_QueryExtensionList(); |
|
222 |
EGL_TRACE(" CGuestEGL::Create initExtensionList=0x%x (\"%s\") <--", |
|
223 |
initExtensionList, initExtensionList ? initExtensionList : ""); |
|
224 |
} |
|
225 |
||
226 |
// ----------------------------------------------------------------------------- |
|
227 |
// |
|
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
CGuestEGL* CGuestEGL::New() |
|
231 |
{ |
|
232 |
EGL_TRACE("CGuestEGL::New start -->"); |
|
233 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
234 |
CGuestEGL* result = new CGuestEGL(); |
|
235 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
236 |
EGLPANIC_ASSERT(result, EEglPanicGuestGraphicsAllocFailed); |
|
237 |
if (result) |
|
238 |
{ |
|
239 |
result->Create(); |
|
240 |
} |
|
241 |
EGL_TRACE("CGuestEGL::New end - result=0x%x <--", result); |
|
242 |
return result; |
|
243 |
} |
|
244 |
||
245 |
// ----------------------------------------------------------------------------- |
|
246 |
// |
|
247 |
// ----------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
void CGuestEGL::SetError(EGLint aError) |
|
250 |
{ // ToDo remove - everything except EGL Sync already uses threadState->SetEglError |
|
251 |
EGL_TRACE( "CGuestEGL::SetError EGL error=0x%x", aError); |
|
252 |
TEglThreadState* threadState = CVghwUtils::EglThreadState(); |
|
253 |
if (threadState) |
|
254 |
{ |
|
255 |
threadState->SetEglError(aError); |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
EGLint CGuestEGL::CheckColorAttributes(const EGLint* aAttribList, EGLint aColorBufferType, EGLint aLuminanceBits, EGLint aRedBits, |
|
260 |
EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits) |
|
261 |
{ |
|
262 |
const EGLint* pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE); |
|
263 |
if (pValue && (*pValue != aColorBufferType)) |
|
264 |
{ |
|
265 |
return EGL_BAD_MATCH; |
|
266 |
} |
|
267 |
EGLint colorBits = 0; |
|
268 |
if (aColorBufferType == EGL_RGB_BUFFER) |
|
269 |
{ |
|
270 |
colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits; |
|
271 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE); |
|
272 |
if (pValue && (*pValue < aRedBits)) |
|
273 |
{ |
|
274 |
return EGL_BAD_MATCH; |
|
275 |
} |
|
276 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE); |
|
277 |
if (pValue && (*pValue < aGreenBits)) |
|
278 |
{ |
|
279 |
return EGL_BAD_MATCH; |
|
280 |
} |
|
281 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE); |
|
282 |
if (pValue && (*pValue < aBlueBits)) |
|
283 |
{ |
|
284 |
return EGL_BAD_MATCH; |
|
285 |
} |
|
286 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE); |
|
287 |
if (pValue && (*pValue != 0)) |
|
288 |
{ |
|
289 |
return EGL_BAD_MATCH; |
|
290 |
} |
|
291 |
} |
|
292 |
else |
|
293 |
{ // EGL_LUMINANCE_BUFFER |
|
294 |
colorBits = aLuminanceBits + aAlphaBits; |
|
295 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE); |
|
296 |
if (pValue && (*pValue != 0)) |
|
297 |
{ |
|
298 |
return EGL_BAD_MATCH; |
|
299 |
} |
|
300 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE); |
|
301 |
if (pValue && (*pValue != 0)) |
|
302 |
{ |
|
303 |
return EGL_BAD_MATCH; |
|
304 |
} |
|
305 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE); |
|
306 |
if (pValue && (*pValue != 0)) |
|
307 |
{ |
|
308 |
return EGL_BAD_MATCH; |
|
309 |
} |
|
310 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE); |
|
311 |
if (pValue && (*pValue < aLuminanceBits)) |
|
312 |
{ |
|
313 |
return EGL_BAD_MATCH; |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
if (aAlphaBits) |
|
318 |
{ |
|
319 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE); |
|
320 |
if (pValue && (*pValue < aAlphaBits)) |
|
321 |
{ |
|
322 |
return EGL_BAD_MATCH; |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE); |
|
327 |
if (pValue && (*pValue < colorBits)) |
|
328 |
{ |
|
329 |
return EGL_BAD_MATCH; |
|
330 |
} |
|
331 |
return EGL_SUCCESS; |
|
332 |
} |
|
333 |
||
334 |
void CGuestEGL::AppendColorAttributes(EGLint* aAttribList, EGLint aColorBufferType, EGLint aLuminanceBits, EGLint aRedBits, |
|
335 |
EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits, TBool aSetVgPreMultAlpha) |
|
336 |
{ |
|
337 |
const EGLint* pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE); |
|
338 |
if (!pValue) |
|
339 |
{ |
|
340 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE, aColorBufferType); |
|
341 |
} |
|
342 |
||
343 |
EGLint colorBits = 0; |
|
344 |
if (aColorBufferType == EGL_RGB_BUFFER) |
|
345 |
{ |
|
346 |
colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits; |
|
347 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE); |
|
348 |
if (!pValue) |
|
349 |
{ |
|
350 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_RED_SIZE, aRedBits); |
|
351 |
} |
|
352 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE); |
|
353 |
if (!pValue) |
|
354 |
{ |
|
355 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_GREEN_SIZE, aGreenBits); |
|
356 |
} |
|
357 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE); |
|
358 |
if (!pValue) |
|
359 |
{ |
|
360 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_BLUE_SIZE, aBlueBits); |
|
361 |
} |
|
362 |
} |
|
363 |
else |
|
364 |
{ // EGL_LUMINANCE_BUFFER |
|
365 |
colorBits = aLuminanceBits + aAlphaBits; |
|
366 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE); |
|
367 |
if (!pValue) |
|
368 |
{ |
|
369 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_LUMINANCE_SIZE, aLuminanceBits); |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE); |
|
374 |
if (!pValue) |
|
375 |
{ |
|
376 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_BUFFER_SIZE, colorBits); |
|
377 |
} |
|
378 |
||
379 |
if (aAlphaBits) |
|
380 |
{ |
|
381 |
pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE); |
|
382 |
if (!pValue) |
|
383 |
{ |
|
384 |
TAttribUtils::AppendAttribValue(aAttribList, EGL_ALPHA_SIZE, aAlphaBits); |
|
385 |
} |
|
386 |
} |
|
387 |
if (aSetVgPreMultAlpha) |
|
388 |
{ |
|
389 |
EGLint* pSurfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE); |
|
390 |
if (pSurfaceType) |
|
391 |
{ |
|
392 |
*pSurfaceType |= EGL_VG_ALPHA_FORMAT_PRE_BIT; |
|
393 |
} |
|
394 |
} |
|
395 |
} |
|
396 |
||
397 |
EGLBoolean CGuestEGL::ChooseConfigForPixmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint* aAttribList, EGLConfig* aConfigs, EGLint aConfigSize, |
|
398 |
EGLint* aNumConfig, const void* aPixmap) |
|
399 |
{ |
|
400 |
EGLint error = EGL_SUCCESS; |
|
401 |
EGLint* newList = NULL; |
|
402 |
||
403 |
switch ( EglInternalFunction_GetNativePixmapType((EGLNativePixmapType) (aPixmap)) ) |
|
404 |
{ |
|
405 |
case EPixmapTypeFbsBitmap: |
|
406 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.a pixmap type is FbsBitmap (aPixmap=0x%x)", aPixmap); |
|
407 |
error = ChooseConfigAttribsForFbsBitmap(aThreadState, aAttribList, reinterpret_cast<const CFbsBitmap*>(aPixmap), &newList); |
|
408 |
break; |
|
409 |
||
410 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
411 |
case EPixmapTypeSgImage: |
|
412 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.b pixmap type is SgImage (aPixmap=0x%x)", aPixmap); |
|
413 |
error = ChooseConfigAttribsForSgImage(aThreadState, aAttribList, reinterpret_cast<const RSgImage*>(aPixmap), &newList); |
|
414 |
break; |
|
415 |
#endif |
|
416 |
||
417 |
case EPixmapTypeNone: |
|
418 |
default: |
|
419 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.c pixmap type is unknown (aPixmap=0x%x)", aPixmap); |
|
420 |
error = EGL_BAD_NATIVE_PIXMAP; |
|
421 |
break; |
|
422 |
} |
|
423 |
||
424 |
if (error != EGL_SUCCESS) |
|
425 |
{ |
|
426 |
aThreadState.SetEglError(error); |
|
427 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 2.a encountered error=0x%x", error); |
|
428 |
if (newList) |
|
429 |
{ |
|
430 |
CVghwUtils::Free(newList); |
|
431 |
} |
|
432 |
return EGL_FALSE; |
|
433 |
} |
|
434 |
||
435 |
EGLPANIC_ASSERT(newList, EEglPanicTemp); |
|
436 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 2.b temp AttribList ... (*newList=0x%x)", *newList); |
|
437 |
EGL_TRACE_ATTRIB_LIST(newList); |
|
438 |
||
439 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
440 |
eglApiData.Init( EglRFC::EeglChooseConfig ); |
|
441 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
442 |
eglApiData.AppendEGLintVector(newList, TAttribUtils::AttribListLength(newList) ); |
|
443 |
eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut); |
|
444 |
eglApiData.AppendEGLint(aConfigSize); |
|
445 |
eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut); |
|
446 |
EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
447 |
EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 3. Host EGL success=%d", result); |
|
448 |
||
449 |
CVghwUtils::Free(newList); |
|
450 |
return result; |
|
451 |
} |
|
452 |
||
453 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
454 |
EGLBoolean CGuestEGL::ChooseConfigForNativeSgImagePixmapSurface( TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint* aAttribList, EGLConfig* aConfigs, EGLint aConfigSize, |
|
455 |
EGLint* aNumConfig, const EGLint* aPixmap ) |
|
456 |
{ |
|
457 |
EGLConfig* sgConfigs; |
|
458 |
EGLint sgConfigCnt; |
|
459 |
TBool* sgConfigsMatchingAttributes; |
|
460 |
TInt sgConfigsMatchingAttributesCnt=0; |
|
461 |
EGLint* sgConfigAttribs; |
|
462 |
EGLint sgConfigsAttribtCnt; |
|
463 |
EGL_TRACE( "CGuestEGL::eglChooseConfig: ChooseConfigForNativePixmapSurface" ); |
|
464 |
EglInternalFunction_MetaGetConfigs( aThreadState, sgConfigs, sgConfigCnt, sgConfigAttribs, sgConfigsAttribtCnt ); |
|
465 |
EGL_TRACE( "EglInternalFunction_MetaGetConfigAttirb cnt = %d ", sgConfigsAttribtCnt ); |
|
466 |
||
467 |
sgConfigsMatchingAttributes = new TBool[sgConfigCnt]; |
|
468 |
||
469 |
TInt attribs_per_config = EglRFC::MetaGetConfigAttributeCnt(); |
|
470 |
TInt configcnt = (TInt) sgConfigsAttribtCnt / attribs_per_config; |
|
471 |
EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", configcnt ); |
|
472 |
||
473 |
//The attribute values of aAttribList, in the order of MetaGetConfigAttribute(i) |
|
474 |
EGLint* specAttribVals = new EGLint[ attribs_per_config ]; |
|
475 |
for( TInt i=0;i<attribs_per_config;++i ) |
|
476 |
{ |
|
477 |
*( specAttribVals + i ) = -1; |
|
478 |
} |
|
479 |
int spec_attrib_kind; |
|
480 |
int i_spec_attrib = 0; |
|
481 |
//Go through all the given attributes |
|
482 |
while( (spec_attrib_kind = *(aAttribList + i_spec_attrib )) != EGL_NONE ) |
|
483 |
{ |
|
484 |
//Check which type of attribute is specified, then set the value if types match |
|
485 |
for( TInt i=0;i<attribs_per_config;++i ) |
|
486 |
{ |
|
487 |
if( spec_attrib_kind == EglRFC::MetaGetConfigAttribute( i ) ) |
|
488 |
*(specAttribVals + i) = *( aAttribList + i_spec_attrib ); |
|
489 |
} |
|
490 |
i_spec_attrib += 2; |
|
491 |
} |
|
492 |
||
493 |
//Go through the configurations |
|
494 |
for( TInt i_config = 0;i_config < configcnt; ++i_config ) |
|
495 |
{ |
|
496 |
TBool pass = ETrue;//true, unless we bump into an attribute that doesn't match |
|
497 |
//Go throught the attributes of this configuration |
|
498 |
for( TInt i_attr = 0; i_attr < attribs_per_config; ++i_attr ) |
|
499 |
{ |
|
500 |
EGL_TRACE( "cnf %d, attr %d = %d ", i_config, i_attr, *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) ); |
|
501 |
//Match attribute values here, if the client-specified attribute value isn't empty |
|
502 |
if( *( specAttribVals + i_attr ) != -1 ) |
|
503 |
{ |
|
504 |
switch( EglRFC::MetaGetConfigAttributeSelCriteria( i_attr ) ) |
|
505 |
{ |
|
506 |
case EExact: |
|
507 |
{ |
|
508 |
if( *( specAttribVals + i_attr ) != *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) ) |
|
509 |
{ |
|
510 |
pass = EFalse; |
|
511 |
} |
|
512 |
break; |
|
513 |
} |
|
514 |
case EAtLeast: |
|
515 |
{ |
|
516 |
if( *( specAttribVals + i_attr ) > *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) ) |
|
517 |
{ |
|
518 |
pass = EFalse; |
|
519 |
} |
|
520 |
break; |
|
521 |
} |
|
522 |
case EMask: |
|
523 |
{ |
|
524 |
if( !(*( specAttribVals + i_attr ) & *( sgConfigAttribs + i_config*attribs_per_config + i_attr )) ) |
|
525 |
{ |
|
526 |
pass = EFalse; |
|
527 |
} |
|
528 |
break; |
|
529 |
} |
|
530 |
}//switch comparison method |
|
531 |
||
532 |
}//if attribute value specified by client |
|
533 |
}//for through the attributes of a configuration |
|
534 |
if( pass ) |
|
535 |
{ |
|
536 |
*(sgConfigsMatchingAttributes + i_config) = ETrue; |
|
537 |
} |
|
538 |
else |
|
539 |
{ |
|
540 |
*(sgConfigsMatchingAttributes + i_config) = EFalse; |
|
541 |
} |
|
542 |
}//end for through the configurations |
|
543 |
||
544 |
//Now get the configs that match, and return those |
|
545 |
TInt aConfigsIndex = 0; |
|
546 |
for( TInt i_config = 0;i_config < configcnt; ++i_config ) |
|
547 |
{ |
|
548 |
if( *(sgConfigsMatchingAttributes + i_config) ) |
|
549 |
{ |
|
550 |
if( aConfigsIndex < aConfigSize ) |
|
551 |
{ |
|
552 |
*(aConfigs + (aConfigsIndex++)) = *(sgConfigs + i_config); |
|
553 |
++sgConfigsMatchingAttributesCnt; |
|
554 |
} |
|
555 |
} |
|
556 |
} |
|
557 |
//Ok, all done. Delete allocated memory |
|
558 |
// ToDo use correct Heap! |
|
559 |
delete[] sgConfigs; |
|
560 |
delete[] sgConfigsMatchingAttributes; |
|
561 |
delete[] sgConfigAttribs; |
|
562 |
delete[] specAttribVals; |
|
563 |
return EGL_TRUE; |
|
564 |
} |
|
565 |
#endif |
|
566 |
||
567 |
EGLint CGuestEGL::ChooseConfigAttribsForFbsBitmap(TEglThreadState& aThreadState, const EGLint* aAttribList, const CFbsBitmap* aBitmap, EGLint** aNewList) |
|
568 |
{ |
|
569 |
EGLPANIC_ASSERT_DEBUG(aNewList, EEglPanicTemp); |
|
570 |
EGLint error = EGL_SUCCESS; |
|
571 |
const TInt listLength = TAttribUtils::AttribListLength(aAttribList); |
|
572 |
ASSERT(listLength); |
|
573 |
TDisplayMode mode = ENone; |
|
574 |
const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE); |
|
575 |
||
576 |
mode = aBitmap->DisplayMode(); |
|
577 |
EGL_TRACE("CGuestEGL::ChooseConfigAttribsForFbsBitmap bitmap addr=0x%x, Display Mode=%d", aBitmap, mode); |
|
578 |
switch (mode) |
|
579 |
{ |
|
580 |
case EColor64K: |
|
581 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 5, 6, 5); |
|
582 |
break; |
|
583 |
case EColor16M: |
|
584 |
case EColor16MU: |
|
585 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8); |
|
586 |
break; |
|
587 |
case EColor16MA: |
|
588 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
589 |
break; |
|
590 |
case EColor16MAP: |
|
591 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
592 |
break; |
|
593 |
default: // pixmap not supported |
|
594 |
error = EGL_BAD_NATIVE_PIXMAP; |
|
595 |
break; |
|
596 |
} |
|
597 |
||
598 |
if (error != EGL_SUCCESS) |
|
599 |
{ |
|
600 |
return error; |
|
601 |
} |
|
602 |
||
603 |
const TInt KExpansionSpace = 10 * 2; // want enough space for 10 extra attribute/value pairs |
|
604 |
*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) ); |
|
605 |
if (!*aNewList) |
|
606 |
{ |
|
607 |
return EGL_BAD_ALLOC; |
|
608 |
} |
|
609 |
memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint)); |
|
610 |
||
611 |
switch (mode) |
|
612 |
{ |
|
613 |
case EColor64K: |
|
614 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5); |
|
615 |
break; |
|
616 |
case EColor16M: |
|
617 |
case EColor16MU: |
|
618 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8); |
|
619 |
break; |
|
620 |
case EColor16MA: |
|
621 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
622 |
break; |
|
623 |
case EColor16MAP: |
|
624 |
if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) ) |
|
625 |
{ |
|
626 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8, ETrue); |
|
627 |
} |
|
628 |
else |
|
629 |
{ |
|
630 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
631 |
} |
|
632 |
break; |
|
633 |
default: |
|
634 |
EGLPANIC_ALWAYS(EEglPanicTemp); |
|
635 |
} |
|
636 |
||
637 |
return EGL_SUCCESS; |
|
638 |
} |
|
639 |
||
640 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
641 |
EGLint CGuestEGL::ChooseConfigAttribsForSgImage(TEglThreadState& aThreadState, const EGLint* aAttribList, const RSgImage* aSgImage, EGLint** aNewList) |
|
642 |
{ |
|
643 |
ASSERT(aNewList); |
|
644 |
EGLint error = EGL_SUCCESS; |
|
645 |
const TInt listLength = TAttribUtils::AttribListLength(aAttribList); |
|
646 |
ASSERT(listLength); |
|
647 |
const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE); |
|
648 |
||
649 |
/* |
|
650 |
if (!iSgConfigAttribs) |
|
651 |
{ |
|
652 |
EGL_TRACE( "CGuestEGL::ChooseConfigAttribsForSgImage 1. EglInternalFunction_MetaGetConfigs" ); |
|
653 |
EGLConfig* config; |
|
654 |
EGLint config_cnt; |
|
655 |
EglInternalFunction_MetaGetConfigs(aThreadState, config, config_cnt, iSgConfigAttribs, iSgConfigsAttribtCnt); |
|
656 |
EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", iSgConfigsAttribtCnt ); |
|
657 |
} |
|
658 |
if (!iSgConfigAttribs) |
|
659 |
{ // exit if EglInternalFunction_MetaGetConfigs still failed |
|
660 |
return EGL_BAD_ALLOC; |
|
661 |
} |
|
662 |
*/ |
|
663 |
// ToDo use iSgConfigAttribs |
|
664 |
||
665 |
// temporarily open a handle to the SgImage |
|
666 |
TSgDrawableId sgId = aSgImage->Id(); |
|
667 |
RSgDrawable sgHandle; |
|
668 |
TSgImageInfo imgInfo; |
|
669 |
EGL_TRACE("CGuestEGL::ChooseConfigAttribsForSgImage 1. SgImage Id=0x%lx", sgId); |
|
670 |
||
671 |
// ToDo check SgImage usage bits |
|
672 |
if ( (sgId != KSgNullDrawableId) && (KErrNone == sgHandle.Open(sgId)) && (KErrNone == aSgImage->GetInfo(imgInfo)) ) |
|
673 |
{ |
|
674 |
EGL_TRACE("CGuestEGL::ChooseConfigAttribsForSgImage 2. SgImage PixelFormat=0x%x; size=%d,%d; Usage=0x%x", |
|
675 |
imgInfo.iPixelFormat, imgInfo.iSizeInPixels.iWidth, imgInfo.iSizeInPixels.iHeight, imgInfo.iUsage); |
|
676 |
||
677 |
switch (imgInfo.iPixelFormat) |
|
678 |
{ |
|
679 |
case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE |
|
680 |
case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888, |
|
681 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
682 |
break; |
|
683 |
case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888, |
|
684 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8); |
|
685 |
break; |
|
686 |
case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565, |
|
687 |
error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 5, 6, 5); |
|
688 |
break; |
|
689 |
case ESgPixelFormatA_8: // == EUidPixelFormatA_8 |
|
690 |
error = CheckColorAttributes(aAttribList, EGL_LUMINANCE_BUFFER, 8, 0, 0, 0); |
|
691 |
break; |
|
692 |
default: // pixmap not supported |
|
693 |
error = EGL_BAD_NATIVE_PIXMAP; |
|
694 |
break; |
|
695 |
} |
|
696 |
} |
|
697 |
else |
|
698 |
{ |
|
699 |
error = EGL_BAD_PARAMETER; |
|
700 |
} |
|
701 |
sgHandle.Close(); |
|
702 |
||
703 |
||
704 |
if (error != EGL_SUCCESS) |
|
705 |
{ |
|
706 |
return error; |
|
707 |
} |
|
708 |
||
709 |
const TInt KExpansionSpace = 10 * 2; // want enough space for 10 extra attribute/value pairs |
|
710 |
*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) ); |
|
711 |
if (!*aNewList) |
|
712 |
{ |
|
713 |
return EGL_BAD_ALLOC; |
|
714 |
} |
|
715 |
memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint)); |
|
716 |
||
717 |
switch (imgInfo.iPixelFormat) |
|
718 |
{ |
|
719 |
case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE |
|
720 |
if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) ) |
|
721 |
{ |
|
722 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8, ETrue); |
|
723 |
} |
|
724 |
else |
|
725 |
{ |
|
726 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
727 |
} |
|
728 |
break; |
|
729 |
case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888, |
|
730 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8); |
|
731 |
break; |
|
732 |
case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888, |
|
733 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8); |
|
734 |
break; |
|
735 |
case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565, |
|
736 |
AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5); |
|
737 |
break; |
|
738 |
case ESgPixelFormatA_8: // == EUidPixelFormatA_8 |
|
739 |
AppendColorAttributes(*aNewList, EGL_LUMINANCE_BUFFER, 8, 0, 0, 0); |
|
740 |
break; |
|
741 |
default: // pixmap not supported - panic because this code should be in-sync with supported SgImage formats |
|
742 |
EGLPANIC_ALWAYS(EEglPanicTemp); |
|
743 |
break; |
|
744 |
} |
|
745 |
||
746 |
// change requested surface type from pixmap to Pbuffer |
|
747 |
EGLint* pSurfaceType = TAttribUtils::FindAttribValue(*aNewList, EGL_SURFACE_TYPE); |
|
748 |
EGLint surfaceType = *pSurfaceType; |
|
749 |
*pSurfaceType = EGL_PBUFFER_BIT | (surfaceType & ~EGL_PIXMAP_BIT); |
|
750 |
||
751 |
TAttribUtils::RemoveAttrib(*aNewList, EGL_MATCH_NATIVE_PIXMAP); |
|
752 |
return EGL_SUCCESS; |
|
753 |
} |
|
754 |
#endif |
|
755 |
||
756 |
/* |
|
757 |
Create an information object for an opened Display. |
|
758 |
*/ |
|
759 |
TBool CGuestEGL::CreateDisplayInfo(EGLDisplay aDisplay) |
|
760 |
{ |
|
761 |
TBool result = EFalse; |
|
762 |
EGL_TRACE("CGuestEGL::CreateDisplayInfo begin aDisplay=%d", aDisplay); |
|
763 |
iDisplayMapLock.WriteLock(); |
|
764 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
765 |
if (NULL != iDisplayMap.Find( aDisplay)) |
|
766 |
{ |
|
767 |
result = ETrue; |
|
768 |
} |
|
769 |
else |
|
770 |
{ |
|
771 |
TInt err = KErrNoMemory; |
|
772 |
CEglDisplayInfo* dispInfo = new CEglDisplayInfo; |
|
773 |
||
774 |
if (dispInfo) |
|
775 |
{ |
|
776 |
err = iDisplayMap.Insert(aDisplay, dispInfo); |
|
777 |
// EGL_TRACE("CreateDisplayInfo - DisplayMap insert error %d", err); |
|
778 |
EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicDisplayMapInsertFailed); |
|
779 |
||
780 |
//added for egl sync extension benefit |
|
781 |
if (iEglSyncExtension) |
|
782 |
{ |
|
783 |
err = iEglSyncExtension->EglSyncDisplayCreate(aDisplay); |
|
784 |
// EGL_TRACE("CreateDisplayInfo - EglSyncDisplayCreate error %d", err); |
|
785 |
EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicEglSyncDisplayCreateFailed); |
|
786 |
||
787 |
if (err) |
|
788 |
{ |
|
789 |
iDisplayMap.Remove(aDisplay); |
|
790 |
} |
|
791 |
} |
|
792 |
} |
|
793 |
||
794 |
if (err == KErrNone) |
|
795 |
{ |
|
796 |
result = ETrue; |
|
797 |
} |
|
798 |
} |
|
799 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
800 |
iDisplayMapLock.Unlock(); |
|
801 |
||
802 |
EGL_TRACE("CreateDisplayInfo end, result=%d", result); |
|
803 |
return result; |
|
804 |
} |
|
805 |
||
806 |
/* |
|
807 |
Mark information object for Display as Initialised |
|
808 |
*/ |
|
809 |
TBool CGuestEGL::InitializeDisplayInfo(EGLDisplay aDisplay) |
|
810 |
{ |
|
811 |
TBool result = EFalse; |
|
812 |
EGL_TRACE("CGuestEGL::InitialiseDisplayInfo begin aDisplay=%d", aDisplay); |
|
813 |
iDisplayMapLock.WriteLock(); |
|
814 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
815 |
if (pDispInfo && *pDispInfo) |
|
816 |
{ |
|
817 |
(*pDispInfo)->iInitialized = ETrue; |
|
818 |
result = ETrue; |
|
819 |
} |
|
820 |
iDisplayMapLock.Unlock(); |
|
821 |
||
822 |
EGL_TRACE("InitialiseDisplayInfo end, result=%d", result); |
|
823 |
return result; |
|
824 |
} |
|
825 |
||
826 |
/* |
|
827 |
Check whether Display exists and is Initialised |
|
828 |
*/ |
|
829 |
TBool CGuestEGL::IsDisplayInitialized(EGLDisplay aDisplay) |
|
830 |
{ |
|
831 |
TBool result = EFalse; |
|
832 |
EGL_TRACE("CGuestEGL::IsDisplayInitialized begin aDisplay=%d", aDisplay); |
|
833 |
iDisplayMapLock.ReadLock(); |
|
834 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
835 |
if ( pDispInfo && *pDispInfo && (*pDispInfo)->iInitialized) |
|
836 |
{ |
|
837 |
result = ETrue; |
|
838 |
} |
|
839 |
iDisplayMapLock.Unlock(); |
|
840 |
||
841 |
EGL_TRACE("IsDisplayInitialized end, result=%d", result); |
|
842 |
return result; |
|
843 |
} |
|
844 |
||
845 |
EGLBoolean CGuestEGL::eglSwapBuffers(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface) |
|
846 |
{ |
|
847 |
EglInternalFunction_SwapWindowSurface(aThreadState, aDisplay, aSurface); |
|
848 |
||
849 |
// ToDo when all surfaces are recorded in client validate BEFORE sending cmd to host |
|
850 |
TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface( aDisplay, aSurface ); |
|
851 |
EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE, EGL_FALSE ); |
|
852 |
||
853 |
//Check if surface size has changed |
|
854 |
TSize size = surfaceInfo->iNativeWindow->Size(); |
|
855 |
||
856 |
if (size != surfaceInfo->iSize) |
|
857 |
{ |
|
858 |
EGL_TRACE("CGuestEGL::eglSwapBuffers Surface Resized size=%d,%d, surfaceInfo->iSize=%d,%d", |
|
859 |
size.iHeight, size.iWidth, surfaceInfo->iSize.iHeight, surfaceInfo->iSize.iWidth); |
|
860 |
return EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo, aDisplay, aSurface); |
|
861 |
} |
|
862 |
return EGL_TRUE; |
|
863 |
} |
|
864 |
||
865 |
EGLBoolean CGuestEGL::eglMakeCurrent(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aDraw, EGLSurface aRead, EGLContext aContext) |
|
866 |
{ |
|
867 |
if (aContext == EGL_NO_CONTEXT) |
|
868 |
{ |
|
869 |
if ( (aDraw != EGL_NO_SURFACE) || (aRead != EGL_NO_SURFACE) ) |
|
870 |
{ |
|
871 |
aThreadState.SetEglError(EGL_BAD_SURFACE); |
|
872 |
return EGL_FALSE; |
|
873 |
} |
|
874 |
EGL_TRACE("CGuestEGL::eglMakeCurrent call host"); |
|
875 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
876 |
eglApiData.Init( EglRFC::EeglMakeCurrent ); |
|
877 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
878 |
eglApiData.AppendEGLSurface(EGL_NO_SURFACE); |
|
879 |
eglApiData.AppendEGLSurface(EGL_NO_SURFACE); |
|
880 |
eglApiData.AppendEGLContext(EGL_NO_CONTEXT); |
|
881 |
||
882 |
EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
883 |
EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret); |
|
884 |
return (EGLBoolean)ret; |
|
885 |
} |
|
886 |
else |
|
887 |
{ |
|
888 |
if ( (aDraw == EGL_NO_SURFACE) || (aRead == EGL_NO_SURFACE) ) |
|
889 |
{ |
|
890 |
aThreadState.SetEglError(EGL_BAD_SURFACE); |
|
891 |
return EGL_FALSE; |
|
892 |
} |
|
893 |
// ToDo use new CEglContext code |
|
894 |
const TInt KMaxSurfaces( 2 ); |
|
895 |
EGLSurface surfaces[KMaxSurfaces]; |
|
896 |
TSurfaceInfo* surfaceInfo[KMaxSurfaces] = {NULL, NULL}; |
|
897 |
surfaces[0] = aDraw; |
|
898 |
if (aDraw != aRead) |
|
899 |
{ |
|
900 |
surfaces[1] = aRead; |
|
901 |
} |
|
902 |
else |
|
903 |
{ |
|
904 |
surfaces[1] = EGL_NO_SURFACE; |
|
905 |
} |
|
906 |
||
907 |
for ( TInt i = 0; i < KMaxSurfaces; i++ ) |
|
908 |
{ |
|
909 |
if ( EGL_NO_SURFACE != surfaces[i] ) |
|
910 |
{ |
|
911 |
EGL_TRACE("CGuestEGL::eglMakeCurrent check surface %d", surfaces[i] ); |
|
912 |
surfaceInfo[i] = EglInternalFunction_GetPlatformSurface( aDisplay, surfaces[i] ); |
|
913 |
//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE ); |
|
914 |
if ( surfaceInfo[i] ) |
|
915 |
{ |
|
916 |
TSize newSize; |
|
917 |
switch (surfaceInfo[i]->iSurfaceType) |
|
918 |
{ |
|
919 |
case ESurfaceTypePixmapFbsBitmap: |
|
920 |
EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iFbsBitmap, EEglPanicTemp); |
|
921 |
newSize = surfaceInfo[i]->iFbsBitmap->SizeInPixels(); |
|
922 |
break; |
|
923 |
case ESurfaceTypeWindow: |
|
924 |
EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iNativeWindow, EEglPanicTemp); |
|
925 |
newSize = surfaceInfo[i]->iNativeWindow->Size(); |
|
926 |
break; |
|
927 |
default: |
|
928 |
// size cannot change for other surface types |
|
929 |
newSize = surfaceInfo[i]->iSize; |
|
930 |
break; |
|
931 |
} |
|
932 |
if (newSize != surfaceInfo[i]->iSize) |
|
933 |
{ |
|
934 |
EGL_TRACE("CGuestEGL::eglMakeCurrent resize surface"); |
|
935 |
if ( !EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo[i], aDisplay, surfaces[i] ) ) |
|
936 |
{ |
|
937 |
return EGL_FALSE; |
|
938 |
} |
|
939 |
surfaceInfo[i]->iSize = newSize; |
|
940 |
} |
|
941 |
} |
|
942 |
} |
|
943 |
} |
|
944 |
||
945 |
// adapt to only some surfaces having CEglSurfaceInfo objects so far |
|
946 |
EGLSurface drawId = surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : aDraw; |
|
947 |
EGLSurface readId = aRead; |
|
948 |
if ((aRead == aDraw) && surfaceInfo[0]) |
|
949 |
{ |
|
950 |
readId = surfaceInfo[0]->iHostSurfaceId; |
|
951 |
} |
|
952 |
else if (surfaceInfo[1]) |
|
953 |
{ |
|
954 |
readId = surfaceInfo[1]->iHostSurfaceId; |
|
955 |
} |
|
956 |
||
957 |
EGL_TRACE(" eglMakeCurrent surfaces[0]=0x%x, surfaces[1]=0x%x", surfaces[0], surfaces[1]); |
|
958 |
EGL_TRACE(" eglMakeCurrent surfacesInfo[0]=0x%x, surfacesInfo[0].iHostSurfaceId=0x%x", |
|
959 |
surfaceInfo[0], surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : NULL); |
|
960 |
EGL_TRACE(" eglMakeCurrent surfacesInfo[1]=0x%x, surfacesInfo[1].iHostSurfaceId=0x%x", |
|
961 |
surfaceInfo[1], surfaceInfo[1] ? surfaceInfo[1]->iHostSurfaceId : NULL); |
|
962 |
||
963 |
EGL_TRACE("CGuestEGL::eglMakeCurrent call host"); |
|
964 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
965 |
eglApiData.Init( EglRFC::EeglMakeCurrent ); |
|
966 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
967 |
||
968 |
EGL_TRACE(" eglApiData.AppendEGLSurface(drawId = 0x%x)", drawId); |
|
969 |
eglApiData.AppendEGLSurface(drawId); |
|
970 |
EGL_TRACE(" eglApiData.AppendEGLSurface(readId = 0x%x);", readId); |
|
971 |
eglApiData.AppendEGLSurface(readId); |
|
972 |
||
973 |
eglApiData.AppendEGLContext(aContext); |
|
974 |
EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
975 |
EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret); |
|
976 |
return (EGLBoolean)ret; |
|
977 |
} |
|
978 |
} |
|
979 |
||
980 |
// FAISALMEMON HOLE 0.1 |
|
981 |
||
982 |
||
983 |
// ----------------------------------------------------------------------------- |
|
984 |
// |
|
985 |
// ----------------------------------------------------------------------------- |
|
986 |
// |
|
987 |
TBool CGuestEGL::EglInternalFunction_CreateSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, RWindow* aNativeWindow, |
|
988 |
TSurfaceInfo& aSurfaceInfo) |
|
989 |
{ |
|
990 |
RSurfaceManager::TSurfaceCreationAttributesBuf attributes; |
|
991 |
RSurfaceManager::TInfoBuf info; |
|
992 |
||
993 |
aSurfaceInfo.iNativeWindow = aNativeWindow; |
|
994 |
aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow; |
|
995 |
aSurfaceInfo.iSize = aNativeWindow->Size(); |
|
996 |
aSurfaceInfo.iConfigId = aConfig; |
|
997 |
aSurfaceInfo.iHostSurfaceId = aSurface; |
|
998 |
||
999 |
// ToDo have function variants that do not validate parameters |
|
1000 |
eglQuerySurface(aThreadState, aDisplay, aSurface, EGL_VG_ALPHA_FORMAT, &aSurfaceInfo.iAlphaFormat); |
|
1001 |
eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &aSurfaceInfo.iColorBits); |
|
1002 |
eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &aSurfaceInfo.iRedBits); |
|
1003 |
eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &aSurfaceInfo.iGreenBits); |
|
1004 |
eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &aSurfaceInfo.iBlueBits); |
|
1005 |
eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &aSurfaceInfo.iAlphaBits); |
|
1006 |
||
1007 |
/* |
|
1008 |
TInt err = LastError(); |
|
1009 |
EGL_CHECK_ERROR( EGL_SUCCESS == err, err, EGL_FALSE ); |
|
1010 |
*/ |
|
1011 |
EGL_TRACE(" Win surface details: width=%d height=%d colorbits=%d red=%d green=%d blue=%d alpha=%d alphaformat=0x%x", |
|
1012 |
aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight, aSurfaceInfo.iColorBits, aSurfaceInfo.iRedBits, |
|
1013 |
aSurfaceInfo.iGreenBits, aSurfaceInfo.iBlueBits, aSurfaceInfo.iAlphaBits, aSurfaceInfo.iAlphaFormat); |
|
1014 |
||
1015 |
TSize size; |
|
1016 |
||
1017 |
// FAISALMEMON HOLE 1 |
|
1018 |
||
1019 |
// FAISALMEMON STUB CODE |
|
1020 |
TUint8 offsetToFirstBuffer = 0; // This is wrong; just stub code |
|
1021 |
TUint8 offsetToSecondBuffer = 0; // This is wrong; just stub code |
|
1022 |
// FAISALMEMON END OF STUB CODE |
|
1023 |
||
1024 |
TUint32 chunkHWBase = 0; |
|
1025 |
(void)CVghwUtils::MapToHWAddress(aSurfaceInfo.iChunk->Handle(), chunkHWBase); |
|
1026 |
// FAISALMEMON write code to handle errors in the above function |
|
1027 |
EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface AFTER VGHWUtils::MapToHWAddress"); |
|
1028 |
||
1029 |
/* Store the pointer to the pixel data */ |
|
1030 |
aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk->Base() + offsetToFirstBuffer; |
|
1031 |
aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk->Base() + offsetToSecondBuffer; |
|
1032 |
||
1033 |
aSurfaceInfo.iBuffer0Index = (chunkHWBase + offsetToFirstBuffer) - VVI_FRAMEBUFFER_BASE_ADDRESS; |
|
1034 |
aSurfaceInfo.iBuffer1Index = (chunkHWBase + offsetToSecondBuffer) - VVI_FRAMEBUFFER_BASE_ADDRESS; |
|
1035 |
EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface %u %x %x %x %x",chunkHWBase, offsetToFirstBuffer, offsetToSecondBuffer, |
|
1036 |
aSurfaceInfo.iBuffer0Index, |
|
1037 |
aSurfaceInfo.iBuffer1Index); |
|
1038 |
||
1039 |
if ( !EglInternalFunction_CallSetSurfaceParams(aThreadState, aDisplay, aSurface, aSurfaceInfo) ) |
|
1040 |
{ |
|
1041 |
EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end failure"); |
|
1042 |
||
1043 |
return EGL_FALSE; |
|
1044 |
} |
|
1045 |
EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end success"); |
|
1046 |
||
1047 |
return EGL_TRUE; |
|
1048 |
} |
|
1049 |
||
1050 |
// ----------------------------------------------------------------------------- |
|
1051 |
// |
|
1052 |
// ----------------------------------------------------------------------------- |
|
1053 |
// |
|
1054 |
EGLBoolean CGuestEGL::eglDestroySurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface) |
|
1055 |
{ |
|
1056 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1057 |
EGLBoolean result = EGL_FALSE; |
|
1058 |
||
1059 |
// do not destroy SgImage surfaces on the Host! |
|
1060 |
TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface(aDisplay, aSurface); |
|
1061 |
if (!surfaceInfo) |
|
1062 |
{ // Note: Pbuffer surfaces are not currently recorded in client |
|
1063 |
eglApiData.Init( EglRFC::EeglDestroySurface ); |
|
1064 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1065 |
eglApiData.AppendEGLSurface(aSurface); |
|
1066 |
result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1067 |
} |
|
1068 |
else |
|
1069 |
{ |
|
1070 |
if (surfaceInfo->iSurfaceType != ESurfaceTypePixmapSgImage) |
|
1071 |
{ // destroy surface allocated by Host EGL |
|
1072 |
eglApiData.Init( EglRFC::EeglDestroySurface ); |
|
1073 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1074 |
eglApiData.AppendEGLSurface(surfaceInfo->iHostSurfaceId); |
|
1075 |
result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1076 |
} |
|
1077 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
1078 |
else |
|
1079 |
{ // release SgImage handle |
|
1080 |
surfaceInfo->iSgHandle.Close(); |
|
1081 |
} |
|
1082 |
#endif |
|
1083 |
||
1084 |
DestroySurfaceInfo(aDisplay, aSurface); |
|
1085 |
} |
|
1086 |
||
1087 |
return result; |
|
1088 |
} |
|
1089 |
// ----------------------------------------------------------------------------- |
|
1090 |
// |
|
1091 |
// ----------------------------------------------------------------------------- |
|
1092 |
// |
|
1093 |
void CGuestEGL::DestroySurfaceInfo(EGLDisplay aDisplay, EGLSurface aSurface) |
|
1094 |
{ |
|
1095 |
EGL_TRACE("DestroySurfaceInfo begin"); |
|
1096 |
||
1097 |
iDisplayMapLock.ReadLock(); |
|
1098 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
1099 |
if (!pDispInfo || !*pDispInfo) |
|
1100 |
{ |
|
1101 |
EGL_TRACE("cannot find display %d", aDisplay); |
|
1102 |
} |
|
1103 |
else |
|
1104 |
{ |
|
1105 |
TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find(aSurface); |
|
1106 |
if (!pSurfaceInfo) |
|
1107 |
{ |
|
1108 |
EGL_TRACE("cannot find surface %d for display %d", aSurface, aDisplay); |
|
1109 |
} |
|
1110 |
else |
|
1111 |
{ |
|
1112 |
TSurfaceInfo* surfaceInfo = *pSurfaceInfo; |
|
1113 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
1114 |
if (surfaceInfo->iNativeWindow) |
|
1115 |
{ |
|
1116 |
EglInternalFunction_DestroyWindowSurface(*surfaceInfo); |
|
1117 |
} |
|
1118 |
delete surfaceInfo; |
|
1119 |
(*pDispInfo)->iSurfaceMap.Remove( aSurface ); |
|
1120 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
1121 |
EGL_TRACE("DestroySurfaceInfo end"); |
|
1122 |
} |
|
1123 |
} |
|
1124 |
||
1125 |
iDisplayMapLock.Unlock(); |
|
1126 |
} |
|
1127 |
||
1128 |
// ----------------------------------------------------------------------------- |
|
1129 |
// |
|
1130 |
// ----------------------------------------------------------------------------- |
|
1131 |
// |
|
1132 |
TBool CGuestEGL::DestroyDisplayInfo (EGLDisplay aDisplay) |
|
1133 |
{ |
|
1134 |
EGL_TRACE("DestroyDisplayInfo begin aDisplay=%d", aDisplay); |
|
1135 |
TBool success = EFalse; |
|
1136 |
||
1137 |
iDisplayMapLock.WriteLock(); |
|
1138 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
1139 |
if (!pDispInfo || !*pDispInfo) |
|
1140 |
{ |
|
1141 |
EGL_TRACE("cannot find display %d", aDisplay); |
|
1142 |
} |
|
1143 |
else |
|
1144 |
{ |
|
1145 |
success = ETrue; |
|
1146 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
1147 |
RHashMap<TInt, TSurfaceInfo*>::TIter iter((*pDispInfo)->iSurfaceMap); |
|
1148 |
for (;;) |
|
1149 |
{ |
|
1150 |
TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter.NextValue()); |
|
1151 |
if (!pSurfaceInfo) |
|
1152 |
{ |
|
1153 |
break; |
|
1154 |
} |
|
1155 |
||
1156 |
EGL_TRACE("destroying surface %d", *iter.CurrentKey()); |
|
1157 |
||
1158 |
TSurfaceInfo* surfaceInfo = *pSurfaceInfo; |
|
1159 |
if (surfaceInfo->iNativeWindow) |
|
1160 |
{ |
|
1161 |
EglInternalFunction_DestroyWindowSurface(*surfaceInfo); |
|
1162 |
} |
|
1163 |
delete surfaceInfo; |
|
1164 |
} |
|
1165 |
iDisplayMap.Remove(aDisplay); |
|
1166 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
1167 |
||
1168 |
//added for egl sync extension benefit |
|
1169 |
if (iEglSyncExtension) |
|
1170 |
{ |
|
1171 |
iEglSyncExtension->EglSyncDisplayDestroy(aDisplay); |
|
1172 |
} |
|
1173 |
} |
|
1174 |
||
1175 |
iDisplayMapLock.Unlock(); |
|
1176 |
EGL_TRACE("DestroyDisplayInfo end - ret=%d", success); |
|
1177 |
return success; |
|
1178 |
} |
|
1179 |
||
1180 |
||
1181 |
// ----------------------------------------------------------------------------- |
|
1182 |
// |
|
1183 |
// ----------------------------------------------------------------------------- |
|
1184 |
// |
|
1185 |
EGLBoolean CGuestEGL::EglInternalFunction_CallSetSurfaceParams(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, TSurfaceInfo& aSurfaceInfo) |
|
1186 |
{ |
|
1187 |
EGL_TRACE("EglInternalFunction_CallSetSurfaceParams begin"); |
|
1188 |
||
1189 |
RemoteFunctionCallData rfcdata; |
|
1190 |
EglRFC eglApiData( rfcdata ); |
|
1191 |
eglApiData.Init(EglRFC::EeglSimulatorSetSurfaceParams); |
|
1192 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1193 |
eglApiData.AppendEGLSurface( aSurface ); |
|
1194 |
EGLNativeWindowType win = (EGLNativeWindowType)aSurfaceInfo.iNativeWindow->ClientHandle(); |
|
1195 |
eglApiData.AppendEGLNativeWindowType( win ); |
|
1196 |
eglApiData.AppendEGLSize(aSurfaceInfo.iSize); |
|
1197 |
eglApiData.AppendEGLint(aSurfaceInfo.iStride); |
|
1198 |
eglApiData.AppendEGLint(aSurfaceInfo.iBuffer0Index); |
|
1199 |
eglApiData.AppendEGLint(aSurfaceInfo.iBuffer1Index); |
|
1200 |
aThreadState.ExecuteEglNeverErrorCmd(eglApiData); |
|
1201 |
||
1202 |
EGL_TRACE("EglInternalFunction_CallSetSurfaceParams end"); |
|
1203 |
return EGL_TRUE; |
|
1204 |
} |
|
1205 |
||
1206 |
// ----------------------------------------------------------------------------- |
|
1207 |
// |
|
1208 |
// ----------------------------------------------------------------------------- |
|
1209 |
// |
|
1210 |
EGLint CGuestEGL::ConfigMatchesFbsBitmapPixmap(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const EGLint* aAttribList, TDisplayMode aMode) |
|
1211 |
{ |
|
1212 |
// ToDo check EGL_VG_ALPHA_FORMAT ? |
|
1213 |
EGLint colorBits, redBits, greenBits, blueBits, alphaBits; |
|
1214 |
EGLint wantColorBits, wantRedBits, wantGreenBits, wantBlueBits; |
|
1215 |
EGLint wantAlphaBits = 0; |
|
1216 |
switch (aMode) |
|
1217 |
{ |
|
1218 |
case EColor64K: |
|
1219 |
wantColorBits = 12; |
|
1220 |
wantRedBits = 5; |
|
1221 |
wantGreenBits = 6; |
|
1222 |
wantBlueBits = 5; |
|
1223 |
break; |
|
1224 |
case EColor16M: |
|
1225 |
case EColor16MU: |
|
1226 |
wantColorBits = 24; |
|
1227 |
wantRedBits = 8; |
|
1228 |
wantGreenBits = 8; |
|
1229 |
wantBlueBits = 8; |
|
1230 |
break; |
|
1231 |
case EColor16MA: |
|
1232 |
wantColorBits = 32; |
|
1233 |
wantRedBits = 8; |
|
1234 |
wantGreenBits = 8; |
|
1235 |
wantBlueBits = 8; |
|
1236 |
wantAlphaBits = 8; |
|
1237 |
break; |
|
1238 |
case EColor16MAP: |
|
1239 |
wantColorBits = 32; |
|
1240 |
wantRedBits = 8; |
|
1241 |
wantGreenBits = 8; |
|
1242 |
wantBlueBits = 8; |
|
1243 |
wantAlphaBits = 8; |
|
1244 |
break; |
|
1245 |
default: // pixmap format not supported |
|
1246 |
return EGL_BAD_NATIVE_PIXMAP; |
|
1247 |
} |
|
1248 |
||
1249 |
// ToDo version of these functions lighter on parameter checking - maybe use cached values |
|
1250 |
if (!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &colorBits) || |
|
1251 |
!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &redBits) || |
|
1252 |
!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &greenBits) || |
|
1253 |
!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &blueBits) || |
|
1254 |
!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &alphaBits) ) |
|
1255 |
{ // fetch failed |
|
1256 |
return EGL_BAD_MATCH; |
|
1257 |
} |
|
1258 |
||
1259 |
EGL_TRACE("CGuestEGL::ConfigMatchesFbsBitmapPixmap: want %d bpp, %d red, %d green, %d blue, %d alpha\n\tconfig has %d bpp, %d red, %d green, %d blue, %d alpha", |
|
1260 |
wantColorBits, wantRedBits, wantGreenBits, wantBlueBits, wantAlphaBits, |
|
1261 |
colorBits, redBits, greenBits, blueBits, alphaBits); |
|
1262 |
||
1263 |
if ( (colorBits < wantColorBits) || (redBits < wantRedBits) || (greenBits < wantGreenBits) || |
|
1264 |
(blueBits < wantBlueBits) || (alphaBits < wantAlphaBits) ) |
|
1265 |
{ // config does not match bitmap |
|
1266 |
return EGL_BAD_MATCH; |
|
1267 |
} |
|
1268 |
||
1269 |
return EGL_SUCCESS; |
|
1270 |
} |
|
1271 |
||
1272 |
/* |
|
1273 |
Returns EGL_NO_SURFACE on failure. If the attributes of pixmap do not |
|
1274 |
correspond to config, then an EGL_BAD_MATCH error is generated. If config does |
|
1275 |
not support rendering to pixmaps (the EGL_SURFACE_TYPE attribute does not |
|
1276 |
contain EGL_PIXMAP_BIT), an EGL_BAD_MATCH error is generated. If config does |
|
1277 |
not support the colorspace or alpha format attributes specified in attrib list |
|
1278 |
(as defined for eglCreateWindowSurface), an EGL_BAD_MATCH error is generated. |
|
1279 |
If config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If |
|
1280 |
pixmap is not a valid native pixmap handle, then an EGL_BAD_NATIVE_PIXMAP |
|
1281 |
error should be generated. If there is already an EGLSurface associated with |
|
1282 |
pixmap (as a result of a previous eglCreatePixmapSurface call), then a |
|
1283 |
EGL_BAD_ALLOC error is generated. Finally, if the implementation cannotallocate |
|
1284 |
resources for the new EGL pixmap, an EGL_BAD_ALLOC error is generated. |
|
1285 |
*/ |
|
1286 |
EGLSurface CGuestEGL::eglCreatePixmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, EGLNativePixmapType aNativePixmap, const EGLint *aAttribList) |
|
1287 |
{ |
|
1288 |
EGL_TRACE( "CGuestEGL::eglCreatePixmapSurface"); |
|
1289 |
EGL_TRACE_ATTRIB_LIST(aAttribList); |
|
1290 |
||
1291 |
EGLSurface newSurfaceId = EGL_NO_SURFACE; |
|
1292 |
TSurfaceInfo* surfaceInfo = NULL; |
|
1293 |
EGLint error = EGL_BAD_DISPLAY; |
|
1294 |
TSymbianPixmapTypeId pixmapType = EPixmapTypeNone; |
|
1295 |
||
1296 |
const EGLint* pixmapMatch = TAttribUtils::FindAttribValue(aAttribList, EGL_MATCH_NATIVE_PIXMAP); |
|
1297 |
if ( pixmapMatch && ( (*pixmapMatch) != (EGLint)(aNativePixmap) ) ) |
|
1298 |
{ // if EGL_MATCH_NATIVE_PIXMAP is in the attribute list it must be the same pixmap as aNativePixmap |
|
1299 |
error = EGL_BAD_MATCH; |
|
1300 |
} |
|
1301 |
else |
|
1302 |
{ |
|
1303 |
iDisplayMapLock.WriteLock(); |
|
1304 |
CEglDisplayInfo** pDispInfo; |
|
1305 |
pDispInfo = iDisplayMap.Find(aDisplay); |
|
1306 |
||
1307 |
if (pDispInfo && *pDispInfo) |
|
1308 |
{ |
|
1309 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
1310 |
||
1311 |
surfaceInfo = new TSurfaceInfo(); |
|
1312 |
if (surfaceInfo) |
|
1313 |
{ |
|
1314 |
surfaceInfo->iConfigId = aConfig; |
|
1315 |
pixmapType = EglInternalFunction_GetNativePixmapType(aNativePixmap); |
|
1316 |
switch (pixmapType) |
|
1317 |
{ |
|
1318 |
case EPixmapTypeFbsBitmap: |
|
1319 |
newSurfaceId = CreateFbsBitmapSurface(aThreadState, aDisplay, aConfig, reinterpret_cast<CFbsBitmap*>(aNativePixmap), aAttribList, |
|
1320 |
*surfaceInfo); |
|
1321 |
break; |
|
1322 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
1323 |
case EPixmapTypeSgImage: |
|
1324 |
newSurfaceId = CreateSgImageSurface(aThreadState, aDisplay, aConfig, reinterpret_cast<const RSgImage*>(aNativePixmap), aAttribList, |
|
1325 |
*surfaceInfo); |
|
1326 |
break; |
|
1327 |
#endif |
|
1328 |
default: |
|
1329 |
break; |
|
1330 |
} |
|
1331 |
if (newSurfaceId == EGL_NO_SURFACE) |
|
1332 |
{ |
|
1333 |
error = EGL_BAD_NATIVE_PIXMAP; |
|
1334 |
} |
|
1335 |
else |
|
1336 |
{ |
|
1337 |
error = EGL_SUCCESS; |
|
1338 |
EGL_TRACE( "CGuestEGL::eglCreatePixmapSurface inserting surface 0x%x to display %d", newSurfaceId, aDisplay); |
|
1339 |
if (KErrNone != (*pDispInfo)->iSurfaceMap.Insert(newSurfaceId, surfaceInfo)) |
|
1340 |
{ |
|
1341 |
error = EGL_BAD_ALLOC; |
|
1342 |
if (pixmapType == EPixmapTypeFbsBitmap) |
|
1343 |
{ |
|
1344 |
(void) eglDestroySurface(aThreadState, aDisplay, newSurfaceId); |
|
1345 |
} |
|
1346 |
newSurfaceId = EGL_NO_SURFACE; |
|
1347 |
} |
|
1348 |
} |
|
1349 |
if (error != EGL_SUCCESS) |
|
1350 |
{ |
|
1351 |
delete surfaceInfo; |
|
1352 |
surfaceInfo = NULL; |
|
1353 |
} |
|
1354 |
} |
|
1355 |
else |
|
1356 |
{ |
|
1357 |
error = EGL_BAD_ALLOC; |
|
1358 |
} |
|
1359 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
1360 |
} // dispInfo |
|
1361 |
iDisplayMapLock.Unlock(); |
|
1362 |
} |
|
1363 |
||
1364 |
aThreadState.SetEglError(error); |
|
1365 |
||
1366 |
// parameter check failed |
|
1367 |
if (error != EGL_SUCCESS) |
|
1368 |
{ |
|
1369 |
EGLPANIC_ASSERT_DEBUG(newSurfaceId == EGL_NO_SURFACE, EEglPanicTemp); |
|
1370 |
EGLPANIC_ASSERT_DEBUG(surfaceInfo == NULL, EEglPanicTemp); |
|
1371 |
return EGL_NO_SURFACE; |
|
1372 |
} |
|
1373 |
||
1374 |
EGLPANIC_ASSERT_DEBUG(newSurfaceId != EGL_NO_SURFACE, EEglPanicTemp); |
|
1375 |
EGLPANIC_ASSERT_DEBUG(surfaceInfo != NULL, EEglPanicTemp); |
|
1376 |
||
1377 |
return newSurfaceId; |
|
1378 |
} |
|
1379 |
||
1380 |
EGLSurface CGuestEGL::CreateFbsBitmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, CFbsBitmap* aBitmap, |
|
1381 |
const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo) |
|
1382 |
{ |
|
1383 |
EGLSurface newSurfaceId = EGL_NO_SURFACE; |
|
1384 |
aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapFbsBitmap; |
|
1385 |
aSurfaceInfo.iFbsBitmap = aBitmap; |
|
1386 |
||
1387 |
TDisplayMode mode = ENone; |
|
1388 |
TInt stride; |
|
1389 |
aSurfaceInfo.iSize = aBitmap->SizeInPixels(); |
|
1390 |
EGL_TRACE("CGuestEGL::CreateFbsBitmapSurface image width=%d, height=%d", aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight); |
|
1391 |
||
1392 |
// check that a pixmap surface has not previously been created from this CFbsBitmap |
|
1393 |
if (!EglInternalFunction_PixmapSurfacePreviouslyCreated(aBitmap, EPixmapTypeFbsBitmap)) |
|
1394 |
{ |
|
1395 |
// error = EGL_BAD_ALLOC; |
|
1396 |
return EGL_NO_SURFACE; |
|
1397 |
} |
|
1398 |
else |
|
1399 |
{ |
|
1400 |
mode = aBitmap->DisplayMode(); |
|
1401 |
if (EGL_SUCCESS != ConfigMatchesFbsBitmapPixmap(aThreadState, aDisplay, aConfig, aAttribList, mode)) |
|
1402 |
{ |
|
1403 |
return EGL_NO_SURFACE; |
|
1404 |
} |
|
1405 |
} |
|
1406 |
||
1407 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1408 |
stride = CFbsBitmap::ScanLineLength(aSurfaceInfo.iSize.iWidth, mode); |
|
1409 |
eglApiData.Init( EglRFC::EeglCreatePixmapSurface ); |
|
1410 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1411 |
eglApiData.AppendEGLConfig(aConfig); |
|
1412 |
eglApiData.AppendEGLNativePixmapType((EGLNativePixmapType) aBitmap); |
|
1413 |
eglApiData.AppendEGLint(mode); |
|
1414 |
eglApiData.AppendEGLSize(aSurfaceInfo.iSize); |
|
1415 |
eglApiData.AppendEGLint(stride); |
|
1416 |
eglApiData.AppendEGLint(EPixmapTypeFbsBitmap); |
|
1417 |
eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList)); |
|
1418 |
newSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); |
|
1419 |
EGL_TRACE( "EeglCreatePixmapSurface aDisplay=%d, config=%d, format=%d, width=%d, height=%d, stride=%d, pixmapType=%d, newSurface=%d", |
|
1420 |
aDisplay, aConfig, mode, aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight, stride, EPixmapTypeFbsBitmap, newSurfaceId); |
|
1421 |
||
1422 |
aSurfaceInfo.iHostSurfaceId = newSurfaceId; |
|
1423 |
return newSurfaceId; |
|
1424 |
} |
|
1425 |
||
1426 |
#ifdef FAISALMEMON_S4_SGIMAGE |
|
1427 |
EGLSurface CGuestEGL::CreateSgImageSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const RSgImage* aSgImage, |
|
1428 |
const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo) |
|
1429 |
{ |
|
1430 |
// ToDo check that the SgImage is not already being used for a surface or EglImage |
|
1431 |
aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapSgImage; |
|
1432 |
aSurfaceInfo.iSgId = aSgImage->Id(); |
|
1433 |
||
1434 |
EGL_TRACE("CGuestEGL::CreateSgImageSurface sgImage id 0x%lx", aSurfaceInfo.iSgId); |
|
1435 |
TSgImageInfo imgInfo; |
|
1436 |
// ToDo ensure SgImage has correct suitable usage bits |
|
1437 |
if ( (aSurfaceInfo.iSgId != KSgNullDrawableId) && (KErrNone == aSurfaceInfo.iSgHandle.Open(aSurfaceInfo.iSgId)) && |
|
1438 |
(KErrNone == aSgImage->GetInfo(imgInfo)) ) |
|
1439 |
{ |
|
1440 |
EGL_TRACE("CGuestEGL::CreateSgImageSurface 1. SgImage PixelFormat=%d; size=%d,%d; Usage=0x%x", |
|
1441 |
imgInfo.iPixelFormat, imgInfo.iSizeInPixels.iWidth, imgInfo.iSizeInPixels.iHeight, imgInfo.iUsage); |
|
1442 |
aSurfaceInfo.iSize = imgInfo.iSizeInPixels; |
|
1443 |
||
1444 |
/* Package the handles to 64-bit value, since there's only one parameter available. |
|
1445 |
pbufferHandle is the lower 32 bits, VGImageHandle is the upper bits. */ |
|
1446 |
TUint64 sgHandles; |
|
1447 |
EGLint hostResult = CVghwUtils::EglGetSgHandles(aSurfaceInfo.iSgId.iId, &sgHandles); |
|
1448 |
EGL_TRACE("CGuestEGL::CreateSgImageSurface 2. EglGetSgHandles result=%d, sgHandles=0x%lx", hostResult, sgHandles); |
|
1449 |
aSurfaceInfo.iHostSurfaceId = (EGLSurface)(sgHandles&0xFFFFFFFF); |
|
1450 |
return aSurfaceInfo.iHostSurfaceId; |
|
1451 |
} |
|
1452 |
||
1453 |
aSurfaceInfo.iSgHandle.Close(); |
|
1454 |
return EGL_NO_SURFACE; |
|
1455 |
} |
|
1456 |
#endif |
|
1457 |
||
1458 |
// ----------------------------------------------------------------------------- |
|
1459 |
// |
|
1460 |
// ----------------------------------------------------------------------------- |
|
1461 |
// |
|
1462 |
TSurfaceInfo* CGuestEGL::EglInternalFunction_GetPlatformSurface( EGLDisplay display, EGLSurface surface ) |
|
1463 |
{ |
|
1464 |
EGL_TRACE( "CGuestEGL::EglInternalFunction_GetPlatformSurface"); |
|
1465 |
TSurfaceInfo* result = NULL; |
|
1466 |
||
1467 |
iDisplayMapLock.ReadLock(); |
|
1468 |
||
1469 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display ); |
|
1470 |
if (pDispInfo && *pDispInfo) |
|
1471 |
{ |
|
1472 |
TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface ); |
|
1473 |
if (pSurfaceInfo) |
|
1474 |
{ |
|
1475 |
result = *pSurfaceInfo; |
|
1476 |
} |
|
1477 |
} |
|
1478 |
||
1479 |
// TODO on success should probably Unlock() the surface in the caller |
|
1480 |
iDisplayMapLock.Unlock(); |
|
1481 |
||
1482 |
/* TODO review calling code, to see if this suggestion makes sense |
|
1483 |
if (result == NULL) |
|
1484 |
{ |
|
1485 |
EGL_RAISE_ERROR( EGL_BAD_SURFACE, NULL); //Enable this when all surfaces are in surface map |
|
1486 |
} |
|
1487 |
*/ |
|
1488 |
return result; |
|
1489 |
} |
|
1490 |
||
1491 |
// ----------------------------------------------------------------------------- |
|
1492 |
// |
|
1493 |
// ----------------------------------------------------------------------------- |
|
1494 |
// |
|
1495 |
EGLBoolean CGuestEGL::eglWaitClient(TEglThreadState& aThreadState) |
|
1496 |
{ |
|
1497 |
EGL_TRACE( "CGuestEGL::eglWaitClient"); |
|
1498 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1499 |
eglApiData.Init(EglRFC::EeglWaitClient); |
|
1500 |
EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1501 |
||
1502 |
if (result) |
|
1503 |
{ |
|
1504 |
// ToDo cache in client, check results are not EGL_NO_DISPLAY / EGL_NO_SURFACE |
|
1505 |
EGLDisplay display = eglGetCurrentDisplay(aThreadState); |
|
1506 |
EGLSurface surface = eglGetCurrentSurface(aThreadState, EGL_DRAW); |
|
1507 |
iDisplayMapLock.ReadLock(); |
|
1508 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display ); |
|
1509 |
TSurfaceInfo* surfaceInfo = NULL; |
|
1510 |
||
1511 |
if (!pDispInfo || !*pDispInfo) |
|
1512 |
{ |
|
1513 |
EGL_TRACE( "cannot find display %d", display ); |
|
1514 |
} |
|
1515 |
else |
|
1516 |
{ |
|
1517 |
TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface ); |
|
1518 |
if (!pSurfaceInfo) |
|
1519 |
{ |
|
1520 |
EGL_TRACE( "cannot find surface %d for display %d", surface, display ); |
|
1521 |
} |
|
1522 |
else |
|
1523 |
{ |
|
1524 |
surfaceInfo = *pSurfaceInfo; |
|
1525 |
} |
|
1526 |
} |
|
1527 |
iDisplayMapLock.Unlock(); |
|
1528 |
if (surfaceInfo == NULL) |
|
1529 |
{ |
|
1530 |
return EGL_FALSE; |
|
1531 |
} |
|
1532 |
if (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap) |
|
1533 |
{ |
|
1534 |
EGLPANIC_ASSERT_DEBUG(surfaceInfo->iFbsBitmap, EEglPanicTemp); |
|
1535 |
surfaceInfo->iFbsBitmap->BeginDataAccess(); |
|
1536 |
||
1537 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1538 |
eglApiData.Init( EglRFC::EeglSimulatorCopyImageData ); |
|
1539 |
const TSize sizePixels( surfaceInfo->iFbsBitmap->Header().iSizeInPixels ); |
|
1540 |
eglApiData.AppendVector( (void*)surfaceInfo->iFbsBitmap->DataAddress(), |
|
1541 |
CFbsBitmap::ScanLineLength( sizePixels.iWidth, surfaceInfo->iFbsBitmap->DisplayMode() )*sizePixels.iHeight, |
|
1542 |
RemoteFunctionCallData::EOut ); |
|
1543 |
aThreadState.ExecuteEglNeverErrorCmd(eglApiData); |
|
1544 |
||
1545 |
surfaceInfo->iFbsBitmap->EndDataAccess(); |
|
1546 |
} |
|
1547 |
} |
|
1548 |
||
1549 |
return result; |
|
1550 |
} |
|
1551 |
||
1552 |
// ----------------------------------------------------------------------------- |
|
1553 |
// |
|
1554 |
// ----------------------------------------------------------------------------- |
|
1555 |
// |
|
1556 |
EGLSurface CGuestEGL::eglGetCurrentSurface(TEglThreadState& aThreadState, EGLint aReadDraw) |
|
1557 |
{ |
|
1558 |
// ToDo cache in client |
|
1559 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1560 |
eglApiData.Init(EglRFC::EeglGetCurrentSurface); |
|
1561 |
eglApiData.AppendEGLint(aReadDraw); |
|
1562 |
return ExecEglSurfaceNoErrorCmd(aThreadState, eglApiData); |
|
1563 |
} |
|
1564 |
||
1565 |
// ----------------------------------------------------------------------------- |
|
1566 |
// |
|
1567 |
// ----------------------------------------------------------------------------- |
|
1568 |
// |
|
1569 |
EGLDisplay CGuestEGL::eglGetCurrentDisplay(TEglThreadState& aThreadState) |
|
1570 |
{ |
|
1571 |
// ToDo cache in client |
|
1572 |
EGL_TRACE("CGuestEGL::eglGetCurrentDisplay"); |
|
1573 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1574 |
eglApiData.Init(EglRFC::EeglGetCurrentDisplay); |
|
1575 |
return ExecEglDisplayNoErrorCmd(aThreadState, eglApiData); |
|
1576 |
} |
|
1577 |
||
1578 |
// ----------------------------------------------------------------------------- |
|
1579 |
// |
|
1580 |
// ----------------------------------------------------------------------------- |
|
1581 |
// |
|
1582 |
EGLBoolean CGuestEGL::eglCopyBuffers(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLNativePixmapType aTarget) |
|
1583 |
{ |
|
1584 |
TSize pixmapSize; |
|
1585 |
||
1586 |
EGL_TRACE("CGuestEGL::eglCopyBuffers"); |
|
1587 |
EGLBoolean hostResult = EGL_FALSE; |
|
1588 |
TSymbianPixmapTypeId targetPixmapType = EglInternalFunction_GetNativePixmapType(aTarget); |
|
1589 |
||
1590 |
// Only CFbsBitmap native pixmaps are supported by this API. (SgImages are not supported, as per the SgImsge Lite spec.) |
|
1591 |
if ( (targetPixmapType == EPixmapTypeFbsBitmap) && EglInternalFunction_IsValidNativePixmap(aTarget, targetPixmapType) ) |
|
1592 |
{ |
|
1593 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata); |
|
1594 |
CFbsBitmap* bitmap = (CFbsBitmap*)aTarget; |
|
1595 |
TSize pixmapSize = bitmap->SizeInPixels(); |
|
1596 |
bitmap->BeginDataAccess(); |
|
1597 |
||
1598 |
TDisplayMode mode = bitmap->DisplayMode(); |
|
1599 |
EGLint stride = CFbsBitmap::ScanLineLength(bitmap->Header().iSizeInPixels.iWidth, mode); |
|
1600 |
void* data = bitmap->DataAddress(); |
|
1601 |
||
1602 |
#ifdef _DEBUG |
|
1603 |
char* modeName = NULL; |
|
1604 |
switch (mode) |
|
1605 |
{ |
|
1606 |
case ENone: modeName = "ENone"; break; |
|
1607 |
case EGray2: modeName = "EGray2"; break; |
|
1608 |
case EGray4: modeName = "EGray4"; break; |
|
1609 |
case EGray16: modeName = "EGray16"; break; |
|
1610 |
case EGray256: modeName = "EGray256"; break; |
|
1611 |
case EColor16: modeName = "EColor16"; break; |
|
1612 |
case EColor256: modeName = "EColor256"; break; |
|
1613 |
case EColor64K: modeName = "EColor64K"; break; |
|
1614 |
case EColor16M: modeName = "EColor16M"; break; |
|
1615 |
case ERgb: modeName = "ERgb"; break; |
|
1616 |
case EColor4K: modeName = "EColor4K"; break; |
|
1617 |
case EColor16MU: modeName = "EColor16MU"; break; |
|
1618 |
case EColor16MA: modeName = "EColor16MA"; break; |
|
1619 |
case EColor16MAP: modeName = "EColor16MAP"; break; |
|
1620 |
case EColorLast: modeName = "EColorLast"; break; |
|
1621 |
default: modeName = "unknown"; break; |
|
1622 |
} |
|
1623 |
EGL_TRACE("EglInternalFunction_GetNativePixmapInfo (0x%x) -> CFbsBitmap: DisplayMode=%d (\"%s\"), ScanLineLength=%d, data addr=0x%x", |
|
1624 |
bitmap, mode, modeName, stride, data); |
|
1625 |
#endif |
|
1626 |
||
1627 |
eglApiData.Init(EglRFC::EeglCopyBuffers); |
|
1628 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1629 |
eglApiData.AppendEGLSurface(aSurface); |
|
1630 |
const TSize sizePixels( bitmap->Header().iSizeInPixels ); |
|
1631 |
eglApiData.AppendVector((void*)bitmap->DataAddress(), |
|
1632 |
stride*pixmapSize.iHeight, |
|
1633 |
RemoteFunctionCallData::EOut); |
|
1634 |
||
1635 |
eglApiData.AppendEGLint((EGLint) mode); |
|
1636 |
eglApiData.AppendEGLSize(pixmapSize); |
|
1637 |
eglApiData.AppendEGLint(stride); |
|
1638 |
eglApiData.AppendEGLint(targetPixmapType); |
|
1639 |
||
1640 |
hostResult = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1641 |
bitmap->EndDataAccess(); |
|
1642 |
} |
|
1643 |
else |
|
1644 |
{ |
|
1645 |
aThreadState.SetEglError(EGL_BAD_NATIVE_PIXMAP); |
|
1646 |
} |
|
1647 |
||
1648 |
return hostResult; |
|
1649 |
} |
|
1650 |
||
1651 |
// ----------------------------------------------------------------------------- |
|
1652 |
// |
|
1653 |
// ----------------------------------------------------------------------------- |
|
1654 |
// |
|
1655 |
// Beware odd logic: EFalse if surface is found, otherwise ETrue |
|
1656 |
TBool CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated(EGLNativePixmapType pixmap, TSymbianPixmapTypeId pixmapType) |
|
1657 |
{ |
|
1658 |
// ToDo keep a hashmap of pixmap addresses currently used for surfaces |
|
1659 |
TBool result = ETrue; |
|
1660 |
if(pixmapType == EPixmapTypeFbsBitmap) |
|
1661 |
{ |
|
1662 |
iDisplayMapLock.ReadLock(); |
|
1663 |
RHashMap<TInt, CEglDisplayInfo*>::TIter iter( iDisplayMap ); |
|
1664 |
for (;;) |
|
1665 |
{ |
|
1666 |
CEglDisplayInfo** pDispInfo = const_cast<CEglDisplayInfo**>(iter.NextValue()); |
|
1667 |
if (!pDispInfo || !*pDispInfo) |
|
1668 |
{ |
|
1669 |
break; |
|
1670 |
} |
|
1671 |
||
1672 |
RHashMap<TInt, TSurfaceInfo*>::TIter iter2((*pDispInfo)->iSurfaceMap); |
|
1673 |
for (;;) |
|
1674 |
{ |
|
1675 |
TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter2.NextValue()); |
|
1676 |
if (!pSurfaceInfo) |
|
1677 |
{ |
|
1678 |
break; |
|
1679 |
} |
|
1680 |
||
1681 |
TSurfaceInfo* surfaceInfo = *pSurfaceInfo; |
|
1682 |
if ( (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap) && (surfaceInfo->iFbsBitmap == pixmap) ) |
|
1683 |
{ |
|
1684 |
result = EFalse; |
|
1685 |
} |
|
1686 |
} |
|
1687 |
} |
|
1688 |
iDisplayMapLock.Unlock(); |
|
1689 |
} |
|
1690 |
||
1691 |
EGL_TRACE("CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated %d", result); |
|
1692 |
return result; |
|
1693 |
} |
|
1694 |
||
1695 |
// FAISALMEMON HOLE 2 |
|
1696 |
||
1697 |
EGLDisplay CGuestEGL::eglGetDisplay(TEglThreadState& aThreadState, EGLNativeDisplayType aDisplayId) |
|
1698 |
{ |
|
1699 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata); |
|
1700 |
eglApiData.Init(EglRFC::EeglGetDisplay); |
|
1701 |
eglApiData.AppendEGLNativeDisplayType(aDisplayId); |
|
1702 |
EGLDisplay display = ExecEglDisplayNoErrorCmd(aThreadState, eglApiData); |
|
1703 |
||
1704 |
if (display != EGL_NO_DISPLAY) |
|
1705 |
{ |
|
1706 |
if (!CreateDisplayInfo(display)) |
|
1707 |
{ // alloc failed |
|
1708 |
display = EGL_NO_DISPLAY; |
|
1709 |
} |
|
1710 |
} |
|
1711 |
return display; |
|
1712 |
} |
|
1713 |
||
1714 |
// ----------------------------------------------------------------------------- |
|
1715 |
// |
|
1716 |
// ----------------------------------------------------------------------------- |
|
1717 |
// |
|
1718 |
EGLint CGuestEGL::InitialiseExtensions() |
|
1719 |
{ |
|
1720 |
iEglSyncExtension = CEglSyncExtension::Create(*this); |
|
1721 |
return EGL_SUCCESS; |
|
1722 |
} |
|
1723 |
||
1724 |
||
1725 |
// API supporting EGL sync extension |
|
1726 |
// lock the display once found |
|
1727 |
EGLint CGuestEGL::FindAndLockDisplay(EGLDisplay aDisplay) |
|
1728 |
{ |
|
1729 |
EGLint result = EGL_BAD_DISPLAY; |
|
1730 |
EGL_TRACE("CGuestEGL::FindAndLockDisplay aDisplay=%d", aDisplay); |
|
1731 |
iDisplayMapLock.ReadLock(); |
|
1732 |
CEglDisplayInfo** pDisp = iDisplayMap.Find(aDisplay); |
|
1733 |
if (pDisp && *pDisp) |
|
1734 |
{ |
|
1735 |
CEglDisplayInfo* disp = *pDisp; |
|
1736 |
if (disp->iInitialized) |
|
1737 |
{ |
|
1738 |
EGL_TRACE("CGuestEGL::FindAndLockDisplay display found"); |
|
1739 |
result = EGL_SUCCESS; |
|
1740 |
} |
|
1741 |
else |
|
1742 |
{ |
|
1743 |
EGL_TRACE("CGuestEGL::FindAndLockDisplay display not initialized"); |
|
1744 |
result = EGL_NOT_INITIALIZED; |
|
1745 |
} |
|
1746 |
} |
|
1747 |
else |
|
1748 |
{ |
|
1749 |
EGL_TRACE("CGuestEGL::FindAndLockDisplay cannot find display"); |
|
1750 |
} |
|
1751 |
if (result != EGL_SUCCESS) |
|
1752 |
{ |
|
1753 |
iDisplayMapLock.Unlock(); |
|
1754 |
} |
|
1755 |
return result; |
|
1756 |
} |
|
1757 |
||
1758 |
// release the lock |
|
1759 |
void CGuestEGL::ReleaseDisplayLock(EGLDisplay aDisplay) |
|
1760 |
{ |
|
1761 |
EGL_TRACE("CGuestEGL::ReleaseDisplayLock aDisplay=%d", aDisplay); |
|
1762 |
iDisplayMapLock.Unlock(); |
|
1763 |
} |
|
1764 |
||
1765 |
||
1766 |
CEglSyncExtension* CGuestEGL::EGLSyncExtension() |
|
1767 |
{ |
|
1768 |
return iEglSyncExtension; |
|
1769 |
} |
|
1770 |
||
1771 |
||
1772 |
/* |
|
1773 |
EGL_FALSE is returned on failure and major and minor are not updated. An |
|
1774 |
EGL_BAD_DISPLAY error is generated if the dpy argument does not refer to a valid |
|
1775 |
EGLDisplay. An EGL_NOT_INITIALIZED error is generated if EGL cannot be |
|
1776 |
initialized for an otherwise valid dpy. |
|
1777 |
*/ |
|
1778 |
EGLBoolean CGuestEGL::eglInitialize(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLint *aMajor, EGLint *aMinor) |
|
1779 |
{ |
|
1780 |
if ((aDisplay == EGL_NO_DISPLAY) || !InitializeDisplayInfo(aDisplay)) |
|
1781 |
{ |
|
1782 |
aThreadState.SetEglError(EGL_BAD_DISPLAY); |
|
1783 |
return EGL_FALSE; |
|
1784 |
} |
|
1785 |
||
1786 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata); |
|
1787 |
eglApiData.Init(EglRFC::EeglInitialize); |
|
1788 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1789 |
EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1790 |
||
1791 |
if(ret) |
|
1792 |
{ |
|
1793 |
if(aMajor) |
|
1794 |
*aMajor = EGL_VERSION_MAJOR; |
|
1795 |
if(aMinor) |
|
1796 |
*aMinor = EGL_VERSION_MINOR; |
|
1797 |
} |
|
1798 |
EGL_TRACE("eglInitialize <-" ); |
|
1799 |
return ret; |
|
1800 |
} |
|
1801 |
||
1802 |
/* |
|
1803 |
Returns EGL_FALSE on failure and value is not updated. If attribute is not a |
|
1804 |
valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If |
|
1805 |
surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated. |
|
1806 |
*/ |
|
1807 |
EGLBoolean CGuestEGL::eglQuerySurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aAttribute, EGLint *aValue) |
|
1808 |
{ |
|
1809 |
// ToDo more parameter validation, and possibly use cached values |
|
1810 |
if ( (aValue == NULL) || (3 & (TUint32)aValue) ) |
|
1811 |
{ |
|
1812 |
aThreadState.SetEglError(EGL_BAD_PARAMETER); |
|
1813 |
return EGL_FALSE; |
|
1814 |
} |
|
1815 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1816 |
eglApiData.Init(EglRFC::EeglQuerySurface); |
|
1817 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1818 |
eglApiData.AppendEGLSurface(aSurface); |
|
1819 |
eglApiData.AppendEGLint(aAttribute); |
|
1820 |
eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut); |
|
1821 |
||
1822 |
EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1823 |
EGL_TRACE_GET_ATTRIB("eglQuerySurface", "surface", aDisplay, aSurface, aAttribute, aValue, result); |
|
1824 |
return result; |
|
1825 |
} |
|
1826 |
||
1827 |
/* |
|
1828 |
On failure eglCreatePbufferFromClientBuffer returns EGL_NO_SURFACE. In |
|
1829 |
addition to the errors described eglCreatePbufferSurface, |
|
1830 |
eglCreatePbufferFromClientBuffer may fail and generate errors for the |
|
1831 |
following reasons: |
|
1832 |
* If buftype is not a recognized client API resource type (e.g. is not |
|
1833 |
EGL_OPENVG_IMAGE), an EGL_BAD_PARAMETER error is generated. |
|
1834 |
* If buffer is not a valid handle or name of a client API resource of the |
|
1835 |
specified buftype in the currently bound context corresponding to that |
|
1836 |
type, an EGL_BAD_PARAMETER error is generated. |
|
1837 |
* If the buffers contained in buffer do not correspond to a proper subset |
|
1838 |
of the buffers described by config, and match the bit depths for those |
|
1839 |
buffers specified in config, then an EGL_BAD_MATCH error is generated. |
|
1840 |
For example, a VGImage with pixel format VG_lRGBA_8888 corresponds to an |
|
1841 |
EGLConfig with EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, and |
|
1842 |
EGL_ALPHA_SIZE values of 8. |
|
1843 |
* If no context corresponding to the specified buftype is current, an |
|
1844 |
EGL_BAD_ACCESS error is generated. |
|
1845 |
* There may be additional constraints on which types of buffers may be |
|
1846 |
bound to EGL surfaces, as described in client API specifications. If |
|
1847 |
those constraints are violated, then an EGL_BAD_MATCH error is generated. |
|
1848 |
* If buffer is already bound to another pbuffer, or is in use by a client |
|
1849 |
API an EGL_BAD_ACCESS error is generated. |
|
1850 |
*/ |
|
1851 |
EGLSurface CGuestEGL::eglCreatePbufferFromClientBuffer(TEglThreadState& aThreadState, |
|
1852 |
EGLDisplay aDisplay, EGLenum aBufType, EGLClientBuffer aBuffer, EGLConfig aConfig, const EGLint *aAttribList) |
|
1853 |
{ |
|
1854 |
// ToDo validate parameters |
|
1855 |
// ToDo SgImage Design Spec 5.12 - eglCreatePbufferFromClientBuffer should fail with EGL_BAD_ACCESS for VgImages derived from SgImages |
|
1856 |
EGL_TRACE("eglCreatePbufferFromClientBuffer %d %d %d", aDisplay, aBufType, aConfig); |
|
1857 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1858 |
eglApiData.Init(EglRFC::EeglCreatePbufferFromClientBuffer); |
|
1859 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1860 |
eglApiData.AppendEGLenum(aBufType); |
|
1861 |
eglApiData.AppendEGLClientBuffer(aBuffer); |
|
1862 |
eglApiData.AppendEGLConfig(aConfig); |
|
1863 |
eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) ); |
|
1864 |
||
1865 |
return aThreadState.ExecEglSurfaceCmd(eglApiData); |
|
1866 |
} |
|
1867 |
||
1868 |
/* |
|
1869 |
If the dpy argument does not refer to a valid EGLDisplay, EGL_FALSE is |
|
1870 |
returned, and an EGL_BAD_DISPLAY error is generated. |
|
1871 |
*/ |
|
1872 |
EGLBoolean CGuestEGL::eglTerminate(TEglThreadState& aThreadState, EGLDisplay aDisplay) |
|
1873 |
{ |
|
1874 |
EGLBoolean success = EGL_FALSE; |
|
1875 |
if (DestroyDisplayInfo(aDisplay)) |
|
1876 |
{ |
|
1877 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1878 |
eglApiData.Init(EglRFC::EeglTerminate); |
|
1879 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1880 |
||
1881 |
success = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1882 |
EGL_TRACE("eglTerminate display=%d ret=%d", aDisplay, success); |
|
1883 |
} |
|
1884 |
else |
|
1885 |
{ |
|
1886 |
aThreadState.SetEglError(EGL_BAD_DISPLAY); |
|
1887 |
} |
|
1888 |
||
1889 |
return success; |
|
1890 |
} |
|
1891 |
||
1892 |
/* |
|
1893 |
On failure, EGL_FALSE is returned. An EGL_NOT_INITIALIZED error is generated |
|
1894 |
if EGL is not initialized on dpy. An EGL_BAD_PARAMETER error is generated |
|
1895 |
if num config is NULL. |
|
1896 |
*/ |
|
1897 |
EGLBoolean CGuestEGL::eglGetConfigs(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig *aConfigs, |
|
1898 |
EGLint aConfigSize, EGLint *aNumConfig) |
|
1899 |
{ |
|
1900 |
EGLint error = EGL_SUCCESS; |
|
1901 |
||
1902 |
if (aNumConfig == NULL) |
|
1903 |
{ |
|
1904 |
error = EGL_BAD_PARAMETER; |
|
1905 |
} |
|
1906 |
||
1907 |
// ToDo check display is valid |
|
1908 |
if (error != EGL_SUCCESS) |
|
1909 |
{ |
|
1910 |
aThreadState.SetEglError(EGL_BAD_PARAMETER); |
|
1911 |
return EGL_FALSE; |
|
1912 |
} |
|
1913 |
if (aConfigs && !aConfigSize) |
|
1914 |
aConfigSize = 1; |
|
1915 |
else if (!aConfigs) |
|
1916 |
aConfigSize = 0; |
|
1917 |
||
1918 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1919 |
eglApiData.Init(EglRFC::EeglGetConfigs); |
|
1920 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1921 |
eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut); |
|
1922 |
eglApiData.AppendEGLint(aConfigSize); |
|
1923 |
eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut); |
|
1924 |
||
1925 |
// ToDo cache successful result for next time |
|
1926 |
EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1927 |
return result; |
|
1928 |
} |
|
1929 |
||
1930 |
EGLBoolean CGuestEGL::eglChooseConfig(TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint *aAttribList, |
|
1931 |
EGLConfig *aConfigs, EGLint aConfigSize, EGLint *aNumConfig) |
|
1932 |
{ |
|
1933 |
if (aConfigs && !aConfigSize) |
|
1934 |
{ |
|
1935 |
aConfigSize = 1; |
|
1936 |
} |
|
1937 |
else if (!aConfigs) |
|
1938 |
{ |
|
1939 |
aConfigSize = 0; |
|
1940 |
} |
|
1941 |
||
1942 |
const EGLint* surfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE); |
|
1943 |
if (surfaceType && (*surfaceType & EGL_PIXMAP_BIT)) |
|
1944 |
{ |
|
1945 |
EGL_TRACE("CGuestEGL::eglChooseConfig for Pixmap Surface"); |
|
1946 |
const EGLint* pixmapMatch = TAttribUtils::FindAttribValue(aAttribList, EGL_MATCH_NATIVE_PIXMAP); |
|
1947 |
if (pixmapMatch && *pixmapMatch) |
|
1948 |
{ |
|
1949 |
EGL_TRACE("CGuestEGL::eglChooseConfig attributes include EGL_MATCH_NATIVE_PIXMAP, value is 0x%x", *pixmapMatch); |
|
1950 |
// check/copy color & alpha sizes from pixmap |
|
1951 |
return ChooseConfigForPixmapSurface(aThreadState, aDisplay, aAttribList, aConfigs, aConfigSize, aNumConfig, (const void*)*pixmapMatch); |
|
1952 |
} |
|
1953 |
else |
|
1954 |
{ // Pixmap to match is missing |
|
1955 |
EGL_TRACE("CGuestEGL::eglChooseConfig EGL_MATCH_NATIVE_PIXMAP attribute is missing or NULL"); |
|
1956 |
aThreadState.SetEglError(EGL_BAD_PARAMETER); |
|
1957 |
return EGL_FALSE; |
|
1958 |
} |
|
1959 |
} |
|
1960 |
||
1961 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1962 |
eglApiData.Init( EglRFC::EeglChooseConfig ); |
|
1963 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1964 |
eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList)); |
|
1965 |
eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut ); |
|
1966 |
eglApiData.AppendEGLint(aConfigSize); |
|
1967 |
eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut); |
|
1968 |
||
1969 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1970 |
} |
|
1971 |
||
1972 |
/* |
|
1973 |
On failure returns EGL_FALSE. If attribute |
|
1974 |
is not a valid attribute then EGL_BAD_ATTRIBUTE is generated. |
|
1975 |
*/ |
|
1976 |
EGLBoolean CGuestEGL::eglGetConfigAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, |
|
1977 |
EGLint aAttribute, EGLint *aValue) |
|
1978 |
{ |
|
1979 |
// ToDo validate display & aAttribute, and maybe get result from local cache |
|
1980 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
1981 |
eglApiData.Init(EglRFC::EeglGetConfigAttrib); |
|
1982 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
1983 |
eglApiData.AppendEGLConfig(aConfig); |
|
1984 |
eglApiData.AppendEGLint(aAttribute); |
|
1985 |
eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut); |
|
1986 |
||
1987 |
EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData); |
|
1988 |
EGL_TRACE_GET_ATTRIB("eglGetConfigAttrib", "config", aDisplay, aConfig, aAttribute, aValue, result); |
|
1989 |
return result; |
|
1990 |
} |
|
1991 |
||
1992 |
/* |
|
1993 |
Returns EGL_FALSE on failure and value is not updated. If attribute is not a |
|
1994 |
valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If |
|
1995 |
surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated. |
|
1996 |
*/ |
|
1997 |
EGLBoolean CGuestEGL::eglSurfaceAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, |
|
1998 |
EGLint aAttribute, EGLint aValue) |
|
1999 |
{ |
|
2000 |
EGL_TRACE_SET_ATTRIB("eglSurfaceAttrib", "surface", aDisplay, aSurface, aAttribute, aValue); |
|
2001 |
||
2002 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2003 |
eglApiData.Init(EglRFC::EeglSurfaceAttrib); |
|
2004 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
2005 |
eglApiData.AppendEGLSurface(aSurface); |
|
2006 |
eglApiData.AppendEGLint(aAttribute); |
|
2007 |
eglApiData.AppendEGLint(aValue); |
|
2008 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
2009 |
} |
|
2010 |
||
2011 |
/* |
|
2012 |
If eglBindTexImage is called and the surface attribute EGL_TEXTURE_FORMAT is set |
|
2013 |
to EGL_NO_TEXTURE, then an EGL_BAD_MATCH error is returned. If buffer is already |
|
2014 |
bound to a texture then an EGL_BAD_ACCESS error is returned. If buffer is not a |
|
2015 |
valid buffer, then an EGL_BAD_PARAMETER error is generated. If surface is not a |
|
2016 |
valid EGLSurface, or is not a pbuffer surface supporting texture |
|
2017 |
binding, then an EGL_BAD_SURFACE error is generated. |
|
2018 |
*/ |
|
2019 |
EGLBoolean CGuestEGL::eglBindTexImage(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer) |
|
2020 |
{ |
|
2021 |
// ToDo validate parameters |
|
2022 |
if ( (aBuffer == NULL) || (3 & (TUint)aBuffer)) |
|
2023 |
{ |
|
2024 |
aThreadState.SetEglError(EGL_BAD_PARAMETER); |
|
2025 |
return EGL_FALSE; |
|
2026 |
} |
|
2027 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2028 |
eglApiData.Init(EglRFC::EeglBindTexImage); |
|
2029 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
2030 |
eglApiData.AppendEGLSurface(aSurface); |
|
2031 |
eglApiData.AppendEGLint(aBuffer); |
|
2032 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
2033 |
} |
|
2034 |
||
2035 |
/* |
|
2036 |
If the value of surface attribute EGL_TEXTURE_FORMAT is EGL_NO_TEXTURE, |
|
2037 |
then an EGL_BAD_MATCH error is returned. If buffer is not a valid buffer |
|
2038 |
(currently only EGL_BACK_BUFFER may be specified), then an |
|
2039 |
EGL_BAD_PARAMETER error is generated. If surface is not a valid EGLSurface, |
|
2040 |
or is not a bound pbuffer surface, then an EGL_BAD_SURFACE error is |
|
2041 |
returned. |
|
2042 |
*/ |
|
2043 |
EGLBoolean CGuestEGL::eglReleaseTexImage(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer) |
|
2044 |
{ |
|
2045 |
// ToDo validate parameters |
|
2046 |
if ( (aBuffer == NULL) || (3 & (TUint)aBuffer)) |
|
2047 |
{ |
|
2048 |
aThreadState.SetEglError(EGL_BAD_PARAMETER); |
|
2049 |
return EGL_FALSE; |
|
2050 |
} |
|
2051 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2052 |
eglApiData.Init(EglRFC::EeglReleaseTexImage); |
|
2053 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
2054 |
eglApiData.AppendEGLSurface(aSurface); |
|
2055 |
eglApiData.AppendEGLint(aBuffer); |
|
2056 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
2057 |
} |
|
2058 |
||
2059 |
/* |
|
2060 |
Returns EGL_FALSE on failure. If there is no current context on the calling |
|
2061 |
thread, a EGL_BAD_CONTEXT error is generated. If there is no surface bound |
|
2062 |
to the current context, a EGL_BAD_SURFACE error is generated. |
|
2063 |
*/ |
|
2064 |
EGLBoolean CGuestEGL::eglSwapInterval(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLint aInterval) |
|
2065 |
{ |
|
2066 |
// ToDo validate parameters |
|
2067 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2068 |
eglApiData.Init(EglRFC::EeglSwapInterval); |
|
2069 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
2070 |
eglApiData.AppendEGLint(aInterval); |
|
2071 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
2072 |
} |
|
2073 |
||
2074 |
/* |
|
2075 |
On failure returns EGL_NO_CONTEXT. If the current rendering api is EGL_NONE, |
|
2076 |
then an EGL_BAD_MATCH error is generated (this situation can only arise in |
|
2077 |
an implementation which does not support OpenGL ES, and prior to the first |
|
2078 |
call to eglBindAPI). If share context is neither zero nor a valid context |
|
2079 |
of the same client API type as the newly created context, then an EGL_- |
|
2080 |
BAD_CONTEXT error is generated. |
|
2081 |
||
2082 |
... |
|
2083 |
*/ |
|
2084 |
EGLContext CGuestEGL::eglCreateContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, |
|
2085 |
EGLContext aShareContext, const EGLint *aAttribList) |
|
2086 |
{ |
|
2087 |
EGLContext result = EGL_NO_CONTEXT; |
|
2088 |
iDisplayMapLock.ReadLock(); |
|
2089 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
2090 |
if (!pDispInfo || !*pDispInfo) |
|
2091 |
{ |
|
2092 |
EGL_TRACE("cannot find display %d", aDisplay); |
|
2093 |
} |
|
2094 |
else |
|
2095 |
{ |
|
2096 |
CEglContext* shareContext = NULL; |
|
2097 |
if (aShareContext) |
|
2098 |
{ |
|
2099 |
CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aShareContext); |
|
2100 |
if (!pContext || (*pContext)->IsDestroyed()) |
|
2101 |
{ |
|
2102 |
EGL_TRACE("cannot find share context %d for display %d, or it is destroyed", aShareContext, aDisplay); |
|
2103 |
aThreadState.SetEglError(EGL_BAD_CONTEXT); |
|
2104 |
iDisplayMapLock.Unlock(); |
|
2105 |
return EGL_NO_CONTEXT; |
|
2106 |
} |
|
2107 |
} |
|
2108 |
||
2109 |
CEglContext* newContext = CEglContext::Create(aThreadState, aDisplay, aConfig, shareContext, aAttribList); |
|
2110 |
if (newContext) |
|
2111 |
{ |
|
2112 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
2113 |
TInt err = (*pDispInfo)->iContextMap.Insert(newContext->ClientContext(), newContext); |
|
2114 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
2115 |
if (err != KErrNone) |
|
2116 |
{ |
|
2117 |
newContext->Destroy(aThreadState); |
|
2118 |
aThreadState.SetEglError(EGL_BAD_ALLOC); |
|
2119 |
} |
|
2120 |
else |
|
2121 |
{ |
|
2122 |
result = newContext->ClientContext(); |
|
2123 |
} |
|
2124 |
} |
|
2125 |
} |
|
2126 |
||
2127 |
iDisplayMapLock.Unlock(); |
|
2128 |
return result; |
|
2129 |
} |
|
2130 |
||
2131 |
/* |
|
2132 |
Returns EGL_FALSE on failure. An EGL_BAD_CONTEXT error is generated if ctx is |
|
2133 |
not a valid context. |
|
2134 |
*/ |
|
2135 |
EGLBoolean CGuestEGL::eglDestroyContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLContext aContext) |
|
2136 |
{ |
|
2137 |
EGLBoolean success = EGL_FALSE; |
|
2138 |
iDisplayMapLock.ReadLock(); |
|
2139 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
2140 |
if (!pDispInfo || !*pDispInfo) |
|
2141 |
{ |
|
2142 |
EGL_TRACE("cannot find display %d", aDisplay); |
|
2143 |
aThreadState.SetEglError(EGL_BAD_DISPLAY); |
|
2144 |
} |
|
2145 |
else |
|
2146 |
{ |
|
2147 |
CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext); |
|
2148 |
if (!pContext || (*pContext)->IsDestroyed()) |
|
2149 |
{ |
|
2150 |
EGL_TRACE("cannot find context %d for display %d, or it is destroyed", aContext, aDisplay); |
|
2151 |
aThreadState.SetEglError(EGL_BAD_CONTEXT); |
|
2152 |
} |
|
2153 |
else |
|
2154 |
{ |
|
2155 |
success = EGL_TRUE; |
|
2156 |
if ((*pContext)->Destroy(aThreadState)) |
|
2157 |
{ |
|
2158 |
RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap(); |
|
2159 |
(*pDispInfo)->iContextMap.Remove(aContext); |
|
2160 |
CVghwUtils::SwitchFromVghwHeap(threadHeap); |
|
2161 |
} |
|
2162 |
EGL_TRACE("eglDestroyContext end"); |
|
2163 |
} |
|
2164 |
} |
|
2165 |
||
2166 |
iDisplayMapLock.Unlock(); |
|
2167 |
return success; |
|
2168 |
} |
|
2169 |
||
2170 |
/* |
|
2171 |
Returns EGL_FALSE on failure and value is not updated. If attribute is not |
|
2172 |
a valid EGL context attribute, then an EGL_BAD_ATTRIBUTE error is generated. |
|
2173 |
If ctx is invalid, an EGL_BAD_CONTEXT error is generated. |
|
2174 |
*/ |
|
2175 |
EGLBoolean CGuestEGL::eglQueryContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLContext aContext, EGLint aAttribute, EGLint *aValue) |
|
2176 |
{ |
|
2177 |
EGLBoolean success = EGL_FALSE; |
|
2178 |
iDisplayMapLock.ReadLock(); |
|
2179 |
CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay); |
|
2180 |
if (!pDispInfo || !*pDispInfo) |
|
2181 |
{ |
|
2182 |
EGL_TRACE("cannot find display %d", aDisplay); |
|
2183 |
aThreadState.SetEglError(EGL_BAD_DISPLAY); |
|
2184 |
} |
|
2185 |
else |
|
2186 |
{ |
|
2187 |
CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext); |
|
2188 |
if (!pContext || (*pContext)->IsDestroyed()) |
|
2189 |
{ |
|
2190 |
EGL_TRACE("cannot find context %d for display %d, or it is destroyed", aContext, aDisplay); |
|
2191 |
aThreadState.SetEglError(EGL_BAD_CONTEXT); |
|
2192 |
} |
|
2193 |
else |
|
2194 |
{ |
|
2195 |
success = (*pContext)->QueryAttribute(aThreadState, aAttribute, aValue); |
|
2196 |
} |
|
2197 |
} |
|
2198 |
||
2199 |
iDisplayMapLock.Unlock(); |
|
2200 |
return success; |
|
2201 |
} |
|
2202 |
||
2203 |
/* |
|
2204 |
On failure returns EGL_NO_SURFACE. If the pbuffer could not be created due |
|
2205 |
to insufficient resources, then an EGL_BAD_ALLOC error is generated. If |
|
2206 |
config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If |
|
2207 |
the value specified for either EGL_WIDTH or EGL_HEIGHT is less than zero, |
|
2208 |
an EGL_BAD_PARAMETER error is generated. If config does not support |
|
2209 |
pbuffers, an EGL_BAD_MATCH error is generated. |
|
2210 |
||
2211 |
... see also comment on exported API |
|
2212 |
*/ |
|
2213 |
EGLSurface CGuestEGL::eglCreatePbufferSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const EGLint *aAttribList) |
|
2214 |
{ |
|
2215 |
// ToDo validate parameters |
|
2216 |
// ToDo store info about surface |
|
2217 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2218 |
eglApiData.Init(EglRFC::EeglCreatePbufferSurface); |
|
2219 |
eglApiData.AppendEGLDisplay(aDisplay); |
|
2220 |
eglApiData.AppendEGLConfig(aConfig); |
|
2221 |
eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) ); |
|
2222 |
return aThreadState.ExecEglBooleanCmd(eglApiData); |
|
2223 |
} |
|
2224 |
||
2225 |
/* |
|
2226 |
If there is no current context for the current rendering API, or if the |
|
2227 |
current rendering API is EGL_NONE, then EGL_NO_CONTEXT is returned (this |
|
2228 |
is not an error). |
|
2229 |
*/ |
|
2230 |
EGLContext CGuestEGL::eglGetCurrentContext(TEglThreadState& aThreadState) |
|
2231 |
{ |
|
2232 |
// ToDo should have this information cached |
|
2233 |
RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata ); |
|
2234 |
eglApiData.Init(EglRFC::EeglGetCurrentContext); |
|
2235 |
return ExecEglContextNoErrorCmd(aThreadState, eglApiData); |
|
2236 |
} |
|
2237 |
||
2238 |
/** |
|
2239 |
* |
|
2240 |
* |
|
2241 |
* @param aConfigs handle to an EGLConfig pointer, where the new configuration data will be. Ownership is transferred to the client. |
|
2242 |
* @param aConfigsCnt number of configs that will be in aConfigs upon returning |
|
2243 |
* |
|
2244 |
* @param aConfigAttribs handle to a pointer, where the memory will be allocated, and data copied. This will contain a list of |
|
2245 |
* config attribute _values_, in the order set out in eglrfc::MetaGetConfigAttribute(). |
|
2246 |
* Format: c1attrval1, c1attrval2, ..., c2attrval1, c2attrval2, ... cNattrvalM |
|
2247 |
* (the number of attribute values per config is eglrfc::MetaGetConfigAttributeCnt() |
|
2248 |
* Ownership is transferred to the client. |
|
2249 |
* @param aConfigAttribsLen handle to an integer value, where the size of the above vector will be stored. |
|
2250 |
* @param aFetchMode: which configs to fetch, default = EMetaGetConfigsSg (get configs that support sgImage), possible values are |
|
2251 |
* EMetaGetConfigsAll, //get all the configs available |
|
2252 |
* EMetaGetConfigsSg, //get configs supporting sg images |
|
2253 |
* EMetaGetConfigsNonSg, //get configs not supporting sg images |
|
2254 |
* (only sgImage implemented!) |
|
2255 |
* |
|
2256 |
*/ |
|
2257 |
TBool CGuestEGL::EglInternalFunction_MetaGetConfigs(TEglThreadState& aThreadState, EGLConfig*& aConfigs, EGLint& aConfigCnt, EGLint*& aConfigAttribs, EGLint& aConfigAttribsLen, TMetaGetConfigsMode aFetchMode ) |
|
2258 |
{ |
|
2259 |
aConfigCnt = KConfigsMaxCnt; |
|
2260 |
//TODO: optimize this so that the length is the number of returned items |
|
2261 |
aConfigs = (EGLConfig*) CVghwUtils::Alloc( sizeof(EGLConfig) * aConfigCnt ); |
|
2262 |
aConfigAttribsLen = KConfigsMaxCnt * 29; |
|
2263 |
//TODO: optimize this so that the length is the number of returned items |
|
2264 |
aConfigAttribs = (EGLint*) CVghwUtils::Alloc( sizeof(EGLint) * aConfigAttribsLen ); |
|
2265 |
||
2266 |
RemoteFunctionCallData rfcdata; EglRFC call( rfcdata ); |
|
2267 |
call.Init( EglRFC::EeglMetaGetConfigs ); |
|
2268 |
call.AppendEGLintVector( aConfigs, aConfigCnt, RemoteFunctionCallData::EInOut ); |
|
2269 |
call.AppendEGLintVector( aConfigAttribs, aConfigAttribsLen, RemoteFunctionCallData::EInOut ); |
|
2270 |
||
2271 |
call.AppendEGLint( (EGLint)aFetchMode ); |
|
2272 |
||
2273 |
return aThreadState.ExecEglBooleanCmd( call ); |
|
2274 |
} |
|
2275 |
||
2276 |
||
2277 |
// Private interfaces for EGL to call into Open VG & Open GL ES |
|
2278 |
// class MVgApiForEgl - redirects via CVghwUtils to exported functions from Open VG |
|
2279 |
ExtensionProcPointer CGuestEGL::guestGetVgProcAddress (const char *aProcName) |
|
2280 |
{ |
|
2281 |
if (!iVgApiForEgl) |
|
2282 |
{ |
|
2283 |
iVgApiForEgl = CVghwUtils::VgApiForEgl(); |
|
2284 |
} |
|
2285 |
if (iVgApiForEgl) |
|
2286 |
{ |
|
2287 |
return iVgApiForEgl->guestGetVgProcAddress(aProcName); |
|
2288 |
} |
|
2289 |
return NULL; |
|
2290 |
} |
|
2291 |
||
2292 |
||
2293 |
// class MGles11ApiForEgl - redirects via CVghwUtils to exported functions from Open GL ES 1.1 |
|
2294 |
ExtensionProcPointer CGuestEGL::guestGetGles11ProcAddress (const char *aProcName) |
|
2295 |
{ |
|
2296 |
if (!iGles11ApiForEgl) |
|
2297 |
{ |
|
2298 |
iGles11ApiForEgl = CVghwUtils::Gles11ApiForEgl(); |
|
2299 |
} |
|
2300 |
if (iGles11ApiForEgl) |
|
2301 |
{ |
|
2302 |
return iGles11ApiForEgl->guestGetGles11ProcAddress(aProcName); |
|
2303 |
} |
|
2304 |
return NULL; |
|
2305 |
} |
|
2306 |
||
2307 |
||
2308 |
// class MGles2ApiForEgl - redirects via CVghwUtils to exported functions from Open GL ES 2 |
|
2309 |
ExtensionProcPointer CGuestEGL::guestGetGles2ProcAddress (const char *aProcName) |
|
2310 |
{ |
|
2311 |
if (!iGles2ApiForEgl) |
|
2312 |
{ |
|
2313 |
iGles2ApiForEgl = CVghwUtils::Gles2ApiForEgl(); |
|
2314 |
} |
|
2315 |
if (iGles2ApiForEgl) |
|
2316 |
{ |
|
2317 |
return iGles2ApiForEgl->guestGetGles2ProcAddress(aProcName); |
|
2318 |
} |
|
2319 |
return NULL; |
|
2320 |
} |