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_SURFACE_H
     17 #define EGL_SURFACE_H
     18 
     19 #include <map>
     20 
     21 #include <EGL/egl.h>
     22 #include <EGL/eglinternalplatform.h>
     23 #include "emugl/common/smart_ptr.h"
     24 #include "EglConfig.h"
     25 
     26 class EglSurface;
     27 typedef emugl::SmartPtr<EglSurface> SurfacePtr;
     28 
     29 class EglDisplay;
     30 
     31 class EglSurface {
     32 public:
     33     typedef enum {
     34                   WINDOW  = 0,
     35                   PBUFFER = 1,
     36                   PIXMAP  = 3
     37                  } ESurfaceType;
     38   ESurfaceType  type(){ return m_type;};
     39   EGLNativeSurfaceType native(){return m_native;}
     40   virtual bool  setAttrib(EGLint attrib,EGLint val);
     41   virtual bool  getAttrib(EGLint attrib,EGLint* val) = 0;
     42   void          setDim(int width,int height){ m_width = width; m_height = height;};
     43   EglConfig*    getConfig(){return m_config;};
     44   unsigned int  getHndl(){return m_hndl;};
     45   virtual       ~EglSurface();
     46 
     47 private:
     48     static unsigned int   s_nextSurfaceHndl;
     49     ESurfaceType          m_type;
     50     unsigned int          m_hndl;
     51 
     52 protected:
     53     EglSurface(EglDisplay *dpy,
     54                ESurfaceType type,
     55                EglConfig* config,
     56                EGLint width,
     57                EGLint height) :
     58        m_type(type),
     59        m_config(config),
     60        m_width(width),
     61        m_height(height),
     62        m_native(NULL),
     63        m_dpy(dpy)
     64     {
     65         m_hndl = ++s_nextSurfaceHndl;
     66     }
     67 
     68 protected:
     69     EglConfig*            m_config;
     70     EGLint                m_width;
     71     EGLint                m_height;
     72     EGLNativeSurfaceType  m_native;
     73     EglDisplay           *m_dpy;
     74 };
     75 #endif
     76