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_GLOBAL_INFO
     17 #define EGL_GLOBAL_INFO
     18 
     19 #include <list>
     20 #include <EGL/egl.h>
     21 #include <utils/threads.h>
     22 #include <GLcommon/TranslatorIfaces.h>
     23 #include "EglDisplay.h"
     24 #include "EglConfig.h"
     25 #include "EglContext.h"
     26 
     27 typedef std::map<EglDisplay*,EGLNativeDisplayType>DisplaysMap;
     28 
     29 
     30 class EglGlobalInfo {
     31 
     32 public:
     33     EglDisplay* addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy);
     34     EglDisplay* getDisplay(EGLNativeDisplayType dpy);
     35     EglDisplay* getDisplay(EGLDisplay dpy);
     36     bool removeDisplay(EGLDisplay dpy);
     37     EGLNativeInternalDisplayType getDefaultNativeDisplay(){ return m_default;};
     38     EGLNativeInternalDisplayType generateInternalDisplay(EGLNativeDisplayType dpy);
     39 
     40     void setIface(GLESiface* iface,GLESVersion ver) { m_gles_ifaces[ver] = iface;};
     41     GLESiface* getIface(GLESVersion ver){ return m_gles_ifaces[ver];}
     42 
     43     int  nDisplays() const { return m_displays.size();};
     44 
     45     void initClientExtFuncTable(GLESVersion ver);
     46 
     47     static EglGlobalInfo* getInstance();
     48     static void delInstance();
     49 
     50 private:
     51     EglGlobalInfo();
     52     ~EglGlobalInfo(){};
     53 
     54     static EglGlobalInfo*          m_singleton;
     55     static int                     m_refCount;
     56 
     57     DisplaysMap                    m_displays;
     58     EGLNativeInternalDisplayType   m_default;
     59     GLESiface*                     m_gles_ifaces[MAX_GLES_VERSION];
     60     bool                           m_gles_extFuncs_inited[MAX_GLES_VERSION];
     61     android::Mutex                 m_lock;
     62 };
     63 
     64 #endif
     65