blob: 0464bcd04660b0e71af77c8db98b9c5fea19135b [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
Chia-I Wu1c457272016-11-17 10:11:32 +080019import android.hardware.graphics.common@1.0::PixelFormat;
20
Chia-I Wue78aa1b2016-09-05 11:46:36 +080021interface IAllocator {
22 enum Capability : int32_t {
23 /* reserved */
24 INVALID = 0,
25
26 /*
27 * testAllocate will always return UNDEFINED unless this capability
28 * is supported.
29 */
30 TEST_ALLOCATE = 1,
Craig Donner0b00adf2016-10-20 17:12:58 -070031
32 /*
33 * layerCount must be 1 unless this capability is supported.
34 */
35 LAYERED_BUFFERS = 2,
Chia-I Wue78aa1b2016-09-05 11:46:36 +080036 };
37
38 struct BufferDescriptorInfo {
39 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070040 * The width specifies how many columns of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080041 * allocated buffer, but does not necessarily represent the offset in
42 * columns between the same column in adjacent rows. The rows may be
43 * padded.
44 */
45 uint32_t width;
46
47 /*
Craig Donner0b00adf2016-10-20 17:12:58 -070048 * The height specifies how many rows of pixels must be in the
Chia-I Wue78aa1b2016-09-05 11:46:36 +080049 * allocated buffer.
50 */
51 uint32_t height;
52
Craig Donner0b00adf2016-10-20 17:12:58 -070053 /*
54 * The number of image layers that must be in the allocated buffer.
55 */
56 uint32_t layerCount;
57
Chia-I Wue78aa1b2016-09-05 11:46:36 +080058 /* Buffer pixel format. */
59 PixelFormat format;
60
61 /*
62 * Buffer producer usage mask; valid flags can be found in the
63 * definition of ProducerUsage.
64 */
65 uint64_t producerUsageMask;
66
67 /*
68 * Buffer consumer usage mask; valid flags can be found in the
69 * definition of ConsumerUsage.
70 */
71 uint64_t consumerUsageMask;
72 };
73
74 /*
75 * Provides a list of supported capabilities (as described in the
76 * definition of Capability above). This list must not change after
77 * initialization.
78 *
79 * @return capabilities is a list of supported capabilities.
80 */
81 getCapabilities() generates (vec<Capability> capabilities);
82
83 /*
84 * Retrieves implementation-defined debug information, which will be
85 * displayed during, for example, `dumpsys SurfaceFlinger`.
86 *
87 * @return debugInfo is a string of debug information.
88 */
89 dumpDebugInfo() generates (string debugInfo);
90
91 /*
92 * Creates a new, opaque buffer descriptor.
93 *
94 * @param descriptorInfo specifies the attributes of the buffer
95 * descriptor.
96 * @return error is NONE upon success. Otherwise,
97 * BAD_VALUE when any attribute in descriptorInfo is invalid.
98 * NO_RESOURCES when no more descriptors can currently be created.
99 * @return descriptor is the newly created buffer descriptor.
100 */
101 createDescriptor(BufferDescriptorInfo descriptorInfo)
102 generates (Error error,
103 BufferDescriptor descriptor);
104
105 /*
106 * Destroys an existing buffer descriptor.
107 *
108 * @param descriptor is the descriptor to destroy.
109 * @return error is either NONE or BAD_DESCRIPTOR.
110 */
111 destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
112
113 /*
114 * Tests whether a buffer allocation can succeed, ignoring potential
115 * resource contention which might lead to a NO_RESOURCES error.
116 *
117 * @param descriptors is a list of buffer descriptors.
118 * @return error is NONE or NOT_SHARED upon success;
119 * NONE when buffers can be created and share a backing store.
120 * NOT_SHARED when buffers can be created but require more than a
121 * backing store.
122 * Otherwise,
123 * BAD_DESCRIPTOR when any of the descriptors is invalid.
124 * UNSUPPORTED when any of the descriptors can never be satisfied.
125 * UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
126 */
127 testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
128
129 /*
130 * Attempts to allocate a list of buffers sharing a backing store.
131 *
132 * Each buffer will correspond to one of the descriptors passed into the
133 * function and will hold a reference to its backing store. If the device
134 * is unable to share the backing store between the buffers, it must
135 * attempt to allocate the buffers with different backing stores and
136 * return NOT_SHARED if it is successful.
137 *
138 * @param descriptors is the buffer descriptors to attempt to allocate.
139 * @return error is NONE or NOT_SHARED upon success;
140 * NONE when buffers can be created and share a backing store.
141 * NOT_SHARED when buffers can be created but require more than a
142 * backing store.
143 * Otherwise,
144 * BAD_DESCRIPTOR when any of the descriptors is invalid.
145 * UNSUPPORTED when any of the descriptors can never be satisfied.
146 * NO_RESOURCES when any of the buffers cannot be created at this
147 * time.
148 * @return buffers is the allocated buffers.
149 */
150 allocate(vec<BufferDescriptor> descriptors)
151 generates (Error error,
152 vec<Buffer> buffers);
153
154 /*
155 * Frees a buffer.
156 *
157 * @param buffer is the buffer to be freed.
158 * @return error is NONE upon success. Otherwise,
159 * BAD_BUFFER when the buffer is invalid.
160 */
161 free(Buffer buffer) generates (Error error);
162
163 /*
164 * Exports a buffer for use in other client libraries or for cross-process
165 * sharing.
166 *
167 * The exported handle is a handle to the backing store of the buffer, not
168 * to the buffer itself. It however may not hold any reference to the
169 * backing store and may be considered invalid by client libraries. To use
170 * it and, in most cases, to save it for later use, a client must make a
171 * clone of the handle and have the cloned handle hold a reference to the
172 * backing store. Such a cloned handle will stay valid even after the
173 * original buffer is freed. Refer to native_handle_clone and IMapper for
174 * how a handle is cloned and how a reference is added.
175 *
176 * @param descriptor is the descriptor used to allocate the buffer.
177 * @param buffer is the buffer to be exported.
178 * @return error is NONE upon success. Otherwise,
179 * BAD_DESCRIPTOR when the descriptor is invalid.
180 * BAD_BUFFER when the buffer is invalid.
181 * BAD_VALUE when descriptor and buffer do not match.
182 * NO_RESOURCES when the buffer cannot be exported at this time.
183 * @return bufferHandle is the exported handle.
184 */
185 exportHandle(BufferDescriptor descriptor,
186 Buffer buffer)
187 generates (Error error,
188 handle bufferHandle);
189};