151 //EGL TRANSPARENT RED VALUE integer transparent red value (undefined) |
136 //EGL TRANSPARENT RED VALUE integer transparent red value (undefined) |
152 //EGL TRANSPARENT GREEN VALUE integer transparent green value (undefined) |
137 //EGL TRANSPARENT GREEN VALUE integer transparent green value (undefined) |
153 //EGL TRANSPARENT BLUE VALUE integer transparent blue value (undefined) |
138 //EGL TRANSPARENT BLUE VALUE integer transparent blue value (undefined) |
154 }; |
139 }; |
155 |
140 |
|
141 |
156 /*-------------------------------------------------------------------*//*! |
142 /*-------------------------------------------------------------------*//*! |
157 * \brief |
143 * \brief |
158 * \param |
144 * \param |
159 * \return |
145 * \return |
160 * \note |
146 * \note |
161 *//*-------------------------------------------------------------------*/ |
147 *//*-------------------------------------------------------------------*/ |
162 |
148 |
163 class RIEGLContext |
149 #define EGL_NUMCONFIGS 60 |
|
150 |
|
151 class RIEGLDisplay |
164 { |
152 { |
165 public: |
153 public: |
166 RIEGLContext(OpenVGRI::VGContext* vgctx, const EGLConfig config); |
154 RIEGLDisplay(EGLDisplay id); |
167 ~RIEGLContext(); |
155 ~RIEGLDisplay(); |
168 void addReference() { m_referenceCount++; } |
156 |
169 int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; } |
157 int getNumConfigs() const { return EGL_NUMCONFIGS; } |
170 |
158 const RIEGLConfig& getConfigByIdx(int i) const { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; } |
171 VGContext* getVGContext() const { return m_vgContext; } |
159 const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; } |
172 EGLConfig getConfig() const { return m_config; } |
160 |
|
161 EGLDisplay getID() const { return m_id; } |
|
162 |
|
163 void addContext(RIEGLContext* ctx) { RI_ASSERT(ctx); m_contexts.push_back(ctx); } //throws bad_alloc |
|
164 void removeContext(RIEGLContext* ctx) { RI_ASSERT(ctx); bool res = m_contexts.remove(ctx); RI_ASSERT(res); RI_UNREF(res); } |
|
165 |
|
166 void addSurface(RIEGLSurface* srf) { RI_ASSERT(srf); m_surfaces.push_back(srf); } //throws bad_alloc |
|
167 void removeSurface(RIEGLSurface* srf) { RI_ASSERT(srf); bool res = m_surfaces.remove(srf); RI_ASSERT(res); RI_UNREF(res); } |
|
168 |
|
169 EGLBoolean contextExists(const EGLContext ctx) const; |
|
170 EGLBoolean surfaceExists(const EGLSurface srf) const; |
|
171 EGLBoolean configExists(const EGLConfig cfg) const; |
|
172 |
173 private: |
173 private: |
174 RIEGLContext(const RIEGLContext&); |
174 RIEGLDisplay(const RIEGLDisplay& t); |
175 RIEGLContext& operator=(const RIEGLContext&); |
175 RIEGLDisplay& operator=(const RIEGLDisplay&t); |
176 VGContext* m_vgContext; |
176 |
177 const EGLConfig m_config; |
177 EGLDisplay m_id; |
178 int m_referenceCount; |
178 |
|
179 Array<RIEGLContext*> m_contexts; |
|
180 Array<RIEGLSurface*> m_surfaces; |
|
181 |
|
182 RIEGLConfig m_configs[EGL_NUMCONFIGS]; |
179 }; |
183 }; |
180 |
|
181 RIEGLContext* CastToRIEGLContext(EGLContext aCtxId); |
|
182 EGLContext CastFromRIEGLContext(RIEGLContext* aCtx); |
|
183 |
184 |
184 /*-------------------------------------------------------------------*//*! |
185 /*-------------------------------------------------------------------*//*! |
185 * \brief |
186 * \brief |
186 * \param |
187 * \param |
187 * \return |
188 * \return |
188 * \note |
189 * \note |
189 *//*-------------------------------------------------------------------*/ |
190 *//*-------------------------------------------------------------------*/ |
190 |
191 |
191 class RIEGLSurface |
|
192 { |
|
193 public: |
|
194 RIEGLSurface(void* OSWindowContext, const EGLConfig config, Drawable* drawable, bool largestPbuffer, int renderBuffer); |
|
195 ~RIEGLSurface(); |
|
196 void addReference() { m_referenceCount++; } |
|
197 int removeReference() { m_referenceCount--; RI_ASSERT(m_referenceCount >= 0); return m_referenceCount; } |
|
198 |
|
199 void* getOSWindowContext() const { return m_OSWindowContext; } |
|
200 EGLConfig getConfig() const { return m_config; } |
|
201 Drawable* getDrawable() const { return m_drawable; } |
|
202 bool isLargestPbuffer() const { return m_largestPbuffer; } |
|
203 int getRenderBuffer() const { return m_renderBuffer; } |
|
204 |
|
205 private: |
|
206 RIEGLSurface(const RIEGLSurface&); |
|
207 RIEGLSurface& operator=(const RIEGLSurface&); |
|
208 void* m_OSWindowContext; |
|
209 const EGLConfig m_config; |
|
210 Drawable* m_drawable; |
|
211 bool m_largestPbuffer; |
|
212 int m_renderBuffer; //EGL_BACK_BUFFER or EGL_SINGLE_BUFFER |
|
213 int m_referenceCount; |
|
214 }; |
|
215 |
|
216 RIEGLSurface* CastToRIEGLSurface(EGLSurface aSurfaceId); |
|
217 EGLSurface CastFromRIEGLSurface(RIEGLSurface* aSurface); |
|
218 |
|
219 /*-------------------------------------------------------------------*//*! |
|
220 * \brief |
|
221 * \param |
|
222 * \return |
|
223 * \note |
|
224 *//*-------------------------------------------------------------------*/ |
|
225 |
|
226 #define EGL_NUMCONFIGS 60 |
|
227 |
|
228 class RIEGLDisplay |
|
229 { |
|
230 public: |
|
231 RIEGLDisplay(EGLDisplay id); |
|
232 ~RIEGLDisplay(); |
|
233 |
|
234 int getNumConfigs() const { return EGL_NUMCONFIGS; } |
|
235 const RIEGLConfig& getConfigByIdx(int i) const { RI_ASSERT(i >= 0 && i < EGL_NUMCONFIGS); return m_configs[i]; } |
|
236 const RIEGLConfig& getConfig(const EGLConfig config) const { for(int i=0;i<EGL_NUMCONFIGS;i++) { if(m_configs[i].m_config == config) return m_configs[i]; } RI_ASSERT(0); return m_configs[0]; } |
|
237 |
|
238 EGLDisplay getID() const { return m_id; } |
|
239 |
|
240 void addContext(RIEGLContext* ctx) { RI_ASSERT(ctx); m_contexts.push_back(ctx); } //throws bad_alloc |
|
241 void removeContext(RIEGLContext* ctx) { RI_ASSERT(ctx); bool res = m_contexts.remove(ctx); RI_ASSERT(res); RI_UNREF(res); } |
|
242 |
|
243 void addSurface(RIEGLSurface* srf) { RI_ASSERT(srf); m_surfaces.push_back(srf); } //throws bad_alloc |
|
244 void removeSurface(RIEGLSurface* srf) { RI_ASSERT(srf); bool res = m_surfaces.remove(srf); RI_ASSERT(res); RI_UNREF(res); } |
|
245 |
|
246 EGLBoolean contextExists(const EGLContext ctx) const; |
|
247 EGLBoolean surfaceExists(const EGLSurface srf) const; |
|
248 EGLBoolean configExists(const EGLConfig cfg) const; |
|
249 |
|
250 private: |
|
251 RIEGLDisplay(const RIEGLDisplay& t); |
|
252 RIEGLDisplay& operator=(const RIEGLDisplay&t); |
|
253 |
|
254 EGLDisplay m_id; |
|
255 |
|
256 Array<RIEGLContext*> m_contexts; |
|
257 Array<RIEGLSurface*> m_surfaces; |
|
258 |
|
259 RIEGLConfig m_configs[EGL_NUMCONFIGS]; |
|
260 }; |
|
261 |
|
262 |
|
263 /*-------------------------------------------------------------------*//*! |
|
264 * \brief |
|
265 * \param |
|
266 * \return |
|
267 * \note |
|
268 *//*-------------------------------------------------------------------*/ |
|
269 |
|
270 class RIEGLThread |
|
271 { |
|
272 public: |
|
273 RIEGLThread(void* currentThreadID); |
|
274 ~RIEGLThread(); |
|
275 |
|
276 void* getThreadID() const { return m_threadID; } |
|
277 |
|
278 void makeCurrent(RIEGLContext* c, RIEGLSurface* s) { m_context = c; m_surface = s; } |
|
279 RIEGLContext* getCurrentContext() const { return m_context; } |
|
280 RIEGLSurface* getCurrentSurface() const { return m_surface; } |
|
281 |
|
282 void setError(EGLint error) { m_error = error; } |
|
283 EGLint getError() const { return m_error; } |
|
284 |
|
285 void bindAPI(EGLint api) { m_boundAPI = api; } |
|
286 EGLint getBoundAPI() const { return m_boundAPI; } |
|
287 |
|
288 private: |
|
289 RIEGLThread(const RIEGLThread&); |
|
290 RIEGLThread operator=(const RIEGLThread&); |
|
291 |
|
292 RIEGLContext* m_context; |
|
293 RIEGLSurface* m_surface; |
|
294 EGLint m_error; |
|
295 void* m_threadID; |
|
296 EGLint m_boundAPI; |
|
297 }; |
|
298 |
|
299 |
|
300 Image* CastToImage(EGLClientBuffer aBufferId); |
|
301 EGLClientBuffer CastFromImage(Image* aBUffer); |
|
302 |
|
303 /*-------------------------------------------------------------------*//*! |
|
304 * \brief |
|
305 * \param |
|
306 * \return |
|
307 * \note |
|
308 *//*-------------------------------------------------------------------*/ |
|
309 |
|
310 class EGL |
192 class EGL |
311 { |
193 { |
312 public: |
194 public: |
313 EGL(); |
195 EGL(); |
314 ~EGL(); |
196 ~EGL(); |
339 Array<RIEGLDisplay*> m_displays; |
221 Array<RIEGLDisplay*> m_displays; |
340 |
222 |
341 int m_referenceCount; |
223 int m_referenceCount; |
342 }; |
224 }; |
343 |
225 |
344 |
|
345 void* eglvgGetCurrentVGContext(void); |
226 void* eglvgGetCurrentVGContext(void); |
346 bool eglvgIsInUse(void* image); |
227 bool eglvgIsInUse(void* image); |
347 |
228 |
348 } //end of namespace |
229 } //end of namespace |
349 |
230 |
350 |
|
351 /*-------------------------------------------------------------------*//*! |
|
352 * \brief |
|
353 * \param |
|
354 * \return |
|
355 * \note |
|
356 *//*-------------------------------------------------------------------*/ |
|
357 |
|
358 #define EGL_GET_DISPLAY(DISPLAY, RETVAL) \ |
|
359 OSAcquireMutex(); \ |
|
360 EGL* egl = getEGL(); \ |
|
361 if(!egl) \ |
|
362 { \ |
|
363 OSReleaseMutex(); \ |
|
364 return RETVAL; \ |
|
365 } \ |
|
366 RIEGLDisplay* display = egl->getDisplay(DISPLAY); \ |
|
367 |
|
368 #define EGL_GET_EGL(RETVAL) \ |
|
369 OSAcquireMutex(); \ |
|
370 EGL* egl = getEGL(); \ |
|
371 if(!egl) \ |
|
372 { \ |
|
373 OSReleaseMutex(); \ |
|
374 return RETVAL; \ |
|
375 } \ |
|
376 |
|
377 #define EGL_IF_ERROR(COND, ERRORCODE, RETVAL) \ |
|
378 if(COND) { eglSetError(egl, ERRORCODE); OSReleaseMutex(); return RETVAL; } \ |
|
379 |
|
380 #define EGL_RETURN(ERRORCODE, RETVAL) \ |
|
381 { \ |
|
382 eglSetError(egl, ERRORCODE); \ |
|
383 OSReleaseMutex(); \ |
|
384 return RETVAL; \ |
|
385 } |
|
386 |
|
387 //#undef EGL_NUMCONFIGS |
|
388 |
|
389 #endif /* __RIMINIEGL_H */ |
231 #endif /* __RIMINIEGL_H */ |
390 |
232 |
391 |
233 |