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