1 #ifndef ANDROID_DVR_DISPLAY_MANAGER_H_ 2 #define ANDROID_DVR_DISPLAY_MANAGER_H_ 3 4 #include <stdbool.h> 5 #include <stddef.h> 6 #include <stdint.h> 7 #include <sys/cdefs.h> 8 9 #include <dvr/dvr_display_types.h> 10 #include <dvr/dvr_surface.h> 11 12 __BEGIN_DECLS 13 14 typedef struct DvrBuffer DvrBuffer; 15 typedef struct DvrDisplayManager DvrDisplayManager; 16 typedef struct DvrSurfaceState DvrSurfaceState; 17 typedef struct DvrReadBufferQueue DvrReadBufferQueue; 18 19 typedef uint64_t DvrSurfaceUpdateFlags; 20 21 // Attempts to connect to the display manager service. 22 // @return 0 on success. Otherwise returns a negative error value. 23 int dvrDisplayManagerCreate(DvrDisplayManager** client_out); 24 25 // Destroys the display manager client object. 26 void dvrDisplayManagerDestroy(DvrDisplayManager* client); 27 28 // Returns an fd used to signal when surface updates occur. Note that depending 29 // on the underlying transport, only a subset of the real event bits may be 30 // supported. Use dvrDisplayManagerClientTranslateEpollEventMask to get the real 31 // event flags. 32 // @return the fd on success. Otherwise returns a negative error value. 33 int dvrDisplayManagerGetEventFd(DvrDisplayManager* client); 34 35 // @param in_events pass in the epoll revents that were initially returned by 36 // poll/epoll. 37 // @param on success, this value will be overwritten with the true poll/epoll 38 // values. 39 // @return 0 on success. Otherwise returns a negative error value. 40 int dvrDisplayManagerTranslateEpollEventMask(DvrDisplayManager* client, 41 int in_events, int* out_events); 42 43 // Queries the display manager service for the current state of the display 44 // surfaces and stores the results in the given surface state object. 45 // @return 0 on success. Otherwise returns a negative error value. 46 int dvrDisplayManagerGetSurfaceState(DvrDisplayManager* client, 47 DvrSurfaceState* surface_state); 48 49 // Gets a read buffer queue from the surface |surface_id| named |queue_id|. Each 50 // call returns a different read buffer queue connected to the same write buffer 51 // queue. Callers should cache these instead of requesting new ones when 52 // possible. 53 int dvrDisplayManagerGetReadBufferQueue(DvrDisplayManager* client, 54 int surface_id, int queue_id, 55 DvrReadBufferQueue** queue_out); 56 57 // Creates a new surface state object. This object may be used to receive the 58 // results of a surface state query. More than one state object may be created 59 // to keep multiple snapshots, if desired. 60 // @return 0 on success. Otherwise returns a negative error value. 61 int dvrSurfaceStateCreate(DvrSurfaceState** surface_state); 62 63 // Destorys the surface state object. 64 void dvrSurfaceStateDestroy(DvrSurfaceState* surface_state); 65 66 // Writes the number of surfaces described in the state object into |count_out|. 67 // @return 0 on success. Otherwise returns a negative error value. 68 int dvrSurfaceStateGetSurfaceCount(DvrSurfaceState* surface_state, 69 size_t* count_out); 70 71 // Returns the update flags for the surface at |surface_index| in the state 72 // object. The flags may be used to determine what changes, if any, occurred to 73 // the surface since the last state update. 74 // @return 0 on success. Otherwise returns a negative error value. 75 int dvrSurfaceStateGetUpdateFlags(DvrSurfaceState* surface_state, 76 size_t surface_index, 77 DvrSurfaceUpdateFlags* flags_out); 78 79 // Returns the unique identifier of surface at |surface_index| in the state 80 // object. The identifier may be used to distinguish between surfaces. 81 // @return 0 on success. Otherwise returns a negative error value. 82 int dvrSurfaceStateGetSurfaceId(DvrSurfaceState* surface_state, 83 size_t surface_index, int* surface_id_out); 84 85 // Returns the process id of surface at |surface_index| in the state object. 86 // @return 0 on success. Otherwise returns a negative error value. 87 int dvrSurfaceStateGetProcessId(DvrSurfaceState* surface_state, 88 size_t surface_index, int* process_id_out); 89 90 // Writes the number of queues in the surface at |surface_index| in the state 91 // object into |count_out|. 92 // @return 0 on success. Otherwise returns a negative error value. 93 int dvrSurfaceStateGetQueueCount(DvrSurfaceState* surface_state, 94 size_t surface_index, size_t* count_out); 95 96 // Returns up to |max_count| queue ids for the queues belonging to the surface 97 // at |surface_index| in the state object. 98 // @return The number of queue ids written on success. Otherwise returns a 99 // negative error value. 100 ssize_t dvrSurfaceStateGetQueueIds(DvrSurfaceState* surface_state, 101 size_t surface_index, int* queue_ids, 102 size_t max_count); 103 104 // Writes the z-order of the surface at |surface_index| in surface state object 105 // into |z_order_out|. 106 // @return 0 on success. Otherwise returns a negative error value. 107 int dvrSurfaceStateGetZOrder(DvrSurfaceState* surface_state, 108 size_t surface_index, int* z_order_out); 109 110 // Writes the visible state of the surface at |surface_index| in the surface 111 // state object into |visible_out|. 112 // @return 0 on success. Otherwise it returns a negative error value. 113 int dvrSurfaceStateGetVisible(DvrSurfaceState* surface_state, 114 size_t surface_index, bool* visible_out); 115 116 // Writes the number of attributes on the surface at |surface_index| in the 117 // state object into |count_out|. 118 // @return 0 on success. Otherwise it returns a negative error value. 119 int dvrSurfaceStateGetAttributeCount(DvrSurfaceState* surface_state, 120 size_t surface_index, size_t* count_out); 121 122 // Writes the list of attribute key/value pairs for the surface at 123 // |surface_index| in the surface state object into |attributes|. 124 // @return The number of attributes written on success. Otherwise returns a 125 // negative error value. 126 ssize_t dvrSurfaceStateGetAttributes(DvrSurfaceState* surface_state, 127 size_t surface_index, 128 DvrSurfaceAttribute* attributes, 129 size_t max_count); 130 131 __END_DECLS 132 133 #endif // ANDROID_DVR_DISPLAY_MANAGER_H_ 134