• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 
17 #ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_DISPLAY_GLWRAPPER_H
18 #define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_DISPLAY_GLWRAPPER_H
19 
20 #include <EGL/egl.h>
21 #include <EGL/eglext.h>
22 #include <GLES2/gl2.h>
23 #include <GLES2/gl2ext.h>
24 #include <GLES3/gl3.h>
25 #include <GLES3/gl3ext.h>
26 
27 #include <gui/ISurfaceComposer.h>
28 #include <gui/Surface.h>
29 #include <gui/SurfaceComposerClient.h>
30 
31 #include <android/hardware/automotive/evs/1.0/types.h>
32 
33 
34 using ::android::sp;
35 using ::android::SurfaceComposerClient;
36 using ::android::SurfaceControl;
37 using ::android::Surface;
38 using ::android::hardware::automotive::evs::V1_0::BufferDesc;
39 
40 
41 class GlWrapper {
42 public:
43     bool initialize();
44     void shutdown();
45 
46     bool updateImageTexture(const BufferDesc& buffer);
47     void renderImageToScreen();
48 
49     void showWindow();
50     void hideWindow();
51 
getWidth()52     unsigned getWidth()     { return mWidth; };
getHeight()53     unsigned getHeight()    { return mHeight; };
54 
55 private:
56     sp<SurfaceComposerClient>   mFlinger;
57     sp<SurfaceControl>          mFlingerSurfaceControl;
58     sp<Surface>                 mFlingerSurface;
59     EGLDisplay                  mDisplay;
60     EGLSurface                  mSurface;
61     EGLContext                  mContext;
62 
63     unsigned mWidth  = 0;
64     unsigned mHeight = 0;
65 
66     EGLImageKHR mKHRimage = EGL_NO_IMAGE_KHR;
67 
68     GLuint mTextureMap    = 0;
69     GLuint mShaderProgram = 0;
70 };
71 
72 #endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_DISPLAY_GLWRAPPER_H
73