• 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 "EglConfig.h"
20 #include "EglOsApi.h"
21 
22 #include <EGL/egl.h>
23 #include <GLES2/gl2.h>
24 
25 #include <memory>
26 
27 class EglSurface;
28 typedef std::shared_ptr<EglSurface> SurfacePtr;
29 
30 class EglDisplay;
31 
32 class EglSurface {
33 public:
34     typedef enum {
35         WINDOW  = 0,
36         PBUFFER = 1,
37         PIXMAP  = 3
38     } ESurfaceType;
39 
type()40     ESurfaceType type() const { return m_type; }
41 
native()42     EglOS::Surface* native() const { return m_native; }
43 
44     virtual bool setAttrib(EGLint attrib, EGLint val);
45     virtual bool getAttrib(EGLint attrib, EGLint* val) = 0;
46 
setDim(int width,int height)47     void setDim(int width, int height) {
48         m_width = width;
49         m_height = height;
50     }
51 
getConfig()52     EglConfig* getConfig() const { return m_config; }
53 
getHndl()54     unsigned int getHndl() const { return m_hndl; }
55 
56     virtual ~EglSurface();
57 
58     // Shared backing GL renderbuffer
59     GLuint glRboColor = 0;
60     GLuint glRboDepth = 0;
61 
62 private:
63     static unsigned int s_nextSurfaceHndl;
64 
65     ESurfaceType m_type = WINDOW;
66     unsigned int m_hndl = 0;
67 
68 protected:
EglSurface(EglDisplay * dpy,ESurfaceType type,EglConfig * config,EGLint width,EGLint height)69     EglSurface(EglDisplay *dpy,
70                ESurfaceType type,
71                EglConfig* config,
72                EGLint width,
73                EGLint height) :
74        m_type(type),
75        m_config(config),
76        m_width(width),
77        m_height(height),
78        m_dpy(dpy)
79     {
80         m_hndl = ++s_nextSurfaceHndl;
81     }
82 
83 protected:
84     EglConfig*            m_config = nullptr;
85     EGLint                m_width = 0;
86     EGLint                m_height = 0;
87     EglOS::Surface*       m_native = nullptr;
88     EglDisplay*           m_dpy = nullptr;
89 };
90 
91 #endif  // EGL_SURFACE_H
92