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_RENDERTOPVIEW_H 18 #define CAR_EVS_APP_RENDERTOPVIEW_H 19 20 #include "ConfigManager.h" 21 #include "RenderBase.h" 22 #include "VideoTex.h" 23 24 #include <aidl/android/hardware/automotive/evs/BufferDesc.h> 25 #include <aidl/android/hardware/automotive/evs/IEvsEnumerator.h> 26 #include <math/mat4.h> 27 28 /* 29 * Combines the views from all available cameras into one reprojected top down view. 30 */ 31 class RenderTopView final : public RenderBase { 32 public: 33 RenderTopView( 34 std::shared_ptr<aidl::android::hardware::automotive::evs::IEvsEnumerator> enumerator, 35 const std::vector<ConfigManager::CameraInfo>& camList, const ConfigManager& config); 36 37 virtual bool activate() override; 38 virtual void deactivate() override; 39 40 virtual bool drawFrame(const aidl::android::hardware::automotive::evs::BufferDesc& tgtBuffer); 41 42 protected: 43 struct ActiveCamera { 44 const ConfigManager::CameraInfo& info; 45 std::unique_ptr<VideoTex> tex; 46 ActiveCameraActiveCamera47 ActiveCamera(const ConfigManager::CameraInfo& c) : info(c) {}; 48 }; 49 50 void renderCarTopView(); 51 void renderCameraOntoGroundPlane(const ActiveCamera& cam); 52 53 std::shared_ptr<aidl::android::hardware::automotive::evs::IEvsEnumerator> mEnumerator; 54 const ConfigManager& mConfig; 55 std::vector<ActiveCamera> mActiveCameras; 56 57 struct { 58 std::unique_ptr<TexWrapper> checkerBoard; 59 std::unique_ptr<TexWrapper> carTopView; 60 } mTexAssets; 61 62 struct { 63 GLuint simpleTexture; 64 GLuint projectedTexture; 65 } mPgmAssets; 66 67 android::mat4 orthoMatrix; 68 }; 69 70 #endif // CAR_EVS_APP_RENDERTOPVIEW_H 71