1b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph/*
2b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * Copyright (C) 2016 The Android Open Source Project
3b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph *
4b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * Licensed under the Apache License, Version 2.0 (the "License");
5b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * you may not use this file except in compliance with the License.
6b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * You may obtain a copy of the License at
7b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph *
8b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph *      http://www.apache.org/licenses/LICENSE-2.0
9b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph *
10b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * Unless required by applicable law or agreed to in writing, software
11b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * distributed under the License is distributed on an "AS IS" BASIS,
12b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * See the License for the specific language governing permissions and
14b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph * limitations under the License.
15b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph */
16b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
17b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
18b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
19b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
20b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#include <android/hardware/automotive/evs/1.0/IEvsDisplay.h>
21b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#include <ui/GraphicBuffer.h>
22b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
23b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#include "GlWrapper.h"
24b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
25b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
26b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace android {
27b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace hardware {
28b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace automotive {
29b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace evs {
30b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace V1_0 {
31b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphnamespace implementation {
32b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
33b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
34b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphclass EvsGlDisplay : public IEvsDisplay {
35b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphpublic:
36b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    // Methods from ::android::hardware::automotive::evs::V1_0::IEvsDisplay follow.
37b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    Return<void> getDisplayInfo(getDisplayInfo_cb _hidl_cb)  override;
38b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    Return<EvsResult> setDisplayState(DisplayState state)  override;
39b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    Return<DisplayState> getDisplayState()  override;
40b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    Return<void> getTargetBuffer(getTargetBuffer_cb _hidl_cb)  override;
41b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    Return<EvsResult> returnTargetBufferForDisplay(const BufferDesc& buffer)  override;
42b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
43b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    // Implementation details
44b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    EvsGlDisplay();
45b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    virtual ~EvsGlDisplay() override;
46b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
47b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    void forceShutdown();   // This gets called if another caller "steals" ownership of the display
48b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
49b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolphprivate:
50b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    DisplayDesc     mInfo           = {};
51b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    BufferDesc      mBuffer         = {};       // A graphics buffer into which we'll store images
52b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
53b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    bool            mFrameBusy      = false;    // A flag telling us our buffer is in use
54b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    DisplayState    mRequestedState = DisplayState::NOT_VISIBLE;
55b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
56b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    GlWrapper       mGlWrapper;
57b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
58b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph    std::mutex      mAccessLock;
59b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph};
60b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
61b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace implementation
62b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace V1_0
63b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace evs
64b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace automotive
65b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace hardware
66b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph} // namespace android
67b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph
68b342cb163393317d8af77339ff8ff5e921bd4a8fScott Randolph#endif  // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_0_EVSGLDISPLAY_H
69