#ifndef ANDROID_DVR_VR_FLINGER_H_ #define ANDROID_DVR_VR_FLINGER_H_ #include #include #define HWC2_INCLUDE_STRINGIFICATION #define HWC2_USE_CPP11 #include #undef HWC2_INCLUDE_STRINGIFICATION #undef HWC2_USE_CPP11 #include #include namespace android { namespace Hwc2 { class Composer; } // namespace Hwc2 namespace dvr { class DisplayService; class VrFlinger { public: using RequestDisplayCallback = std::function; static std::unique_ptr Create( Hwc2::Composer* hidl, hwc2_display_t primary_display_id, RequestDisplayCallback request_display_callback); ~VrFlinger(); // These functions are all called on surface flinger's main thread. void OnBootFinished(); void GrantDisplayOwnership(); void SeizeDisplayOwnership(); // dump all vr flinger state. std::string Dump(); private: VrFlinger(); bool Init(Hwc2::Composer* hidl, hwc2_display_t primary_display_id, RequestDisplayCallback request_display_callback); // Needs to be a separate class for binder's ref counting class PersistentVrStateCallback : public BnPersistentVrStateCallbacks { public: PersistentVrStateCallback(RequestDisplayCallback request_display_callback) : request_display_callback_(request_display_callback) {} void onPersistentVrStateChanged(bool enabled) override; private: RequestDisplayCallback request_display_callback_; }; std::thread dispatcher_thread_; std::unique_ptr dispatcher_; std::shared_ptr display_service_; sp persistent_vr_state_callback_; RequestDisplayCallback request_display_callback_; }; } // namespace dvr } // namespace android #endif // ANDROID_DVR_VR_FLINGER_H_