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