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_DISPLAY_H 17 #define EGL_DISPLAY_H 18 19 #include <list> 20 #include <map> 21 #include <EGL/egl.h> 22 #include <EGL/eglext.h> 23 #include "emugl/common/mutex.h" 24 #include "emugl/common/smart_ptr.h" 25 26 #include "EglConfig.h" 27 #include "EglContext.h" 28 #include "EglSurface.h" 29 #include "EglWindowSurface.h" 30 31 32 33 34 typedef std::list<EglConfig*> ConfigsList; 35 typedef std::map< unsigned int, ContextPtr> ContextsHndlMap; 36 typedef std::map< unsigned int, SurfacePtr> SurfacesHndlMap; 37 38 class EglDisplay { 39 public: 40 41 42 EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault = true); 43 EGLNativeInternalDisplayType nativeType(); nConfigs()44 int nConfigs(){ return m_configs.size();} 45 int getConfigs(EGLConfig* configs,int config_size); 46 int chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size); 47 EglConfig* getConfig(EGLConfig conf); 48 EglConfig* getConfig(EGLint id ); 49 50 EGLSurface addSurface(SurfacePtr s ); 51 SurfacePtr getSurface(EGLSurface surface); 52 bool removeSurface(EGLSurface s); 53 bool removeSurface(SurfacePtr s); 54 55 EGLContext addContext(ContextPtr ctx ); 56 ContextPtr getContext(EGLContext ctx); 57 bool removeContext(EGLContext ctx); 58 bool removeContext(ContextPtr ctx); getManager(GLESVersion ver)59 ObjectNameManager* getManager(GLESVersion ver){ return m_manager[ver];} 60 61 ~EglDisplay(); 62 void initialize(int renderableType); 63 void terminate(); 64 bool isInitialize(); 65 66 ImagePtr getImage(EGLImageKHR img); 67 EGLImageKHR addImageKHR(ImagePtr); 68 bool destroyImageKHR(EGLImageKHR img); 69 EGLNativeContextType getGlobalSharedContext(); 70 71 private: 72 int doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size); 73 void addMissingConfigs(void); 74 void initConfigurations(int renderableType); 75 76 EGLNativeInternalDisplayType m_dpy; 77 bool m_initialized; 78 bool m_configInitialized; 79 bool m_isDefault; 80 ConfigsList m_configs; 81 ContextsHndlMap m_contexts; 82 SurfacesHndlMap m_surfaces; 83 GlobalNameSpace m_globalNameSpace; 84 ObjectNameManager *m_manager[MAX_GLES_VERSION]; 85 emugl::Mutex m_lock; 86 ImagesHndlMap m_eglImages; 87 unsigned int m_nextEglImageId; 88 EGLNativeContextType m_globalSharedContext; 89 }; 90 91 #endif 92 93 94