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