1#ifndef ANDROID_DVR_SERVICES_VRFLINGER_DISPLAY_MANAGER_SERVICE_H_ 2#define ANDROID_DVR_SERVICES_VRFLINGER_DISPLAY_MANAGER_SERVICE_H_ 3 4#include <pdx/service.h> 5#include <pdx/status.h> 6#include <private/dvr/display_protocol.h> 7 8#include "display_service.h" 9 10namespace android { 11namespace dvr { 12 13class DisplayManagerService; 14 15// The display manager is a client of the display manager service. This class 16// represents the connected client that the display manager service sends 17// notifications to. 18class DisplayManager : public pdx::Channel { 19 public: 20 DisplayManager(DisplayManagerService* service, int channel_id) 21 : service_(service), channel_id_(channel_id) {} 22 23 int channel_id() const { return channel_id_; } 24 25 // Sets or clears the channel event mask to indicate pending events that the 26 // display manager on the other end of the channel should read and handle. 27 // When |pending| is true the POLLIN bit is set in the event mask; when 28 // |pending| is false the POLLIN bit is cleared in the event mask. 29 void SetNotificationsPending(bool pending); 30 31 private: 32 DisplayManager(const DisplayManager&) = delete; 33 void operator=(const DisplayManager&) = delete; 34 35 DisplayManagerService* service_; 36 int channel_id_; 37}; 38 39// The display manager service marshalls state and events from the display 40// service to the display manager. 41class DisplayManagerService : public pdx::ServiceBase<DisplayManagerService> { 42 public: 43 std::shared_ptr<pdx::Channel> OnChannelOpen(pdx::Message& message) override; 44 void OnChannelClose(pdx::Message& message, 45 const std::shared_ptr<pdx::Channel>& channel) override; 46 pdx::Status<void> HandleMessage(pdx::Message& message) override; 47 48 private: 49 friend BASE; 50 51 explicit DisplayManagerService( 52 const std::shared_ptr<DisplayService>& display_service); 53 54 pdx::Status<std::vector<display::SurfaceState>> OnGetSurfaceState( 55 pdx::Message& message); 56 pdx::Status<pdx::LocalChannelHandle> OnGetSurfaceQueue(pdx::Message& message, 57 int surface_id, 58 int queue_id); 59 pdx::Status<BorrowedNativeBufferHandle> OnSetupNamedBuffer( 60 pdx::Message& message, const std::string& name, size_t size, 61 uint64_t usage); 62 63 // Called by the display service to indicate changes to display surfaces that 64 // the display manager should evaluate. 65 void OnDisplaySurfaceChange(); 66 67 DisplayManagerService(const DisplayManagerService&) = delete; 68 void operator=(const DisplayManagerService&) = delete; 69 70 std::shared_ptr<DisplayService> display_service_; 71 std::shared_ptr<DisplayManager> display_manager_; 72}; 73 74} // namespace dvr 75} // namespace android 76 77#endif // ANDROID_DVR_SERVICES_VRFLINGER_DISPLAY_MANAGER_SERVICE_H_ 78