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 |
// EGL sync implementation
|
|
15 |
|
|
16 |
#include "eglapi.h"
|
|
17 |
|
|
18 |
const EGLint CEglSync::KSupportedFlags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR;
|
|
19 |
|
|
20 |
// ToDo get rid of these macros
|
|
21 |
#define EGL_SET_ERROR(e) { Instance().SetError(e); }
|
|
22 |
#define TEST_AND_RET(c, r, t) { if (!(c)) { EGL_TRACE(t); return (r); } }
|
|
23 |
#define TEST_CLEANUP_RET(c, r, clnp, t) { if (!(c)) { clnp; EGL_TRACE(t); return (r); } }
|
|
24 |
#define CHECK_AND_RET(c, e, r, t) { if (!(c)) { EGL_SET_ERROR(e); EGL_TRACE(t); return (r); } }
|
|
25 |
#define CHECK_CLEANUP_RET(c, e, r, clnp, t) { if (!(c)) { EGL_SET_ERROR(e); clnp; EGL_TRACE(t); return (r); } }
|
|
26 |
#define RESET_EGL_ERROR() { EGL_SET_ERROR(EGL_SUCCESS); }
|
|
27 |
|
|
28 |
// ToDo use EGL Panics & panic messages
|
|
29 |
void SyncPanic(TInt aPanic)
|
|
30 |
{
|
|
31 |
_LIT(KPanic, "EGL SYNC");
|
|
32 |
User::Panic(KPanic, aPanic);
|
|
33 |
}
|
|
34 |
|
|
35 |
CEglSync* CEglSync::Create(RFastLock& aFrontLock, EGLSyncKHR aSync, EGLDisplay aDisplay, EGLenum aType)
|
|
36 |
{
|
|
37 |
CEglSync* sync= new CEglSync(aFrontLock, aSync, aDisplay, aType);
|
|
38 |
TEST_AND_RET(sync != NULL, sync, "CEglSync::Create couldn't create the object");
|
|
39 |
if (KErrNone == sync->Initialize())
|
|
40 |
{
|
|
41 |
EGL_TRACE("CEglSync::Create OK aDisplay=%d aSync=%d aSyncType=0x%x", aDisplay, aSync, aType);
|
|
42 |
return sync;
|
|
43 |
}
|
|
44 |
else
|
|
45 |
{
|
|
46 |
EGL_TRACE("CEglSync::Create FAILED aDisplay=%d aSync=%d aSyncType=0x%x", aDisplay, aSync, aType);
|
|
47 |
delete sync;
|
|
48 |
return NULL;
|
|
49 |
}
|
|
50 |
}
|
|
51 |
|
|
52 |
TInt CEglSync::Initialize()
|
|
53 |
{
|
|
54 |
TInt err = KErrNone;
|
|
55 |
err = iSyncMutex.CreateLocal();
|
|
56 |
TEST_AND_RET(err == KErrNone, err, "CEglSync::Initialize failed to create mutex");
|
|
57 |
err = iSyncCondVar.CreateLocal();
|
|
58 |
TEST_AND_RET(err == KErrNone, err, "CEglSync::Initialize failed to create cond var");
|
|
59 |
return err;
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
CEglSync::CEglSync(RFastLock& aFrontLock, EGLSyncKHR aSync, EGLDisplay aDisplay, EGLenum aType):
|
|
64 |
iEglSync(aSync),
|
|
65 |
iDisplay(aDisplay),
|
|
66 |
iSyncType(aType),
|
|
67 |
iSyncState(EGL_UNSIGNALED_KHR),
|
|
68 |
iDestroyed(EGL_FALSE),
|
|
69 |
iWaiters(0),
|
|
70 |
iFrontLock(aFrontLock)
|
|
71 |
{
|
|
72 |
|
|
73 |
}
|
|
74 |
|
|
75 |
CEglSync::~CEglSync()
|
|
76 |
{
|
|
77 |
iSyncMutex.Close();
|
|
78 |
iSyncCondVar.Close();
|
|
79 |
EGL_TRACE("CEglSync::~CEglSync iDisplay=%d iEglSync=%d", iDisplay, iEglSync);
|
|
80 |
}
|
|
81 |
|
|
82 |
EGLBoolean CEglSync::DestroySyncReady()
|
|
83 |
{
|
|
84 |
EGL_TRACE("CEglSync::DestroySync iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
|
|
85 |
iSyncMutex.Wait();
|
|
86 |
if (iWaiters == 0)
|
|
87 |
{
|
|
88 |
EGL_TRACE("CEglSync::DestroySync READY TO DESTROY iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
|
|
89 |
iDestroyed = EGL_TRUE;
|
|
90 |
return EGL_TRUE;
|
|
91 |
}
|
|
92 |
else if (!iDestroyed)
|
|
93 |
{
|
|
94 |
EGL_TRACE("CEglSync::DestroySync BROADCAST iDisplay=%d iEglSync=%d iWaiters=%d", iDisplay, iEglSync, iWaiters);
|
|
95 |
iSyncCondVar.Broadcast();
|
|
96 |
}
|
|
97 |
iDestroyed = EGL_TRUE;
|
|
98 |
iSyncMutex.Signal();
|
|
99 |
return EGL_FALSE;
|
|
100 |
}
|
|
101 |
|
|
102 |
|
|
103 |
EGLint CEglSync::SignalSync(EGLenum aMode)
|
|
104 |
{
|
|
105 |
EGL_TRACE("CEglSync::SignalSync aMode=%d", aMode);
|
|
106 |
|
|
107 |
iSyncMutex.Wait();
|
|
108 |
if (aMode != iSyncState)
|
|
109 |
{
|
|
110 |
iSyncState = aMode;
|
|
111 |
if (aMode == EGL_SIGNALED_KHR)
|
|
112 |
{
|
|
113 |
iSyncCondVar.Broadcast();
|
|
114 |
}
|
|
115 |
}
|
|
116 |
|
|
117 |
iSyncMutex.Signal();
|
|
118 |
return EGL_SUCCESS;
|
|
119 |
}
|
|
120 |
|
|
121 |
EGLint CEglSync::ClientWaitSync(EGLint aFlags, EGLTimeKHR aTimeout)
|
|
122 |
{
|
|
123 |
EGL_TRACE("CEglSync::ClientWaitSync aFlags=%d aTimeout=%d", aFlags, aTimeout);
|
|
124 |
|
|
125 |
CHECK_CLEANUP_RET(!(aFlags & (~KSupportedFlags)),
|
|
126 |
EGL_BAD_PARAMETER,
|
|
127 |
EGL_FALSE,
|
|
128 |
iFrontLock.Signal();,
|
|
129 |
"CEglSync::ClientWaitSync bad flags parameter");
|
|
130 |
|
|
131 |
iSyncMutex.Wait();
|
|
132 |
iFrontLock.Signal();
|
|
133 |
|
|
134 |
CHECK_CLEANUP_RET(!iDestroyed ,
|
|
135 |
EGL_BAD_PARAMETER,
|
|
136 |
EGL_FALSE,
|
|
137 |
iSyncMutex.Signal();,
|
|
138 |
"CEglSync::ClientWaitSync sync already destroyed");
|
|
139 |
|
|
140 |
EGLint ret = (EGLint) EGL_FALSE;
|
|
141 |
if (iSyncState == EGL_UNSIGNALED_KHR)
|
|
142 |
{
|
|
143 |
if (aTimeout && (aFlags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR) && (eglGetCurrentContext() != EGL_NO_CONTEXT))
|
|
144 |
{
|
|
145 |
switch(eglQueryAPI())
|
|
146 |
{
|
|
147 |
case EGL_OPENGL_ES_API:
|
|
148 |
//ToDo: make sure these cases are covered
|
|
149 |
//glFlush();
|
|
150 |
break;
|
|
151 |
case EGL_OPENVG_API:
|
|
152 |
//ToDo: make sure these cases are covered
|
|
153 |
//vgFlush();
|
|
154 |
break;
|
|
155 |
default:
|
|
156 |
SyncPanic(__LINE__);
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
switch (aTimeout)
|
|
161 |
{
|
|
162 |
case 0:
|
|
163 |
ret = EGL_TIMEOUT_EXPIRED_KHR;
|
|
164 |
break;
|
|
165 |
|
|
166 |
case EGL_FOREVER_KHR:
|
|
167 |
{
|
|
168 |
EGLint res = KErrNone;
|
|
169 |
++iWaiters;
|
|
170 |
EGL_TRACE("CEglSync::ClientWaitSync iSyncCondVar.Wait");
|
|
171 |
res = iSyncCondVar.Wait(iSyncMutex);
|
|
172 |
--iWaiters;
|
|
173 |
if (res == KErrNone)
|
|
174 |
{
|
|
175 |
ret = EGL_CONDITION_SATISFIED_KHR;
|
|
176 |
}
|
|
177 |
else
|
|
178 |
{
|
|
179 |
ret = EGL_FALSE;
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
}
|
|
183 |
|
|
184 |
default:
|
|
185 |
{
|
|
186 |
/*
|
|
187 |
* Since the supported range of timeout at function RCondVar::TimedWait(mutex, timeout)
|
|
188 |
* is 0 to KMaxTInt, looping mechanism below is used to support 64bit timeout.
|
|
189 |
*/
|
|
190 |
EGLint res = KErrTimedOut;
|
|
191 |
EGL_TRACE("CEglSync::ClientWaitSync iSyncCondVar.TimedWait");
|
|
192 |
for(TInt64 timeoutMicroseconds = aTimeout/1000; (res == KErrTimedOut) && (timeoutMicroseconds > 0); timeoutMicroseconds -= KMaxTInt)
|
|
193 |
{
|
|
194 |
++iWaiters;
|
|
195 |
res = iSyncCondVar.TimedWait(iSyncMutex, (timeoutMicroseconds > KMaxTInt) ? KMaxTInt:timeoutMicroseconds);
|
|
196 |
--iWaiters;
|
|
197 |
}
|
|
198 |
switch (res)
|
|
199 |
{
|
|
200 |
case KErrNone:
|
|
201 |
ret = EGL_CONDITION_SATISFIED_KHR;
|
|
202 |
break;
|
|
203 |
case KErrTimedOut:
|
|
204 |
ret = EGL_TIMEOUT_EXPIRED_KHR;
|
|
205 |
break;
|
|
206 |
default:
|
|
207 |
ret = EGL_FALSE;
|
|
208 |
break;
|
|
209 |
}
|
|
210 |
break;
|
|
211 |
}
|
|
212 |
}
|
|
213 |
}
|
|
214 |
else
|
|
215 |
{
|
|
216 |
ret = EGL_CONDITION_SATISFIED_KHR;
|
|
217 |
EGL_TRACE("CEglSync::ClientWaitSync sync in signalled state");
|
|
218 |
}
|
|
219 |
if (iDestroyed && (iWaiters == 0))
|
|
220 |
{
|
|
221 |
EGL_TRACE("CEglSync::ClientWaitSync sync autodestroyed");
|
|
222 |
delete this;
|
|
223 |
}
|
|
224 |
else
|
|
225 |
{
|
|
226 |
EGL_TRACE("CEglSync::ClientWaitSync release sync mutex");
|
|
227 |
iSyncMutex.Signal();
|
|
228 |
}
|
|
229 |
EGL_TRACE("CEglSync::ClientWaitSync sync exit ret=0x%x", ret);
|
|
230 |
return ret;
|
|
231 |
}
|
|
232 |
|
|
233 |
EGLBoolean CEglSync::GetSyncAttrib(EGLint aAttribute, EGLint *aValue)
|
|
234 |
{
|
|
235 |
EGL_TRACE("CEglSync::GetSyncAttrib aAttribute=0x%x aValue", aValue);
|
|
236 |
|
|
237 |
CHECK_AND_RET(aValue,
|
|
238 |
EGL_BAD_PARAMETER,
|
|
239 |
EGL_FALSE,
|
|
240 |
"CEglSync::GetSyncAttrib undefined parameter aValue is NUL");
|
|
241 |
|
|
242 |
CHECK_AND_RET((aAttribute == EGL_SYNC_TYPE_KHR) || (aAttribute == EGL_SYNC_STATUS_KHR),
|
|
243 |
EGL_BAD_ATTRIBUTE,
|
|
244 |
EGL_FALSE,
|
|
245 |
"CEglSync::GetSyncAttrib unnexpected attribute parameter");
|
|
246 |
|
|
247 |
|
|
248 |
iSyncMutex.Wait();
|
|
249 |
EGLBoolean ret = EGL_FALSE;
|
|
250 |
switch(aAttribute)
|
|
251 |
{
|
|
252 |
case EGL_SYNC_TYPE_KHR:
|
|
253 |
{
|
|
254 |
*aValue = iSyncType;
|
|
255 |
ret = EGL_TRUE;
|
|
256 |
break;
|
|
257 |
}
|
|
258 |
case EGL_SYNC_STATUS_KHR:
|
|
259 |
{
|
|
260 |
*aValue = iSyncState;
|
|
261 |
ret = EGL_TRUE;
|
|
262 |
break;
|
|
263 |
}
|
|
264 |
default:
|
|
265 |
{
|
|
266 |
EGL_SET_ERROR(EGL_BAD_ATTRIBUTE);
|
|
267 |
}
|
|
268 |
}
|
|
269 |
iSyncMutex.Signal();
|
|
270 |
return ret;
|
|
271 |
}
|
|
272 |
|
|
273 |
|
|
274 |
CEglSyncExtension* CEglSyncExtension::Create(CGuestEGL& aEglInstance)
|
|
275 |
{
|
|
276 |
EGL_TRACE("CEglSyncExtension::Create");
|
|
277 |
CEglSyncExtension* eglSyncExt= new CEglSyncExtension(aEglInstance);
|
|
278 |
if (eglSyncExt && eglSyncExt->Construct())
|
|
279 |
{
|
|
280 |
return eglSyncExt;
|
|
281 |
}
|
|
282 |
|
|
283 |
delete eglSyncExt;
|
|
284 |
return NULL;
|
|
285 |
}
|
|
286 |
|
|
287 |
EGLBoolean CEglSyncExtension::Construct()
|
|
288 |
{
|
|
289 |
if (iEglSyncMapLock.CreateLocal() == KErrNone)
|
|
290 |
{
|
|
291 |
EGL_TRACE("CEglSyncExtension::Construct OK");
|
|
292 |
return EGL_TRUE;
|
|
293 |
}
|
|
294 |
|
|
295 |
EGL_TRACE("CEglSyncExtension::Construct FAILED");
|
|
296 |
return EGL_FALSE;
|
|
297 |
}
|
|
298 |
|
|
299 |
CEglSyncExtension::CEglSyncExtension(CGuestEGL& aEglInstance):
|
|
300 |
iEglSyncMap(),
|
|
301 |
iEglSyncId(0),
|
|
302 |
iEglInstance(aEglInstance)
|
|
303 |
{
|
|
304 |
|
|
305 |
}
|
|
306 |
|
|
307 |
CEglSyncExtension::~CEglSyncExtension()
|
|
308 |
{
|
|
309 |
if (iEglSyncMapLock.Handle())
|
|
310 |
{
|
|
311 |
iEglSyncMapLock.Wait();
|
|
312 |
}
|
|
313 |
|
|
314 |
EglDestroySync(EGL_NO_DISPLAY);
|
|
315 |
|
|
316 |
iEglSyncMap.Close();
|
|
317 |
iEglSyncMapLock.Close();
|
|
318 |
}
|
|
319 |
|
|
320 |
TInt CEglSyncExtension::EglSyncDisplayCreate(EGLDisplay aDisplay)
|
|
321 |
{
|
|
322 |
return KErrNone;
|
|
323 |
}
|
|
324 |
|
|
325 |
void CEglSyncExtension::EglDestroySync(EGLDisplay aDisplay)
|
|
326 |
{
|
|
327 |
EGL_TRACE("CEglSyncExtension::EglDestroySync");
|
|
328 |
REglSyncHashMap::TIter iter(iEglSyncMap);
|
|
329 |
|
|
330 |
while (iter.NextKey())
|
|
331 |
{
|
|
332 |
CEglSync* const* syncpp = NULL;
|
|
333 |
syncpp = iter.CurrentValue();
|
|
334 |
if (syncpp && *syncpp && ((aDisplay == EGL_NO_DISPLAY) || (*syncpp)->Display() == aDisplay))
|
|
335 |
{
|
|
336 |
const EGLint* key = iter.CurrentKey();
|
|
337 |
EGLPANIC_ASSERT(key, EEglPanicTemp);
|
|
338 |
if (aDisplay != EGL_NO_DISPLAY)
|
|
339 |
{
|
|
340 |
// we expect that the map is to be closed after removing the elements
|
|
341 |
// therefore we can skip to remove the syncs from map
|
|
342 |
if (KErrNone != iEglSyncMap.Remove(*key))
|
|
343 |
{
|
|
344 |
SyncPanic(__LINE__);
|
|
345 |
}
|
|
346 |
}
|
|
347 |
if ((*syncpp)->DestroySyncReady())
|
|
348 |
{
|
|
349 |
delete *syncpp;
|
|
350 |
}
|
|
351 |
}
|
|
352 |
}
|
|
353 |
}
|
|
354 |
|
|
355 |
void CEglSyncExtension::EglSyncDisplayDestroy(EGLDisplay aDisplay)
|
|
356 |
{
|
|
357 |
iEglSyncMapLock.Wait();
|
|
358 |
EglDestroySync(aDisplay);
|
|
359 |
iEglSyncMapLock.Signal();
|
|
360 |
}
|
|
361 |
|
|
362 |
EGLSyncKHR CEglSyncExtension::EglCreateSyncKHR(EGLDisplay aDisplay, EGLenum aType, const EGLint* aAttribList)
|
|
363 |
{
|
|
364 |
EGL_TRACE("CEglSyncExtension::EglCreateSyncKHR aDisplay=%d, aType=%d", aDisplay, aType);
|
|
365 |
RESET_EGL_ERROR();
|
|
366 |
|
|
367 |
CHECK_AND_RET(aType == EGL_SYNC_REUSABLE_KHR,
|
|
368 |
EGL_BAD_ATTRIBUTE,
|
|
369 |
EGL_NO_SYNC_KHR,
|
|
370 |
"CEglSyncExtension::EglCreateSyncKHR unsupported sync type");
|
|
371 |
|
|
372 |
CHECK_AND_RET((aAttribList == NULL) || (*aAttribList == EGL_NONE),
|
|
373 |
EGL_BAD_ATTRIBUTE,
|
|
374 |
EGL_NO_SYNC_KHR,
|
|
375 |
"CEglSyncExtension::EglCreateSyncKHR invalid attribute list");
|
|
376 |
|
|
377 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
378 |
|
|
379 |
CHECK_AND_RET(lockErr == EGL_SUCCESS,
|
|
380 |
lockErr,
|
|
381 |
EGL_NO_SYNC_KHR,
|
|
382 |
"CEglSyncExtension::EglCreateSyncKHR couldn't find and lock display");
|
|
383 |
|
|
384 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
385 |
|
|
386 |
iEglSyncMapLock.Wait();
|
|
387 |
ReleaseDisplayLock(aDisplay);
|
|
388 |
|
|
389 |
EGLSyncKHR dispRet = CreateSync(aDisplay, aType);
|
|
390 |
|
|
391 |
iEglSyncMapLock.Signal();
|
|
392 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
393 |
EGL_TRACE("CEglSyncExtension::EglCreateSyncKHR EXIT aDisplay=%d, sync=%d", aDisplay, dispRet);
|
|
394 |
return dispRet;
|
|
395 |
}
|
|
396 |
|
|
397 |
EGLBoolean CEglSyncExtension::EglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync)
|
|
398 |
{
|
|
399 |
EGL_TRACE("CEglSyncExtension::EglDestroySyncKHR aDisplay=%d, aSync=%d", aDisplay, aSync);
|
|
400 |
|
|
401 |
RESET_EGL_ERROR();
|
|
402 |
|
|
403 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
404 |
|
|
405 |
CHECK_AND_RET(lockErr == EGL_SUCCESS,
|
|
406 |
lockErr,
|
|
407 |
EGL_FALSE,
|
|
408 |
"CEglSyncExtension::EglDestroySyncKHR couldn't find and lock display");
|
|
409 |
|
|
410 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
411 |
|
|
412 |
iEglSyncMapLock.Wait();
|
|
413 |
ReleaseDisplayLock(aDisplay);
|
|
414 |
|
|
415 |
CEglSync** sync = iEglSyncMap.Find((EGLint)aSync);
|
|
416 |
CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display() == aDisplay),
|
|
417 |
EGL_BAD_PARAMETER,
|
|
418 |
EGL_FALSE,
|
|
419 |
iEglSyncMapLock.Signal(),
|
|
420 |
"CEglSyncDisplayMap::EglDestroySyncKHR cannot find the sync");
|
|
421 |
|
|
422 |
if (KErrNone != iEglSyncMap.Remove((EGLint)aSync))
|
|
423 |
{
|
|
424 |
SyncPanic(__LINE__);
|
|
425 |
}
|
|
426 |
|
|
427 |
if ((*sync)->DestroySyncReady())
|
|
428 |
{
|
|
429 |
delete *sync;
|
|
430 |
}
|
|
431 |
|
|
432 |
iEglSyncMapLock.Signal();
|
|
433 |
|
|
434 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
435 |
EGL_TRACE("CEglSyncExtension::EglDestroySyncKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, "EGL_TRUE");
|
|
436 |
return EGL_TRUE;
|
|
437 |
}
|
|
438 |
|
|
439 |
EGLBoolean CEglSyncExtension::EglSignalSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
|
|
440 |
{
|
|
441 |
EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR aDisplay=%d, aSync=%d aMode=%d", aDisplay, aSync, aMode);
|
|
442 |
EGLBoolean ret = EGL_FALSE;
|
|
443 |
|
|
444 |
RESET_EGL_ERROR();
|
|
445 |
|
|
446 |
CHECK_AND_RET((aMode == EGL_SIGNALED_KHR) || (aMode == EGL_UNSIGNALED_KHR),
|
|
447 |
EGL_BAD_PARAMETER,
|
|
448 |
ret,
|
|
449 |
"CEglSyncExtension::EglSignalSyncKHR unsupported sync mode");
|
|
450 |
|
|
451 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
452 |
|
|
453 |
CHECK_AND_RET(lockErr == EGL_SUCCESS,
|
|
454 |
lockErr,
|
|
455 |
EGL_FALSE,
|
|
456 |
"CEglSyncExtension::EglSignalSyncKHR couldn't find and lock display");
|
|
457 |
|
|
458 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
459 |
|
|
460 |
iEglSyncMapLock.Wait();
|
|
461 |
ReleaseDisplayLock(aDisplay);
|
|
462 |
|
|
463 |
CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
|
|
464 |
|
|
465 |
CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
|
|
466 |
EGL_BAD_PARAMETER,
|
|
467 |
EGL_FALSE,
|
|
468 |
iEglSyncMapLock.Signal(); CVghwUtils::SwitchFromVghwHeap(callerHeap);,
|
|
469 |
"CEglSyncExtension::EglSignalSyncKHR cannot find the lock");
|
|
470 |
|
|
471 |
TEST_CLEANUP_RET((*sync)->Display() == EGL_SYNC_REUSABLE_KHR,
|
|
472 |
EGL_BAD_MATCH,
|
|
473 |
iEglSyncMapLock.Signal(); CVghwUtils::SwitchFromVghwHeap(callerHeap);,
|
|
474 |
"CEglSyncExtension::EglSignalSyncKHR bad sync type");
|
|
475 |
|
|
476 |
EGLint signalRet = (*sync)->SignalSync(aMode);
|
|
477 |
|
|
478 |
if (signalRet != EGL_SUCCESS)
|
|
479 |
{
|
|
480 |
EGL_SET_ERROR(ret);
|
|
481 |
EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR failed (%d)", ret);
|
|
482 |
ret = EGL_FALSE;
|
|
483 |
}
|
|
484 |
else
|
|
485 |
{
|
|
486 |
ret = EGL_TRUE;
|
|
487 |
}
|
|
488 |
|
|
489 |
iEglSyncMapLock.Signal();
|
|
490 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
491 |
EGL_TRACE("CEglSyncExtension::EglSignalSyncKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, ret ? "EGL_TRUE":"EGL_FALSE");
|
|
492 |
return ret;
|
|
493 |
}
|
|
494 |
|
|
495 |
EGLint CEglSyncExtension::Egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
|
|
496 |
{
|
|
497 |
EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR aDisplay=%d, aSync=%d aMode=%d", aDisplay, aSync, aMode);
|
|
498 |
|
|
499 |
TEST_AND_RET((aMode == EGL_SIGNALED_KHR) || (aMode == EGL_UNSIGNALED_KHR),
|
|
500 |
EGL_BAD_PARAMETER,
|
|
501 |
"CEglSyncExtension::EglPrivateSignalSyncKHR unsupported sync mode");
|
|
502 |
|
|
503 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
504 |
|
|
505 |
TEST_AND_RET(lockErr == EGL_SUCCESS,
|
|
506 |
lockErr,
|
|
507 |
"CEglSyncExtension::EglPrivateSignalSyncKHR couldn't find and lock display");
|
|
508 |
|
|
509 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
510 |
|
|
511 |
iEglSyncMapLock.Wait();
|
|
512 |
ReleaseDisplayLock(aDisplay);
|
|
513 |
|
|
514 |
CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
|
|
515 |
|
|
516 |
TEST_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
|
|
517 |
EGL_BAD_PARAMETER,
|
|
518 |
iEglSyncMapLock.Signal(); CVghwUtils::SwitchFromVghwHeap(callerHeap);,
|
|
519 |
"CEglSyncExtension::EglPrivateSignalSyncKHR cannot find the lock");
|
|
520 |
|
|
521 |
EGLint ret = (*sync)->SignalSync(aMode);
|
|
522 |
|
|
523 |
if (ret != EGL_SUCCESS)
|
|
524 |
{
|
|
525 |
EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR failed (%d)", ret);
|
|
526 |
}
|
|
527 |
|
|
528 |
iEglSyncMapLock.Signal();
|
|
529 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
530 |
EGL_TRACE("CEglSyncExtension::EglPrivateSignalSyncKHR EXIT aDisplay=%d, aSync=%d ret=%d", aDisplay, aSync, ret);
|
|
531 |
return ret;
|
|
532 |
}
|
|
533 |
|
|
534 |
EGLint CEglSyncExtension::EglClientWaitSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aFlags, EGLTimeKHR aTimeout)
|
|
535 |
{
|
|
536 |
EGL_TRACE("CEglSyncExtension::EglClientWaitSyncKHR aDisplay=%d, aSync=%d aFlags=0x%x, aTimeout=%ld", aDisplay, aSync, aFlags, aTimeout);
|
|
537 |
|
|
538 |
RESET_EGL_ERROR();
|
|
539 |
|
|
540 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
541 |
|
|
542 |
CHECK_AND_RET(lockErr == EGL_SUCCESS,
|
|
543 |
lockErr,
|
|
544 |
EGL_FALSE,
|
|
545 |
"CEglSyncExtension::EglClientWaitSyncKHR couldn't find and lock display");
|
|
546 |
|
|
547 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
548 |
|
|
549 |
iEglSyncMapLock.Wait();
|
|
550 |
ReleaseDisplayLock(aDisplay);
|
|
551 |
|
|
552 |
CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
|
|
553 |
|
|
554 |
CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
|
|
555 |
EGL_BAD_PARAMETER,
|
|
556 |
EGL_FALSE,
|
|
557 |
iEglSyncMapLock.Signal(); CVghwUtils::SwitchFromVghwHeap(callerHeap);,
|
|
558 |
"CEglSyncExtension::EglClientWaitSyncKHR cannot find the sync");
|
|
559 |
|
|
560 |
EGLint ret = (*sync)->ClientWaitSync(aFlags, aTimeout);
|
|
561 |
|
|
562 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
563 |
EGL_TRACE("CEglSyncExtension::EglClientWaitSyncKHR EXIT aDisplay=%d, aSync=%d ret=%d", aDisplay, aSync, ret);
|
|
564 |
return ret;
|
|
565 |
}
|
|
566 |
|
|
567 |
EGLBoolean CEglSyncExtension::EglGetSyncAttribKHR(EGLDisplay aDisplay,
|
|
568 |
EGLSyncKHR aSync,
|
|
569 |
EGLint aAttribute,
|
|
570 |
EGLint* aValue)
|
|
571 |
{
|
|
572 |
EGL_TRACE("CEglSyncExtension::EglGetSyncAttribKHR aDisplay=%d, aSync=%d aAttribute=0x%x, aValue=0x%x", aDisplay,
|
|
573 |
aSync,
|
|
574 |
aAttribute,
|
|
575 |
aValue);
|
|
576 |
RESET_EGL_ERROR();
|
|
577 |
|
|
578 |
EGLint lockErr = FindAndLockDisplay(aDisplay);
|
|
579 |
|
|
580 |
CHECK_AND_RET(lockErr == EGL_SUCCESS,
|
|
581 |
lockErr,
|
|
582 |
EGL_FALSE,
|
|
583 |
"CEglSyncExtension::EglGetSyncAttribKHR couldn't find and lock display");
|
|
584 |
|
|
585 |
RHeap* callerHeap = CVghwUtils::SwitchToVghwHeap();
|
|
586 |
|
|
587 |
iEglSyncMapLock.Wait();
|
|
588 |
ReleaseDisplayLock(aDisplay);
|
|
589 |
|
|
590 |
CEglSync** sync= iEglSyncMap.Find((EGLint)aSync);
|
|
591 |
|
|
592 |
CHECK_CLEANUP_RET(sync && (*sync) && ((*sync)->Display()==aDisplay),
|
|
593 |
EGL_BAD_PARAMETER,
|
|
594 |
EGL_FALSE,
|
|
595 |
iEglSyncMapLock.Signal(); CVghwUtils::SwitchFromVghwHeap(callerHeap);,
|
|
596 |
"CEglSyncExtension::EglGetSyncAttribKHR cannot find the lock");
|
|
597 |
|
|
598 |
|
|
599 |
EGLint ret = (*sync)->GetSyncAttrib(aAttribute, aValue);
|
|
600 |
|
|
601 |
iEglSyncMapLock.Signal();
|
|
602 |
|
|
603 |
CVghwUtils::SwitchFromVghwHeap(callerHeap);
|
|
604 |
|
|
605 |
EGL_TRACE("CEglSyncExtension::EglGetSyncAttribKHR EXIT aDisplay=%d, aSync=%d ret=%s", aDisplay, aSync, ret ? "EGL_TRUE":"EGL_FALSE");
|
|
606 |
return ret;
|
|
607 |
}
|
|
608 |
|
|
609 |
EGLint CEglSyncExtension::FindAndLockDisplay(EGLDisplay aDisplay)
|
|
610 |
{
|
|
611 |
return iEglInstance.FindAndLockDisplay(aDisplay);
|
|
612 |
}
|
|
613 |
|
|
614 |
void CEglSyncExtension::ReleaseDisplayLock(EGLDisplay aDisplay)
|
|
615 |
{
|
|
616 |
iEglInstance.ReleaseDisplayLock(aDisplay);
|
|
617 |
}
|
|
618 |
|
|
619 |
EGLSyncKHR CEglSyncExtension::CreateSync(EGLDisplay aDisplay, EGLenum aType)
|
|
620 |
{
|
|
621 |
CEglSync* sync = CEglSync::Create(iEglSyncMapLock,
|
|
622 |
(EGLSyncKHR)(++iEglSyncId),
|
|
623 |
aDisplay,
|
|
624 |
aType);
|
|
625 |
|
|
626 |
CHECK_AND_RET(sync != NULL,
|
|
627 |
EGL_BAD_ALLOC,
|
|
628 |
EGL_NO_SYNC_KHR,
|
|
629 |
"CEglSyncDisplayMap::CreateSync failed to create sync");
|
|
630 |
|
|
631 |
TInt err = KErrNone;
|
|
632 |
err = iEglSyncMap.Insert(iEglSyncId, sync);
|
|
633 |
|
|
634 |
CHECK_CLEANUP_RET(err == KErrNone,
|
|
635 |
EGL_BAD_ALLOC,
|
|
636 |
EGL_NO_SYNC_KHR,
|
|
637 |
delete sync,
|
|
638 |
"CEglSyncDisplayMap::CreateSync insert failed");
|
|
639 |
|
|
640 |
return (EGLSyncKHR)iEglSyncId;
|
|
641 |
}
|
|
642 |
|
|
643 |
EGLSyncKHR CEglSyncExtension::eglCreateSyncKHR(EGLDisplay aDisplay, EGLenum aType, const EGLint* aAttribList)
|
|
644 |
{
|
|
645 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
646 |
CHECK_AND_RET(eglSyncInstance,
|
|
647 |
EGL_NOT_INITIALIZED,
|
|
648 |
EGL_NO_SYNC_KHR,
|
|
649 |
"CEglSyncExtension::eglCreateSyncKHR extension instance not created");
|
|
650 |
|
|
651 |
return eglSyncInstance->EglCreateSyncKHR(aDisplay, aType, aAttribList);
|
|
652 |
}
|
|
653 |
|
|
654 |
EGLBoolean CEglSyncExtension::eglDestroySyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync)
|
|
655 |
{
|
|
656 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
657 |
CHECK_AND_RET(eglSyncInstance,
|
|
658 |
EGL_NOT_INITIALIZED,
|
|
659 |
EGL_FALSE,
|
|
660 |
"CEglSyncExtension::eglDestroySyncKHR extension instance not created");
|
|
661 |
|
|
662 |
return eglSyncInstance->EglDestroySyncKHR(aDisplay, aSync);
|
|
663 |
}
|
|
664 |
|
|
665 |
EGLint CEglSyncExtension::eglClientWaitSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aFlags, EGLTimeKHR aTimeout)
|
|
666 |
{
|
|
667 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
668 |
CHECK_AND_RET(eglSyncInstance,
|
|
669 |
EGL_NOT_INITIALIZED,
|
|
670 |
EGL_FALSE,
|
|
671 |
"CEglSyncExtension::eglGetSyncAttribKHR extension instance not created");
|
|
672 |
|
|
673 |
return eglSyncInstance->EglClientWaitSyncKHR(aDisplay, aSync, aFlags, aTimeout);
|
|
674 |
}
|
|
675 |
|
|
676 |
EGLBoolean CEglSyncExtension::eglSignalSyncKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
|
|
677 |
{
|
|
678 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
679 |
CHECK_AND_RET(eglSyncInstance,
|
|
680 |
EGL_NOT_INITIALIZED,
|
|
681 |
EGL_FALSE,
|
|
682 |
"CEglSyncExtension::eglSignalSyncKHR extension instance not created");
|
|
683 |
|
|
684 |
return eglSyncInstance->EglSignalSyncKHR(aDisplay, aSync, aMode);
|
|
685 |
}
|
|
686 |
|
|
687 |
|
|
688 |
EGLBoolean CEglSyncExtension::eglGetSyncAttribKHR(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLint aAttribute, EGLint* aValue)
|
|
689 |
{
|
|
690 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
691 |
CHECK_AND_RET(eglSyncInstance,
|
|
692 |
EGL_NOT_INITIALIZED,
|
|
693 |
EGL_FALSE,
|
|
694 |
"CEglSyncExtension::eglGetSyncAttribKHR extension instance not created");
|
|
695 |
|
|
696 |
return eglSyncInstance->EglGetSyncAttribKHR(aDisplay, aSync, aAttribute, aValue);
|
|
697 |
}
|
|
698 |
|
|
699 |
EGLint CEglSyncExtension::egl_Private_SignalSyncNOK(EGLDisplay aDisplay, EGLSyncKHR aSync, EGLenum aMode)
|
|
700 |
{
|
|
701 |
CEglSyncExtension* eglSyncInstance = Instance().EGLSyncExtension();
|
|
702 |
CHECK_AND_RET(eglSyncInstance,
|
|
703 |
EGL_NOT_INITIALIZED,
|
|
704 |
EGL_NOT_INITIALIZED,
|
|
705 |
"CEglSyncExtension::egl_Private_SignalSyncNOK extension instance not created");
|
|
706 |
|
|
707 |
return eglSyncInstance->Egl_Private_SignalSyncNOK(aDisplay, aSync, aMode);
|
|
708 |
}
|