1 #ifndef ANDROID_DVR_HARDWARE_COMPOSER_VR_COMPOSER_H 2 #define ANDROID_DVR_HARDWARE_COMPOSER_VR_COMPOSER_H 3 4 #include <android/dvr/BnVrComposer.h> 5 #include <impl/vr_hwc.h> 6 7 namespace android { 8 namespace dvr { 9 10 class VrComposerCallback; 11 12 // Implementation of the IVrComposer service used to notify VR Window Manager 13 // when SurfaceFlinger presents 2D UI changes. 14 // 15 // VR HWC updates the presented frame via the ComposerView::Observer interface. 16 // On notification |callback_| is called to update VR Window Manager. 17 // NOTE: If VR Window Manager isn't connected, the notification is a no-op. 18 class VrComposer 19 : public BnVrComposer, 20 public ComposerView::Observer, 21 public IBinder::DeathRecipient { 22 public: 23 explicit VrComposer(ComposerView* composer_view); 24 ~VrComposer() override; 25 26 // BnVrComposer: 27 binder::Status registerObserver( 28 const sp<IVrComposerCallback>& callback) override; 29 30 binder::Status clearObserver() override; 31 32 // ComposerView::Observer: 33 base::unique_fd OnNewFrame(const ComposerView::Frame& frame) override; 34 35 private: 36 // IBinder::DeathRecipient: 37 void binderDied(const wp<IBinder>& who) override; 38 39 std::mutex mutex_; 40 41 sp<IVrComposerCallback> callback_; 42 43 ComposerView* composer_view_; // Not owned. 44 45 VrComposer(const VrComposer&) = delete; 46 void operator=(const VrComposer&) = delete; 47 }; 48 49 } // namespace dvr 50 } // namespace android 51 52 #endif // ANDROID_DVR_HARDWARE_COMPOSER_VR_COMPOSER_H 53