• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
2 #define ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
3 
4 #include <dvr/dvr_hardware_composer_types.h>
5 #include <stdbool.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 typedef struct AHardwareBuffer AHardwareBuffer;
12 typedef struct DvrHwcClient DvrHwcClient;
13 typedef struct DvrHwcFrame DvrHwcFrame;
14 
15 // Called when a new frame has arrived.
16 //
17 // @param client_state Pointer to client state passed in |dvrHwcCreateClient()|.
18 // @param frame New frame. Owned by the client.
19 // @return fence FD for the release of the last frame.
20 typedef int(*DvrHwcOnFrameCallback)(void* client_state, DvrHwcFrame* frame);
21 
22 // @param callback Called when a new frame is available.
23 // @param client_state Pointer to client state passed back in the callback.
24 DvrHwcClient* dvrHwcClientCreate(DvrHwcOnFrameCallback callback,
25                                  void* client_state);
26 
27 // Called to free the DvrHwcClient pointer.
28 void dvrHwcClientDestroy(DvrHwcClient* client);
29 
30 // Called to free the frame information.
31 // @param frame Pointer for the valid frame used for the query.
32 void dvrHwcFrameDestroy(DvrHwcFrame* frame);
33 
34 // @param frame Pointer for the valid frame used for the query.
35 // @return Identifier for the display associated by the frame.
36 DvrHwcDisplay dvrHwcFrameGetDisplayId(DvrHwcFrame* frame);
37 
38 // @param frame Pointer for the valid frame used for the query.
39 // @return width of the physical display associated with |frame|. This does not
40 // take into account any orientation changes.
41 int32_t dvrHwcFrameGetDisplayWidth(DvrHwcFrame* frame);
42 
43 // @param frame Pointer for the valid frame used for the query.
44 // @return height of the physical display associated with |frame|. This does not
45 // take into account any orientation changes.
46 int32_t dvrHwcFrameGetDisplayHeight(DvrHwcFrame* frame);
47 
48 // @param frame Pointer for the valid frame used for the query.
49 // @return True if the display has been removed. In this case the current frame
50 // does not contain any valid layers to display. It is a signal to clean up any
51 // display related state.
52 bool dvrHwcFrameGetDisplayRemoved(DvrHwcFrame* frame);
53 
54 // @param frame Pointer for the valid frame used for the query.
55 // @return Number of layers in the frame.
56 size_t dvrHwcFrameGetLayerCount(DvrHwcFrame* frame);
57 
58 // @param frame Pointer for the valid frame used for the query.
59 // @return The ID of the currently active display configuration.
60 uint32_t dvrHwcFrameGetActiveConfig(DvrHwcFrame* frame);
61 
62 // @param frame Pointer for the valid frame used for the query.
63 // @return The ID of the current color mode. See HAL_COLOR_MODE_* for valid
64 // values.
65 uint32_t dvrHwcFrameGetColorMode(DvrHwcFrame* frame);
66 
67 // @param frame Pointer for the valid frame used for the query.
68 // @param out_matrix Output parameter for a float[16] array which will be filled
69 // with the color transform matrix.
70 // @param out_hint Output parameter which will contain the color transform hint.
71 // See HAL_COLOR_TRANSFORM_* for valid values.
72 void dvrHwcFrameGetColorTransform(DvrHwcFrame* frame, float* out_matrix,
73                                   int32_t* out_hint);
74 
75 // @param frame Pointer for the valid frame used for the query.
76 // @return The current power mode for the display. See HWC2_POWER_MODE_* for
77 // valid values.
78 uint32_t dvrHwcFrameGetPowerMode(DvrHwcFrame* frame);
79 
80 // @param frame Pointer for the valid frame used for the query.
81 // @return The current state of vsync. See HWC2_VSYNC_* for valid values.
82 uint32_t dvrHwcFrameGetVsyncEnabled(DvrHwcFrame* frame);
83 
84 // @param frame Pointer for the valid frame used for the query.
85 // @param layer_index The index of the layer in the frame.
86 // @return A unique ID for the layer.
87 DvrHwcLayer dvrHwcFrameGetLayerId(DvrHwcFrame* frame, size_t layer_index);
88 
89 // Return the graphic buffer associated with the layer at |layer_index| in
90 // |frame|.
91 //
92 // @param frame Pointer for the valid frame used for the query.
93 // @param layer_index The index of the layer in the frame.
94 // @return Graphic buffer. Caller owns the buffer and is responsible for freeing
95 // it. (see AHardwareBuffer_release())
96 AHardwareBuffer* dvrHwcFrameGetLayerBuffer(DvrHwcFrame* frame,
97                                            size_t layer_index);
98 
99 // Returns the fence FD for the layer at index |layer_index| in |frame|.
100 //
101 // @param frame Pointer for the valid frame used for the query.
102 // @param layer_index The index of the layer in the frame.
103 // @return Fence FD. Caller owns the FD and is responsible for closing it.
104 int dvrHwcFrameGetLayerFence(DvrHwcFrame* frame, size_t layer_index);
105 
106 // @param frame Pointer for the valid frame used for the query.
107 // @param layer_index The index of the layer in the frame.
108 // @return describing the portion of the display covered by the layer. Will
109 // not exceed the display dimensions.
110 DvrHwcRecti dvrHwcFrameGetLayerDisplayFrame(DvrHwcFrame* frame,
111                                             size_t layer_index);
112 
113 // @param frame Pointer for the valid frame used for the query.
114 // @param layer_index The index of the layer in the frame.
115 // @return describing the portion of the layer that will fill the display
116 // frame. Will not exceed the layer dimensions.
117 DvrHwcRectf dvrHwcFrameGetLayerCrop(DvrHwcFrame* frame, size_t layer_index);
118 
119 // @param frame Pointer for the valid frame used for the query.
120 // @param layer_index The index of the layer in the frame.
121 // @return The blend mode of the layer.
122 DvrHwcBlendMode dvrHwcFrameGetLayerBlendMode(DvrHwcFrame* frame,
123                                              size_t layer_index);
124 
125 // @param frame Pointer for the valid frame used for the query.
126 // @param layer_index The index of the layer in the frame.
127 // @return The alpha value to be applied to the whole layer. Will be in the
128 // [0.0, 1.0] range.
129 float dvrHwcFrameGetLayerAlpha(DvrHwcFrame* frame, size_t layer_index);
130 
131 // @param frame Pointer for the valid frame used for the query.
132 // @param layer_index The index of the layer in the frame.
133 // @return The type of the layer assigned by the window manager.
134 uint32_t dvrHwcFrameGetLayerType(DvrHwcFrame* frame, size_t layer_index);
135 
136 // @param frame Pointer for the valid frame used for the query.
137 // @param layer_index The index of the layer in the frame.
138 // @return The application id the layer belongs to.
139 uint32_t dvrHwcFrameGetLayerApplicationId(DvrHwcFrame* frame,
140                                           size_t layer_index);
141 
142 // @param frame Pointer for the valid frame used for the query.
143 // @param layer_index The index of the layer in the frame.
144 // @return The z-order for the layer.
145 uint32_t dvrHwcFrameGetLayerZOrder(DvrHwcFrame* frame, size_t layer_index);
146 
147 // @param frame Pointer for the valid frame used for the query.
148 // @param layer_index The index of the layer in the frame.
149 // @param out_x Output parameter for the x coordinate of the cursor location.
150 // @param out_y Output parameter for the y coordinate of the cursor location.
151 void dvrHwcFrameGetLayerCursor(DvrHwcFrame* frame, size_t layer_index,
152                                int32_t* out_x, int32_t* out_y);
153 
154 // @param frame Pointer for the valid frame used for the query.
155 // @param layer_index The index of the layer in the frame.
156 // @return The transformation that needs to be applied to the layer before
157 // presenting it. See DVR_HWC_TRANSFORM_* for valid values.
158 uint32_t dvrHwcFrameGetLayerTransform(DvrHwcFrame* frame, size_t layer_index);
159 
160 // @param frame Pointer for the valid frame used for the query.
161 // @param layer_index The index of the layer in the frame.
162 // @return The dataspace which represents how the pixel values should be
163 // interpreted. See HAL_DATASPACE_* for valid values.
164 uint32_t dvrHwcFrameGetLayerDataspace(DvrHwcFrame* frame, size_t layer_index);
165 
166 // @param frame Pointer for the valid frame used for the query.
167 // @param layer_index The index of the layer in the frame.
168 // @return The color of the layer if layer composition is SOLID_COLOR.
169 uint32_t dvrHwcFrameGetLayerColor(DvrHwcFrame* frame, size_t layer_index);
170 
171 // @param frame Pointer for the valid frame used for the query.
172 // @param layer_index The index of the layer in the frame.
173 // @return The number of visible regions.
174 uint32_t dvrHwcFrameGetLayerNumVisibleRegions(DvrHwcFrame* frame,
175                                               size_t layer_index);
176 // @param frame Pointer for the valid frame used for the query.
177 // @param layer_index The index of the layer in the frame.
178 // @param index The index of the visible region for the layer.
179 // @return The rectangle describing the visible region.
180 DvrHwcRecti dvrHwcFrameGetLayerVisibleRegion(DvrHwcFrame* frame,
181                                              size_t layer_index, size_t index);
182 
183 // @param frame Pointer for the valid frame used for the query.
184 // @param layer_index The index of the layer in the frame.
185 // @return The number of damanged regions.
186 uint32_t dvrHwcFrameGetLayerNumDamagedRegions(DvrHwcFrame* frame,
187                                               size_t layer_index);
188 
189 // @param frame Pointer for the valid frame used for the query.
190 // @param layer_index The index of the layer in the frame.
191 // @param index The index of the damanged region for the layer.
192 // @return The rectangle describing the damaged region.
193 DvrHwcRecti dvrHwcFrameGetLayerDamagedRegion(DvrHwcFrame* frame,
194                                              size_t layer_index, size_t index);
195 #ifdef __cplusplus
196 }  // extern "C"
197 #endif
198 
199 #endif  // ANDROID_DVR_HARDWARE_COMPOSER_CLIENT_H
200