• 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 CAR_EVS_APP_RENDERBASE_H
18 #define CAR_EVS_APP_RENDERBASE_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 <android/hardware/automotive/evs/1.1/IEvsEnumerator.h>
28 
29 using namespace ::android::hardware::automotive::evs::V1_1;
30 using ::android::sp;
31 
32 
33 /*
34  * Abstract base class for the workhorse classes that handle the user interaction and display for
35  * each mode of the EVS application.
36  */
37 class RenderBase {
38 public:
~RenderBase()39     virtual ~RenderBase() {};
40 
41     virtual bool activate() = 0;
42     virtual void deactivate() = 0;
43 
44     virtual bool drawFrame(const BufferDesc& tgtBuffer) = 0;
45 
46 protected:
47     static bool prepareGL();
48 
49     static bool attachRenderTarget(const BufferDesc& tgtBuffer);
50     static void detachRenderTarget();
51 
52     // OpenGL state shared among all renderers
53     static EGLDisplay   sDisplay;
54     static EGLContext   sContext;
55     static EGLSurface   sMockSurface;
56     static GLuint       sFrameBuffer;
57     static GLuint       sColorBuffer;
58     static GLuint       sDepthBuffer;
59 
60     static EGLImageKHR  sKHRimage;
61 
62     static unsigned     sWidth;
63     static unsigned     sHeight;
64     static float        sAspectRatio;
65 };
66 
67 
68 #endif //CAR_EVS_APP_RENDERBASE_H
69