blob: ff08a7edee950a8deba92f3fdcbc954852cc6ad4 [file] [log] [blame]
Chia-I Wue78aa1b2016-09-05 11:46:36 +08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.graphics.allocator@2.0;
18
19interface IAllocator {
20 enum Capability : int32_t {
21 /* reserved */
22 INVALID = 0,
23
24 /*
25 * testAllocate will always return UNDEFINED unless this capability
26 * is supported.
27 */
28 TEST_ALLOCATE = 1,
Craig Donner0b00adf2016-10-20 17:12:58 -070029
30 /*
31 * layerCount must be 1 unless this capability is supported.
32 */
33 LAYERED_BUFFERS = 2,
Chia-I Wue78aa1b2016-09-05 11:46:36 +080034 };
35
36 struct BufferDescriptorInfo {
37 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070038 * The width specifies how many columns of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080039 * allocated buffer, but does not necessarily represent the offset in
40 * columns between the same column in adjacent rows. The rows may be
41 * padded.
42 */
43 uint32_t width;
44
45 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070046 * The height specifies how many rows of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080047 * allocated buffer.
48 */
49 uint32_t height;
50
Craig Donner0b00adf2016-10-20 17:12:58 -070051 /*
52 * The number of image layers that must be in the allocated buffer.
53 */
54 uint32_t layerCount;
55
Chia-I Wue78aa1b2016-09-05 11:46:36 +080056 /* Buffer pixel format. */
57 PixelFormat format;
58
59 /*
60 * Buffer producer usage mask; valid flags can be found in the
61 * definition of ProducerUsage.
62 */
63 uint64_t producerUsageMask;
64
65 /*
66 * Buffer consumer usage mask; valid flags can be found in the
67 * definition of ConsumerUsage.
68 */
69 uint64_t consumerUsageMask;
70 };
71
72 /*
73 * Provides a list of supported capabilities (as described in the
74 * definition of Capability above). This list must not change after
75 * initialization.
76 *
77 * @return capabilities is a list of supported capabilities.
78 */
79 getCapabilities() generates (vec<Capability> capabilities);
80
81 /*
82 * Retrieves implementation-defined debug information, which will be
83 * displayed during, for example, `dumpsys SurfaceFlinger`.
84 *
85 * @return debugInfo is a string of debug information.
86 */
87 dumpDebugInfo() generates (string debugInfo);
88
89 /*
90 * Creates a new, opaque buffer descriptor.
91 *
92 * @param descriptorInfo specifies the attributes of the buffer
93 * descriptor.
94 * @return error is NONE upon success. Otherwise,
95 * BAD_VALUE when any attribute in descriptorInfo is invalid.
96 * NO_RESOURCES when no more descriptors can currently be created.
97 * @return descriptor is the newly created buffer descriptor.
98 */
99 createDescriptor(BufferDescriptorInfo descriptorInfo)
100 generates (Error error,
101 BufferDescriptor descriptor);
102
103 /*
104 * Destroys an existing buffer descriptor.
105 *
106 * @param descriptor is the descriptor to destroy.
107 * @return error is either NONE or BAD_DESCRIPTOR.
108 */
109 destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
110
111 /*
112 * Tests whether a buffer allocation can succeed, ignoring potential
113 * resource contention which might lead to a NO_RESOURCES error.
114 *
115 * @param descriptors is a list of buffer descriptors.
116 * @return error is NONE or NOT_SHARED upon success;
117 * NONE when buffers can be created and share a backing store.
118 * NOT_SHARED when buffers can be created but require more than a
119 * backing store.
120 * Otherwise,
121 * BAD_DESCRIPTOR when any of the descriptors is invalid.
122 * UNSUPPORTED when any of the descriptors can never be satisfied.
123 * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
124 */
125 testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
126
127 /*
128 * Attempts to allocate a list of buffers sharing a backing store.
129 *
130 * Each buffer will correspond to one of the descriptors passed into the
131 * function and will hold a reference to its backing store. If the device
132 * is unable to share the backing store between the buffers, it must
133 * attempt to allocate the buffers with different backing stores and
134 * return NOT_SHARED if it is successful.
135 *
136 * @param descriptors is the buffer descriptors to attempt to allocate.
137 * @return error is NONE or NOT_SHARED upon success;
138 * NONE when buffers can be created and share a backing store.
139 * NOT_SHARED when buffers can be created but require more than a
140 * backing store.
141 * Otherwise,
142 * BAD_DESCRIPTOR when any of the descriptors is invalid.
143 * UNSUPPORTED when any of the descriptors can never be satisfied.
144 * NO_RESOURCES when any of the buffers cannot be created at this
145 * time.
146 * @return buffers is the allocated buffers.
147 */
148 allocate(vec<BufferDescriptor> descriptors)
149 generates (Error error,
150 vec<Buffer> buffers);
151
152 /*
153 * Frees a buffer.
154 *
155 * @param buffer is the buffer to be freed.
156 * @return error is NONE upon success. Otherwise,
157 * BAD_BUFFER when the buffer is invalid.
158 */
159 free(Buffer buffer) generates (Error error);
160
161 /*
162 * Exports a buffer for use in other client libraries or for cross-process
163 * sharing.
164 *
165 * The exported handle is a handle to the backing store of the buffer, not
166 * to the buffer itself. It however may not hold any reference to the
167 * backing store and may be considered invalid by client libraries. To use
168 * it and, in most cases, to save it for later use, a client must make a
169 * clone of the handle and have the cloned handle hold a reference to the
170 * backing store. Such a cloned handle will stay valid even after the
171 * original buffer is freed. Refer to native_handle_clone and IMapper for
172 * how a handle is cloned and how a reference is added.
173 *
174 * @param descriptor is the descriptor used to allocate the buffer.
175 * @param buffer is the buffer to be exported.
176 * @return error is NONE upon success. Otherwise,
177 * BAD_DESCRIPTOR when the descriptor is invalid.
178 * BAD_BUFFER when the buffer is invalid.
179 * BAD_VALUE when descriptor and buffer do not match.
180 * NO_RESOURCES when the buffer cannot be exported at this time.
181 * @return bufferHandle is the exported handle.
182 */
183 exportHandle(BufferDescriptor descriptor,
184 Buffer buffer)
185 generates (Error error,
186 handle bufferHandle);
187};