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.0/IEvsEnumerator.h> 28 29 #include <BaseRenderCallback.h> 30 31 namespace android { 32 namespace automotive { 33 namespace evs { 34 namespace support { 35 36 using namespace ::android::hardware::automotive::evs::V1_0; 37 using ::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 */ 44 class RenderBase { 45 public: ~RenderBase()46 virtual ~RenderBase() {}; 47 48 virtual bool activate() = 0; 49 virtual void deactivate() = 0; 50 51 virtual bool drawFrame(const BufferDesc& tgtBuffer, const BufferDesc& imageBuffer) = 0; 52 53 protected: 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 sMockSurface; 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 74 } // namespace support 75 } // namespace evs 76 } // namespace automotive 77 } // namespace android 78 79 #endif //CAR_EVS_APP_RENDERBASE_H 80