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