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