• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (C) 2017 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef CAR_EVS_APP_RENDERTOPVIEW_H
19 #define CAR_EVS_APP_RENDERTOPVIEW_H
20 
21 
22 #include "RenderBase.h"
23 
24 #include <android/hardware/automotive/evs/1.0/IEvsEnumerator.h>
25 #include "ConfigManager.h"
26 #include "VideoTex.h"
27 #include <math/mat4.h>
28 
29 
30 using namespace ::android::hardware::automotive::evs::V1_0;
31 
32 
33 /*
34  * Combines the views from all available cameras into one reprojected top down view.
35  */
36 class RenderTopView: public RenderBase {
37 public:
38     RenderTopView(sp<IEvsEnumerator> enumerator,
39                   const std::vector<ConfigManager::CameraInfo>& camList,
40                   const ConfigManager& config);
41 
42     virtual bool activate() override;
43     virtual void deactivate() override;
44 
45     virtual bool drawFrame(const BufferDesc& tgtBuffer);
46 
47 protected:
48     struct ActiveCamera {
49         const ConfigManager::CameraInfo&    info;
50         std::unique_ptr<VideoTex>           tex;
51 
ActiveCameraActiveCamera52         ActiveCamera(const ConfigManager::CameraInfo& c) : info(c) {};
53     };
54 
55     void renderCarTopView();
56     void renderCameraOntoGroundPlane(const ActiveCamera& cam);
57 
58     sp<IEvsEnumerator>              mEnumerator;
59     const ConfigManager&            mConfig;
60     std::vector<ActiveCamera>       mActiveCameras;
61 
62     struct {
63         std::unique_ptr<TexWrapper> checkerBoard;
64         std::unique_ptr<TexWrapper> carTopView;
65     } mTexAssets;
66 
67     struct {
68         GLuint simpleTexture;
69         GLuint projectedTexture;
70     } mPgmAssets;
71 
72     android::mat4   orthoMatrix;
73 };
74 
75 
76 #endif //CAR_EVS_APP_RENDERTOPVIEW_H
77