File: dvr_surface.h

package info (click to toggle)
android-platform-tools 34.0.5-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,900 kB
  • sloc: cpp: 805,786; java: 293,500; ansic: 128,288; xml: 127,491; python: 41,481; sh: 14,245; javascript: 9,665; cs: 3,846; asm: 2,049; makefile: 1,917; yacc: 440; awk: 368; ruby: 183; sql: 140; perl: 88; lex: 67
file content (113 lines) | stat: -rw-r--r-- 4,459 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef ANDROID_DVR_SURFACE_H_
#define ANDROID_DVR_SURFACE_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/cdefs.h>

#include <dvr/dvr_api.h>
#include <dvr/dvr_buffer.h>
#include <dvr/dvr_buffer_queue.h>
#include <dvr/dvr_display_types.h>

__BEGIN_DECLS

// Attribute types. The values are one-hot encoded to support singluar types or
// masks of supported types.
enum {
  DVR_SURFACE_ATTRIBUTE_TYPE_NONE = 0,
  DVR_SURFACE_ATTRIBUTE_TYPE_INT32 = (1 << 0),
  DVR_SURFACE_ATTRIBUTE_TYPE_INT64 = (1 << 1),
  DVR_SURFACE_ATTRIBUTE_TYPE_BOOL = (1 << 2),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT = (1 << 3),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT2 = (1 << 4),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT3 = (1 << 5),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT4 = (1 << 6),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT8 = (1 << 7),
  DVR_SURFACE_ATTRIBUTE_TYPE_FLOAT16 = (1 << 8),
};

typedef uint64_t DvrSurfaceAttributeType;
typedef int32_t DvrSurfaceAttributeKey;

typedef struct DvrSurfaceAttributeValue {
  DvrSurfaceAttributeType type;
  union {
    int32_t int32_value;
    int64_t int64_value;
    bool bool_value;
    float float_value;
    float float2_value[2];
    float float3_value[3];
    float float4_value[4];
    float float8_value[8];
    float float16_value[16];
  };
} DvrSurfaceAttributeValue;

typedef struct DvrSurfaceAttribute {
  DvrSurfaceAttributeKey key;
  DvrSurfaceAttributeValue value;
} DvrSurfaceAttribute;

// Creates a new display surface with the given attributes.
// @return 0 on success. Otherwise returns a negative error value.
int dvrSurfaceCreate(const DvrSurfaceAttribute* attributes,
                     size_t attribute_count, DvrSurface** surface_out);

// Destroys the display surface.
void dvrSurfaceDestroy(DvrSurface* surface);

// Gets the DisplayService global id for this surface.
int dvrSurfaceGetId(DvrSurface* surface);

// Sets attributes on the given display surface.
// @return 0 on success. Otherwise returns a negative error value.
int dvrSurfaceSetAttributes(DvrSurface* surface,
                            const DvrSurfaceAttribute* attributes,
                            size_t attribute_count);

// Creates a new write-side buffer queue on the given surface. Direct surfaces
// may only have one queue, the latest call replacing any prior queue. Replaced
// queues are still referenced and should be destryoed using the queue destroy
// API.
// @return 0 on success. Otherwise returns a negative error value.
int dvrSurfaceCreateWriteBufferQueue(DvrSurface* surface, uint32_t width,
                                     uint32_t height, uint32_t format,
                                     uint32_t layer_count, uint64_t usage,
                                     size_t capacity, size_t metadata_size,
                                     DvrWriteBufferQueue** queue_out);

// Sets up a named buffer for shared memory data transfer between display
// clients and the system. Protected API that may only be called with sufficient
// privilege.
// @return 0 on success. Otherwise returns a negative error value.
int dvrSetupGlobalBuffer(DvrGlobalBufferKey key, size_t size, uint64_t usage,
                         DvrBuffer** buffer_out);

// Deletes a named buffer. WARNING: This is dangerous because any existing
// clients of this buffer will not be notified and will remain attached to
// the old buffer. This is useful for tests, but probably not for production
// code.
// @return 0 on success. Otherwise returns a negative error value.
int dvrDeleteGlobalBuffer(DvrGlobalBufferKey key);

// Get a global buffer from the display service.
// @return 0 on success. Otherwise returns a negative error value.
int dvrGetGlobalBuffer(DvrGlobalBufferKey key, DvrBuffer** out_buffer);

// Read the native device display metrics as reported by the hardware composer.
// This is useful as otherwise the device metrics are only reported as
// relative to the current device orientation.
// @param sizeof_metrics the size of the passed in metrics struct. This is used
//   to ensure we don't break each other during active development.
// @param metrics on success holds the retrieved device metrics.
// @return 0 on success. Otherwise returns a negative error value (typically
//   this means the display service is not available).
int dvrGetNativeDisplayMetrics(size_t metrics_struct_size,
                               DvrNativeDisplayMetrics* metrics);

__END_DECLS

#endif  // ANDROID_DVR_SURFACE_H_