1 /*
2  * Copyright (C) 2016 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 ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
18 #define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
19 
20 #include <android/hardware/automotive/evs/1.0/IEvsDisplay.h>
21 #include <ui/GraphicBuffer.h>
22 
23 #include "GlWrapper.h"
24 
25 
26 namespace android {
27 namespace hardware {
28 namespace automotive {
29 namespace evs {
30 namespace V1_0 {
31 namespace implementation {
32 
33 
34 class EvsGlDisplay : public IEvsDisplay {
35 public:
36     // Methods from ::android::hardware::automotive::evs::V1_0::IEvsDisplay follow.
37     Return<void> getDisplayInfo(getDisplayInfo_cb _hidl_cb)  override;
38     Return<EvsResult> setDisplayState(DisplayState state)  override;
39     Return<DisplayState> getDisplayState()  override;
40     Return<void> getTargetBuffer(getTargetBuffer_cb _hidl_cb)  override;
41     Return<EvsResult> returnTargetBufferForDisplay(const BufferDesc& buffer)  override;
42 
43     // Implementation details
44     EvsGlDisplay();
45     virtual ~EvsGlDisplay() override;
46 
47     void forceShutdown();   // This gets called if another caller "steals" ownership of the display
48 
49 private:
50     DisplayDesc     mInfo           = {};
51     BufferDesc      mBuffer         = {};       // A graphics buffer into which we'll store images
52 
53     bool            mFrameBusy      = false;    // A flag telling us our buffer is in use
54     DisplayState    mRequestedState = DisplayState::NOT_VISIBLE;
55 
56     GlWrapper       mGlWrapper;
57 
58     std::mutex      mAccessLock;
59 };
60 
61 } // namespace implementation
62 } // namespace V1_0
63 } // namespace evs
64 } // namespace automotive
65 } // namespace hardware
66 } // namespace android
67 
68 #endif  // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
69