holdingarea/libEGL/inc/EGLState.h
author Faisal Memon <faisal.memon@nokia.com>
Fri, 22 Oct 2010 10:54:17 +0100
branchbug235_bringup_0
changeset 60 dfe4593146ee
parent 24 a3f46bb01be2
permissions -rw-r--r--
Fix guestegl to actually supply the params for eglMakeCurrent
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     1
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     2
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     3
 * Permission is hereby granted, free of charge, to any person obtaining a
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     4
 * copy of this software and /or associated documentation files
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     5
 * (the "Materials "), to deal in the Materials without restriction,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     6
 * including without limitation the rights to use, copy, modify, merge,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     7
 * publish, distribute, sublicense, and/or sell copies of the Materials,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     8
 * and to permit persons to whom the Materials are furnished to do so,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     9
 * subject to the following conditions:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    10
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    11
 * The above copyright notice and this permission notice shall be included
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    12
 * in all copies or substantial portions of the Materials.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    13
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    14
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    15
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    16
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    17
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    18
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    19
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    20
 * THE USE OR OTHER DEALINGS IN THE MATERIALS.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    21
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    22
 * Initial Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    23
 * Nokia Corporation - initial contribution.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    24
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    25
 * Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    26
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    27
 * Description:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    28
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    29
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    30
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    31
#ifndef _EGLSTATE_H_
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    32
#define _EGLSTATE_H_
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    33
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    34
#include <EGL/egl.h>
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    35
#include "eglInternal.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    36
#include <vector>
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    37
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    38
class CEGLDisplay;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    39
class CEGLProcess;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    40
class CEGLConfig;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    41
class CEGLSurface;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    42
struct SurfaceDescriptor;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    43
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    44
class CEGLState : public RefCountingObject, public IVGtoEGLInterface, public IGLEStoEGLInterface
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    45
{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    46
public:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    47
	CEGLState(void);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    48
	~CEGLState(void);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    49
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    50
public:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    51
    bool Initialize();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    52
    EGLint SupportedApis() const { return m_supportedApis; }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    53
    inline bool IsInitialized() const { return m_initialized; }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    54
    CEGLDisplay* AddDisplay( EGLINativeDisplayType nativeType, EGLint processId );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    55
    void RemoveDisplay( EGLDisplay displayId );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    56
    CEGLDisplay* GetDisplayByNativeType( EGLINativeDisplayType nativeType, EGLint processId ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    57
    CEGLDisplay* GetDisplay( EGLDisplay displayId ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    58
	EGLINativeDisplayType DefaultDisplay() const { return m_defaultDisplay; }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    59
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    60
    CEGLProcess* AddProcess( EGLint processId, bool setCurrent);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    61
    void RemoveProcess( EGLint processId );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    62
    CEGLProcess* GetProcess( EGLint processId ) const ;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    63
    inline CEGLProcess* GetCurrentProcess() const { return m_currentProcess; }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    64
    void SetCurrentProcessThread( EGLint processId, EGLI_THREAD_ID threadId );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    65
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    66
    inline EGLint ConfigCount() const { return m_configs.size(); }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    67
    void FillConfigs( EGLConfig* configs, EGLint size ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    68
    CEGLConfig* FindConfigById( EGLint id ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    69
    EGLint MatchConfigs( CEGLConfig* filter, EGLConfig* configs, EGLint maxCount ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    70
    CEGLConfig* GetConfig( EGLConfig config ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    71
    
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    72
    inline IEGLtoVGInterface* VGInterface() const { return m_VGInterface; }
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    73
	IEGLtoGLESInterface* GLESInterface( EGLint clientVersion ) const;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    74
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    75
	bool SyncSurface( EGLenum api, EGLint apiVersion, CEGLSurface* surface, CEGLSurface* currentGLESReadSurface );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    76
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    77
public: // from IVGtoEGLInterface and IGLEStoEGLInterface
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    78
	void GetDescForImage( void* image, SurfaceDescriptor& ImageDesc );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    79
    void* GetDataForImage( void* image );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    80
	void RegisterImageTarget( void* image, EImageTarget target, void* buffer );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    81
	void UnregisterImageTarget( void* image, EImageTarget target, void* buffer );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    82
	void UpdateImageSiblings( void* image, EImageTarget target, void* buffer );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    83
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    84
public: // from IVGtoEGLInterface
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    85
    void* GetVGContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    86
    bool IsImageInUse( void* image );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    87
    bool LockVGSurface( bool read, bool write );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    88
    bool UnlockVGSurface();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    89
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    90
public: // from IGLEStoEGLInterface
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    91
	void* GetGLESContext();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    92
	void* GetHostProcAddress(const char* proc);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    93
    bool LockGLESSurface( bool read, bool write );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    94
    bool UnlockGLESSurface();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    95
	void ReleaseTexImage(void* surface, int name, int level);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    96
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    97
private:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    98
    bool CreateConfigs();
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    99
    bool LockSurface( EGLenum api, bool read, bool write );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   100
    bool UnlockSurface( EGLenum api );
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   101
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   102
private:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   103
    bool                        m_initialized;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   104
    std::vector<CEGLDisplay*>   m_displays;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   105
    std::vector<CEGLProcess*>   m_processes;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   106
    std::vector<CEGLConfig*>    m_configs;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   107
    CEGLProcess*                m_currentProcess;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   108
    EGLILibraryHandle           m_VGLib;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   109
    IEGLtoVGInterface*          m_VGInterface;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   110
    EGLILibraryHandle           m_GLES1Lib;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   111
    IEGLtoGLESInterface*        m_GLES1Interface;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   112
    EGLILibraryHandle           m_GLES2Lib;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   113
    IEGLtoGLES2Interface*       m_GLES2Interface;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   114
	EGLILibraryHandle			m_hostGL;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   115
    EGLint                      m_supportedApis;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   116
	EGLINativeDisplayType       m_defaultDisplay;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   117
    EGLINativeWindowType        m_dummyWindow;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   118
};
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   119
#endif //_EGLSTATE_H_