• 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 _LIBRENDER_WINDOWSURFACE_H
17 #define _LIBRENDER_WINDOWSURFACE_H
18 
19 #include "ColorBuffer.h"
20 #include "RenderContext.h"
21 #include "FBConfig.h"
22 #include "SmartPtr.h"
23 #include "FixedBuffer.h"
24 #include <EGL/egl.h>
25 #include <GLES/gl.h>
26 
27 enum SurfaceBindType {
28     SURFACE_BIND_READ,
29     SURFACE_BIND_DRAW,
30     SURFACE_BIND_READDRAW
31 };
32 
33 class WindowSurface
34 {
35 public:
36     static WindowSurface *create(int p_config, int p_width, int p_height);
37     ~WindowSurface();
getEGLSurface()38     EGLSurface getEGLSurface() const { return m_eglSurface; }
39 
40     void setColorBuffer(ColorBufferPtr p_colorBuffer);
41     void flushColorBuffer();
42     void bind(RenderContextPtr p_ctx, SurfaceBindType p_bindType);
43 
44 private:
45     WindowSurface();
46 
47     void blitToColorBuffer();  // copy pbuffer content with texload and blit
48     bool resizePbuffer(unsigned int p_width, unsigned int p_height);
49 
50 private:
51     GLuint m_fbObj;   // GLES Framebuffer object (when EGLimage is used)
52     GLuint m_depthRB;
53     GLuint m_stencilRB;
54     EGLSurface m_eglSurface;
55     ColorBufferPtr m_attachedColorBuffer;
56     RenderContextPtr m_readContext;
57     RenderContextPtr m_drawContext;
58     GLuint m_width;
59     GLuint m_height;
60     GLuint m_pbufWidth;
61     GLuint m_pbufHeight;
62     bool m_useEGLImage;
63     bool m_useBindToTexture;
64     FixedBuffer m_xferBuffer;
65     FixedBuffer m_xUpdateBuf;
66     const FBConfig *m_fbconf;
67 };
68 
69 typedef SmartPtr<WindowSurface> WindowSurfacePtr;
70 
71 #endif
72