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