1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef EGL_GLOBAL_INFO 17 #define EGL_GLOBAL_INFO 18 19 #include "EglDisplay.h" 20 #include "EglConfig.h" 21 #include "EglContext.h" 22 23 #include <GLcommon/TranslatorIfaces.h> 24 #include "emugl/common/mutex.h" 25 #include <list> 26 #include <EGL/egl.h> 27 28 typedef std::map<EglDisplay*,EGLNativeDisplayType>DisplaysMap; 29 30 31 class EglGlobalInfo { 32 33 public: 34 EglDisplay* addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy); 35 EglDisplay* getDisplay(EGLNativeDisplayType dpy); 36 EglDisplay* getDisplay(EGLDisplay dpy); 37 bool removeDisplay(EGLDisplay dpy); getDefaultNativeDisplay()38 EGLNativeInternalDisplayType getDefaultNativeDisplay(){ return m_default;}; 39 EGLNativeInternalDisplayType generateInternalDisplay(EGLNativeDisplayType dpy); 40 setIface(GLESiface * iface,GLESVersion ver)41 void setIface(GLESiface* iface,GLESVersion ver) { m_gles_ifaces[ver] = iface;}; getIface(GLESVersion ver)42 GLESiface* getIface(GLESVersion ver){ return m_gles_ifaces[ver];} 43 nDisplays()44 int nDisplays() const { return m_displays.size();}; 45 46 void initClientExtFuncTable(GLESVersion ver); 47 48 static EglGlobalInfo* getInstance(); 49 static void delInstance(); 50 51 private: 52 EglGlobalInfo(); ~EglGlobalInfo()53 ~EglGlobalInfo(){}; 54 55 static EglGlobalInfo* m_singleton; 56 static int m_refCount; 57 58 DisplaysMap m_displays; 59 EGLNativeInternalDisplayType m_default; 60 GLESiface* m_gles_ifaces[MAX_GLES_VERSION]; 61 bool m_gles_extFuncs_inited[MAX_GLES_VERSION]; 62 emugl::Mutex m_lock; 63 }; 64 65 #endif 66