26 * |
26 * |
27 *//** |
27 *//** |
28 * \file |
28 * \file |
29 * \brief Simple implementation of EGL 1.3 |
29 * \brief Simple implementation of EGL 1.3 |
30 * \note caveats: |
30 * \note caveats: |
31 - always renders into the backbuffer and blits it to window (no single buffered rendering) |
31 - always renders into the backbuffer and blits it to window (no single buffered rendering) |
32 - no native Windows or Mac OS X pixmap support |
32 - no native Windows or Mac OS X pixmap support |
33 - no power management events |
33 - no power management events |
34 - no support for swap interval |
34 - no support for swap interval |
35 * \todo what happens in egl functions when eglTerminate has been called but the context and surface are still in use? |
35 * \todo what happens in egl functions when eglTerminate has been called but the context and surface are still in use? |
36 * \todo OSDeinitMutex should be called in case getEGL fails. |
36 * \todo OSDeinitMutex should be called in case getEGL fails. |
37 *//*-------------------------------------------------------------------*/ |
37 *//*-------------------------------------------------------------------*/ |
38 |
38 |
39 #include "riMiniEGL.h" |
39 #include "riMiniEGL.h" |
40 #include "eglprivate.h" |
40 #include "eglprivate.h" |
|
41 #include "riMath.h" |
41 #include <e32debug.h> |
42 #include <e32debug.h> |
|
43 |
|
44 //============================================================================================== |
|
45 |
42 namespace OpenVGRI |
46 namespace OpenVGRI |
43 { |
47 { |
44 //using namespace OpenVGRI; |
48 void* OSGetCurrentThreadID(void); |
|
49 void OSAcquireMutex(void); |
|
50 void OSReleaseMutex(void); |
|
51 void OSDeinitMutex(void); |
|
52 |
|
53 EGLDisplay OSGetDisplay(EGLNativeDisplayType display_id); |
|
54 void* OSCreateWindowContext(EGLNativeWindowType window); |
|
55 void OSDestroyWindowContext(void* context); |
|
56 bool OSIsWindow(const void* context); |
|
57 void OSGetWindowSize(const void* context, int& width, int& height); |
|
58 void OSBlitToWindow(void* context, const Drawable* drawable); |
|
59 EGLBoolean OSGetNativePixmapInfo(NativePixmapType pixmap, int* width, int* height, int* stride, VGImageFormat* format, int** data); |
|
60 |
|
61 |
|
62 |
|
63 /*-------------------------------------------------------------------*//*! |
|
64 * \brief |
|
65 * \param |
|
66 * \return |
|
67 * \note |
|
68 *//*-------------------------------------------------------------------*/ |
|
69 |
|
70 class RIEGLContext |
|
71 { |
|
72 public: |
|
73 RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config); |
|
74 ~RIEGLContext(); |
|
75 void addReference() { m_referenceCount++; } |
|
76 int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; } |
|
77 |
|
78 VGContext* getVGContext() const { return m_vgContext; } |
|
79 EGLConfig getConfig() const { return m_config; } |
|
80 private: |
|
81 RIEGLContext(const RIEGLContext&); |
|
82 RIEGLContext& operator=(const RIEGLContext&); |
|
83 VGContext* m_vgContext; |
|
84 const EGLConfig m_config; |
|
85 int m_referenceCount; |
|
86 }; |
|
87 |
|
88 RIEGLContext* CastToRIEGLContext(EGLContext aCtxId); |
|
89 EGLContext CastFromRIEGLContext(RIEGLContext* aCtx); |
45 |
90 |
46 RIEGLContext::RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config) : |
91 RIEGLContext::RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config) : |
47 m_vgContext(vgctx), m_config(config), m_referenceCount(0) |
92 m_vgContext(vgctx), |
48 { |
93 m_config(config), |
49 } |
94 m_referenceCount(0) |
|
95 { |
|
96 } |
50 RIEGLContext::~RIEGLContext() |
97 RIEGLContext::~RIEGLContext() |
51 { |
98 { |
52 RI_ASSERT(m_referenceCount == 0); |
99 RI_ASSERT(m_referenceCount == 0); |
53 RI_DELETE(m_vgContext); |
100 RI_DELETE(m_vgContext); |
54 } |
101 } |
55 |
102 |
56 /*-------------------------------------------------------------------*//*! |
103 /*-------------------------------------------------------------------*//*! |
57 * \brief |
104 * \brief |
58 * \param |
105 * \param |
59 * \return |
106 * \return |
60 * \note |
107 * \note |
61 *//*-------------------------------------------------------------------*/ |
108 *//*-------------------------------------------------------------------*/ |
62 |
109 |
63 RIEGLSurface::RIEGLSurface(void* OSWindowContext, const EGLConfig config, |
110 class RIEGLSurface |
64 Drawable* drawable, bool largestPbuffer, int renderBuffer) : |
111 { |
65 m_OSWindowContext(OSWindowContext), m_config(config), m_drawable(drawable), |
112 public: |
66 m_largestPbuffer(largestPbuffer), m_renderBuffer(renderBuffer), |
113 RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer); |
67 m_referenceCount(0) |
114 ~RIEGLSurface(); |
68 { |
115 void addReference() { m_referenceCount++; } |
69 RI_ASSERT(m_renderBuffer == EGL_BACK_BUFFER); //only back buffer rendering is supported |
116 int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; } |
70 m_drawable->addReference(); |
117 |
71 } |
118 void* getOSWindowContext() const { return m_OSWindowContext; } |
|
119 EGLConfig getConfig() const { return m_config; } |
|
120 Drawable* getDrawable() const { return m_drawable; } |
|
121 bool isLargestPbuffer() const { return m_largestPbuffer; } |
|
122 int getRenderBuffer() const { return m_renderBuffer; } |
|
123 |
|
124 private: |
|
125 RIEGLSurface(const RIEGLSurface&); |
|
126 RIEGLSurface& operator=(const RIEGLSurface&); |
|
127 void* m_OSWindowContext; |
|
128 const EGLConfig m_config; |
|
129 Drawable* m_drawable; |
|
130 bool m_largestPbuffer; |
|
131 int m_renderBuffer; //EGL_BACK_BUFFER or EGL_SINGLE_BUFFER |
|
132 int m_referenceCount; |
|
133 }; |
|
134 |
|
135 RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId); |
|
136 EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface); |
|
137 |
|
138 RIEGLSurface::RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer) : |
|
139 m_OSWindowContext(OSWindowContext), |
|
140 m_config(config), |
|
141 m_drawable(drawable), |
|
142 m_largestPbuffer(largestPbuffer), |
|
143 m_renderBuffer(renderBuffer), |
|
144 m_referenceCount(0) |
|
145 { |
|
146 RI_ASSERT(m_renderBuffer == EGL_BACK_BUFFER); //only back buffer rendering is supported |
|
147 m_drawable->addReference(); |
|
148 } |
72 |
149 |
73 RIEGLSurface::~RIEGLSurface() |
150 RIEGLSurface::~RIEGLSurface() |
74 { |
151 { |
75 RI_ASSERT(m_referenceCount == 0); |
152 RI_ASSERT(m_referenceCount == 0); |
76 OSDestroyWindowContext(m_OSWindowContext); |
153 OSDestroyWindowContext(m_OSWindowContext); |
77 if (m_drawable) |
154 if(m_drawable) |
78 { |
155 { |
79 if (!m_drawable->removeReference()) |
156 if(!m_drawable->removeReference()) |
80 RI_DELETE(m_drawable); |
157 RI_DELETE(m_drawable); |
81 } |
158 } |
82 } |
159 } |
83 |
160 |
84 RIEGLDisplay::RIEGLDisplay(EGLDisplay id) : |
161 RIEGLDisplay::RIEGLDisplay(EGLDisplay id) : |
85 m_id(id), m_contexts(), m_surfaces() |
162 m_id(id), |
86 { |
163 m_contexts(), |
|
164 m_surfaces() |
|
165 { |
87 RI_ASSERT(EGL_NUMCONFIGS == 60); |
166 RI_ASSERT(EGL_NUMCONFIGS == 60); |
88 |
167 |
89 //sorted by RGB/LUMINANCE (exact), larger total number of color bits (at least), buffer size (at least), config ID (exact) |
168 //sorted by RGB/LUMINANCE (exact), larger total number of color bits (at least), buffer size (at least), config ID (exact) |
90 //NOTE: 16 bit configs need to be sorted on the fly if the request ignores some channels |
169 //NOTE: 16 bit configs need to be sorted on the fly if the request ignores some channels |
91 //NOTE: config IDs start from 1 |
170 //NOTE: config IDs start from 1 |
92 // R B G A L bpp samples maskBits ID |
171 // R B G A L bpp samples maskBits ID |
93 m_configs[0].set(8, 8, 8, 8, 0, 32, 1, 8, 1); //EGL_RGB_BUFFER, buffer size = 32 |
172 m_configs[0].set(8, 8, 8, 8, 0, 32, 1, 8, 1); //EGL_RGB_BUFFER, buffer size = 32 |
94 m_configs[1].set(8, 8, 8, 0, 0, 32, 1, 8, 2); //EGL_RGB_BUFFER, buffer size = 24 |
173 m_configs[1].set(8, 8, 8, 0, 0, 32, 1, 8, 2); //EGL_RGB_BUFFER, buffer size = 24 |
95 m_configs[2].set(5, 5, 5, 1, 0, 16, 1, 4, 3); //EGL_RGB_BUFFER, buffer size = 16 |
174 m_configs[2].set(5, 5, 5, 1, 0, 16, 1, 4, 3); //EGL_RGB_BUFFER, buffer size = 16 |
96 m_configs[3].set(5, 6, 5, 0, 0, 16, 1, 4, 4); //EGL_RGB_BUFFER, buffer size = 16 |
175 m_configs[3].set(5, 6, 5, 0, 0, 16, 1, 4, 4); //EGL_RGB_BUFFER, buffer size = 16 |
97 m_configs[4].set(4, 4, 4, 4, 0, 16, 1, 4, 5); //EGL_RGB_BUFFER, buffer size = 16 |
176 m_configs[4].set(4, 4, 4, 4, 0, 16, 1, 4, 5); //EGL_RGB_BUFFER, buffer size = 16 |
98 m_configs[5].set(0, 0, 0, 8, 0, 8, 1, 8, 6); //EGL_RGB_BUFFER, buffer size = 8 |
177 m_configs[5].set(0, 0, 0, 8, 0, 8, 1, 8, 6); //EGL_RGB_BUFFER, buffer size = 8 |
99 m_configs[6].set(0, 0, 0, 4, 0, 4, 1, 4, 7); //EGL_RGB_BUFFER, buffer size = 8 |
178 m_configs[6].set(0, 0, 0, 4, 0, 4, 1, 4, 7); //EGL_RGB_BUFFER, buffer size = 8 |
100 m_configs[7].set(0, 0, 0, 1, 0, 1, 1, 1, 8); //EGL_RGB_BUFFER, buffer size = 8 |
179 m_configs[7].set(0, 0, 0, 1, 0, 1, 1, 1, 8); //EGL_RGB_BUFFER, buffer size = 8 |
101 m_configs[8].set(0, 0, 0, 0, 8, 8, 1, 8, 9); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
180 m_configs[8].set(0, 0, 0, 0, 8, 8, 1, 8, 9); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
102 m_configs[9].set(0, 0, 0, 0, 1, 1, 1, 1, 10); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
181 m_configs[9].set(0, 0, 0, 0, 1, 1, 1, 1, 10); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
103 |
182 |
104 m_configs[10].set(8, 8, 8, 8, 0, 32, 4, 1, 11); //EGL_RGB_BUFFER, buffer size = 32 |
183 m_configs[10].set(8, 8, 8, 8, 0, 32, 4, 1, 11); //EGL_RGB_BUFFER, buffer size = 32 |
105 m_configs[11].set(8, 8, 8, 0, 0, 32, 4, 1, 12); //EGL_RGB_BUFFER, buffer size = 24 |
184 m_configs[11].set(8, 8, 8, 0, 0, 32, 4, 1, 12); //EGL_RGB_BUFFER, buffer size = 24 |
106 m_configs[12].set(5, 5, 5, 1, 0, 16, 4, 1, 13); //EGL_RGB_BUFFER, buffer size = 16 |
185 m_configs[12].set(5, 5, 5, 1, 0, 16, 4, 1, 13); //EGL_RGB_BUFFER, buffer size = 16 |
107 m_configs[13].set(5, 6, 5, 0, 0, 16, 4, 1, 14); //EGL_RGB_BUFFER, buffer size = 16 |
186 m_configs[13].set(5, 6, 5, 0, 0, 16, 4, 1, 14); //EGL_RGB_BUFFER, buffer size = 16 |
108 m_configs[14].set(4, 4, 4, 4, 0, 16, 4, 1, 15); //EGL_RGB_BUFFER, buffer size = 16 |
187 m_configs[14].set(4, 4, 4, 4, 0, 16, 4, 1, 15); //EGL_RGB_BUFFER, buffer size = 16 |
109 m_configs[15].set(0, 0, 0, 8, 0, 8, 4, 1, 16); //EGL_RGB_BUFFER, buffer size = 8 |
188 m_configs[15].set(0, 0, 0, 8, 0, 8, 4, 1, 16); //EGL_RGB_BUFFER, buffer size = 8 |
110 m_configs[16].set(0, 0, 0, 4, 0, 4, 4, 1, 17); //EGL_RGB_BUFFER, buffer size = 8 |
189 m_configs[16].set(0, 0, 0, 4, 0, 4, 4, 1, 17); //EGL_RGB_BUFFER, buffer size = 8 |
111 m_configs[17].set(0, 0, 0, 1, 0, 1, 4, 1, 18); //EGL_RGB_BUFFER, buffer size = 8 |
190 m_configs[17].set(0, 0, 0, 1, 0, 1, 4, 1, 18); //EGL_RGB_BUFFER, buffer size = 8 |
112 m_configs[18].set(0, 0, 0, 0, 8, 8, 4, 1, 19); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
191 m_configs[18].set(0, 0, 0, 0, 8, 8, 4, 1, 19); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
113 m_configs[19].set(0, 0, 0, 0, 1, 1, 4, 1, 20); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
192 m_configs[19].set(0, 0, 0, 0, 1, 1, 4, 1, 20); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
114 |
193 |
115 m_configs[20].set(8, 8, 8, 8, 0, 32, 32, 1, 21); //EGL_RGB_BUFFER, buffer size = 32 |
194 m_configs[20].set(8, 8, 8, 8, 0, 32, 32, 1, 21); //EGL_RGB_BUFFER, buffer size = 32 |
116 m_configs[21].set(8, 8, 8, 0, 0, 32, 32, 1, 22); //EGL_RGB_BUFFER, buffer size = 24 |
195 m_configs[21].set(8, 8, 8, 0, 0, 32, 32, 1, 22); //EGL_RGB_BUFFER, buffer size = 24 |
117 m_configs[22].set(5, 5, 5, 1, 0, 16, 32, 1, 23); //EGL_RGB_BUFFER, buffer size = 16 |
196 m_configs[22].set(5, 5, 5, 1, 0, 16, 32, 1, 23); //EGL_RGB_BUFFER, buffer size = 16 |
118 m_configs[23].set(5, 6, 5, 0, 0, 16, 32, 1, 24); //EGL_RGB_BUFFER, buffer size = 16 |
197 m_configs[23].set(5, 6, 5, 0, 0, 16, 32, 1, 24); //EGL_RGB_BUFFER, buffer size = 16 |
119 m_configs[24].set(4, 4, 4, 4, 0, 16, 32, 1, 25); //EGL_RGB_BUFFER, buffer size = 16 |
198 m_configs[24].set(4, 4, 4, 4, 0, 16, 32, 1, 25); //EGL_RGB_BUFFER, buffer size = 16 |
120 m_configs[25].set(0, 0, 0, 8, 0, 8, 32, 1, 26); //EGL_RGB_BUFFER, buffer size = 8 |
199 m_configs[25].set(0, 0, 0, 8, 0, 8, 32, 1, 26); //EGL_RGB_BUFFER, buffer size = 8 |
121 m_configs[26].set(0, 0, 0, 4, 0, 4, 32, 1, 27); //EGL_RGB_BUFFER, buffer size = 8 |
200 m_configs[26].set(0, 0, 0, 4, 0, 4, 32, 1, 27); //EGL_RGB_BUFFER, buffer size = 8 |
122 m_configs[27].set(0, 0, 0, 1, 0, 1, 32, 1, 28); //EGL_RGB_BUFFER, buffer size = 8 |
201 m_configs[27].set(0, 0, 0, 1, 0, 1, 32, 1, 28); //EGL_RGB_BUFFER, buffer size = 8 |
123 m_configs[28].set(0, 0, 0, 0, 8, 8, 32, 1, 29); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
202 m_configs[28].set(0, 0, 0, 0, 8, 8, 32, 1, 29); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
124 m_configs[29].set(0, 0, 0, 0, 1, 1, 32, 1, 30); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
203 m_configs[29].set(0, 0, 0, 0, 1, 1, 32, 1, 30); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
125 |
204 |
126 //configs without mask |
205 //configs without mask |
127 m_configs[30].set(8, 8, 8, 8, 0, 32, 1, 0, 31); //EGL_RGB_BUFFER, buffer size = 32 |
206 m_configs[30].set(8, 8, 8, 8, 0, 32, 1, 0, 31); //EGL_RGB_BUFFER, buffer size = 32 |
128 m_configs[31].set(8, 8, 8, 0, 0, 32, 1, 0, 32); //EGL_RGB_BUFFER, buffer size = 24 |
207 m_configs[31].set(8, 8, 8, 0, 0, 32, 1, 0, 32); //EGL_RGB_BUFFER, buffer size = 24 |
129 m_configs[32].set(5, 5, 5, 1, 0, 16, 1, 0, 33); //EGL_RGB_BUFFER, buffer size = 16 |
208 m_configs[32].set(5, 5, 5, 1, 0, 16, 1, 0, 33); //EGL_RGB_BUFFER, buffer size = 16 |
130 m_configs[33].set(5, 6, 5, 0, 0, 16, 1, 0, 34); //EGL_RGB_BUFFER, buffer size = 16 |
209 m_configs[33].set(5, 6, 5, 0, 0, 16, 1, 0, 34); //EGL_RGB_BUFFER, buffer size = 16 |
131 m_configs[34].set(4, 4, 4, 4, 0, 16, 1, 0, 35); //EGL_RGB_BUFFER, buffer size = 16 |
210 m_configs[34].set(4, 4, 4, 4, 0, 16, 1, 0, 35); //EGL_RGB_BUFFER, buffer size = 16 |
132 m_configs[35].set(0, 0, 0, 8, 0, 8, 1, 0, 36); //EGL_RGB_BUFFER, buffer size = 8 |
211 m_configs[35].set(0, 0, 0, 8, 0, 8, 1, 0, 36); //EGL_RGB_BUFFER, buffer size = 8 |
133 m_configs[36].set(0, 0, 0, 4, 0, 4, 1, 0, 37); //EGL_RGB_BUFFER, buffer size = 8 |
212 m_configs[36].set(0, 0, 0, 4, 0, 4, 1, 0, 37); //EGL_RGB_BUFFER, buffer size = 8 |
134 m_configs[37].set(0, 0, 0, 1, 0, 1, 1, 0, 38); //EGL_RGB_BUFFER, buffer size = 8 |
213 m_configs[37].set(0, 0, 0, 1, 0, 1, 1, 0, 38); //EGL_RGB_BUFFER, buffer size = 8 |
135 m_configs[38].set(0, 0, 0, 0, 8, 8, 1, 0, 39); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
214 m_configs[38].set(0, 0, 0, 0, 8, 8, 1, 0, 39); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
136 m_configs[39].set(0, 0, 0, 0, 1, 1, 1, 0, 40); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
215 m_configs[39].set(0, 0, 0, 0, 1, 1, 1, 0, 40); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
137 |
216 |
138 m_configs[40].set(8, 8, 8, 8, 0, 32, 4, 0, 41); //EGL_RGB_BUFFER, buffer size = 32 |
217 m_configs[40].set(8, 8, 8, 8, 0, 32, 4, 0, 41); //EGL_RGB_BUFFER, buffer size = 32 |
139 m_configs[41].set(8, 8, 8, 0, 0, 32, 4, 0, 42); //EGL_RGB_BUFFER, buffer size = 24 |
218 m_configs[41].set(8, 8, 8, 0, 0, 32, 4, 0, 42); //EGL_RGB_BUFFER, buffer size = 24 |
140 m_configs[42].set(5, 5, 5, 1, 0, 16, 4, 0, 43); //EGL_RGB_BUFFER, buffer size = 16 |
219 m_configs[42].set(5, 5, 5, 1, 0, 16, 4, 0, 43); //EGL_RGB_BUFFER, buffer size = 16 |
141 m_configs[43].set(5, 6, 5, 0, 0, 16, 4, 0, 44); //EGL_RGB_BUFFER, buffer size = 16 |
220 m_configs[43].set(5, 6, 5, 0, 0, 16, 4, 0, 44); //EGL_RGB_BUFFER, buffer size = 16 |
142 m_configs[44].set(4, 4, 4, 4, 0, 16, 4, 0, 45); //EGL_RGB_BUFFER, buffer size = 16 |
221 m_configs[44].set(4, 4, 4, 4, 0, 16, 4, 0, 45); //EGL_RGB_BUFFER, buffer size = 16 |
143 m_configs[45].set(0, 0, 0, 8, 0, 8, 4, 0, 46); //EGL_RGB_BUFFER, buffer size = 8 |
222 m_configs[45].set(0, 0, 0, 8, 0, 8, 4, 0, 46); //EGL_RGB_BUFFER, buffer size = 8 |
144 m_configs[46].set(0, 0, 0, 4, 0, 4, 4, 0, 47); //EGL_RGB_BUFFER, buffer size = 8 |
223 m_configs[46].set(0, 0, 0, 4, 0, 4, 4, 0, 47); //EGL_RGB_BUFFER, buffer size = 8 |
145 m_configs[47].set(0, 0, 0, 1, 0, 1, 4, 0, 48); //EGL_RGB_BUFFER, buffer size = 8 |
224 m_configs[47].set(0, 0, 0, 1, 0, 1, 4, 0, 48); //EGL_RGB_BUFFER, buffer size = 8 |
146 m_configs[48].set(0, 0, 0, 0, 8, 8, 4, 0, 49); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
225 m_configs[48].set(0, 0, 0, 0, 8, 8, 4, 0, 49); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
147 m_configs[49].set(0, 0, 0, 0, 1, 1, 4, 0, 50); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
226 m_configs[49].set(0, 0, 0, 0, 1, 1, 4, 0, 50); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
148 |
227 |
149 m_configs[50].set(8, 8, 8, 8, 0, 32, 32, 0, 51); //EGL_RGB_BUFFER, buffer size = 32 |
228 m_configs[50].set(8, 8, 8, 8, 0, 32, 32, 0, 51); //EGL_RGB_BUFFER, buffer size = 32 |
150 m_configs[51].set(8, 8, 8, 0, 0, 32, 32, 0, 52); //EGL_RGB_BUFFER, buffer size = 24 |
229 m_configs[51].set(8, 8, 8, 0, 0, 32, 32, 0, 52); //EGL_RGB_BUFFER, buffer size = 24 |
151 m_configs[52].set(5, 5, 5, 1, 0, 16, 32, 0, 53); //EGL_RGB_BUFFER, buffer size = 16 |
230 m_configs[52].set(5, 5, 5, 1, 0, 16, 32, 0, 53); //EGL_RGB_BUFFER, buffer size = 16 |
152 m_configs[53].set(5, 6, 5, 0, 0, 16, 32, 0, 54); //EGL_RGB_BUFFER, buffer size = 16 |
231 m_configs[53].set(5, 6, 5, 0, 0, 16, 32, 0, 54); //EGL_RGB_BUFFER, buffer size = 16 |
153 m_configs[54].set(4, 4, 4, 4, 0, 16, 32, 0, 55); //EGL_RGB_BUFFER, buffer size = 16 |
232 m_configs[54].set(4, 4, 4, 4, 0, 16, 32, 0, 55); //EGL_RGB_BUFFER, buffer size = 16 |
154 m_configs[55].set(0, 0, 0, 8, 0, 8, 32, 0, 56); //EGL_RGB_BUFFER, buffer size = 8 |
233 m_configs[55].set(0, 0, 0, 8, 0, 8, 32, 0, 56); //EGL_RGB_BUFFER, buffer size = 8 |
155 m_configs[56].set(0, 0, 0, 4, 0, 4, 32, 0, 57); //EGL_RGB_BUFFER, buffer size = 8 |
234 m_configs[56].set(0, 0, 0, 4, 0, 4, 32, 0, 57); //EGL_RGB_BUFFER, buffer size = 8 |
156 m_configs[57].set(0, 0, 0, 1, 0, 1, 32, 0, 58); //EGL_RGB_BUFFER, buffer size = 8 |
235 m_configs[57].set(0, 0, 0, 1, 0, 1, 32, 0, 58); //EGL_RGB_BUFFER, buffer size = 8 |
157 m_configs[58].set(0, 0, 0, 0, 8, 8, 32, 0, 59); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
236 m_configs[58].set(0, 0, 0, 0, 8, 8, 32, 0, 59); //EGL_LUMINANCE_BUFFER, buffer size = 8 |
158 m_configs[59].set(0, 0, 0, 0, 1, 1, 32, 0, 60); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
237 m_configs[59].set(0, 0, 0, 0, 1, 1, 32, 0, 60); //EGL_LUMINANCE_BUFFER, buffer size = 1 |
159 /* |
238 /* |
160 attrib default criteria order priority |
239 attrib default criteria order priority |
161 -------------------------------------------------------------- |
240 -------------------------------------------------------------- |
162 EGL_COLOR_BUFFER_TYPE EGL_RGB_BUFFER Exact None 2 |
241 EGL_COLOR_BUFFER_TYPE EGL_RGB_BUFFER Exact None 2 |
163 EGL_RED_SIZE 0 AtLeast Special 3 |
242 EGL_RED_SIZE 0 AtLeast Special 3 |
164 EGL_GREEN_SIZE 0 AtLeast Special 3 |
243 EGL_GREEN_SIZE 0 AtLeast Special 3 |
165 EGL_BLUE_SIZE 0 AtLeast Special 3 |
244 EGL_BLUE_SIZE 0 AtLeast Special 3 |
166 EGL_LUMINANCE_SIZE 0 AtLeast Special 3 |
245 EGL_LUMINANCE_SIZE 0 AtLeast Special 3 |
167 EGL_ALPHA_SIZE 0 AtLeast Special 3 |
246 EGL_ALPHA_SIZE 0 AtLeast Special 3 |
168 EGL_BUFFER_SIZE 0 AtLeast Smaller 4 |
247 EGL_BUFFER_SIZE 0 AtLeast Smaller 4 |
169 EGL_CONFIG_ID EGL_DONT_CARE Exact Smaller 11 |
248 EGL_CONFIG_ID EGL_DONT_CARE Exact Smaller 11 |
170 */ |
249 */ |
171 } |
250 } |
172 |
251 |
173 RIEGLDisplay::~RIEGLDisplay() |
252 RIEGLDisplay::~RIEGLDisplay() |
174 { |
253 { |
175 //mark everything for deletion, but don't delete the current context and surface |
254 //mark everything for deletion, but don't delete the current context and surface |
176 for (int i = 0; i < m_contexts.size(); i++) |
255 for(int i=0;i<m_contexts.size();i++) |
177 { |
256 { |
178 if (!m_contexts[i]->removeReference()) |
257 if(!m_contexts[i]->removeReference()) |
179 RI_DELETE(m_contexts[i]); |
258 RI_DELETE(m_contexts[i]); |
180 } |
259 } |
181 m_contexts.clear(); //remove all contexts from the list (makes further references to the current contexts invalid) |
260 m_contexts.clear(); //remove all contexts from the list (makes further references to the current contexts invalid) |
182 |
261 |
183 for (int i = 0; i < m_surfaces.size(); i++) |
262 for(int i=0;i<m_surfaces.size();i++) |
184 { |
263 { |
185 if (!m_surfaces[i]->removeReference()) |
264 if(!m_surfaces[i]->removeReference()) |
186 RI_DELETE(m_surfaces[i]); |
265 RI_DELETE(m_surfaces[i]); |
187 } |
266 } |
188 m_surfaces.clear(); //remove all surfaces from the list (makes further references to the current surfaces invalid) |
267 m_surfaces.clear(); //remove all surfaces from the list (makes further references to the current surfaces invalid) |
189 } |
268 } |
190 |
269 |
191 EGLBoolean RIEGLDisplay::contextExists(const EGLContext ctx) const |
270 EGLBoolean RIEGLDisplay::contextExists(const EGLContext ctx) const |
192 { |
271 { |
193 for (int i = 0; i < m_contexts.size(); i++) |
272 for(int i=0;i<m_contexts.size();i++) |
194 { |
273 { |
195 if (m_contexts[i] == CastToRIEGLContext(ctx)) |
274 if(m_contexts[i] == CastToRIEGLContext(ctx)) |
196 return EGL_TRUE; |
275 return EGL_TRUE; |
197 } |
276 } |
198 return EGL_FALSE; |
277 return EGL_FALSE; |
199 } |
278 } |
200 |
279 |
201 EGLBoolean RIEGLDisplay::surfaceExists(const EGLSurface surf) const |
280 EGLBoolean RIEGLDisplay::surfaceExists(const EGLSurface surf) const |
202 { |
281 { |
203 for (int i = 0; i < m_surfaces.size(); i++) |
282 for(int i=0;i<m_surfaces.size();i++) |
204 { |
283 { |
205 if (m_surfaces[i] == CastToRIEGLSurface(surf)) |
284 if(m_surfaces[i] == CastToRIEGLSurface(surf)) |
206 return EGL_TRUE; |
285 return EGL_TRUE; |
207 } |
286 } |
208 return EGL_FALSE; |
287 return EGL_FALSE; |
209 } |
288 } |
210 |
289 |
211 EGLBoolean RIEGLDisplay::configExists(const EGLConfig config) const |
290 EGLBoolean RIEGLDisplay::configExists(const EGLConfig config) const |
212 { |
291 { |
213 for (int i = 0; i < EGL_NUMCONFIGS; i++) |
292 for(int i=0;i<EGL_NUMCONFIGS;i++) |
214 { |
293 { |
215 if (m_configs[i].m_config == config) |
294 if(m_configs[i].m_config == config) |
216 return EGL_TRUE; |
295 return EGL_TRUE; |
217 } |
296 } |
218 return EGL_FALSE; |
297 return EGL_FALSE; |
219 } |
298 } |
|
299 |
|
300 /*-------------------------------------------------------------------*//*! |
|
301 * \brief |
|
302 * \param |
|
303 * \return |
|
304 * \note |
|
305 *//*-------------------------------------------------------------------*/ |
|
306 |
|
307 class RIEGLThread |
|
308 { |
|
309 public: |
|
310 RIEGLThread(void* currentThreadID); |
|
311 ~RIEGLThread(); |
|
312 |
|
313 void* getThreadID() const { return m_threadID; } |
|
314 |
|
315 void makeCurrent(RIEGLContext* c, RIEGLSurface* s) { m_context = c; m_surface = s; } |
|
316 RIEGLContext* getCurrentContext() const { return m_context; } |
|
317 RIEGLSurface* getCurrentSurface() const { return m_surface; } |
|
318 |
|
319 void setError(EGLint error) { m_error = error; } |
|
320 EGLint getError() const { return m_error; } |
|
321 |
|
322 void bindAPI(EGLint api) { m_boundAPI = api; } |
|
323 EGLint getBoundAPI() const { return m_boundAPI; } |
|
324 |
|
325 private: |
|
326 RIEGLThread(const RIEGLThread&); |
|
327 RIEGLThread operator=(const RIEGLThread&); |
|
328 |
|
329 RIEGLContext* m_context; |
|
330 RIEGLSurface* m_surface; |
|
331 EGLint m_error; |
|
332 void* m_threadID; |
|
333 EGLint m_boundAPI; |
|
334 }; |
220 |
335 |
221 RIEGLThread::RIEGLThread(void* currentThreadID) : |
336 RIEGLThread::RIEGLThread(void* currentThreadID) : |
222 m_context(NULL), m_surface(NULL), m_error(EGL_SUCCESS), m_threadID( |
337 m_context(NULL), |
223 currentThreadID), m_boundAPI(EGL_NONE) |
338 m_surface(NULL), |
224 { |
339 m_error(EGL_SUCCESS), |
225 } |
340 m_threadID(currentThreadID), |
|
341 m_boundAPI(EGL_NONE) |
|
342 { |
|
343 } |
226 |
344 |
227 RIEGLThread::~RIEGLThread() |
345 RIEGLThread::~RIEGLThread() |
228 { |
346 { |
229 } |
347 } |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 Image* CastToImage(EGLClientBuffer aBufferId); |
|
354 EGLClientBuffer CastFromImage(Image* aBUffer); |
|
355 |
|
356 |
230 |
357 |
231 EGL::EGL() : |
358 EGL::EGL() : |
232 m_threads(), m_currentThreads(), m_displays(), m_referenceCount(0) |
359 m_threads(), |
233 { |
360 m_currentThreads(), |
234 } |
361 m_displays(), |
|
362 m_referenceCount(0) |
|
363 { |
|
364 } |
235 EGL::~EGL() |
365 EGL::~EGL() |
236 { |
366 { |
237 for (int i = 0; i < m_displays.size(); i++) |
367 for(int i=0;i<m_displays.size();i++) |
238 { |
368 { |
239 RI_DELETE(m_displays[i]); |
369 RI_DELETE(m_displays[i]); |
240 } |
370 } |
241 for (int i = 0; i < m_threads.size(); i++) |
371 for(int i=0;i<m_threads.size();i++) |
242 { |
372 { |
243 RI_DELETE(m_threads[i]); |
373 RI_DELETE(m_threads[i]); |
244 } |
374 } |
245 //currentThreads contain just pointers to threads we just deleted |
375 //currentThreads contain just pointers to threads we just deleted |
246 } |
376 } |
247 |
377 |
248 /*-------------------------------------------------------------------*//*! |
378 /*-------------------------------------------------------------------*//*! |
249 * \brief |
379 * \brief |
250 * \param |
380 * \param |
251 * \return |
381 * \return |
252 * \note |
382 * \note |
253 *//*-------------------------------------------------------------------*/ |
383 *//*-------------------------------------------------------------------*/ |
254 |
384 |
255 //static EGL* g_egl = NULL; //never use this directly |
385 //static EGL* g_egl = NULL; //never use this directly |
256 EGL* getEGL() |
386 EGL* getEGL() |
257 { |
387 { |
258 /*if(!g_egl) |
388 /*if(!g_egl) |
259 { |
389 { |
260 try |
390 try |
261 { |
391 { |
262 g_egl = RI_NEW(EGL, ()); //throws bad_alloc |
392 g_egl = RI_NEW(EGL, ()); //throws bad_alloc |
263 g_egl->addReference(); |
393 g_egl->addReference(); |
264 } |
394 } |
265 catch(std::bad_alloc) |
395 catch(std::bad_alloc) |
266 { |
396 { |
267 g_egl = NULL; |
397 g_egl = NULL; |
268 } |
398 } |
269 } |
399 } |
270 return g_egl; |
400 return g_egl; |
271 */ |
401 */ |
|
402 |
272 |
403 |
273 //use TLS to store static global g_egl |
404 //use TLS to store static global g_egl |
274 EGL* pEgl = NULL; |
405 EGL* pEgl = NULL; |
275 |
406 |
276 CEglThreadSession* es = reinterpret_cast<CEglThreadSession*>(Dll::Tls()); |
407 CEglThreadSession* es = reinterpret_cast<CEglThreadSession*>(Dll::Tls()); |
277 if (es) |
408 if (es) |
278 { |
409 { |
279 return es->getEgl(); |
410 return es->getEgl(); |
280 } |
411 } |
281 |
412 |
282 const TInt err = CEglDriver::Open(); |
413 const TInt err = CEglDriver::Open(); |
283 if (err != KErrNone) |
414 if (err != KErrNone) |
284 { |
415 { |
297 { |
428 { |
298 delete es; |
429 delete es; |
299 return NULL; |
430 return NULL; |
300 } |
431 } |
301 return es->getEgl(); |
432 return es->getEgl(); |
302 } |
433 |
303 |
434 |
|
435 } |
304 static void releaseEGL() |
436 static void releaseEGL() |
305 { |
437 { |
306 /* |
438 /* |
307 if(g_egl) |
439 if(g_egl) |
308 { |
440 { |
309 if(!g_egl->removeReference()) |
441 if(!g_egl->removeReference()) |
310 { |
442 { |
311 RI_DELETE(g_egl); |
443 RI_DELETE(g_egl); |
312 g_egl = NULL; |
444 g_egl = NULL; |
313 } |
445 } |
314 } |
446 } |
315 */ |
447 */ |
316 EGL* pEgl = static_cast<EGL*> (Dll::Tls()); |
448 EGL* pEgl = static_cast<EGL*>(Dll::Tls()); |
317 if (pEgl) |
449 if (pEgl) |
318 delete pEgl; |
450 delete pEgl; |
319 Dll::SetTls(NULL); |
451 Dll::SetTls(NULL); |
320 |
452 |
321 } |
453 } |
322 |
454 |
323 /*-------------------------------------------------------------------*//*! |
455 /*-------------------------------------------------------------------*//*! |
324 * \brief Given a display ID, return the corresponding object, or NULL |
456 * \brief Given a display ID, return the corresponding object, or NULL |
325 * if the ID hasn't been initialized. |
457 * if the ID hasn't been initialized. |
326 * \param |
458 * \param |
327 * \return |
459 * \return |
328 * \note if egl has been initialized for this display, the display ID can |
460 * \note if egl has been initialized for this display, the display ID can |
329 * be found from egl->m_displays |
461 * be found from egl->m_displays |
330 *//*-------------------------------------------------------------------*/ |
462 *//*-------------------------------------------------------------------*/ |
331 |
463 |
332 RIEGLDisplay* EGL::getDisplay(EGLDisplay displayID) const |
464 RIEGLDisplay* EGL::getDisplay(EGLDisplay displayID) const |
333 { |
465 { |
334 for (int i = 0; i < m_displays.size(); i++) |
466 for(int i=0;i<m_displays.size();i++) |
335 { |
467 { |
336 if (displayID == m_displays[i]->getID()) |
468 if(displayID == m_displays[i]->getID()) |
337 return m_displays[i]; |
469 return m_displays[i]; |
338 } |
470 } |
339 return NULL; //error: the display hasn't been eglInitialized |
471 return NULL; //error: the display hasn't been eglInitialized |
340 } |
472 } |
341 |
473 |
342 /*-------------------------------------------------------------------*//*! |
474 /*-------------------------------------------------------------------*//*! |
343 * \brief return EGLDisplay for the current context |
475 * \brief return EGLDisplay for the current context |
344 * \param |
476 * \param |
345 * \return |
477 * \return |
346 * \note |
478 * \note |
347 *//*-------------------------------------------------------------------*/ |
479 *//*-------------------------------------------------------------------*/ |
348 |
480 |
349 EGLDisplay EGL::findDisplay(EGLContext ctx) const |
481 EGLDisplay EGL::findDisplay(EGLContext ctx) const |
350 { |
482 { |
351 for (int i = 0; i < m_displays.size(); i++) |
483 for(int i=0;i<m_displays.size();i++) |
352 { |
484 { |
353 if (m_displays[i]->contextExists(ctx)) |
485 if(m_displays[i]->contextExists(ctx)) |
354 return m_displays[i]->getID(); |
486 return m_displays[i]->getID(); |
355 } |
487 } |
356 return EGL_NO_DISPLAY; |
488 return EGL_NO_DISPLAY; |
357 } |
489 } |
358 |
490 |
359 /*-------------------------------------------------------------------*//*! |
491 /*-------------------------------------------------------------------*//*! |
360 * \brief return an EGL thread struct for the thread made current, or |
492 * \brief return an EGL thread struct for the thread made current, or |
361 * NULL if there's no current context. |
493 * NULL if there's no current context. |
362 * \param |
494 * \param |
363 * \return |
495 * \return |
364 * \note |
496 * \note |
365 *//*-------------------------------------------------------------------*/ |
497 *//*-------------------------------------------------------------------*/ |
366 |
498 |
367 RIEGLThread* EGL::getCurrentThread() const |
499 RIEGLThread* EGL::getCurrentThread() const |
368 { |
500 { |
369 void* currentThreadID = OSGetCurrentThreadID(); |
501 void* currentThreadID = OSGetCurrentThreadID(); |
370 for (int i = 0; i < m_currentThreads.size(); i++) |
502 for(int i=0;i<m_currentThreads.size();i++) |
371 { |
503 { |
372 if (currentThreadID == m_currentThreads[i]->getThreadID()) |
504 if(currentThreadID == m_currentThreads[i]->getThreadID()) |
373 return m_currentThreads[i]; |
505 return m_currentThreads[i]; |
374 } |
506 } |
375 return NULL; //thread is not current |
507 return NULL; //thread is not current |
376 } |
508 } |
377 |
509 |
378 /*-------------------------------------------------------------------*//*! |
510 /*-------------------------------------------------------------------*//*! |
379 * \brief return an EGL thread struct corresponding to current OS thread. |
511 * \brief return an EGL thread struct corresponding to current OS thread. |
380 * \param |
512 * \param |
381 * \return |
513 * \return |
382 * \note |
514 * \note |
383 *//*-------------------------------------------------------------------*/ |
515 *//*-------------------------------------------------------------------*/ |
384 |
516 |
385 RIEGLThread* EGL::getThread() |
517 RIEGLThread* EGL::getThread() |
386 { |
518 { |
387 void* currentThreadID = OSGetCurrentThreadID(); |
519 void* currentThreadID = OSGetCurrentThreadID(); |
388 for (int i = 0; i < m_threads.size(); i++) |
520 for(int i=0;i<m_threads.size();i++) |
389 { |
521 { |
390 if (currentThreadID == m_threads[i]->getThreadID()) |
522 if(currentThreadID == m_threads[i]->getThreadID()) |
391 return m_threads[i]; |
523 return m_threads[i]; |
392 } |
524 } |
393 |
525 |
394 //EGL doesn't have a struct for the thread yet, add it to EGL's list |
526 //EGL doesn't have a struct for the thread yet, add it to EGL's list |
395 RIEGLThread* newThread = NULL; |
527 RIEGLThread* newThread = NULL; |
396 try |
528 try |
397 { |
529 { |
398 newThread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID())); //throws bad_alloc |
530 newThread = RI_NEW(RIEGLThread, (OSGetCurrentThreadID())); //throws bad_alloc |
399 m_threads.push_back(newThread); //throws bad_alloc |
531 m_threads.push_back(newThread); //throws bad_alloc |
400 return newThread; |
532 return newThread; |
401 } |
533 } |
402 catch (std::bad_alloc) |
534 catch(std::bad_alloc) |
403 { |
535 { |
404 RI_DELETE(newThread); |
536 RI_DELETE(newThread); |
405 return NULL; |
537 return NULL; |
406 } |
538 } |
407 } |
539 } |
408 |
540 |
409 /*-------------------------------------------------------------------*//*! |
541 /*-------------------------------------------------------------------*//*! |
410 * \brief destroy an EGL thread struct |
542 * \brief destroy an EGL thread struct |
411 * \param |
543 * \param |
412 * \return |
544 * \return |
413 * \note |
545 * \note |
414 *//*-------------------------------------------------------------------*/ |
546 *//*-------------------------------------------------------------------*/ |
415 |
547 |
416 void EGL::destroyThread() |
548 void EGL::destroyThread() |
417 { |
549 { |
418 void* currentThreadID = OSGetCurrentThreadID(); |
550 void* currentThreadID = OSGetCurrentThreadID(); |
419 for (int i = 0; i < m_threads.size(); i++) |
551 for(int i=0;i<m_threads.size();i++) |
420 { |
552 { |
421 if (currentThreadID == m_threads[i]->getThreadID()) |
553 if(currentThreadID == m_threads[i]->getThreadID()) |
422 { |
554 { |
423 RIEGLThread* thread = m_threads[i]; |
555 RIEGLThread* thread = m_threads[i]; |
424 bool res = m_threads.remove(thread); |
556 bool res = m_threads.remove(thread); |
425 RI_ASSERT(res); |
557 RI_ASSERT(res); |
426 RI_UNREF(res); |
558 RI_UNREF(res); |
427 RI_DELETE(thread); |
559 RI_DELETE(thread); |
428 break; |
560 break; |
429 } |
561 } |
430 } |
562 } |
431 } |
563 } |
432 |
564 |
433 /*-------------------------------------------------------------------*//*! |
565 /*-------------------------------------------------------------------*//*! |
434 * \brief |
566 * \brief |
435 * \param |
567 * \param |
436 * \return |
568 * \return |
437 * \note |
569 * \note |
438 *//*-------------------------------------------------------------------*/ |
570 *//*-------------------------------------------------------------------*/ |
439 |
571 |
440 bool EGL::isInUse(const void* image) const |
572 bool EGL::isInUse(const void* image) const |
441 { |
573 { |
442 for (int i = 0; i < m_currentThreads.size(); i++) |
574 for(int i=0;i<m_currentThreads.size();i++) |
443 { |
575 { |
444 RIEGLSurface* s = m_currentThreads[i]->getCurrentSurface(); |
576 RIEGLSurface* s = m_currentThreads[i]->getCurrentSurface(); |
445 if (s && s->getDrawable() && s->getDrawable()->isInUse((Image*) image)) |
577 if(s && s->getDrawable() && s->getDrawable()->isInUse((Image*)image)) |
446 return true; |
578 return true; |
447 } |
579 } |
448 return false; |
580 return false; |
|
581 } |
|
582 |
|
583 /*-------------------------------------------------------------------*//*! |
|
584 * \brief |
|
585 * \param |
|
586 * \return |
|
587 * \note |
|
588 *//*-------------------------------------------------------------------*/ |
|
589 |
|
590 #define EGL_GET_DISPLAY(DISPLAY, RETVAL) \ |
|
591 OSAcquireMutex(); \ |
|
592 EGL* egl = getEGL(); \ |
|
593 if(!egl) \ |
|
594 { \ |
|
595 OSReleaseMutex(); \ |
|
596 return RETVAL; \ |
|
597 } \ |
|
598 RIEGLDisplay* display = egl->getDisplay(DISPLAY); \ |
|
599 |
|
600 #define EGL_GET_EGL(RETVAL) \ |
|
601 OSAcquireMutex(); \ |
|
602 EGL* egl = getEGL(); \ |
|
603 if(!egl) \ |
|
604 { \ |
|
605 OSReleaseMutex(); \ |
|
606 return RETVAL; \ |
|
607 } \ |
|
608 |
|
609 #define EGL_IF_ERROR(COND, ERRORCODE, RETVAL) \ |
|
610 if(COND) { eglSetError(egl, ERRORCODE); OSReleaseMutex(); return RETVAL; } \ |
|
611 |
|
612 #define EGL_RETURN(ERRORCODE, RETVAL) \ |
|
613 { \ |
|
614 eglSetError(egl, ERRORCODE); \ |
|
615 OSReleaseMutex(); \ |
|
616 return RETVAL; \ |
449 } |
617 } |
450 |
618 |
451 // Note: egl error handling model differs from OpenVG. The latest error is stored instead of the oldest one. |
619 // Note: egl error handling model differs from OpenVG. The latest error is stored instead of the oldest one. |
452 static void eglSetError(EGL* egl, EGLint error) |
620 static void eglSetError(EGL* egl, EGLint error) |
453 { |
621 { |
454 RIEGLThread* thread = egl->getThread(); |
622 RIEGLThread* thread = egl->getThread(); |
455 if (thread) |
623 if(thread) |
456 thread->setError(error); |
624 thread->setError(error); |
457 } |
625 } |
458 |
626 |
459 /*-------------------------------------------------------------------*//*! |
627 /*-------------------------------------------------------------------*//*! |
460 * \brief Returns the OpenVG context current to the calling thread. |
628 * \brief Returns the OpenVG context current to the calling thread. |
461 * \param |
629 * \param |
462 * \return |
630 * \return |
463 * \note This function is always called from a mutexed API function |
631 * \note This function is always called from a mutexed API function |
464 *//*-------------------------------------------------------------------*/ |
632 *//*-------------------------------------------------------------------*/ |
465 |
633 |
466 void* eglvgGetCurrentVGContext(void) |
634 void* eglvgGetCurrentVGContext(void) |
467 { |
635 { |
468 EGL* egl = getEGL(); |
636 EGL* egl = getEGL(); |
469 if (egl) |
637 if(egl) |
470 { |
638 { |
471 RIEGLThread* thread = egl->getCurrentThread(); |
639 RIEGLThread* thread = egl->getCurrentThread(); |
472 if (thread) |
640 if(thread) |
473 { |
641 { |
474 RI_ASSERT(thread->getCurrentContext() && thread->getCurrentSurface()); |
642 RI_ASSERT(thread->getCurrentContext() && thread->getCurrentSurface()); |
475 return thread->getCurrentContext()->getVGContext(); |
643 return thread->getCurrentContext()->getVGContext(); |
476 } |
644 } |
477 } |
645 } |
478 return NULL; //not initialized or made current |
646 return NULL; //not initialized or made current |
479 } |
647 } |
480 |
648 |
481 /*-------------------------------------------------------------------*//*! |
649 /*-------------------------------------------------------------------*//*! |
482 * \brief Check if the image is current in any of the displays |
650 * \brief Check if the image is current in any of the displays |
483 * \param |
651 * \param |
484 * \return |
652 * \return |
485 * \note This function is always called from a mutexed API function |
653 * \note This function is always called from a mutexed API function |
486 *//*-------------------------------------------------------------------*/ |
654 *//*-------------------------------------------------------------------*/ |
487 |
655 |
488 bool eglvgIsInUse(void* image) |
656 bool eglvgIsInUse(void* image) |
489 { |
657 { |
490 EGL* egl = getEGL(); |
658 EGL* egl = getEGL(); |
491 if (egl) |
659 if(egl) |
492 { |
660 { |
493 return egl->isInUse(image); |
661 return egl->isInUse(image); |
494 } |
662 } |
495 return false; |
663 return false; |
496 } |
664 } |
497 |
665 |
498 //helper functions |
666 //helper functions |
499 RIEGLContext* CastToRIEGLContext(EGLContext aCtxId) |
667 RIEGLContext* CastToRIEGLContext(EGLContext aCtxId) |
500 { |
668 { |
501 return (RIEGLContext*)(aCtxId); |
669 return (RIEGLContext*)(aCtxId); |
502 } |
670 } |
503 EGLContext CastFromRIEGLContext(RIEGLContext* aCtx) |
671 EGLContext CastFromRIEGLContext(RIEGLContext* aCtx) |
504 { |
672 { |
505 return (EGLContext)(aCtx); |
673 return (EGLContext)(aCtx); |
506 } |
674 } |
507 |
675 |
508 RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId) |
676 RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId) |
509 { |
677 { |
510 return (RIEGLSurface*)(aSurfaceId); |
678 return (RIEGLSurface*)(aSurfaceId); |
511 } |
679 } |
512 EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface) |
680 EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface) |
513 { |
681 { |
514 return (EGLSurface)(aSurface); |
682 return (EGLSurface)(aSurface); |
515 } |
683 } |
516 |
684 |
517 Image* CastToImage(EGLClientBuffer aBufferId) |
685 Image* CastToImage(EGLClientBuffer aBufferId) |
518 { |
686 { |
519 return (Image*)(aBufferId); |
687 return (Image*)(aBufferId); |
520 } |
688 } |
521 |
689 |
522 EGLClientBuffer CastFromImage(Image* aBUffer) |
690 EGLClientBuffer CastFromImage(Image* aBUffer) |
523 { |
691 { |
524 return (EGLClientBuffer)(aBUffer); |
692 return (EGLClientBuffer)(aBUffer); |
525 } |
693 } |
526 }// namespace OpenVGRI |
|
527 |
694 |
528 //============================================================================================== |
695 //============================================================================================== |
529 |
696 |
|
697 } //namespace OpenVGRI |
|
698 |
530 using namespace OpenVGRI; |
699 using namespace OpenVGRI; |
531 /*-------------------------------------------------------------------*//*! |
700 |
532 * \brief |
701 |
533 * \param |
702 |
534 * \return |
703 |
535 * \note |
704 |
536 *//*-------------------------------------------------------------------*/ |
705 /*-------------------------------------------------------------------*//*! |
|
706 * \brief |
|
707 * \param |
|
708 * \return |
|
709 * \note |
|
710 *//*-------------------------------------------------------------------*/ |
537 |
711 |
538 #ifdef BUILD_WITH_PRIVATE_EGL |
712 #ifdef BUILD_WITH_PRIVATE_EGL |
539 RI_APIENTRY EGLint do_eglGetError() |
713 RI_APIENTRY EGLint do_eglGetError() |
540 #else |
714 #else |
541 EGLint eglGetError() |
715 EGLint eglGetError() |
542 #endif |
716 #endif |
543 { |
717 { |
544 OSAcquireMutex(); |
718 OSAcquireMutex(); |
545 EGLint ret = EGL_SUCCESS; |
719 EGLint ret = EGL_SUCCESS; |
546 EGL* egl = getEGL(); |
720 EGL* egl = getEGL(); |
547 if (egl) |
721 if(egl) |
548 { |
722 { |
549 RIEGLThread* thread = egl->getThread(); |
723 RIEGLThread* thread = egl->getThread(); |
550 if (thread) |
724 if(thread) |
551 ret = thread->getError(); //initialized, return error code |
725 ret = thread->getError(); //initialized, return error code |
552 } |
726 } |
553 else |
727 else ret = EGL_NOT_INITIALIZED; |
554 ret = EGL_NOT_INITIALIZED; |
728 OSReleaseMutex(); |
555 OSReleaseMutex(); |
729 return ret; |
556 return ret; |
730 } |
557 } |
731 |
558 |
732 /*-------------------------------------------------------------------*//*! |
559 /*-------------------------------------------------------------------*//*! |
733 * \brief |
560 * \brief |
734 * \param |
561 * \param |
735 * \return |
562 * \return |
736 * \note |
563 * \note |
737 *//*-------------------------------------------------------------------*/ |
564 *//*-------------------------------------------------------------------*/ |
|
565 |
738 |
566 #ifdef BUILD_WITH_PRIVATE_EGL |
739 #ifdef BUILD_WITH_PRIVATE_EGL |
567 RI_APIENTRY EGLDisplay do_eglGetDisplay(EGLNativeDisplayType display_id) |
740 RI_APIENTRY EGLDisplay do_eglGetDisplay(EGLNativeDisplayType display_id) |
568 #else |
741 #else |
569 EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) |
742 EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) |
570 #endif |
743 #endif |
571 { |
744 { |
572 return OSGetDisplay(display_id); |
745 return OSGetDisplay(display_id); |
573 } |
746 } |
574 |
747 |
575 /*-------------------------------------------------------------------*//*! |
748 /*-------------------------------------------------------------------*//*! |
576 * \brief |
749 * \brief |
577 * \param |
750 * \param |
578 * \return |
751 * \return |
579 * \note |
752 * \note |
580 *//*-------------------------------------------------------------------*/ |
753 *//*-------------------------------------------------------------------*/ |
581 |
754 |
582 #ifdef BUILD_WITH_PRIVATE_EGL |
755 #ifdef BUILD_WITH_PRIVATE_EGL |
583 RI_APIENTRY EGLBoolean do_eglInitialize(EGLDisplay dpy, EGLint *major, |
756 RI_APIENTRY EGLBoolean do_eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
584 EGLint *minor) |
|
585 #else |
757 #else |
586 EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
758 EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
587 #endif |
759 #endif |
588 { |
760 { |
589 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
761 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
590 EGL_IF_ERROR(display, EGL_SUCCESS, EGL_TRUE); //already initialized |
762 EGL_IF_ERROR(display, EGL_SUCCESS, EGL_TRUE); //already initialized |
591 |
763 |
592 //create the current display |
764 //create the current display |
593 //if a context and a surface are bound by the time of eglTerminate, they remain bound until eglMakeCurrent is called |
765 //if a context and a surface are bound by the time of eglTerminate, they remain bound until eglMakeCurrent is called |
594 RIEGLDisplay* newDisplay = NULL; |
766 RIEGLDisplay* newDisplay = NULL; |
595 try |
767 try |
596 { |
768 { |
597 newDisplay = RI_NEW(RIEGLDisplay, (dpy)); //throws bad_alloc |
769 newDisplay = RI_NEW(RIEGLDisplay, (dpy)); //throws bad_alloc |
598 egl->addDisplay(newDisplay); //throws bad_alloc |
770 egl->addDisplay(newDisplay); //throws bad_alloc |
599 display = newDisplay; |
771 display = newDisplay; |
600 RI_ASSERT(display); |
772 RI_ASSERT(display); |
601 } |
773 } |
602 catch (std::bad_alloc) |
774 catch(std::bad_alloc) |
603 { |
775 { |
604 RI_DELETE(newDisplay); |
776 RI_DELETE(newDisplay); |
605 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
777 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
606 } |
778 } |
607 |
779 |
608 if (major) |
780 if(major) *major = 1; |
609 *major = 1; |
781 if(minor) *minor = 2; |
610 if (minor) |
|
611 *minor = 2; |
|
612 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
782 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
613 } |
783 } |
614 |
784 |
615 /*-------------------------------------------------------------------*//*! |
785 /*-------------------------------------------------------------------*//*! |
616 * \brief |
786 * \brief |
617 * \param |
787 * \param |
618 * \return |
788 * \return |
619 * \note |
789 * \note |
620 *//*-------------------------------------------------------------------*/ |
790 *//*-------------------------------------------------------------------*/ |
621 |
791 |
622 #ifdef BUILD_WITH_PRIVATE_EGL |
792 #ifdef BUILD_WITH_PRIVATE_EGL |
623 RI_APIENTRY EGLBoolean do_eglTerminate(EGLDisplay dpy) |
793 RI_APIENTRY EGLBoolean do_eglTerminate(EGLDisplay dpy) |
624 #else |
794 #else |
625 EGLBoolean eglTerminate(EGLDisplay dpy) |
795 EGLBoolean eglTerminate(EGLDisplay dpy) |
626 #endif |
796 #endif |
627 { |
797 { |
628 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
798 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
629 EGL_IF_ERROR(!display, EGL_SUCCESS, EGL_TRUE); |
799 EGL_IF_ERROR(!display, EGL_SUCCESS, EGL_TRUE); |
630 egl->removeDisplay(display); |
800 egl->removeDisplay(display); |
631 RI_DELETE(display); |
801 RI_DELETE(display); |
632 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
802 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
633 } |
803 } |
634 |
804 |
635 /*-------------------------------------------------------------------*//*! |
805 /*-------------------------------------------------------------------*//*! |
636 * \brief |
806 * \brief |
637 * \param |
807 * \param |
638 * \return |
808 * \return |
639 * \note |
809 * \note |
640 *//*-------------------------------------------------------------------*/ |
810 *//*-------------------------------------------------------------------*/ |
641 |
811 |
642 #ifdef BUILD_WITH_PRIVATE_EGL |
812 #ifdef BUILD_WITH_PRIVATE_EGL |
643 RI_APIENTRY const char *do_eglQueryString(EGLDisplay dpy, EGLint name) |
813 RI_APIENTRY const char *do_eglQueryString(EGLDisplay dpy, EGLint name) |
644 #else |
814 #else |
645 const char *eglQueryString(EGLDisplay dpy, EGLint name) |
815 const char *eglQueryString(EGLDisplay dpy, EGLint name) |
646 #endif |
816 #endif |
647 { EGL_GET_DISPLAY(dpy, NULL); |
817 { |
648 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, NULL); |
818 EGL_GET_DISPLAY(dpy, NULL); |
649 |
819 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, NULL); |
650 static const char apis[] = "OpenVG"; |
820 |
651 static const char extensions[] = ""; |
821 static const char apis[] = "OpenVG"; |
652 static const char vendor[] = "Khronos Group"; |
822 static const char extensions[] = ""; |
653 static const char version[] = "1.3"; |
823 static const char vendor[] = "Khronos Group"; |
654 |
824 static const char version[] = "1.3"; |
655 const char* ret = NULL; |
825 |
656 switch(name) |
826 const char* ret = NULL; |
|
827 switch(name) |
657 { |
828 { |
658 case EGL_CLIENT_APIS: |
829 case EGL_CLIENT_APIS: |
659 ret = apis; |
830 ret = apis; |
660 break; |
831 break; |
661 |
832 |
662 case EGL_EXTENSIONS: |
833 case EGL_EXTENSIONS: |
663 ret = extensions; |
834 ret = extensions; |
664 break; |
835 break; |
665 |
836 |
666 case EGL_VENDOR: |
837 case EGL_VENDOR: |
667 ret = vendor; |
838 ret = vendor; |
668 break; |
839 break; |
669 |
840 |
670 case EGL_VERSION: |
841 case EGL_VERSION: |
671 ret = version; |
842 ret = version; |
672 break; |
843 break; |
673 |
844 |
674 default: |
845 default: |
675 EGL_RETURN(EGL_BAD_PARAMETER, NULL); |
846 EGL_RETURN(EGL_BAD_PARAMETER, NULL); |
676 } |
847 } |
677 EGL_RETURN(EGL_SUCCESS, ret); |
848 EGL_RETURN(EGL_SUCCESS, ret); |
678 } |
849 } |
679 |
850 |
680 /*-------------------------------------------------------------------*//*! |
851 /*-------------------------------------------------------------------*//*! |
681 * \brief |
852 * \brief |
682 * \param |
853 * \param |
683 * \return |
854 * \return |
684 * \note |
855 * \note |
685 *//*-------------------------------------------------------------------*/ |
856 *//*-------------------------------------------------------------------*/ |
686 |
857 |
687 #ifdef BUILD_WITH_PRIVATE_EGL |
858 #ifdef BUILD_WITH_PRIVATE_EGL |
688 RI_APIENTRY EGLBoolean do_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, |
859 RI_APIENTRY EGLBoolean do_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
689 EGLint config_size, EGLint *num_config) |
|
690 #else |
860 #else |
691 EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
861 EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
692 #endif |
862 #endif |
693 { |
863 { |
694 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
864 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
695 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
865 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
696 EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE); |
866 EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE); |
697 if (!configs) |
867 if(!configs) |
698 { |
868 { |
699 *num_config = display->getNumConfigs(); |
869 *num_config = display->getNumConfigs(); |
700 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
870 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
701 } |
871 } |
702 *num_config = RI_INT_MIN(config_size, display->getNumConfigs()); |
872 *num_config = RI_INT_MIN(config_size, display->getNumConfigs()); |
703 for (int i = 0; i < *num_config; i++) |
873 for(int i=0;i<*num_config;i++) |
704 configs[i] = display->getConfigByIdx(i).m_config; |
874 configs[i] = display->getConfigByIdx(i).m_config; |
705 |
875 |
706 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
876 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
707 } |
877 } |
708 |
878 |
709 /*-------------------------------------------------------------------*//*! |
879 /*-------------------------------------------------------------------*//*! |
710 * \brief |
880 * \brief |
711 * \param |
881 * \param |
712 * \return |
882 * \return |
713 * \note |
883 * \note |
714 *//*-------------------------------------------------------------------*/ |
884 *//*-------------------------------------------------------------------*/ |
715 |
885 |
716 static bool smaller(EGLint c, EGLint filter) |
886 static bool smaller(EGLint c, EGLint filter) |
717 { |
887 { |
718 return (filter != EGL_DONT_CARE) && (c < filter); |
888 return (filter != EGL_DONT_CARE) && (c < filter); |
719 } |
889 } |
720 |
890 |
721 #ifdef BUILD_WITH_PRIVATE_EGL |
891 #ifdef BUILD_WITH_PRIVATE_EGL |
722 RI_APIENTRY EGLBoolean do_eglChooseConfig(EGLDisplay dpy, |
892 RI_APIENTRY EGLBoolean do_eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
723 const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, |
|
724 EGLint *num_config) |
|
725 #else |
893 #else |
726 EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
894 EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) |
727 #endif |
895 #endif |
728 { |
896 { |
729 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
897 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
730 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
898 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
731 EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE); |
899 EGL_IF_ERROR(!num_config, EGL_BAD_PARAMETER, EGL_FALSE); |
732 |
900 |
733 if (!configs) |
901 if(!configs) |
734 { |
902 { |
735 *num_config = display->getNumConfigs(); |
903 *num_config = display->getNumConfigs(); |
736 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
904 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
737 } |
905 } |
738 *num_config = 0; |
906 *num_config = 0; |
739 if (!config_size) |
907 if(!config_size) |
740 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
908 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
741 |
909 |
742 int bufferSize = 0; |
910 int bufferSize = 0; |
743 int redSize = 0; |
911 int redSize = 0; |
744 int greenSize = 0; |
912 int greenSize = 0; |
747 int alphaSize = 0; |
915 int alphaSize = 0; |
748 int colorBufferType = EGL_RGB_BUFFER; |
916 int colorBufferType = EGL_RGB_BUFFER; |
749 int configID = EGL_DONT_CARE; |
917 int configID = EGL_DONT_CARE; |
750 int sampleBuffers = 0; |
918 int sampleBuffers = 0; |
751 int samples = 0; |
919 int samples = 0; |
752 if (attrib_list) |
920 if(attrib_list) |
|
921 { |
|
922 for(int i=0;attrib_list[i] != EGL_NONE;i+=2) |
753 { |
923 { |
754 for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) |
924 switch(attrib_list[i]) |
755 { |
925 { |
756 switch (attrib_list[i]) |
926 case EGL_BUFFER_SIZE: //depth of the color buffer |
757 { |
927 bufferSize = attrib_list[i+1]; |
758 case EGL_BUFFER_SIZE: //depth of the color buffer |
928 break; |
759 bufferSize = attrib_list[i + 1]; |
929 case EGL_RED_SIZE: //bits of Red in the color buffer |
760 break; |
930 redSize = attrib_list[i+1]; |
761 case EGL_RED_SIZE: //bits of Red in the color buffer |
931 break; |
762 redSize = attrib_list[i + 1]; |
932 case EGL_GREEN_SIZE: //bits of Green in the color buffer |
763 break; |
933 greenSize = attrib_list[i+1]; |
764 case EGL_GREEN_SIZE: //bits of Green in the color buffer |
934 break; |
765 greenSize = attrib_list[i + 1]; |
935 case EGL_BLUE_SIZE: //bits of Blue in the color buffer |
766 break; |
936 blueSize = attrib_list[i+1]; |
767 case EGL_BLUE_SIZE: //bits of Blue in the color buffer |
937 break; |
768 blueSize = attrib_list[i + 1]; |
938 case EGL_LUMINANCE_SIZE: //bits of Luminance in the color buffer |
769 break; |
939 luminanceSize = attrib_list[i+1]; |
770 case EGL_LUMINANCE_SIZE: //bits of Luminance in the color buffer |
940 break; |
771 luminanceSize = attrib_list[i + 1]; |
941 case EGL_ALPHA_SIZE: //bits of Alpha in the color buffer |
772 break; |
942 alphaSize = attrib_list[i+1]; |
773 case EGL_ALPHA_SIZE: //bits of Alpha in the color buffer |
943 break; |
774 alphaSize = attrib_list[i + 1]; |
944 case EGL_ALPHA_MASK_SIZE: //bits of Alpha in the alpha mask buffer |
775 break; |
945 if(attrib_list[i+1] > 8) |
776 case EGL_ALPHA_MASK_SIZE: //bits of Alpha in the alpha mask buffer |
946 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); //not supported |
777 if (attrib_list[i + 1] > 8) |
947 break; |
778 EGL_RETURN(EGL_SUCCESS, EGL_TRUE) |
948 case EGL_COLOR_BUFFER_TYPE: //enum color buffer type (EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER) |
779 ; //not supported |
949 EGL_IF_ERROR(attrib_list[i+1] != EGL_RGB_BUFFER && attrib_list[i+1] != EGL_LUMINANCE_BUFFER && attrib_list[i+1] != EGL_DONT_CARE, EGL_BAD_ATTRIBUTE, EGL_FALSE); |
780 break; |
950 colorBufferType = attrib_list[i+1]; |
781 case EGL_COLOR_BUFFER_TYPE: //enum color buffer type (EGL_RGB_BUFFER, EGL_LUMINANCE_BUFFER) |
951 break; |
782 EGL_IF_ERROR(attrib_list[i+1] != EGL_RGB_BUFFER && attrib_list[i+1] != EGL_LUMINANCE_BUFFER && attrib_list[i+1] != EGL_DONT_CARE, EGL_BAD_ATTRIBUTE, EGL_FALSE) |
952 case EGL_CONFIG_ID: //unique EGLConfig identifier |
783 ; |
953 configID = attrib_list[i+1]; |
784 colorBufferType = attrib_list[i + 1]; |
954 break; |
785 break; |
955 |
786 case EGL_CONFIG_ID: //unique EGLConfig identifier |
956 case EGL_SAMPLE_BUFFERS: //integer number of multisample buffers |
787 configID = attrib_list[i + 1]; |
957 sampleBuffers = attrib_list[i+1]; |
788 break; |
958 break; |
789 |
959 case EGL_SAMPLES: //integer number of samples per pixel |
790 case EGL_SAMPLE_BUFFERS: //integer number of multisample buffers |
960 samples = attrib_list[i+1]; |
791 sampleBuffers = attrib_list[i + 1]; |
961 break; |
792 break; |
962 |
793 case EGL_SAMPLES: //integer number of samples per pixel |
963 case EGL_BIND_TO_TEXTURE_RGB: //boolean True if bindable to RGB textures. (always EGL_FALSE) |
794 samples = attrib_list[i + 1]; |
964 case EGL_BIND_TO_TEXTURE_RGBA: //boolean True if bindable to RGBA textures. (always EGL_FALSE) |
795 break; |
965 case EGL_DEPTH_SIZE: //integer bits of Z in the depth buffer (always 0) |
796 |
966 case EGL_LEVEL: //integer frame buffer level (always 0) |
797 case EGL_BIND_TO_TEXTURE_RGB: //boolean True if bindable to RGB textures. (always EGL_FALSE) |
967 case EGL_NATIVE_RENDERABLE: //boolean EGL TRUE if native rendering APIs can render to surface (always EGL_FALSE) |
798 case EGL_BIND_TO_TEXTURE_RGBA: //boolean True if bindable to RGBA textures. (always EGL_FALSE) |
968 case EGL_STENCIL_SIZE: //integer bits of Stencil in the stencil buffer (always 0) |
799 case EGL_DEPTH_SIZE: //integer bits of Z in the depth buffer (always 0) |
969 if(attrib_list[i+1]) |
800 case EGL_LEVEL: //integer frame buffer level (always 0) |
970 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); //not supported |
801 case EGL_NATIVE_RENDERABLE: //boolean EGL TRUE if native rendering APIs can render to surface (always EGL_FALSE) |
971 break; |
802 case EGL_STENCIL_SIZE: //integer bits of Stencil in the stencil buffer (always 0) |
972 |
803 if (attrib_list[i + 1]) |
973 case EGL_CONFIG_CAVEAT: //enum any caveats for the configuration (always EGL_NONE) |
804 EGL_RETURN(EGL_SUCCESS, EGL_TRUE) |
974 case EGL_NATIVE_VISUAL_TYPE: //integer native visual type of the associated visual (always EGL_NONE) |
805 ; //not supported |
975 if(attrib_list[i+1] != EGL_NONE) |
806 break; |
976 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); //not supported |
807 |
977 break; |
808 case EGL_CONFIG_CAVEAT: //enum any caveats for the configuration (always EGL_NONE) |
978 |
809 case EGL_NATIVE_VISUAL_TYPE: //integer native visual type of the associated visual (always EGL_NONE) |
979 case EGL_MAX_SWAP_INTERVAL: //integer maximum swap interval (always 1) |
810 if (attrib_list[i + 1] != EGL_NONE) |
980 case EGL_MIN_SWAP_INTERVAL: //integer minimum swap interval (always 1) |
811 EGL_RETURN(EGL_SUCCESS, EGL_TRUE) |
981 if(attrib_list[i+1] != 1) |
812 ; //not supported |
982 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); //not supported |
813 break; |
983 break; |
814 |
984 |
815 case EGL_MAX_SWAP_INTERVAL: //integer maximum swap interval (always 1) |
985 case EGL_RENDERABLE_TYPE: //bitmask which client rendering APIs are supported. (always EGL_OPENVG_BIT) |
816 case EGL_MIN_SWAP_INTERVAL: //integer minimum swap interval (always 1) |
986 if(!(attrib_list[i+1] & EGL_OPENVG_BIT)) |
817 if (attrib_list[i + 1] != 1) |
987 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); //not supported |
818 EGL_RETURN(EGL_SUCCESS, EGL_TRUE) |
988 break; |
819 ; //not supported |
989 |
820 break; |
990 case EGL_SURFACE_TYPE: //bitmask which types of EGL surfaces are supported. (always EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT) |
821 |
991 break; //all types are always supported |
822 case EGL_RENDERABLE_TYPE: //bitmask which client rendering APIs are supported. (always EGL_OPENVG_BIT) |
992 |
823 if (!(attrib_list[i + 1] & EGL_OPENVG_BIT)) |
993 case EGL_TRANSPARENT_TYPE: //enum type of transparency supported (always EGL_NONE) |
824 EGL_RETURN(EGL_SUCCESS, EGL_TRUE) |
994 case EGL_NATIVE_VISUAL_ID: //integer handle of corresponding native visual (always 0) |
825 ; //not supported |
995 case EGL_MAX_PBUFFER_WIDTH: //integer maximum width of pbuffer (always INT_MAX) |
826 break; |
996 case EGL_MAX_PBUFFER_HEIGHT: //integer maximum height of pbuffer (always INT_MAX) |
827 |
997 case EGL_MAX_PBUFFER_PIXELS: //integer maximum size of pbuffer (always INT_MAX) |
828 case EGL_SURFACE_TYPE: //bitmask which types of EGL surfaces are supported. (always EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT) |
998 case EGL_TRANSPARENT_RED_VALUE: //integer transparent red value (undefined) |
829 break; //all types are always supported |
999 case EGL_TRANSPARENT_GREEN_VALUE: //integer transparent green value (undefined) |
830 |
1000 case EGL_TRANSPARENT_BLUE_VALUE: //integer transparent blue value (undefined) |
831 case EGL_TRANSPARENT_TYPE: //enum type of transparency supported (always EGL_NONE) |
1001 break; //ignored |
832 case EGL_NATIVE_VISUAL_ID: //integer handle of corresponding native visual (always 0) |
1002 |
833 case EGL_MAX_PBUFFER_WIDTH: //integer maximum width of pbuffer (always INT_MAX) |
1003 default: |
834 case EGL_MAX_PBUFFER_HEIGHT: //integer maximum height of pbuffer (always INT_MAX) |
1004 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE); //unknown attribute |
835 case EGL_MAX_PBUFFER_PIXELS: //integer maximum size of pbuffer (always INT_MAX) |
|
836 case EGL_TRANSPARENT_RED_VALUE: //integer transparent red value (undefined) |
|
837 case EGL_TRANSPARENT_GREEN_VALUE: //integer transparent green value (undefined) |
|
838 case EGL_TRANSPARENT_BLUE_VALUE: //integer transparent blue value (undefined) |
|
839 break; //ignored |
|
840 |
|
841 default: |
|
842 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE) |
|
843 ; //unknown attribute |
|
844 } |
|
845 } |
1005 } |
846 } |
1006 } |
847 |
1007 } |
848 if (configID && configID != EGL_DONT_CARE) |
1008 |
849 { //if CONFIG_ID is defined, ignore the rest of the attribs |
1009 if(configID && configID != EGL_DONT_CARE) |
850 for (int i = 0; i < EGL_NUMCONFIGS; i++) |
1010 { //if CONFIG_ID is defined, ignore the rest of the attribs |
851 { |
1011 for(int i=0;i<EGL_NUMCONFIGS;i++) |
852 if (display->getConfigByIdx(i).m_configID == configID) |
1012 { |
853 { |
1013 if(display->getConfigByIdx(i).m_configID == configID) |
854 *num_config = 1; |
1014 { |
855 *configs = display->getConfigByIdx(i).m_config; |
1015 *num_config = 1; |
856 } |
1016 *configs = display->getConfigByIdx(i).m_config; |
857 } |
1017 } |
|
1018 } |
858 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1019 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
859 } |
1020 } |
860 |
1021 |
861 //go through all configs, add passed configs to return list |
1022 //go through all configs, add passed configs to return list |
862 //TODO take alpha mask size into account |
1023 //TODO take alpha mask size into account |
863 EGLConfig found[EGL_NUMCONFIGS]; |
1024 EGLConfig found[EGL_NUMCONFIGS]; |
864 int keys[EGL_NUMCONFIGS]; |
1025 int keys[EGL_NUMCONFIGS]; |
865 int numFound = 0; |
1026 int numFound = 0; |
866 for (int i = 0; i < display->getNumConfigs(); i++) |
1027 for(int i=0;i<display->getNumConfigs();i++) |
867 { |
1028 { |
868 const RIEGLConfig& c = display->getConfigByIdx(i); |
1029 const RIEGLConfig& c = display->getConfigByIdx(i); |
869 |
1030 |
870 int colorBits = c.m_desc.redBits + c.m_desc.greenBits |
1031 int colorBits = c.m_desc.redBits + c.m_desc.greenBits + c.m_desc.blueBits; |
871 + c.m_desc.blueBits; |
|
872 int luminanceBits = c.m_desc.luminanceBits; |
1032 int luminanceBits = c.m_desc.luminanceBits; |
873 int configBufferSize; |
1033 int configBufferSize; |
874 if (colorBits) |
1034 if(colorBits) |
875 { |
1035 { |
876 RI_ASSERT(!luminanceBits); |
1036 RI_ASSERT(!luminanceBits); |
877 colorBits += c.m_desc.alphaBits; |
1037 colorBits += c.m_desc.alphaBits; |
878 configBufferSize = colorBits; |
1038 configBufferSize = colorBits; |
879 } |
1039 } |
880 else if (luminanceBits) |
1040 else if(luminanceBits) |
881 { |
1041 { |
882 luminanceBits += c.m_desc.alphaBits; |
1042 luminanceBits += c.m_desc.alphaBits; |
883 configBufferSize = luminanceBits; |
1043 configBufferSize = luminanceBits; |
884 } |
1044 } |
885 else |
1045 else |
886 { //alpha only surface |
1046 { //alpha only surface |
887 colorBits = c.m_desc.alphaBits; |
1047 colorBits = c.m_desc.alphaBits; |
888 luminanceBits = c.m_desc.alphaBits; |
1048 luminanceBits = c.m_desc.alphaBits; |
889 configBufferSize = colorBits; |
1049 configBufferSize = colorBits; |
890 } |
1050 } |
891 |
1051 |
892 if (smaller(configBufferSize, bufferSize)) |
1052 if (smaller(configBufferSize, bufferSize)) |
893 continue; |
1053 continue; |
894 |
1054 |
895 int configSampleBuffers = c.m_samples == 1 ? 0 : 1; |
1055 int configSampleBuffers = c.m_samples == 1 ? 0 : 1; |
896 if (smaller(configSampleBuffers, sampleBuffers)) |
1056 if (smaller(configSampleBuffers, sampleBuffers)) |
897 continue; |
1057 continue; |
898 if (smaller(c.m_samples, samples)) |
1058 if (smaller(c.m_samples, samples)) |
899 continue; |
1059 continue; |
900 |
1060 |
901 if (smaller(c.m_desc.redBits, redSize) || smaller(c.m_desc.greenBits, |
1061 if (smaller(c.m_desc.redBits, redSize) |
902 greenSize) || smaller(c.m_desc.blueBits, blueSize) || smaller( |
1062 || smaller(c.m_desc.greenBits, greenSize) |
903 c.m_desc.alphaBits, alphaSize)) |
1063 || smaller(c.m_desc.blueBits, blueSize) |
|
1064 || smaller(c.m_desc.alphaBits, alphaSize) ) |
904 continue; |
1065 continue; |
905 |
1066 |
906 if (smaller(c.m_desc.luminanceBits, luminanceSize)) |
1067 if (smaller(c.m_desc.luminanceBits, luminanceSize)) |
907 continue; |
1068 continue; |
908 |
1069 |
909 if ((colorBufferType == EGL_RGB_BUFFER && !colorBits) |
1070 if ((colorBufferType == EGL_RGB_BUFFER && !colorBits) || |
910 || (colorBufferType == EGL_LUMINANCE_BUFFER && !luminanceBits)) |
1071 (colorBufferType == EGL_LUMINANCE_BUFFER && !luminanceBits)) |
911 continue; |
1072 continue; |
912 |
1073 |
913 int sortKey = c.m_configID; //sort from smaller to larger |
1074 int sortKey = c.m_configID; //sort from smaller to larger |
914 int sortBits = 0; |
1075 int sortBits = 0; |
915 if (redSize != 0 && redSize != EGL_DONT_CARE) |
1076 if(redSize != 0 && redSize != EGL_DONT_CARE) |
916 sortBits += c.m_desc.redBits; |
1077 sortBits += c.m_desc.redBits; |
917 if (greenSize != 0 && greenSize != EGL_DONT_CARE) |
1078 if(greenSize != 0 && greenSize != EGL_DONT_CARE) |
918 sortBits += c.m_desc.greenBits; |
1079 sortBits += c.m_desc.greenBits; |
919 if (blueSize != 0 && blueSize != EGL_DONT_CARE) |
1080 if(blueSize != 0 && blueSize != EGL_DONT_CARE) |
920 sortBits += c.m_desc.blueBits; |
1081 sortBits += c.m_desc.blueBits; |
921 if (alphaSize != 0 && alphaSize != EGL_DONT_CARE) |
1082 if(alphaSize != 0 && alphaSize != EGL_DONT_CARE) |
922 sortBits += c.m_desc.alphaBits; |
1083 sortBits += c.m_desc.alphaBits; |
923 if (luminanceSize != 0 && luminanceSize != EGL_DONT_CARE) |
1084 if(luminanceSize != 0 && luminanceSize != EGL_DONT_CARE) |
924 sortBits += c.m_desc.luminanceBits; |
1085 sortBits += c.m_desc.luminanceBits; |
925 RI_ASSERT(c.m_configID <= EGL_NUMCONFIGS); //if there are more configs, increase the shift value |
1086 RI_ASSERT(c.m_configID <= EGL_NUMCONFIGS); //if there are more configs, increase the shift value |
926 RI_ASSERT(sortBits <= 32); |
1087 RI_ASSERT(sortBits <= 32); |
927 sortKey += (32 - sortBits) << 4; //sort from larger to smaller |
1088 sortKey += (32-sortBits) << 4; //sort from larger to smaller |
928 |
1089 |
929 found[numFound] = c.m_config; |
1090 found[numFound] = c.m_config; |
930 keys[numFound++] = sortKey; |
1091 keys[numFound++] = sortKey; |
931 } |
1092 } |
932 if (!numFound) |
1093 if(!numFound) |
933 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1094 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
934 |
1095 |
935 //sort return list into increasing order |
1096 //sort return list into increasing order |
936 for (int e = 0; e < numFound - 1; e++) |
1097 for(int e=0;e<numFound-1;e++) |
|
1098 { |
|
1099 for(int f=e+1;f<numFound;f++) |
937 { |
1100 { |
938 for (int f = e + 1; f < numFound; f++) |
1101 if(keys[e] > keys[f]) |
939 { |
1102 { |
940 if (keys[e] > keys[f]) |
1103 EGLConfig tmp = found[e]; |
941 { |
1104 found[e] = found[f]; |
942 EGLConfig tmp = found[e]; |
1105 found[f] = tmp; |
943 found[e] = found[f]; |
|
944 found[f] = tmp; |
|
945 RI_INT_SWAP(keys[e], keys[f]); |
1106 RI_INT_SWAP(keys[e], keys[f]); |
946 } |
|
947 } |
1107 } |
948 } |
1108 } |
|
1109 } |
949 |
1110 |
950 //write configs into return array |
1111 //write configs into return array |
951 numFound = RI_INT_MIN(numFound, config_size); |
1112 numFound = RI_INT_MIN(numFound, config_size); |
952 for (int i = 0; i < numFound; i++) |
1113 for(int i=0;i<numFound;i++) |
953 { |
1114 { |
954 configs[i] = found[i]; |
1115 configs[i] = found[i]; |
955 } |
1116 } |
956 *num_config = numFound; |
1117 *num_config = numFound; |
957 |
1118 |
958 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1119 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
959 } |
1120 } |
960 |
1121 |
961 /*-------------------------------------------------------------------*//*! |
1122 /*-------------------------------------------------------------------*//*! |
962 * \brief |
1123 * \brief |
963 * \param |
1124 * \param |
964 * \return |
1125 * \return |
965 * \note |
1126 * \note |
966 *//*-------------------------------------------------------------------*/ |
1127 *//*-------------------------------------------------------------------*/ |
967 |
1128 |
968 #ifdef BUILD_WITH_PRIVATE_EGL |
1129 #ifdef BUILD_WITH_PRIVATE_EGL |
969 RI_APIENTRY EGLBoolean do_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, |
1130 RI_APIENTRY EGLBoolean do_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) |
970 EGLint attribute, EGLint *value) |
|
971 #else |
1131 #else |
972 EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) |
1132 EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) |
973 #endif |
1133 #endif |
974 { |
1134 { |
975 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1135 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
976 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1136 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
977 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_FALSE); |
1137 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_FALSE); |
978 const RIEGLConfig& c = display->getConfig(config); |
1138 const RIEGLConfig& c = display->getConfig(config); |
979 switch (attribute) |
1139 switch(attribute) |
980 { |
1140 { |
981 case EGL_BUFFER_SIZE: |
1141 case EGL_BUFFER_SIZE: |
982 *value = RI_INT_MAX(c.m_desc.redBits + c.m_desc.greenBits |
1142 *value = RI_INT_MAX(c.m_desc.redBits + c.m_desc.greenBits + c.m_desc.blueBits + c.m_desc.alphaBits, c.m_desc.luminanceBits + c.m_desc.alphaBits); |
983 + c.m_desc.blueBits + c.m_desc.alphaBits, |
1143 break; |
984 c.m_desc.luminanceBits + c.m_desc.alphaBits); |
1144 |
985 break; |
1145 case EGL_RED_SIZE: |
986 |
1146 *value = c.m_desc.redBits; |
987 case EGL_RED_SIZE: |
1147 break; |
988 *value = c.m_desc.redBits; |
1148 |
989 break; |
1149 case EGL_GREEN_SIZE: |
990 |
1150 *value = c.m_desc.greenBits; |
991 case EGL_GREEN_SIZE: |
1151 break; |
992 *value = c.m_desc.greenBits; |
1152 |
993 break; |
1153 case EGL_BLUE_SIZE: |
994 |
1154 *value = c.m_desc.blueBits; |
995 case EGL_BLUE_SIZE: |
1155 break; |
996 *value = c.m_desc.blueBits; |
1156 |
997 break; |
1157 case EGL_LUMINANCE_SIZE: |
998 |
1158 *value = c.m_desc.luminanceBits; |
999 case EGL_LUMINANCE_SIZE: |
1159 break; |
1000 *value = c.m_desc.luminanceBits; |
1160 |
1001 break; |
1161 case EGL_ALPHA_SIZE: |
1002 |
1162 *value = c.m_desc.alphaBits; |
1003 case EGL_ALPHA_SIZE: |
1163 break; |
1004 *value = c.m_desc.alphaBits; |
1164 |
1005 break; |
1165 case EGL_ALPHA_MASK_SIZE: |
1006 |
1166 *value = c.m_maskBits; |
1007 case EGL_ALPHA_MASK_SIZE: |
1167 break; |
1008 *value = c.m_maskBits; |
1168 |
1009 break; |
1169 case EGL_BIND_TO_TEXTURE_RGB: |
1010 |
1170 case EGL_BIND_TO_TEXTURE_RGBA: |
1011 case EGL_BIND_TO_TEXTURE_RGB: |
1171 *value = EGL_FALSE; |
1012 case EGL_BIND_TO_TEXTURE_RGBA: |
1172 break; |
1013 *value = EGL_FALSE; |
1173 |
1014 break; |
1174 case EGL_COLOR_BUFFER_TYPE: |
1015 |
1175 if(c.m_desc.redBits) |
1016 case EGL_COLOR_BUFFER_TYPE: |
1176 *value = EGL_RGB_BUFFER; |
1017 if (c.m_desc.redBits) |
1177 else |
1018 *value = EGL_RGB_BUFFER; |
1178 *value = EGL_LUMINANCE_BUFFER; |
1019 else |
1179 break; |
1020 *value = EGL_LUMINANCE_BUFFER; |
1180 |
1021 break; |
1181 case EGL_CONFIG_CAVEAT: |
1022 |
1182 *value = EGL_NONE; |
1023 case EGL_CONFIG_CAVEAT: |
1183 break; |
1024 *value = EGL_NONE; |
1184 |
1025 break; |
1185 case EGL_CONFIG_ID: |
1026 |
1186 *value = c.m_configID; |
1027 case EGL_CONFIG_ID: |
1187 break; |
1028 *value = c.m_configID; |
1188 |
1029 break; |
1189 case EGL_DEPTH_SIZE: |
1030 |
1190 *value = 0; |
1031 case EGL_DEPTH_SIZE: |
1191 break; |
1032 *value = 0; |
1192 |
1033 break; |
1193 case EGL_LEVEL: |
1034 |
1194 *value = 0; |
1035 case EGL_LEVEL: |
1195 break; |
1036 *value = 0; |
1196 |
1037 break; |
1197 case EGL_MAX_PBUFFER_WIDTH: |
1038 |
1198 case EGL_MAX_PBUFFER_HEIGHT: |
1039 case EGL_MAX_PBUFFER_WIDTH: |
1199 *value = 16384; //NOTE arbitrary maximum |
1040 case EGL_MAX_PBUFFER_HEIGHT: |
1200 break; |
1041 *value = 16384; //NOTE arbitrary maximum |
1201 |
1042 break; |
1202 case EGL_MAX_PBUFFER_PIXELS: |
1043 |
1203 *value = 16384*16384; //NOTE arbitrary maximum |
1044 case EGL_MAX_PBUFFER_PIXELS: |
1204 break; |
1045 *value = 16384 * 16384; //NOTE arbitrary maximum |
1205 |
1046 break; |
1206 case EGL_MAX_SWAP_INTERVAL: |
1047 |
1207 case EGL_MIN_SWAP_INTERVAL: |
1048 case EGL_MAX_SWAP_INTERVAL: |
1208 *value = 1; |
1049 case EGL_MIN_SWAP_INTERVAL: |
1209 break; |
1050 *value = 1; |
1210 |
1051 break; |
1211 case EGL_NATIVE_RENDERABLE: |
1052 |
1212 *value = EGL_FALSE; |
1053 case EGL_NATIVE_RENDERABLE: |
1213 break; |
1054 *value = EGL_FALSE; |
1214 |
1055 break; |
1215 case EGL_NATIVE_VISUAL_ID: |
1056 |
1216 *value = 0; |
1057 case EGL_NATIVE_VISUAL_ID: |
1217 break; |
1058 *value = 0; |
1218 |
1059 break; |
1219 case EGL_NATIVE_VISUAL_TYPE: |
1060 |
1220 *value = EGL_NONE; |
1061 case EGL_NATIVE_VISUAL_TYPE: |
1221 break; |
1062 *value = EGL_NONE; |
1222 |
1063 break; |
1223 case EGL_RENDERABLE_TYPE: |
1064 |
1224 *value = EGL_OPENVG_BIT; |
1065 case EGL_RENDERABLE_TYPE: |
1225 break; |
1066 *value = EGL_OPENVG_BIT; |
1226 |
1067 break; |
1227 case EGL_SAMPLE_BUFFERS: |
1068 |
1228 *value = c.m_samples > 1 ? 1 : 0; |
1069 case EGL_SAMPLE_BUFFERS: |
1229 break; |
1070 *value = c.m_samples > 1 ? 1 : 0; |
1230 |
1071 break; |
1231 case EGL_SAMPLES: |
1072 |
1232 *value = c.m_samples > 1 ? c.m_samples : 0; |
1073 case EGL_SAMPLES: |
1233 break; |
1074 *value = c.m_samples > 1 ? c.m_samples : 0; |
1234 |
1075 break; |
1235 case EGL_STENCIL_SIZE: |
1076 |
1236 *value = 0; |
1077 case EGL_STENCIL_SIZE: |
1237 break; |
1078 *value = 0; |
1238 |
1079 break; |
1239 case EGL_SURFACE_TYPE: |
1080 |
1240 *value = EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | EGL_VG_COLORSPACE_LINEAR_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT; |
1081 case EGL_SURFACE_TYPE: |
1241 break; |
1082 *value = EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT |
1242 |
1083 | EGL_VG_COLORSPACE_LINEAR_BIT |
1243 case EGL_TRANSPARENT_TYPE: |
1084 | EGL_VG_ALPHA_FORMAT_PRE_BIT; |
1244 *value = EGL_NONE; |
1085 break; |
1245 break; |
1086 |
1246 |
1087 case EGL_TRANSPARENT_TYPE: |
1247 case EGL_TRANSPARENT_RED_VALUE: |
1088 *value = EGL_NONE; |
1248 case EGL_TRANSPARENT_GREEN_VALUE: |
1089 break; |
1249 case EGL_TRANSPARENT_BLUE_VALUE: |
1090 |
1250 *value = 0; |
1091 case EGL_TRANSPARENT_RED_VALUE: |
1251 break; |
1092 case EGL_TRANSPARENT_GREEN_VALUE: |
1252 |
1093 case EGL_TRANSPARENT_BLUE_VALUE: |
1253 case EGL_CONFORMANT: |
1094 *value = 0; |
1254 *value = EGL_OPENVG_BIT; //TODO return proper value |
1095 break; |
1255 break; |
1096 |
1256 |
1097 case EGL_CONFORMANT: |
1257 default: |
1098 *value = EGL_OPENVG_BIT; //TODO return proper value |
1258 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
1099 break; |
1259 } |
1100 |
|
1101 default: |
|
1102 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE) |
|
1103 ; |
|
1104 } |
|
1105 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1260 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1106 } |
1261 } |
1107 |
1262 |
1108 /*-------------------------------------------------------------------*//*! |
1263 /*-------------------------------------------------------------------*//*! |
1109 * \brief |
1264 * \brief |
1110 * \param |
1265 * \param |
1111 * \return |
1266 * \return |
1112 * \note |
1267 * \note |
1113 *//*-------------------------------------------------------------------*/ |
1268 *//*-------------------------------------------------------------------*/ |
1114 |
1269 |
1115 #ifdef BUILD_WITH_PRIVATE_EGL |
1270 #ifdef BUILD_WITH_PRIVATE_EGL |
1116 RI_APIENTRY EGLSurface do_eglCreateWindowSurface(EGLDisplay dpy, |
1271 RI_APIENTRY EGLSurface do_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) |
1117 EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) |
|
1118 #else |
1272 #else |
1119 EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) |
1273 EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) |
1120 #endif |
1274 #endif |
1121 { |
1275 { |
1122 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1276 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1123 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1277 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1124 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1278 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1125 |
1279 |
1126 int renderBuffer = EGL_BACK_BUFFER; |
1280 int renderBuffer = EGL_BACK_BUFFER; |
1127 int colorSpace = EGL_VG_COLORSPACE_sRGB; |
1281 int colorSpace = EGL_VG_COLORSPACE_sRGB; |
1128 int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; |
1282 int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; |
1129 if (attrib_list) |
1283 if(attrib_list) |
|
1284 { |
|
1285 for(int i=0;attrib_list[i] != EGL_NONE;i+=2) |
1130 { |
1286 { |
1131 for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) |
1287 switch(attrib_list[i]) |
1132 { |
1288 { |
1133 switch (attrib_list[i]) |
1289 case EGL_RENDER_BUFFER: |
1134 { |
1290 renderBuffer = attrib_list[i+1]; |
1135 case EGL_RENDER_BUFFER: |
1291 break; |
1136 renderBuffer = attrib_list[i + 1]; |
1292 |
1137 break; |
1293 case EGL_VG_COLORSPACE: |
1138 |
1294 colorSpace = attrib_list[i+1]; |
1139 case EGL_VG_COLORSPACE: |
1295 break; |
1140 colorSpace = attrib_list[i + 1]; |
1296 |
1141 break; |
1297 case EGL_VG_ALPHA_FORMAT: |
1142 |
1298 alphaFormat = attrib_list[i+1]; |
1143 case EGL_VG_ALPHA_FORMAT: |
1299 break; |
1144 alphaFormat = attrib_list[i + 1]; |
1300 |
1145 break; |
1301 default: |
1146 |
1302 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
1147 default: |
|
1148 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE) |
|
1149 ; |
|
1150 } |
|
1151 } |
1303 } |
1152 } |
1304 } |
|
1305 } |
1153 //we ignore the renderBuffer parameter since we can only render to double buffered surfaces |
1306 //we ignore the renderBuffer parameter since we can only render to double buffered surfaces |
1154 |
1307 |
1155 //TODO If the attributes of win do not correspond to config, then an EGL BAD MATCH error is generated. |
1308 //TODO If the attributes of win do not correspond to config, then an EGL BAD MATCH error is generated. |
1156 //TODO If there is already an EGLConfig associated with win (as a result of a previous eglCreateWindowSurface call), then an EGL BAD ALLOC error is generated |
1309 //TODO If there is already an EGLConfig associated with win (as a result of a previous eglCreateWindowSurface call), then an EGL BAD ALLOC error is generated |
1157 |
1310 |
1158 void* wc = NULL; |
1311 void* wc = NULL; |
1159 Drawable* d = NULL; |
1312 Drawable* d = NULL; |
1160 RIEGLSurface* s = NULL; |
1313 RIEGLSurface* s = NULL; |
1161 try |
1314 try |
1162 { |
1315 { |
1163 wc = OSCreateWindowContext(win); |
1316 wc = OSCreateWindowContext(win); |
1164 RI_ASSERT(wc); |
1317 RI_ASSERT(wc); |
1165 //TODO what should happen if window width or height is zero? |
1318 //TODO what should happen if window width or height is zero? |
1166 int windowWidth = 0, windowHeight = 0; |
1319 int windowWidth = 0, windowHeight = 0; |
1167 OSGetWindowSize(wc, windowWidth, windowHeight); |
1320 OSGetWindowSize(wc, windowWidth, windowHeight); |
1168 bool isWindow = OSIsWindow(wc); |
1321 bool isWindow = OSIsWindow(wc); |
1169 if (windowWidth <= 0 || windowHeight <= 0 || !isWindow) |
1322 if(windowWidth <= 0 || windowHeight <= 0 || !isWindow) |
1170 { |
1323 { |
1171 OSDestroyWindowContext(wc); |
1324 OSDestroyWindowContext(wc); |
1172 EGL_IF_ERROR(!isWindow, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
1325 EGL_IF_ERROR(!isWindow, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
1173 EGL_IF_ERROR(windowWidth <= 0 || windowHeight <= 0, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
1326 EGL_IF_ERROR(windowWidth <= 0 || windowHeight <= 0, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
1174 } |
1327 } |
1175 d |
1328 d = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), windowWidth, windowHeight, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits)); //throws bad_alloc |
1176 = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), windowWidth, windowHeight, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits)); //throws bad_alloc |
|
1177 RI_ASSERT(d); |
1329 RI_ASSERT(d); |
1178 s = RI_NEW(RIEGLSurface,(wc, config, d, false, renderBuffer)); //throws bad_alloc |
1330 s = RI_NEW(RIEGLSurface,(wc, config, d, false, renderBuffer)); //throws bad_alloc |
1179 RI_ASSERT(s); |
1331 RI_ASSERT(s); |
1180 s->addReference(); |
1332 s->addReference(); |
1181 display->addSurface(s); //throws bad_alloc |
1333 display->addSurface(s); //throws bad_alloc |
1182 } |
1334 } |
1183 catch (std::bad_alloc) |
1335 catch(std::bad_alloc) |
1184 { |
1336 { |
1185 OSDestroyWindowContext(wc); |
1337 OSDestroyWindowContext(wc); |
1186 RI_DELETE(d); |
1338 RI_DELETE(d); |
1187 RI_DELETE(s); |
1339 RI_DELETE(s); |
1188 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1340 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1189 } |
1341 } |
1190 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1342 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1191 } |
1343 } |
1192 |
1344 |
1193 /*-------------------------------------------------------------------*//*! |
1345 /*-------------------------------------------------------------------*//*! |
1194 * \brief |
1346 * \brief |
1195 * \param |
1347 * \param |
1196 * \return |
1348 * \return |
1197 * \note |
1349 * \note |
1198 *//*-------------------------------------------------------------------*/ |
1350 *//*-------------------------------------------------------------------*/ |
1199 |
1351 |
1200 #ifdef BUILD_WITH_PRIVATE_EGL |
1352 #ifdef BUILD_WITH_PRIVATE_EGL |
1201 RI_APIENTRY EGLSurface do_eglCreatePbufferSurface(EGLDisplay dpy, |
1353 RI_APIENTRY EGLSurface do_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) |
1202 EGLConfig config, const EGLint *attrib_list) |
|
1203 #else |
1354 #else |
1204 EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) |
1355 EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) |
1205 #endif |
1356 #endif |
1206 { |
1357 { |
1207 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1358 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1208 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1359 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1209 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1360 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1210 |
1361 |
1211 int width = 0, height = 0; |
1362 int width = 0, height = 0; |
1212 bool largestPbuffer = false; |
1363 bool largestPbuffer = false; |
1213 int colorSpace = EGL_VG_COLORSPACE_sRGB; |
1364 int colorSpace = EGL_VG_COLORSPACE_sRGB; |
1214 int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; |
1365 int alphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; |
1215 if (attrib_list) |
1366 if(attrib_list) |
|
1367 { |
|
1368 for(int i=0;attrib_list[i] != EGL_NONE;i+=2) |
1216 { |
1369 { |
1217 for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) |
1370 switch(attrib_list[i]) |
1218 { |
1371 { |
1219 switch (attrib_list[i]) |
1372 case EGL_WIDTH: |
1220 { |
1373 width = attrib_list[i+1]; |
1221 case EGL_WIDTH: |
1374 break; |
1222 width = attrib_list[i + 1]; |
1375 |
1223 break; |
1376 case EGL_HEIGHT: |
1224 |
1377 height = attrib_list[i+1]; |
1225 case EGL_HEIGHT: |
1378 break; |
1226 height = attrib_list[i + 1]; |
1379 |
1227 break; |
1380 case EGL_LARGEST_PBUFFER: |
1228 |
1381 largestPbuffer = attrib_list[i+1] ? true : false; |
1229 case EGL_LARGEST_PBUFFER: |
1382 break; |
1230 largestPbuffer = attrib_list[i + 1] ? true : false; |
1383 |
1231 break; |
1384 case EGL_VG_COLORSPACE: |
1232 |
1385 colorSpace = attrib_list[i+1]; |
1233 case EGL_VG_COLORSPACE: |
1386 break; |
1234 colorSpace = attrib_list[i + 1]; |
1387 |
1235 break; |
1388 case EGL_VG_ALPHA_FORMAT: |
1236 |
1389 alphaFormat = attrib_list[i+1]; |
1237 case EGL_VG_ALPHA_FORMAT: |
1390 break; |
1238 alphaFormat = attrib_list[i + 1]; |
1391 |
1239 break; |
1392 case EGL_TEXTURE_FORMAT: //config doesn't support OpenGL ES |
1240 |
1393 case EGL_TEXTURE_TARGET: //config doesn't support OpenGL ES |
1241 case EGL_TEXTURE_FORMAT: //config doesn't support OpenGL ES |
1394 case EGL_MIPMAP_TEXTURE: //config doesn't support OpenGL ES |
1242 case EGL_TEXTURE_TARGET: //config doesn't support OpenGL ES |
1395 default: |
1243 case EGL_MIPMAP_TEXTURE: //config doesn't support OpenGL ES |
1396 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
1244 default: |
|
1245 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE) |
|
1246 ; |
|
1247 } |
|
1248 } |
1397 } |
1249 } |
1398 } |
|
1399 } |
1250 EGL_IF_ERROR(width <= 0 || height <= 0, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
1400 EGL_IF_ERROR(width <= 0 || height <= 0, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
1251 |
1401 |
1252 Drawable* d = NULL; |
1402 Drawable* d = NULL; |
1253 RIEGLSurface* s = NULL; |
1403 RIEGLSurface* s = NULL; |
1254 try |
1404 try |
1255 { |
1405 { |
1256 d |
1406 d = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), width, height, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits)); //throws bad_alloc |
1257 = RI_NEW(Drawable, (display->getConfig(config).configToDescriptor((colorSpace == EGL_VG_COLORSPACE_LINEAR) ? false : true, (alphaFormat == EGL_VG_ALPHA_FORMAT_PRE) ? true : false), width, height, display->getConfig(config).m_samples, display->getConfig(config).m_maskBits)); //throws bad_alloc |
|
1258 RI_ASSERT(d); |
1407 RI_ASSERT(d); |
1259 s |
1408 s = RI_NEW(RIEGLSurface,(NULL, config, d, largestPbuffer, EGL_BACK_BUFFER)); //throws bad_alloc |
1260 = RI_NEW(RIEGLSurface,(NULL, config, d, largestPbuffer, EGL_BACK_BUFFER)); //throws bad_alloc |
|
1261 RI_ASSERT(s); |
1409 RI_ASSERT(s); |
1262 s->addReference(); |
1410 s->addReference(); |
1263 display->addSurface(s); //throws bad_alloc |
1411 display->addSurface(s); //throws bad_alloc |
1264 } |
1412 } |
1265 catch (std::bad_alloc) |
1413 catch(std::bad_alloc) |
1266 { |
1414 { |
1267 RI_DELETE(d); |
1415 RI_DELETE(d); |
1268 RI_DELETE(s); |
1416 RI_DELETE(s); |
1269 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1417 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1270 } |
1418 } |
1271 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1419 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1272 } |
1420 } |
1273 |
1421 |
1274 /*-------------------------------------------------------------------*//*! |
1422 /*-------------------------------------------------------------------*//*! |
1275 * \brief |
1423 * \brief |
1276 * \param |
1424 * \param |
1277 * \return |
1425 * \return |
1278 * \note |
1426 * \note |
1279 *//*-------------------------------------------------------------------*/ |
1427 *//*-------------------------------------------------------------------*/ |
1280 |
1428 |
1281 #ifdef BUILD_WITH_PRIVATE_EGL |
1429 #ifdef BUILD_WITH_PRIVATE_EGL |
1282 RI_APIENTRY EGLSurface do_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, |
1430 RI_APIENTRY EGLSurface do_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) |
1283 EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, |
|
1284 const EGLint *attrib_list) |
|
1285 #else |
1431 #else |
1286 EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) |
1432 EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) |
1287 #endif |
1433 #endif |
1288 { |
1434 { |
1289 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1435 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1290 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1436 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1291 EGL_IF_ERROR(buftype != EGL_OPENVG_IMAGE, EGL_BAD_PARAMETER, EGL_NO_SURFACE); |
1437 EGL_IF_ERROR(buftype != EGL_OPENVG_IMAGE, EGL_BAD_PARAMETER, EGL_NO_SURFACE); |
1292 EGL_IF_ERROR(!buffer, EGL_BAD_PARAMETER, EGL_NO_SURFACE); //TODO should also check if buffer really is a valid VGImage object (needs VG context for that) |
1438 EGL_IF_ERROR(!buffer, EGL_BAD_PARAMETER, EGL_NO_SURFACE); //TODO should also check if buffer really is a valid VGImage object (needs VG context for that) |
1293 Image* image = (Image*) buffer; |
1439 Image* image = (Image*)buffer; |
1294 EGL_IF_ERROR(image->isInUse(), EGL_BAD_ACCESS, EGL_NO_SURFACE); //buffer is in use by OpenVG |
1440 EGL_IF_ERROR(image->isInUse(), EGL_BAD_ACCESS, EGL_NO_SURFACE); //buffer is in use by OpenVG |
1295 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1441 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1296 EGL_IF_ERROR(attrib_list && attrib_list[0] != EGL_NONE, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); //there are no valid attribs for OpenVG |
1442 EGL_IF_ERROR(attrib_list && attrib_list[0] != EGL_NONE, EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); //there are no valid attribs for OpenVG |
1297 const Color::Descriptor& bc = ((Image*) buffer)->getDescriptor(); |
1443 const Color::Descriptor& bc = ((Image*)buffer)->getDescriptor(); |
1298 const Color::Descriptor& cc = display->getConfig(config).m_desc; |
1444 const Color::Descriptor& cc = display->getConfig(config).m_desc; |
1299 EGL_IF_ERROR(bc.redBits != cc.redBits || bc.greenBits != cc.greenBits || bc.blueBits != cc.blueBits || |
1445 EGL_IF_ERROR(bc.redBits != cc.redBits || bc.greenBits != cc.greenBits || bc.blueBits != cc.blueBits || |
1300 bc.alphaBits != cc.alphaBits || bc.luminanceBits != cc.luminanceBits, EGL_BAD_MATCH, EGL_NO_SURFACE); |
1446 bc.alphaBits != cc.alphaBits || bc.luminanceBits != cc.luminanceBits, EGL_BAD_MATCH, EGL_NO_SURFACE); |
1301 |
1447 |
1302 //TODO If buffer is already bound to another pbuffer, an EGL BAD ACCESS error is generated. |
1448 //TODO If buffer is already bound to another pbuffer, an EGL BAD ACCESS error is generated. |
1303 |
1449 |
1304 Drawable* d = NULL; |
1450 Drawable* d = NULL; |
1305 RIEGLSurface* s = NULL; |
1451 RIEGLSurface* s = NULL; |
1306 try |
1452 try |
1307 { |
1453 { |
1308 d = RI_NEW(Drawable, (image, display->getConfig(config).m_maskBits)); |
1454 d = RI_NEW(Drawable, (image, display->getConfig(config).m_maskBits)); |
1309 RI_ASSERT(d); |
1455 RI_ASSERT(d); |
1310 s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER)); //throws bad_alloc |
1456 s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER)); //throws bad_alloc |
1311 RI_ASSERT(s); |
1457 RI_ASSERT(s); |
1312 s->addReference(); |
1458 s->addReference(); |
1313 display->addSurface(s); //throws bad_alloc |
1459 display->addSurface(s); //throws bad_alloc |
1314 } |
1460 } |
1315 catch (std::bad_alloc) |
1461 catch(std::bad_alloc) |
1316 { |
1462 { |
1317 RI_DELETE(d); |
1463 RI_DELETE(d); |
1318 RI_DELETE(s); |
1464 RI_DELETE(s); |
1319 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1465 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1320 } |
1466 } |
1321 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1467 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1322 } |
1468 } |
1323 |
1469 |
1324 /*-------------------------------------------------------------------*//*! |
1470 /*-------------------------------------------------------------------*//*! |
1325 * \brief |
1471 * \brief |
1326 * \param |
1472 * \param |
1327 * \return |
1473 * \return |
1328 * \note |
1474 * \note |
1329 *//*-------------------------------------------------------------------*/ |
1475 *//*-------------------------------------------------------------------*/ |
1330 |
1476 |
1331 #ifdef BUILD_WITH_PRIVATE_EGL |
1477 #ifdef BUILD_WITH_PRIVATE_EGL |
1332 RI_APIENTRY EGLSurface do_eglCreatePixmapSurface(EGLDisplay dpy, |
1478 RI_APIENTRY EGLSurface do_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
1333 EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
|
1334 #else |
1479 #else |
1335 EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
1480 EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) |
1336 #endif |
1481 #endif |
1337 { |
1482 { |
1338 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1483 EGL_GET_DISPLAY(dpy, EGL_NO_SURFACE); |
1339 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1484 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_SURFACE); |
1340 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1485 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_SURFACE); |
1341 //EGL_IF_ERROR(!pixmap || !isValidImageFormat(pixmap->format) || !pixmap->data || pixmap->width <= 0 || pixmap->height <= 0, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); |
1486 //EGL_IF_ERROR(!pixmap || !isValidImageFormat(pixmap->format) || !pixmap->data || pixmap->width <= 0 || pixmap->height <= 0, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); |
1342 |
1487 |
1343 RI_UNREF(attrib_list); |
1488 RI_UNREF(attrib_list); |
1344 EGL_IF_ERROR(display->getConfig(config).m_samples != 1, EGL_BAD_MATCH, EGL_NO_SURFACE); |
1489 EGL_IF_ERROR(display->getConfig(config).m_samples != 1, EGL_BAD_MATCH, EGL_NO_SURFACE); |
1345 |
1490 |
1346 //TODO If there is already an EGLSurface associated with pixmap (as a result of a previous eglCreatePixmapSurface call), then a EGL BAD ALLOC error is generated. |
1491 //TODO If there is already an EGLSurface associated with pixmap (as a result of a previous eglCreatePixmapSurface call), then a EGL BAD ALLOC error is generated. |
1347 |
1492 |
1348 |
1493 |
1349 EGLint width = -1; |
1494 EGLint width = -1; |
1350 EGLint height = -1; |
1495 EGLint height = -1; |
1351 EGLint stride = -1; |
1496 EGLint stride = -1; |
1352 VGImageFormat format; |
1497 VGImageFormat format; |
1353 int* data = NULL; |
1498 int* data = NULL; |
1354 EGLBoolean err = OSGetNativePixmapInfo(pixmap, &width, &height, &stride, |
1499 EGLBoolean err = OSGetNativePixmapInfo(pixmap, &width, &height, &stride,&format, &data); |
1355 &format, &data); |
1500 |
1356 |
1501 Drawable* d = NULL; |
1357 Drawable* d = NULL; |
|
1358 RIEGLSurface* s = NULL; |
1502 RIEGLSurface* s = NULL; |
1359 try |
1503 try |
1360 { |
1504 { |
1361 d |
1505 d = RI_NEW(Drawable, (Color::formatToDescriptor(format), width, height, stride, (RIuint8*)data, display->getConfig(config).m_maskBits)); //throws bad_alloc |
1362 = RI_NEW(Drawable, (Color::formatToDescriptor(format), width, height, stride, (RIuint8*)data, display->getConfig(config).m_maskBits)); //throws bad_alloc |
|
1363 RI_ASSERT(d); |
1506 RI_ASSERT(d); |
1364 s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER)); //throws bad_alloc |
1507 s = RI_NEW(RIEGLSurface,(NULL, config, d, false, EGL_BACK_BUFFER)); //throws bad_alloc |
1365 RI_ASSERT(s); |
1508 RI_ASSERT(s); |
1366 s->addReference(); |
1509 s->addReference(); |
1367 display->addSurface(s); //throws bad_alloc |
1510 display->addSurface(s); //throws bad_alloc |
1368 } |
1511 } |
1369 catch (std::bad_alloc) |
1512 catch(std::bad_alloc) |
1370 { |
1513 { |
1371 RI_DELETE(d); |
1514 RI_DELETE(d); |
1372 RI_DELETE(s); |
1515 RI_DELETE(s); |
1373 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1516 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
1374 } |
1517 } |
1375 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1518 EGL_RETURN(EGL_SUCCESS, (EGLSurface)s); |
1376 |
1519 |
1377 } |
1520 } |
1378 |
1521 |
1379 /*-------------------------------------------------------------------*//*! |
1522 /*-------------------------------------------------------------------*//*! |
1380 * \brief |
1523 * \brief |
1381 * \param |
1524 * \param |
1382 * \return |
1525 * \return |
1383 * \note |
1526 * \note |
1384 *//*-------------------------------------------------------------------*/ |
1527 *//*-------------------------------------------------------------------*/ |
1385 |
1528 |
1386 #ifdef BUILD_WITH_PRIVATE_EGL |
1529 #ifdef BUILD_WITH_PRIVATE_EGL |
1387 RI_APIENTRY EGLBoolean do_eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
1530 RI_APIENTRY EGLBoolean do_eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
1388 #else |
1531 #else |
1389 EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
1532 EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
1390 #endif |
1533 #endif |
1391 { |
1534 { |
1392 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1535 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1393 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1536 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1394 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1537 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1395 |
1538 |
1396 display->removeSurface((RIEGLSurface*) surface); |
1539 display->removeSurface((RIEGLSurface*)surface); |
1397 if (!((RIEGLSurface*) surface)->removeReference()) |
1540 if(!((RIEGLSurface*)surface)->removeReference()) |
1398 RI_DELETE((RIEGLSurface*)surface); |
1541 RI_DELETE((RIEGLSurface*)surface); |
1399 |
1542 |
1400 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1543 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1401 } |
1544 } |
1402 |
1545 |
1403 /*-------------------------------------------------------------------*//*! |
1546 /*-------------------------------------------------------------------*//*! |
1404 * \brief |
1547 * \brief |
1405 * \param |
1548 * \param |
1406 * \return |
1549 * \return |
1407 * \note |
1550 * \note |
1408 *//*-------------------------------------------------------------------*/ |
1551 *//*-------------------------------------------------------------------*/ |
1409 |
1552 |
1410 #ifdef BUILD_WITH_PRIVATE_EGL |
1553 #ifdef BUILD_WITH_PRIVATE_EGL |
1411 RI_APIENTRY EGLBoolean do_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, |
1554 RI_APIENTRY EGLBoolean do_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) |
1412 EGLint attribute, EGLint value) |
|
1413 #else |
1555 #else |
1414 EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) |
1556 EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) |
1415 #endif |
1557 #endif |
1416 { |
1558 { |
1417 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1559 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1418 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1560 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1419 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1561 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1420 RI_UNREF(attribute); |
1562 RI_UNREF(attribute); |
1421 RI_UNREF(value); |
1563 RI_UNREF(value); |
1422 //do nothing |
1564 //do nothing |
1423 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1565 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1424 } |
1566 } |
1425 |
1567 |
1426 /*-------------------------------------------------------------------*//*! |
1568 /*-------------------------------------------------------------------*//*! |
1427 * \brief |
1569 * \brief |
1428 * \param |
1570 * \param |
1429 * \return |
1571 * \return |
1430 * \note |
1572 * \note |
1431 *//*-------------------------------------------------------------------*/ |
1573 *//*-------------------------------------------------------------------*/ |
1432 |
1574 |
1433 #ifdef BUILD_WITH_PRIVATE_EGL |
1575 #ifdef BUILD_WITH_PRIVATE_EGL |
1434 RI_APIENTRY EGLBoolean do_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, |
1576 RI_APIENTRY EGLBoolean do_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) |
1435 EGLint attribute, EGLint *value) |
|
1436 #else |
1577 #else |
1437 EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) |
1578 EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) |
1438 #endif |
1579 #endif |
1439 { |
1580 { |
1440 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1581 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1441 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1582 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1442 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1583 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1443 //TODO give an error if value is NULL? |
1584 //TODO give an error if value is NULL? |
1444 |
1585 |
1445 RIEGLSurface* s = (RIEGLSurface*) surface; |
1586 RIEGLSurface* s = (RIEGLSurface*)surface; |
1446 switch (attribute) |
1587 switch(attribute) |
1447 { |
1588 { |
1448 case EGL_VG_ALPHA_FORMAT: |
1589 case EGL_VG_ALPHA_FORMAT: |
1449 *value |
1590 *value = (s->getDrawable()->getDescriptor().isPremultiplied()) ? EGL_VG_ALPHA_FORMAT_PRE : EGL_VG_ALPHA_FORMAT_NONPRE; |
1450 = (s->getDrawable()->getDescriptor().isPremultiplied()) ? EGL_VG_ALPHA_FORMAT_PRE |
1591 break; |
1451 : EGL_VG_ALPHA_FORMAT_NONPRE; |
1592 |
1452 break; |
1593 case EGL_VG_COLORSPACE: |
1453 |
1594 *value = (s->getDrawable()->getDescriptor().isNonlinear()) ? EGL_VG_COLORSPACE_sRGB : EGL_VG_COLORSPACE_LINEAR; |
1454 case EGL_VG_COLORSPACE: |
1595 break; |
1455 *value |
1596 |
1456 = (s->getDrawable()->getDescriptor().isNonlinear()) ? EGL_VG_COLORSPACE_sRGB |
1597 case EGL_CONFIG_ID: |
1457 : EGL_VG_COLORSPACE_LINEAR; |
1598 *value = display->getConfig(s->getConfig()).m_configID; |
1458 break; |
1599 break; |
1459 |
1600 |
1460 case EGL_CONFIG_ID: |
1601 case EGL_HEIGHT: |
1461 *value = display->getConfig(s->getConfig()).m_configID; |
1602 *value = s->getDrawable()->getHeight(); |
1462 break; |
1603 break; |
1463 |
1604 |
1464 case EGL_HEIGHT: |
1605 case EGL_HORIZONTAL_RESOLUTION: |
1465 *value = s->getDrawable()->getHeight(); |
1606 *value = EGL_UNKNOWN; //TODO Horizontal dot pitch |
1466 break; |
1607 break; |
1467 |
1608 |
1468 case EGL_HORIZONTAL_RESOLUTION: |
1609 case EGL_LARGEST_PBUFFER: |
1469 *value = EGL_UNKNOWN; //TODO Horizontal dot pitch |
1610 if(!s->getOSWindowContext()) |
1470 break; |
1611 *value = s->isLargestPbuffer() ? EGL_TRUE : EGL_FALSE; |
1471 |
1612 break; |
1472 case EGL_LARGEST_PBUFFER: |
1613 |
1473 if (!s->getOSWindowContext()) |
1614 case EGL_MIPMAP_TEXTURE: |
1474 *value = s->isLargestPbuffer() ? EGL_TRUE : EGL_FALSE; |
1615 if(!s->getOSWindowContext()) |
1475 break; |
1616 *value = EGL_FALSE; |
1476 |
1617 break; |
1477 case EGL_MIPMAP_TEXTURE: |
1618 |
1478 if (!s->getOSWindowContext()) |
1619 case EGL_MIPMAP_LEVEL: |
1479 *value = EGL_FALSE; |
1620 if(!s->getOSWindowContext()) |
1480 break; |
1621 *value = 0; |
1481 |
1622 break; |
1482 case EGL_MIPMAP_LEVEL: |
1623 |
1483 if (!s->getOSWindowContext()) |
1624 case EGL_PIXEL_ASPECT_RATIO: |
1484 *value = 0; |
1625 *value = EGL_UNKNOWN; //TODO Display aspect ratio |
1485 break; |
1626 break; |
1486 |
1627 |
1487 case EGL_PIXEL_ASPECT_RATIO: |
1628 case EGL_RENDER_BUFFER: |
1488 *value = EGL_UNKNOWN; //TODO Display aspect ratio |
1629 *value = s->getRenderBuffer(); |
1489 break; |
1630 break; |
1490 |
1631 |
1491 case EGL_RENDER_BUFFER: |
1632 case EGL_SWAP_BEHAVIOR: |
1492 *value = s->getRenderBuffer(); |
1633 *value = EGL_BUFFER_PRESERVED; |
1493 break; |
1634 break; |
1494 |
1635 |
1495 case EGL_SWAP_BEHAVIOR: |
1636 case EGL_TEXTURE_FORMAT: |
1496 *value = EGL_BUFFER_PRESERVED; |
1637 if(!s->getOSWindowContext()) |
1497 break; |
1638 *value = EGL_NO_TEXTURE; |
1498 |
1639 break; |
1499 case EGL_TEXTURE_FORMAT: |
1640 |
1500 if (!s->getOSWindowContext()) |
1641 case EGL_TEXTURE_TARGET: |
1501 *value = EGL_NO_TEXTURE; |
1642 if(!s->getOSWindowContext()) |
1502 break; |
1643 *value = EGL_NO_TEXTURE; |
1503 |
1644 break; |
1504 case EGL_TEXTURE_TARGET: |
1645 |
1505 if (!s->getOSWindowContext()) |
1646 case EGL_VERTICAL_RESOLUTION: |
1506 *value = EGL_NO_TEXTURE; |
1647 *value = EGL_UNKNOWN; //TODO Vertical dot pitch |
1507 break; |
1648 break; |
1508 |
1649 |
1509 case EGL_VERTICAL_RESOLUTION: |
1650 case EGL_WIDTH: |
1510 *value = EGL_UNKNOWN; //TODO Vertical dot pitch |
1651 *value = s->getDrawable()->getWidth(); |
1511 break; |
1652 break; |
1512 |
1653 |
1513 case EGL_WIDTH: |
1654 default: |
1514 *value = s->getDrawable()->getWidth(); |
1655 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
1515 break; |
1656 } |
1516 |
|
1517 default: |
|
1518 EGL_RETURN(EGL_BAD_ATTRIBUTE, EGL_FALSE) |
|
1519 ; |
|
1520 } |
|
1521 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1657 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1522 } |
1658 } |
1523 |
1659 |
1524 /*-------------------------------------------------------------------*//*! |
1660 /*-------------------------------------------------------------------*//*! |
1525 * \brief |
1661 * \brief |
1526 * \param |
1662 * \param |
1527 * \return |
1663 * \return |
1528 * \note |
1664 * \note |
1529 *//*-------------------------------------------------------------------*/ |
1665 *//*-------------------------------------------------------------------*/ |
1530 |
1666 |
1531 #ifdef BUILD_WITH_PRIVATE_EGL |
1667 #ifdef BUILD_WITH_PRIVATE_EGL |
1532 RI_APIENTRY EGLContext do_eglCreateContext(EGLDisplay dpy, EGLConfig config, |
1668 RI_APIENTRY EGLContext do_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) |
1533 EGLContext share_context, const EGLint *attrib_list) |
|
1534 #else |
1669 #else |
1535 EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) |
1670 EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) |
1536 #endif |
1671 #endif |
1537 { |
1672 { |
1538 EGL_GET_DISPLAY(dpy, EGL_NO_CONTEXT); |
1673 EGL_GET_DISPLAY(dpy, EGL_NO_CONTEXT); |
1539 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_CONTEXT); |
1674 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_NO_CONTEXT); |
1540 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_CONTEXT); |
1675 EGL_IF_ERROR(!display->configExists(config), EGL_BAD_CONFIG, EGL_NO_CONTEXT); |
1541 RI_UNREF(attrib_list); |
1676 RI_UNREF(attrib_list); |
1542 |
1677 |
1543 RIEGLThread* thread = egl->getThread(); |
1678 RIEGLThread* thread = egl->getThread(); |
1544 if (!thread) |
1679 if(!thread) |
1545 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT); |
1680 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT); |
1546 |
1681 |
1547 //creation of OpenGL ES contexts is not allowed in this implementation |
1682 //creation of OpenGL ES contexts is not allowed in this implementation |
1548 if (thread->getBoundAPI() != EGL_OPENVG_API) |
1683 if(thread->getBoundAPI() != EGL_OPENVG_API) |
1549 EGL_RETURN(EGL_BAD_MATCH, EGL_NO_CONTEXT); |
1684 EGL_RETURN(EGL_BAD_MATCH, EGL_NO_CONTEXT); |
1550 |
1685 |
1551 OpenVGRI::VGContext* vgctx = NULL; |
1686 OpenVGRI::VGContext* vgctx = NULL; |
1552 RIEGLContext* c = NULL; |
1687 RIEGLContext* c = NULL; |
1553 try |
1688 try |
1554 { |
1689 { |
1555 vgctx |
1690 vgctx = RI_NEW(OpenVGRI::VGContext, (share_context ? ((RIEGLContext*)share_context)->getVGContext() : NULL)); //throws bad_alloc |
1556 = RI_NEW(OpenVGRI::VGContext, (share_context ? ((RIEGLContext*)share_context)->getVGContext() : NULL)); //throws bad_alloc |
1691 c = RI_NEW(RIEGLContext, (vgctx, config)); //throws bad_alloc |
1557 c = RI_NEW(RIEGLContext, (vgctx, config)); //throws bad_alloc |
|
1558 c->addReference(); |
1692 c->addReference(); |
1559 display->addContext(c); //throws bad_alloc |
1693 display->addContext(c); //throws bad_alloc |
1560 } |
1694 } |
1561 catch (std::bad_alloc) |
1695 catch(std::bad_alloc) |
1562 { |
1696 { |
1563 RI_DELETE(vgctx); |
1697 RI_DELETE(vgctx); |
1564 RI_DELETE(c); |
1698 RI_DELETE(c); |
1565 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT); |
1699 EGL_RETURN(EGL_BAD_ALLOC, EGL_NO_CONTEXT); |
1566 } |
1700 } |
1567 |
1701 |
1568 EGL_RETURN(EGL_SUCCESS, (EGLContext)c); |
1702 EGL_RETURN(EGL_SUCCESS, (EGLContext)c); |
1569 } |
1703 } |
1570 |
1704 |
1571 /*-------------------------------------------------------------------*//*! |
1705 /*-------------------------------------------------------------------*//*! |
1572 * \brief |
1706 * \brief |
1573 * \param |
1707 * \param |
1574 * \return |
1708 * \return |
1575 * \note |
1709 * \note |
1576 *//*-------------------------------------------------------------------*/ |
1710 *//*-------------------------------------------------------------------*/ |
1577 |
1711 |
1578 #ifdef BUILD_WITH_PRIVATE_EGL |
1712 #ifdef BUILD_WITH_PRIVATE_EGL |
1579 RI_APIENTRY EGLBoolean do_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
1713 RI_APIENTRY EGLBoolean do_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
1580 #else |
1714 #else |
1581 EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
1715 EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
1582 #endif |
1716 #endif |
1583 { |
1717 { |
1584 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1718 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1585 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1719 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1586 EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1720 EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1587 |
1721 |
1588 RIEGLContext* context = (RIEGLContext*) ctx; |
1722 RIEGLContext* context = (RIEGLContext*)ctx; |
1589 display->removeContext(context); |
1723 display->removeContext(context); |
1590 if (!context->removeReference()) |
1724 if(!context->removeReference() ) |
1591 RI_DELETE(context); |
1725 RI_DELETE(context); |
1592 |
1726 |
1593 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1727 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1594 } |
1728 } |
1595 |
1729 |
1596 /*-------------------------------------------------------------------*//*! |
1730 /*-------------------------------------------------------------------*//*! |
1597 * \brief |
1731 * \brief |
1598 * \param |
1732 * \param |
1599 * \return |
1733 * \return |
1600 * \note |
1734 * \note |
1601 *//*-------------------------------------------------------------------*/ |
1735 *//*-------------------------------------------------------------------*/ |
1602 |
1736 |
1603 #ifdef BUILD_WITH_PRIVATE_EGL |
1737 #ifdef BUILD_WITH_PRIVATE_EGL |
1604 RI_APIENTRY EGLBoolean do_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, |
1738 RI_APIENTRY EGLBoolean do_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) |
1605 EGLSurface read, EGLContext ctx) |
|
1606 #else |
1739 #else |
1607 EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) |
1740 EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) |
1608 #endif |
1741 #endif |
1609 { |
1742 { |
1610 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1743 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1611 EGL_IF_ERROR(ctx != EGL_NO_CONTEXT && !display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1744 EGL_IF_ERROR(ctx != EGL_NO_CONTEXT && !display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1612 EGL_IF_ERROR(draw != EGL_NO_SURFACE && !display->surfaceExists(draw), EGL_BAD_SURFACE, EGL_FALSE); |
1745 EGL_IF_ERROR(draw != EGL_NO_SURFACE && !display->surfaceExists(draw), EGL_BAD_SURFACE, EGL_FALSE); |
1613 EGL_IF_ERROR(read != EGL_NO_SURFACE && !display->surfaceExists(read), EGL_BAD_SURFACE, EGL_FALSE); |
1746 EGL_IF_ERROR(read != EGL_NO_SURFACE && !display->surfaceExists(read), EGL_BAD_SURFACE, EGL_FALSE); |
1614 EGL_IF_ERROR(draw != read, EGL_BAD_MATCH, EGL_FALSE); //TODO what's the proper error code? |
1747 EGL_IF_ERROR(draw != read, EGL_BAD_MATCH, EGL_FALSE); //TODO what's the proper error code? |
1615 EGL_IF_ERROR((draw != EGL_NO_SURFACE && ctx == EGL_NO_CONTEXT) || (draw == EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT), EGL_BAD_MATCH, EGL_FALSE); |
1748 EGL_IF_ERROR((draw != EGL_NO_SURFACE && ctx == EGL_NO_CONTEXT) || (draw == EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT), EGL_BAD_MATCH, EGL_FALSE); |
1616 |
1749 |
1617 RIEGLSurface* s = NULL; |
1750 RIEGLSurface* s = NULL; |
1618 RIEGLContext* c = NULL; |
1751 RIEGLContext* c = NULL; |
1619 if (draw != EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT) |
1752 if(draw != EGL_NO_SURFACE && ctx != EGL_NO_CONTEXT) |
1620 { |
1753 { |
1621 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1754 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1622 |
1755 |
1623 s = (RIEGLSurface*) draw; |
1756 s = (RIEGLSurface*)draw; |
1624 c = (RIEGLContext*) ctx; |
1757 c = (RIEGLContext*)ctx; |
1625 |
1758 |
1626 //If either draw or read are pbuffers created with eglCreatePbufferFromClientBuffer, and the underlying bound client API buffers |
1759 //If either draw or read are pbuffers created with eglCreatePbufferFromClientBuffer, and the underlying bound client API buffers |
1627 //are in use by the client API that created them, an EGL BAD ACCESS error is generated. |
1760 //are in use by the client API that created them, an EGL BAD ACCESS error is generated. |
1628 EGL_IF_ERROR(s->getDrawable()->isInUse(), EGL_BAD_ACCESS, EGL_FALSE); |
1761 EGL_IF_ERROR(s->getDrawable()->isInUse(), EGL_BAD_ACCESS, EGL_FALSE); |
|
1762 |
1629 |
1763 |
1630 //TODO properly check compatibility of surface and context: |
1764 //TODO properly check compatibility of surface and context: |
1631 //-both have RGB or LUMINANCE configs |
1765 //-both have RGB or LUMINANCE configs |
1632 //-buffer bit depths match |
1766 //-buffer bit depths match |
1633 //-configs support OpenVG |
1767 //-configs support OpenVG |
1634 //-both have the same display |
1768 //-both have the same display |
1635 EGL_IF_ERROR(s->getConfig() != c->getConfig(), EGL_BAD_MATCH, EGL_FALSE); |
1769 EGL_IF_ERROR(s->getConfig() != c->getConfig(), EGL_BAD_MATCH, EGL_FALSE); |
1636 //TODO check if context or surfaces are already bound to another thread |
1770 //TODO check if context or surfaces are already bound to another thread |
1637 |
1771 |
1638 //If a native window underlying either draw or read is no longer valid, an EGL BAD NATIVE WINDOW error is generated. |
1772 //If a native window underlying either draw or read is no longer valid, an EGL BAD NATIVE WINDOW error is generated. |
1639 EGL_IF_ERROR(s->getOSWindowContext() && !OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE); |
1773 EGL_IF_ERROR(s->getOSWindowContext() && !OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE); |
1640 |
1774 |
1641 //TODO If the previous context of the calling display has unflushed commands, and the previous surface is no longer valid, an EGL BAD CURRENT SURFACE error is generated. (can this happen?) |
1775 //TODO If the previous context of the calling display has unflushed commands, and the previous surface is no longer valid, an EGL BAD CURRENT SURFACE error is generated. (can this happen?) |
1642 //TODO If the ancillary buffers for draw and read cannot be allocated, an EGL BAD ALLOC error is generated. (mask buffer?) |
1776 //TODO If the ancillary buffers for draw and read cannot be allocated, an EGL BAD ALLOC error is generated. (mask buffer?) |
1643 } |
1777 } |
1644 |
1778 |
1645 //check if the thread is current |
1779 //check if the thread is current |
1646 RIEGLThread* thread = egl->getCurrentThread(); |
1780 RIEGLThread* thread = egl->getCurrentThread(); |
1647 if (thread) |
1781 if(thread) |
1648 { //thread is current, release the old bindinds and remove the thread from the current thread list |
1782 { //thread is current, release the old bindinds and remove the thread from the current thread list |
1649 RIEGLContext* pc = thread->getCurrentContext(); |
1783 RIEGLContext* pc = thread->getCurrentContext(); |
1650 RIEGLSurface* ps = thread->getCurrentSurface(); |
1784 RIEGLSurface* ps = thread->getCurrentSurface(); |
1651 if (pc) |
1785 if(pc) |
1652 { |
1786 { |
1653 #ifdef BUILD_WITH_PRIVATE_OPENVG |
1787 #ifdef BUILD_WITH_PRIVATE_OPENVG |
1654 do_vgFlush(); |
1788 do_vgFlush(); |
1655 #else |
1789 #else |
1656 vgFlush(); |
1790 vgFlush(); |
1657 #endif |
1791 #endif |
1658 pc->getVGContext()->setDefaultDrawable(NULL); |
1792 pc->getVGContext()->setDefaultDrawable(NULL); |
1659 if (!pc->removeReference()) |
1793 if(!pc->removeReference()) |
1660 RI_DELETE(pc); |
1794 RI_DELETE(pc); |
1661 } |
1795 } |
1662 if (ps) |
1796 if(ps) |
1663 { |
1797 { |
1664 if (!ps->removeReference()) |
1798 if(!ps->removeReference()) |
1665 RI_DELETE(ps); |
1799 RI_DELETE(ps); |
1666 } |
|
1667 |
|
1668 egl->removeCurrentThread(thread); |
|
1669 } |
1800 } |
1670 |
1801 |
1671 if (c && s) |
1802 egl->removeCurrentThread(thread); |
1672 { |
1803 } |
|
1804 |
|
1805 if( c && s ) |
|
1806 { |
1673 //bind context and surface to the current display |
1807 //bind context and surface to the current display |
1674 RIEGLThread* newThread = egl->getThread(); |
1808 RIEGLThread* newThread = egl->getThread(); |
1675 if (!newThread) |
1809 if(!newThread) |
1676 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
1810 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
1677 newThread->makeCurrent(c, s); |
1811 newThread->makeCurrent(c, s); |
1678 Drawable* temp = s->getDrawable(); |
|
1679 c->getVGContext()->setDefaultDrawable(s->getDrawable()); |
1812 c->getVGContext()->setDefaultDrawable(s->getDrawable()); |
1680 |
1813 |
1681 try |
1814 try |
1682 { |
1815 { |
1683 egl->addCurrentThread(newThread); //throws bad_alloc |
1816 egl->addCurrentThread(newThread); //throws bad_alloc |
1684 } |
1817 } |
1685 catch (std::bad_alloc) |
1818 catch(std::bad_alloc) |
1686 { |
1819 { |
1687 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
1820 EGL_RETURN(EGL_BAD_ALLOC, EGL_FALSE); |
1688 } |
1821 } |
1689 |
1822 |
1690 c->addReference(); |
1823 c->addReference(); |
1691 s->addReference(); |
1824 s->addReference(); |
1692 } |
1825 } |
1693 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1826 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1694 } |
1827 } |
1695 |
1828 |
1696 /*-------------------------------------------------------------------*//*! |
1829 /*-------------------------------------------------------------------*//*! |
1697 * \brief |
1830 * \brief |
1698 * \param |
1831 * \param |
1699 * \return |
1832 * \return |
1700 * \note |
1833 * \note |
1701 *//*-------------------------------------------------------------------*/ |
1834 *//*-------------------------------------------------------------------*/ |
1702 |
1835 |
1703 #ifdef BUILD_WITH_PRIVATE_EGL |
1836 #ifdef BUILD_WITH_PRIVATE_EGL |
1704 RI_APIENTRY EGLContext do_eglGetCurrentContext() |
1837 RI_APIENTRY EGLContext do_eglGetCurrentContext() |
1705 #else |
1838 #else |
1706 EGLContext eglGetCurrentContext() |
1839 EGLContext eglGetCurrentContext() |
1707 #endif |
1840 #endif |
1708 { |
1841 { |
1709 EGL_GET_EGL(EGL_NO_CONTEXT); |
1842 EGL_GET_EGL(EGL_NO_CONTEXT); |
1710 EGLContext ret = EGL_NO_CONTEXT; |
1843 EGLContext ret = EGL_NO_CONTEXT; |
1711 RIEGLThread* thread = egl->getCurrentThread(); |
1844 RIEGLThread* thread = egl->getCurrentThread(); |
1712 if (thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1845 if(thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1713 { |
1846 { |
1714 ret = CastFromRIEGLContext(thread->getCurrentContext()); |
1847 ret = CastFromRIEGLContext(thread->getCurrentContext()); |
1715 RI_ASSERT(ret); |
1848 RI_ASSERT(ret); |
1716 } |
1849 } |
1717 EGL_RETURN(EGL_SUCCESS, ret); |
1850 EGL_RETURN(EGL_SUCCESS, ret); |
1718 } |
1851 } |
1719 |
1852 |
1720 /*-------------------------------------------------------------------*//*! |
1853 /*-------------------------------------------------------------------*//*! |
1721 * \brief |
1854 * \brief |
1722 * \param |
1855 * \param |
1723 * \return |
1856 * \return |
1724 * \note |
1857 * \note |
1725 *//*-------------------------------------------------------------------*/ |
1858 *//*-------------------------------------------------------------------*/ |
1726 |
1859 |
1727 #ifdef BUILD_WITH_PRIVATE_EGL |
1860 #ifdef BUILD_WITH_PRIVATE_EGL |
1728 RI_APIENTRY EGLSurface do_eglGetCurrentSurface(EGLint readdraw) |
1861 RI_APIENTRY EGLSurface do_eglGetCurrentSurface(EGLint readdraw) |
1729 #else |
1862 #else |
1730 EGLSurface eglGetCurrentSurface(EGLint readdraw) |
1863 EGLSurface eglGetCurrentSurface(EGLint readdraw) |
1731 #endif |
1864 #endif |
1732 { |
1865 { |
1733 EGL_GET_EGL(EGL_NO_SURFACE); |
1866 EGL_GET_EGL(EGL_NO_SURFACE); |
1734 EGL_IF_ERROR(readdraw != EGL_READ && readdraw != EGL_DRAW, EGL_BAD_PARAMETER, EGL_NO_SURFACE); |
1867 EGL_IF_ERROR(readdraw != EGL_READ && readdraw != EGL_DRAW, EGL_BAD_PARAMETER, EGL_NO_SURFACE); |
1735 EGLContext ret = EGL_NO_SURFACE; |
1868 EGLContext ret = EGL_NO_SURFACE; |
1736 RIEGLThread* thread = egl->getCurrentThread(); |
1869 RIEGLThread* thread = egl->getCurrentThread(); |
1737 if (thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1870 if(thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1738 { |
1871 { |
1739 ret = OpenVGRI::CastFromRIEGLSurface(thread->getCurrentSurface()); |
1872 ret = CastFromRIEGLSurface(thread->getCurrentSurface()); |
1740 RI_ASSERT(ret); |
1873 RI_ASSERT(ret); |
1741 } |
1874 } |
1742 EGL_RETURN(EGL_SUCCESS, ret); |
1875 EGL_RETURN(EGL_SUCCESS, ret); |
1743 } |
1876 } |
1744 |
1877 |
1745 /*-------------------------------------------------------------------*//*! |
1878 /*-------------------------------------------------------------------*//*! |
1746 * \brief Returns the current display |
1879 * \brief Returns the current display |
1747 * \param |
1880 * \param |
1748 * \return |
1881 * \return |
1749 * \note |
1882 * \note |
1750 *//*-------------------------------------------------------------------*/ |
1883 *//*-------------------------------------------------------------------*/ |
1751 |
1884 |
1752 #ifdef BUILD_WITH_PRIVATE_EGL |
1885 #ifdef BUILD_WITH_PRIVATE_EGL |
1753 RI_APIENTRY EGLDisplay do_eglGetCurrentDisplay(void) |
1886 RI_APIENTRY EGLDisplay do_eglGetCurrentDisplay(void) |
1754 #else |
1887 #else |
1755 EGLDisplay eglGetCurrentDisplay(void) |
1888 EGLDisplay eglGetCurrentDisplay(void) |
1756 #endif |
1889 #endif |
1757 { |
1890 { |
1758 EGL_GET_EGL(EGL_NO_DISPLAY); |
1891 EGL_GET_EGL(EGL_NO_DISPLAY); |
1759 |
1892 |
1760 RIEGLThread* thread = egl->getCurrentThread(); |
1893 RIEGLThread* thread = egl->getCurrentThread(); |
1761 if (!thread || thread->getBoundAPI() != EGL_OPENVG_API) |
1894 if(!thread || thread->getBoundAPI() != EGL_OPENVG_API) |
1762 EGL_RETURN(EGL_SUCCESS, EGL_NO_DISPLAY); |
1895 EGL_RETURN(EGL_SUCCESS, EGL_NO_DISPLAY); |
1763 |
1896 |
1764 RIEGLContext* ctx = thread->getCurrentContext(); |
1897 RIEGLContext* ctx = thread->getCurrentContext(); |
1765 RI_ASSERT(ctx); |
1898 RI_ASSERT(ctx); |
1766 EGLDisplay ret = egl->findDisplay(OpenVGRI::CastFromRIEGLContext(ctx)); |
1899 EGLDisplay ret = egl->findDisplay(CastFromRIEGLContext(ctx)); |
1767 EGL_RETURN(EGL_SUCCESS, ret); |
1900 EGL_RETURN(EGL_SUCCESS, ret); |
1768 } |
1901 } |
1769 |
1902 |
1770 /*-------------------------------------------------------------------*//*! |
1903 /*-------------------------------------------------------------------*//*! |
1771 * \brief |
1904 * \brief |
1772 * \param |
1905 * \param |
1773 * \return |
1906 * \return |
1774 * \note |
1907 * \note |
1775 *//*-------------------------------------------------------------------*/ |
1908 *//*-------------------------------------------------------------------*/ |
1776 |
1909 |
1777 #ifdef BUILD_WITH_PRIVATE_EGL |
1910 #ifdef BUILD_WITH_PRIVATE_EGL |
1778 RI_APIENTRY EGLBoolean do_eglQueryContext(EGLDisplay dpy, EGLContext ctx, |
1911 RI_APIENTRY EGLBoolean do_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) |
1779 EGLint attribute, EGLint* value) |
|
1780 #else |
1912 #else |
1781 EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) |
1913 EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) |
1782 #endif |
1914 #endif |
1783 { |
1915 { |
1784 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1916 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1785 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1917 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1786 EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1918 EGL_IF_ERROR(!display->contextExists(ctx), EGL_BAD_CONTEXT, EGL_FALSE); |
1787 EGL_IF_ERROR(attribute != EGL_CONFIG_ID && attribute != EGL_CONTEXT_CLIENT_TYPE, EGL_BAD_ATTRIBUTE, EGL_FALSE); |
1919 EGL_IF_ERROR(attribute != EGL_CONFIG_ID && attribute != EGL_CONTEXT_CLIENT_TYPE, EGL_BAD_ATTRIBUTE, EGL_FALSE); |
1788 if (attribute == EGL_CONFIG_ID) |
1920 if(attribute == EGL_CONFIG_ID) |
1789 *value |
1921 *value = display->getConfig(((RIEGLContext*)ctx)->getConfig()).m_configID; |
1790 = display->getConfig(((RIEGLContext*) ctx)->getConfig()).m_configID; |
1922 if(attribute == EGL_CONTEXT_CLIENT_TYPE) |
1791 if (attribute == EGL_CONTEXT_CLIENT_TYPE) |
|
1792 *value = EGL_OPENVG_API; |
1923 *value = EGL_OPENVG_API; |
1793 // \todo [kalle 05/Jul/05] Handling of EGL_RENDER_BUFFER attribute is missing. |
1924 // \todo [kalle 05/Jul/05] Handling of EGL_RENDER_BUFFER attribute is missing. |
1794 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1925 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1795 } |
1926 } |
1796 |
1927 |
1797 /*-------------------------------------------------------------------*//*! |
1928 /*-------------------------------------------------------------------*//*! |
1798 * \brief |
1929 * \brief |
1799 * \param |
1930 * \param |
1800 * \return |
1931 * \return |
1801 * \note |
1932 * \note |
1802 *//*-------------------------------------------------------------------*/ |
1933 *//*-------------------------------------------------------------------*/ |
1803 |
1934 |
1804 #ifdef BUILD_WITH_PRIVATE_EGL |
1935 #ifdef BUILD_WITH_PRIVATE_EGL |
1805 RI_APIENTRY EGLBoolean do_eglBindAPI(EGLenum api) |
1936 RI_APIENTRY EGLBoolean do_eglBindAPI(EGLenum api) |
1806 #else |
1937 #else |
1807 EGLBoolean eglBindAPI(EGLenum api) |
1938 EGLBoolean eglBindAPI(EGLenum api) |
1808 #endif |
1939 #endif |
1809 { |
1940 { |
1810 EGL_GET_EGL(EGL_FALSE); |
1941 EGL_GET_EGL(EGL_FALSE); |
1811 EGL_IF_ERROR(api != EGL_OPENVG_API && api != EGL_OPENGL_ES_API, EGL_BAD_PARAMETER, EGL_FALSE); |
1942 EGL_IF_ERROR(api != EGL_OPENVG_API && api != EGL_OPENGL_ES_API, EGL_BAD_PARAMETER, EGL_FALSE); |
1812 RIEGLThread* thread = egl->getThread(); |
1943 RIEGLThread* thread = egl->getThread(); |
1813 if (thread) |
1944 if(thread) |
1814 thread->bindAPI(api); |
1945 thread->bindAPI(api); |
1815 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1946 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1816 } |
1947 } |
1817 |
1948 |
1818 /*-------------------------------------------------------------------*//*! |
1949 /*-------------------------------------------------------------------*//*! |
1819 * \brief |
1950 * \brief |
1820 * \param |
1951 * \param |
1821 * \return |
1952 * \return |
1822 * \note |
1953 * \note |
1823 *//*-------------------------------------------------------------------*/ |
1954 *//*-------------------------------------------------------------------*/ |
1824 |
1955 |
1825 #ifdef BUILD_WITH_PRIVATE_EGL |
1956 #ifdef BUILD_WITH_PRIVATE_EGL |
1826 RI_APIENTRY EGLenum do_eglQueryAPI(void) |
1957 RI_APIENTRY EGLenum do_eglQueryAPI(void) |
1827 #else |
1958 #else |
1828 EGLenum eglQueryAPI(void) |
1959 EGLenum eglQueryAPI(void) |
1829 #endif |
1960 #endif |
1830 { |
1961 { |
1831 EGL_GET_EGL(EGL_NONE); |
1962 EGL_GET_EGL(EGL_NONE); |
1832 RIEGLThread* thread = egl->getThread(); |
1963 RIEGLThread* thread = egl->getThread(); |
1833 if (thread) |
1964 if(thread) |
1834 EGL_RETURN(EGL_SUCCESS, thread->getBoundAPI()); |
1965 EGL_RETURN(EGL_SUCCESS, thread->getBoundAPI()); |
1835 EGL_RETURN(EGL_SUCCESS, EGL_NONE); |
1966 EGL_RETURN(EGL_SUCCESS, EGL_NONE); |
1836 } |
1967 } |
1837 |
1968 |
1838 /*-------------------------------------------------------------------*//*! |
1969 /*-------------------------------------------------------------------*//*! |
1839 * \brief |
1970 * \brief |
1840 * \param |
1971 * \param |
1841 * \return |
1972 * \return |
1842 * \note |
1973 * \note |
1843 *//*-------------------------------------------------------------------*/ |
1974 *//*-------------------------------------------------------------------*/ |
1844 |
1975 |
1845 #ifdef BUILD_WITH_PRIVATE_EGL |
1976 #ifdef BUILD_WITH_PRIVATE_EGL |
1846 RI_APIENTRY EGLBoolean do_eglWaitClient() |
1977 RI_APIENTRY EGLBoolean do_eglWaitClient() |
1847 #else |
1978 #else |
1848 EGLBoolean eglWaitClient() |
1979 EGLBoolean eglWaitClient() |
1849 #endif |
1980 #endif |
1850 { |
1981 { |
1851 EGL_GET_EGL(EGL_FALSE); |
1982 EGL_GET_EGL(EGL_FALSE); |
1852 RIEGLThread* thread = egl->getCurrentThread(); |
1983 RIEGLThread* thread = egl->getCurrentThread(); |
1853 if (thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1984 if(thread && thread->getBoundAPI() == EGL_OPENVG_API) |
1854 #ifdef BUILD_WITH_PRIVATE_OPENVG |
1985 #ifdef BUILD_WITH_PRIVATE_OPENVG |
1855 do_vgFinish(); |
1986 do_vgFlush(); |
1856 #else |
1987 #else |
1857 vgFinish(); |
1988 vgFinish(); |
1858 #endif |
1989 #endif |
1859 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1990 EGL_RETURN(EGL_SUCCESS, EGL_TRUE); |
1860 } |
1991 } |
1861 |
1992 |
1862 /*-------------------------------------------------------------------*//*! |
1993 /*-------------------------------------------------------------------*//*! |
1863 * \brief Waits for OpenGL ES |
1994 * \brief Waits for OpenGL ES |
1864 * \param |
1995 * \param |
1865 * \return |
1996 * \return |
1866 * \note |
1997 * \note |
1867 *//*-------------------------------------------------------------------*/ |
1998 *//*-------------------------------------------------------------------*/ |
1868 |
1999 |
1869 #ifdef BUILD_WITH_PRIVATE_EGL |
2000 #ifdef BUILD_WITH_PRIVATE_EGL |
1870 RI_APIENTRY EGLBoolean do_eglWaitGL(void) |
2001 RI_APIENTRY EGLBoolean do_eglWaitGL(void) |
1871 #else |
2002 #else |
1872 EGLBoolean eglWaitGL(void) |
2003 EGLBoolean eglWaitGL(void) |
1873 #endif |
2004 #endif |
1874 { |
2005 { |
1875 return EGL_TRUE; |
2006 return EGL_TRUE; |
1876 } |
2007 } |
1877 |
2008 |
1878 /*-------------------------------------------------------------------*//*! |
2009 /*-------------------------------------------------------------------*//*! |
1879 * \brief |
2010 * \brief |
1880 * \param |
2011 * \param |
1881 * \return |
2012 * \return |
1882 * \note We don't support native rendering |
2013 * \note We don't support native rendering |
1883 *//*-------------------------------------------------------------------*/ |
2014 *//*-------------------------------------------------------------------*/ |
1884 |
2015 |
1885 #ifdef BUILD_WITH_PRIVATE_EGL |
2016 #ifdef BUILD_WITH_PRIVATE_EGL |
1886 RI_APIENTRY EGLBoolean do_eglWaitNative(EGLint engine) |
2017 RI_APIENTRY EGLBoolean do_eglWaitNative(EGLint engine) |
1887 #else |
2018 #else |
1888 EGLBoolean eglWaitNative(EGLint engine) |
2019 EGLBoolean eglWaitNative(EGLint engine) |
1889 #endif |
2020 #endif |
1890 { |
2021 { |
1891 RI_UNREF(engine); |
2022 RI_UNREF(engine); |
1892 return EGL_TRUE; |
2023 return EGL_TRUE; |
1893 } |
2024 } |
1894 |
2025 |
1895 /*-------------------------------------------------------------------*//*! |
2026 /*-------------------------------------------------------------------*//*! |
1896 * \brief |
2027 * \brief |
1897 * \param |
2028 * \param |
1898 * \return |
2029 * \return |
1899 * \note |
2030 * \note |
1900 *//*-------------------------------------------------------------------*/ |
2031 *//*-------------------------------------------------------------------*/ |
1901 |
2032 |
1902 #ifdef BUILD_WITH_PRIVATE_EGL |
2033 #ifdef BUILD_WITH_PRIVATE_EGL |
1903 RI_APIENTRY EGLBoolean do_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
2034 RI_APIENTRY EGLBoolean do_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
1904 #else |
2035 #else |
1905 EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
2036 EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
1906 #endif |
2037 #endif |
1907 { |
2038 { |
1908 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
2039 EGL_GET_DISPLAY(dpy, EGL_FALSE); |
1909 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
2040 EGL_IF_ERROR(!display, EGL_NOT_INITIALIZED, EGL_FALSE); |
1910 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
2041 EGL_IF_ERROR(!display->surfaceExists(surface), EGL_BAD_SURFACE, EGL_FALSE); |
1911 |
2042 |
1912 RIEGLSurface* s = (RIEGLSurface*) surface; |
2043 RIEGLSurface* s = (RIEGLSurface*)surface; |
1913 |
2044 |
1914 RIEGLThread* currentThread = egl->getCurrentThread(); |
2045 RIEGLThread* currentThread = egl->getCurrentThread(); |
1915 EGL_IF_ERROR(!currentThread || currentThread->getCurrentSurface() != s, EGL_BAD_SURFACE, EGL_FALSE); |
2046 EGL_IF_ERROR(!currentThread || currentThread->getCurrentSurface() != s, EGL_BAD_SURFACE, EGL_FALSE); |
1916 EGL_IF_ERROR(!OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE); |
2047 EGL_IF_ERROR(!OSIsWindow(s->getOSWindowContext()), EGL_BAD_NATIVE_WINDOW, EGL_FALSE); |
1917 |
2048 |