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