blob: 0a9be51f918fbb9b4d83822c81014ac3d79102f0 [file] [log] [blame]
Haoxiang Lib21a13e2019-06-18 13:16:28 -07001/*
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.0/IEvsEnumerator.h>
28
Haoxiang Lid2454a52019-06-18 13:23:12 -070029#include <BaseRenderCallback.h>
30
31namespace android {
32namespace automotive {
33namespace evs {
34namespace support {
35
Haoxiang Lib21a13e2019-06-18 13:16:28 -070036using namespace ::android::hardware::automotive::evs::V1_0;
37using ::android::sp;
38
39
40/*
41 * Abstract base class for the workhorse classes that handle the user interaction and display for
42 * each mode of the EVS application.
43 */
44class RenderBase {
45public:
46 virtual ~RenderBase() {};
47
48 virtual bool activate() = 0;
49 virtual void deactivate() = 0;
50
Haoxiang Li1709b372019-09-18 15:08:52 -070051 virtual bool drawFrame(const BufferDesc& tgtBuffer, const BufferDesc& imageBuffer) = 0;
Haoxiang Lib21a13e2019-06-18 13:16:28 -070052
53protected:
54 static bool prepareGL();
55
56 static bool attachRenderTarget(const BufferDesc& tgtBuffer);
57 static void detachRenderTarget();
58
59 // OpenGL state shared among all renderers
60 static EGLDisplay sDisplay;
61 static EGLContext sContext;
62 static EGLSurface sDummySurface;
63 static GLuint sFrameBuffer;
64 static GLuint sColorBuffer;
65 static GLuint sDepthBuffer;
66
67 static EGLImageKHR sKHRimage;
68
69 static unsigned sWidth;
70 static unsigned sHeight;
71 static float sAspectRatio;
72};
73
Haoxiang Lid2454a52019-06-18 13:23:12 -070074} // namespace support
75} // namespace evs
76} // namespace automotive
77} // namespace android
Haoxiang Lib21a13e2019-06-18 13:16:28 -070078
79#endif //CAR_EVS_APP_RENDERBASE_H