1 #ifndef ANDROID_DVR_SURFACE_H_ 2 #define ANDROID_DVR_SURFACE_H_ 3 4 #include <stdbool.h> 5 #include <stddef.h> 6 #include <stdint.h> 7 #include <sys/cdefs.h> 8 9 #include <dvr/dvr_buffer.h> 10 #include <dvr/dvr_buffer_queue.h> 11 #include <dvr/dvr_display_types.h> 12 13 __BEGIN_DECLS 14 15 typedef struct DvrBuffer DvrBuffer; 16 typedef struct DvrSurface DvrSurface; 17 typedef struct DvrWriteBufferQueue DvrWriteBufferQueue; 18 19 // Attribute types. The values are one-hot encoded to support singluar types or 20 // masks of supported types. 21 enum { 22 DVR_SURFACE_ATTRIBUTE_TYPE_NONE = 0, 23 DVR_SURFACE_ATTRIBUTE_TYPE_INT32 = (1 << 0), 24 DVR_SURFACE_ATTRIBUTE_TYPE_INT64 = (1 << 1), 25 DVR_SURFACE_ATTRIBUTE_TYPE_BOOL = (1 << 2), 26 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT = (1 << 3), 27 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT2 = (1 << 4), 28 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT3 = (1 << 5), 29 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT4 = (1 << 6), 30 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT8 = (1 << 7), 31 DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT16 = (1 << 8), 32 }; 33 34 typedef uint64_t DvrSurfaceAttributeType; 35 typedef int32_t DvrSurfaceAttributeKey; 36 37 typedef struct DvrSurfaceAttributeValue { 38 DvrSurfaceAttributeType type; 39 union { 40 int32_t int32_value; 41 int64_t int64_value; 42 bool bool_value; 43 float float_value; 44 float float2_value[2]; 45 float float3_value[3]; 46 float float4_value[4]; 47 float float8_value[8]; 48 float float16_value[16]; 49 }; 50 } DvrSurfaceAttributeValue; 51 52 typedef struct DvrSurfaceAttribute { 53 DvrSurfaceAttributeKey key; 54 DvrSurfaceAttributeValue value; 55 } DvrSurfaceAttribute; 56 57 // Creates a new display surface with the given attributes. 58 // @return 0 on success. Otherwise returns a negative error value. 59 int dvrSurfaceCreate(const DvrSurfaceAttribute* attributes, 60 size_t attribute_count, DvrSurface** surface_out); 61 62 // Destroys the display surface. 63 void dvrSurfaceDestroy(DvrSurface* surface); 64 65 // Gets the DisplayService global id for this surface. 66 int dvrSurfaceGetId(DvrSurface* surface); 67 68 // Sets attributes on the given display surface. 69 // @return 0 on success. Otherwise returns a negative error value. 70 int dvrSurfaceSetAttributes(DvrSurface* surface, 71 const DvrSurfaceAttribute* attributes, 72 size_t attribute_count); 73 74 // Creates a new write-side buffer queue on the given surface. Direct surfaces 75 // may only have one queue, the latest call replacing any prior queue. Replaced 76 // queues are still referenced and should be destryoed using the queue destroy 77 // API. 78 // @return 0 on success. Otherwise returns a negative error value. 79 int dvrSurfaceCreateWriteBufferQueue(DvrSurface* surface, uint32_t width, 80 uint32_t height, uint32_t format, 81 uint32_t layer_count, uint64_t usage, 82 size_t capacity, 83 DvrWriteBufferQueue** queue_out); 84 85 // Get a named buffer from the display service. 86 // @return 0 on success. Otherwise returns a negative error value. 87 int dvrGetNamedBuffer(const char* name, DvrBuffer** out_buffer); 88 89 __END_DECLS 90 91 #endif // ANDROID_DVR_SURFACE_H_ 92