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_CONTEXT_H
     17 #define EGL_CONTEXT_H
     18 
     19 #include <map>
     20 #include <EGL/egl.h>
     21 #include <GLcommon/GLutils.h>
     22 #include <GLcommon/TranslatorIfaces.h>
     23 #include <GLcommon/objectNameManager.h>
     24 
     25 #include "emugl/common/smart_ptr.h"
     26 
     27 #include "EglConfig.h"
     28 #include "EglSurface.h"
     29 
     30 
     31 
     32 class EglContext;
     33 typedef  emugl::SmartPtr<EglContext> ContextPtr;
     34 
     35 class EglDisplay;
     36 
     37 class EglContext {
     38 
     39 public:
     40 
     41     EglContext(EglDisplay *dpy, EGLNativeContextType context,ContextPtr shared_context,EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr);
     42     bool usingSurface(SurfacePtr surface);
     43     EGLNativeContextType nativeType(){return m_native;};
     44     bool getAttrib(EGLint attrib,EGLint* value);
     45     SurfacePtr read(){ return m_read;};
     46     SurfacePtr draw(){ return m_draw;};
     47     ShareGroupPtr getShareGroup(){return m_shareGroup;}
     48     EglConfig* getConfig(){ return m_config;};
     49     GLESVersion version(){return m_version;};
     50     GLEScontext* getGlesContext(){return m_glesContext;}
     51     void setSurfaces(SurfacePtr read,SurfacePtr draw);
     52     unsigned int getHndl(){return m_hndl;}
     53     bool attachImage(unsigned int imageId,ImagePtr img);
     54     void detachImage(unsigned int imageId);
     55 
     56     ~EglContext();
     57 
     58 private:
     59     static unsigned int  s_nextContextHndl;
     60     EglDisplay          *m_dpy;
     61     EGLNativeContextType m_native;
     62     EglConfig*           m_config;
     63     GLEScontext*         m_glesContext;
     64     ShareGroupPtr        m_shareGroup;
     65     SurfacePtr           m_read;
     66     SurfacePtr           m_draw;
     67     GLESVersion          m_version;
     68     ObjectNameManager    *m_mngr;
     69     unsigned int         m_hndl;
     70     ImagesHndlMap        m_attachedImages;
     71 };
     72 
     73 #endif
     74