1 /*
2 * Copyright (C) 2007 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
17 #define LOG_TAG "GraphicBuffer"
18 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
19
20 #include <ui/GraphicBuffer.h>
21
22 #include <cutils/atomic.h>
23
24 #include <grallocusage/GrallocUsageConversion.h>
25
26 #include <ui/GraphicBufferAllocator.h>
27 #include <ui/GraphicBufferMapper.h>
28 #include <utils/Trace.h>
29
30 namespace android {
31
32 // ===========================================================================
33 // Buffer and implementation of ANativeWindowBuffer
34 // ===========================================================================
35
getUniqueId()36 static uint64_t getUniqueId() {
37 static volatile int32_t nextId = 0;
38 uint64_t id = static_cast<uint64_t>(getpid()) << 32;
39 id |= static_cast<uint32_t>(android_atomic_inc(&nextId));
40 return id;
41 }
42
from(ANativeWindowBuffer * anwb)43 sp<GraphicBuffer> GraphicBuffer::from(ANativeWindowBuffer* anwb) {
44 return static_cast<GraphicBuffer *>(anwb);
45 }
46
fromAHardwareBuffer(AHardwareBuffer * buffer)47 GraphicBuffer* GraphicBuffer::fromAHardwareBuffer(AHardwareBuffer* buffer) {
48 return reinterpret_cast<GraphicBuffer*>(buffer);
49 }
50
fromAHardwareBuffer(AHardwareBuffer const * buffer)51 GraphicBuffer const* GraphicBuffer::fromAHardwareBuffer(AHardwareBuffer const* buffer) {
52 return reinterpret_cast<GraphicBuffer const*>(buffer);
53 }
54
toAHardwareBuffer()55 AHardwareBuffer* GraphicBuffer::toAHardwareBuffer() {
56 return reinterpret_cast<AHardwareBuffer*>(this);
57 }
58
toAHardwareBuffer() const59 AHardwareBuffer const* GraphicBuffer::toAHardwareBuffer() const {
60 return reinterpret_cast<AHardwareBuffer const*>(this);
61 }
62
GraphicBuffer()63 GraphicBuffer::GraphicBuffer()
64 : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
65 mInitCheck(NO_ERROR), mId(getUniqueId()), mGenerationNumber(0)
66 {
67 width =
68 height =
69 stride =
70 format =
71 usage_deprecated = 0;
72 usage = 0;
73 layerCount = 0;
74 handle = nullptr;
75 }
76
77 // deprecated
GraphicBuffer(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inUsage,std::string requestorName)78 GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
79 PixelFormat inFormat, uint32_t inUsage, std::string requestorName)
80 : GraphicBuffer(inWidth, inHeight, inFormat, 1, static_cast<uint64_t>(inUsage), requestorName)
81 {
82 }
83
GraphicBuffer(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage,std::string requestorName)84 GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
85 uint32_t inLayerCount, uint64_t inUsage, std::string requestorName)
86 : GraphicBuffer() {
87 mInitCheck = initWithSize(inWidth, inHeight, inFormat, inLayerCount, inUsage,
88 std::move(requestorName));
89 }
90
91 // deprecated
GraphicBuffer(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint32_t inUsage,uint32_t inStride,native_handle_t * inHandle,bool keepOwnership)92 GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
93 PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage,
94 uint32_t inStride, native_handle_t* inHandle, bool keepOwnership)
95 : GraphicBuffer(inHandle, keepOwnership ? TAKE_HANDLE : WRAP_HANDLE,
96 inWidth, inHeight, inFormat, inLayerCount, static_cast<uint64_t>(inUsage),
97 inStride)
98 {
99 }
100
GraphicBuffer(const native_handle_t * inHandle,HandleWrapMethod method,uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage,uint32_t inStride)101 GraphicBuffer::GraphicBuffer(const native_handle_t* inHandle, HandleWrapMethod method,
102 uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
103 uint32_t inLayerCount, uint64_t inUsage, uint32_t inStride)
104 : GraphicBuffer() {
105 mInitCheck = initWithHandle(inHandle, method, inWidth, inHeight, inFormat, inLayerCount,
106 inUsage, inStride);
107 }
108
~GraphicBuffer()109 GraphicBuffer::~GraphicBuffer()
110 {
111 ATRACE_CALL();
112 if (handle) {
113 free_handle();
114 }
115 for (auto& [callback, context] : mDeathCallbacks) {
116 callback(context, mId);
117 }
118 }
119
free_handle()120 void GraphicBuffer::free_handle()
121 {
122 if (mOwner == ownHandle) {
123 mBufferMapper.freeBuffer(handle);
124 } else if (mOwner == ownData) {
125 GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
126 allocator.free(handle);
127 }
128 handle = nullptr;
129 }
130
initCheck() const131 status_t GraphicBuffer::initCheck() const {
132 return static_cast<status_t>(mInitCheck);
133 }
134
dumpAllocationsToSystemLog()135 void GraphicBuffer::dumpAllocationsToSystemLog()
136 {
137 GraphicBufferAllocator::dumpToSystemLog();
138 }
139
getNativeBuffer() const140 ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const
141 {
142 return static_cast<ANativeWindowBuffer*>(
143 const_cast<GraphicBuffer*>(this));
144 }
145
reallocate(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage)146 status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight,
147 PixelFormat inFormat, uint32_t inLayerCount, uint64_t inUsage)
148 {
149 if (mOwner != ownData)
150 return INVALID_OPERATION;
151
152 if (handle &&
153 static_cast<int>(inWidth) == width &&
154 static_cast<int>(inHeight) == height &&
155 inFormat == format &&
156 inLayerCount == layerCount &&
157 inUsage == usage)
158 return NO_ERROR;
159
160 if (handle) {
161 GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
162 allocator.free(handle);
163 handle = nullptr;
164 }
165 return initWithSize(inWidth, inHeight, inFormat, inLayerCount, inUsage, "[Reallocation]");
166 }
167
needsReallocation(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage)168 bool GraphicBuffer::needsReallocation(uint32_t inWidth, uint32_t inHeight,
169 PixelFormat inFormat, uint32_t inLayerCount, uint64_t inUsage)
170 {
171 if (static_cast<int>(inWidth) != width) return true;
172 if (static_cast<int>(inHeight) != height) return true;
173 if (inFormat != format) return true;
174 if (inLayerCount != layerCount) return true;
175 if ((usage & inUsage) != inUsage) return true;
176 if ((usage & USAGE_PROTECTED) != (inUsage & USAGE_PROTECTED)) return true;
177 return false;
178 }
179
initWithSize(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage,std::string requestorName)180 status_t GraphicBuffer::initWithSize(uint32_t inWidth, uint32_t inHeight,
181 PixelFormat inFormat, uint32_t inLayerCount, uint64_t inUsage,
182 std::string requestorName)
183 {
184 GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
185 uint32_t outStride = 0;
186 status_t err = allocator.allocate(inWidth, inHeight, inFormat, inLayerCount,
187 inUsage, &handle, &outStride, mId,
188 std::move(requestorName));
189 if (err == NO_ERROR) {
190 mBufferMapper.getTransportSize(handle, &mTransportNumFds, &mTransportNumInts);
191
192 width = static_cast<int>(inWidth);
193 height = static_cast<int>(inHeight);
194 format = inFormat;
195 layerCount = inLayerCount;
196 usage = inUsage;
197 usage_deprecated = int(usage);
198 stride = static_cast<int>(outStride);
199 }
200 return err;
201 }
202
initWithHandle(const native_handle_t * inHandle,HandleWrapMethod method,uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage,uint32_t inStride)203 status_t GraphicBuffer::initWithHandle(const native_handle_t* inHandle, HandleWrapMethod method,
204 uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
205 uint32_t inLayerCount, uint64_t inUsage, uint32_t inStride) {
206 ANativeWindowBuffer::width = static_cast<int>(inWidth);
207 ANativeWindowBuffer::height = static_cast<int>(inHeight);
208 ANativeWindowBuffer::stride = static_cast<int>(inStride);
209 ANativeWindowBuffer::format = inFormat;
210 ANativeWindowBuffer::usage = inUsage;
211 ANativeWindowBuffer::usage_deprecated = int(inUsage);
212
213 ANativeWindowBuffer::layerCount = inLayerCount;
214
215 mOwner = (method == WRAP_HANDLE) ? ownNone : ownHandle;
216
217 if (method == TAKE_UNREGISTERED_HANDLE || method == CLONE_HANDLE) {
218 buffer_handle_t importedHandle;
219 status_t err = mBufferMapper.importBuffer(inHandle, inWidth, inHeight, inLayerCount,
220 inFormat, inUsage, inStride, &importedHandle);
221 if (err != NO_ERROR) {
222 initWithHandle(nullptr, WRAP_HANDLE, 0, 0, 0, 0, 0, 0);
223
224 return err;
225 }
226
227 if (method == TAKE_UNREGISTERED_HANDLE) {
228 native_handle_close(inHandle);
229 native_handle_delete(const_cast<native_handle_t*>(inHandle));
230 }
231
232 inHandle = importedHandle;
233 mBufferMapper.getTransportSize(inHandle, &mTransportNumFds, &mTransportNumInts);
234 }
235
236 ANativeWindowBuffer::handle = inHandle;
237
238 return NO_ERROR;
239 }
240
lock(uint32_t inUsage,void ** vaddr,int32_t * outBytesPerPixel,int32_t * outBytesPerStride)241 status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr, int32_t* outBytesPerPixel,
242 int32_t* outBytesPerStride) {
243 const Rect lockBounds(width, height);
244 status_t res = lock(inUsage, lockBounds, vaddr, outBytesPerPixel, outBytesPerStride);
245 return res;
246 }
247
lock(uint32_t inUsage,const Rect & rect,void ** vaddr,int32_t * outBytesPerPixel,int32_t * outBytesPerStride)248 status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr,
249 int32_t* outBytesPerPixel, int32_t* outBytesPerStride) {
250 if (rect.left < 0 || rect.right > width ||
251 rect.top < 0 || rect.bottom > height) {
252 ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
253 rect.left, rect.top, rect.right, rect.bottom,
254 width, height);
255 return BAD_VALUE;
256 }
257
258 status_t res = getBufferMapper().lock(handle, inUsage, rect, vaddr, outBytesPerPixel,
259 outBytesPerStride);
260
261 return res;
262 }
263
lockYCbCr(uint32_t inUsage,android_ycbcr * ycbcr)264 status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, android_ycbcr* ycbcr)
265 {
266 const Rect lockBounds(width, height);
267 status_t res = lockYCbCr(inUsage, lockBounds, ycbcr);
268 return res;
269 }
270
lockYCbCr(uint32_t inUsage,const Rect & rect,android_ycbcr * ycbcr)271 status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, const Rect& rect,
272 android_ycbcr* ycbcr)
273 {
274 if (rect.left < 0 || rect.right > width ||
275 rect.top < 0 || rect.bottom > height) {
276 ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
277 rect.left, rect.top, rect.right, rect.bottom,
278 width, height);
279 return BAD_VALUE;
280 }
281 status_t res = getBufferMapper().lockYCbCr(handle, inUsage, rect, ycbcr);
282 return res;
283 }
284
unlock()285 status_t GraphicBuffer::unlock()
286 {
287 status_t res = getBufferMapper().unlock(handle);
288 return res;
289 }
290
lockAsync(uint32_t inUsage,void ** vaddr,int fenceFd,int32_t * outBytesPerPixel,int32_t * outBytesPerStride)291 status_t GraphicBuffer::lockAsync(uint32_t inUsage, void** vaddr, int fenceFd,
292 int32_t* outBytesPerPixel, int32_t* outBytesPerStride) {
293 const Rect lockBounds(width, height);
294 status_t res =
295 lockAsync(inUsage, lockBounds, vaddr, fenceFd, outBytesPerPixel, outBytesPerStride);
296 return res;
297 }
298
lockAsync(uint32_t inUsage,const Rect & rect,void ** vaddr,int fenceFd,int32_t * outBytesPerPixel,int32_t * outBytesPerStride)299 status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, int fenceFd,
300 int32_t* outBytesPerPixel, int32_t* outBytesPerStride) {
301 return lockAsync(inUsage, inUsage, rect, vaddr, fenceFd, outBytesPerPixel, outBytesPerStride);
302 }
303
lockAsync(uint64_t inProducerUsage,uint64_t inConsumerUsage,const Rect & rect,void ** vaddr,int fenceFd,int32_t * outBytesPerPixel,int32_t * outBytesPerStride)304 status_t GraphicBuffer::lockAsync(uint64_t inProducerUsage, uint64_t inConsumerUsage,
305 const Rect& rect, void** vaddr, int fenceFd,
306 int32_t* outBytesPerPixel, int32_t* outBytesPerStride) {
307 if (rect.left < 0 || rect.right > width ||
308 rect.top < 0 || rect.bottom > height) {
309 ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
310 rect.left, rect.top, rect.right, rect.bottom,
311 width, height);
312 return BAD_VALUE;
313 }
314
315 status_t res = getBufferMapper().lockAsync(handle, inProducerUsage, inConsumerUsage, rect,
316 vaddr, fenceFd, outBytesPerPixel, outBytesPerStride);
317
318 return res;
319 }
320
lockAsyncYCbCr(uint32_t inUsage,android_ycbcr * ycbcr,int fenceFd)321 status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, android_ycbcr* ycbcr,
322 int fenceFd)
323 {
324 const Rect lockBounds(width, height);
325 status_t res = lockAsyncYCbCr(inUsage, lockBounds, ycbcr, fenceFd);
326 return res;
327 }
328
lockAsyncYCbCr(uint32_t inUsage,const Rect & rect,android_ycbcr * ycbcr,int fenceFd)329 status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
330 android_ycbcr* ycbcr, int fenceFd)
331 {
332 if (rect.left < 0 || rect.right > width ||
333 rect.top < 0 || rect.bottom > height) {
334 ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
335 rect.left, rect.top, rect.right, rect.bottom,
336 width, height);
337 return BAD_VALUE;
338 }
339 status_t res = getBufferMapper().lockAsyncYCbCr(handle, inUsage, rect, ycbcr, fenceFd);
340 return res;
341 }
342
unlockAsync(int * fenceFd)343 status_t GraphicBuffer::unlockAsync(int *fenceFd)
344 {
345 status_t res = getBufferMapper().unlockAsync(handle, fenceFd);
346 return res;
347 }
348
isSupported(uint32_t inWidth,uint32_t inHeight,PixelFormat inFormat,uint32_t inLayerCount,uint64_t inUsage,bool * outSupported) const349 status_t GraphicBuffer::isSupported(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
350 uint32_t inLayerCount, uint64_t inUsage,
351 bool* outSupported) const {
352 return mBufferMapper.isSupported(inWidth, inHeight, inFormat, inLayerCount, inUsage,
353 outSupported);
354 }
355
getFlattenedSize() const356 size_t GraphicBuffer::getFlattenedSize() const {
357 return static_cast<size_t>(13 + (handle ? mTransportNumInts : 0)) * sizeof(int);
358 }
359
getFdCount() const360 size_t GraphicBuffer::getFdCount() const {
361 return static_cast<size_t>(handle ? mTransportNumFds : 0);
362 }
363
flatten(void * & buffer,size_t & size,int * & fds,size_t & count) const364 status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const {
365 size_t sizeNeeded = GraphicBuffer::getFlattenedSize();
366 if (size < sizeNeeded) return NO_MEMORY;
367
368 size_t fdCountNeeded = GraphicBuffer::getFdCount();
369 if (count < fdCountNeeded) return NO_MEMORY;
370
371 int32_t* buf = static_cast<int32_t*>(buffer);
372 buf[0] = 'GB01';
373 buf[1] = width;
374 buf[2] = height;
375 buf[3] = stride;
376 buf[4] = format;
377 buf[5] = static_cast<int32_t>(layerCount);
378 buf[6] = int(usage); // low 32-bits
379 buf[7] = static_cast<int32_t>(mId >> 32);
380 buf[8] = static_cast<int32_t>(mId & 0xFFFFFFFFull);
381 buf[9] = static_cast<int32_t>(mGenerationNumber);
382 buf[10] = 0;
383 buf[11] = 0;
384 buf[12] = int(usage >> 32); // high 32-bits
385
386 if (handle) {
387 buf[10] = int32_t(mTransportNumFds);
388 buf[11] = int32_t(mTransportNumInts);
389 memcpy(fds, handle->data, static_cast<size_t>(mTransportNumFds) * sizeof(int));
390 memcpy(buf + 13, handle->data + handle->numFds,
391 static_cast<size_t>(mTransportNumInts) * sizeof(int));
392 }
393
394 buffer = static_cast<void*>(static_cast<uint8_t*>(buffer) + sizeNeeded);
395 size -= sizeNeeded;
396 if (handle) {
397 fds += mTransportNumFds;
398 count -= static_cast<size_t>(mTransportNumFds);
399 }
400 return NO_ERROR;
401 }
402
unflatten(void const * & buffer,size_t & size,int const * & fds,size_t & count)403 status_t GraphicBuffer::unflatten(void const*& buffer, size_t& size, int const*& fds,
404 size_t& count) {
405 // Check if size is not smaller than buf[0] is supposed to take.
406 if (size < sizeof(int)) {
407 return NO_MEMORY;
408 }
409
410 int const* buf = static_cast<int const*>(buffer);
411
412 // NOTE: it turns out that some media code generates a flattened GraphicBuffer manually!!!!!
413 // see H2BGraphicBufferProducer.cpp
414 uint32_t flattenWordCount = 0;
415 if (buf[0] == 'GB01') {
416 // new version with 64-bits usage bits
417 flattenWordCount = 13;
418 } else if (buf[0] == 'GBFR') {
419 // old version, when usage bits were 32-bits
420 flattenWordCount = 12;
421 } else {
422 return BAD_TYPE;
423 }
424
425 if (size < 12 * sizeof(int)) {
426 android_errorWriteLog(0x534e4554, "114223584");
427 return NO_MEMORY;
428 }
429
430 const size_t numFds = static_cast<size_t>(buf[10]);
431 const size_t numInts = static_cast<size_t>(buf[11]);
432
433 // Limit the maxNumber to be relatively small. The number of fds or ints
434 // should not come close to this number, and the number itself was simply
435 // chosen to be high enough to not cause issues and low enough to prevent
436 // overflow problems.
437 const size_t maxNumber = 4096;
438 if (numFds >= maxNumber || numInts >= (maxNumber - flattenWordCount)) {
439 width = height = stride = format = usage_deprecated = 0;
440 layerCount = 0;
441 usage = 0;
442 handle = nullptr;
443 ALOGE("unflatten: numFds or numInts is too large: %zd, %zd", numFds, numInts);
444 return BAD_VALUE;
445 }
446
447 const size_t sizeNeeded = (flattenWordCount + numInts) * sizeof(int);
448 if (size < sizeNeeded) return NO_MEMORY;
449
450 size_t fdCountNeeded = numFds;
451 if (count < fdCountNeeded) return NO_MEMORY;
452
453 if (handle) {
454 // free previous handle if any
455 free_handle();
456 }
457
458 if (numFds || numInts) {
459 width = buf[1];
460 height = buf[2];
461 stride = buf[3];
462 format = buf[4];
463 layerCount = static_cast<uintptr_t>(buf[5]);
464 usage_deprecated = buf[6];
465 if (flattenWordCount == 13) {
466 usage = (uint64_t(buf[12]) << 32) | uint32_t(buf[6]);
467 } else {
468 usage = uint64_t(usage_deprecated);
469 }
470 native_handle* h =
471 native_handle_create(static_cast<int>(numFds), static_cast<int>(numInts));
472 if (!h) {
473 width = height = stride = format = usage_deprecated = 0;
474 layerCount = 0;
475 usage = 0;
476 handle = nullptr;
477 ALOGE("unflatten: native_handle_create failed");
478 return NO_MEMORY;
479 }
480 memcpy(h->data, fds, numFds * sizeof(int));
481 memcpy(h->data + numFds, buf + flattenWordCount, numInts * sizeof(int));
482 handle = h;
483 } else {
484 width = height = stride = format = usage_deprecated = 0;
485 layerCount = 0;
486 usage = 0;
487 handle = nullptr;
488 }
489
490 mId = static_cast<uint64_t>(buf[7]) << 32;
491 mId |= static_cast<uint32_t>(buf[8]);
492
493 mGenerationNumber = static_cast<uint32_t>(buf[9]);
494
495 mOwner = ownHandle;
496
497 if (handle != nullptr) {
498 buffer_handle_t importedHandle;
499 status_t err = mBufferMapper.importBuffer(handle, uint32_t(width), uint32_t(height),
500 uint32_t(layerCount), format, usage, uint32_t(stride), &importedHandle);
501 if (err != NO_ERROR) {
502 width = height = stride = format = usage_deprecated = 0;
503 layerCount = 0;
504 usage = 0;
505 handle = nullptr;
506 ALOGE("unflatten: registerBuffer failed: %s (%d)", strerror(-err), err);
507 return err;
508 }
509
510 native_handle_close(handle);
511 native_handle_delete(const_cast<native_handle_t*>(handle));
512 handle = importedHandle;
513 mBufferMapper.getTransportSize(handle, &mTransportNumFds, &mTransportNumInts);
514 }
515
516 buffer = static_cast<void const*>(static_cast<uint8_t const*>(buffer) + sizeNeeded);
517 size -= sizeNeeded;
518 fds += numFds;
519 count -= numFds;
520 return NO_ERROR;
521 }
522
addDeathCallback(GraphicBufferDeathCallback deathCallback,void * context)523 void GraphicBuffer::addDeathCallback(GraphicBufferDeathCallback deathCallback, void* context) {
524 mDeathCallbacks.emplace_back(deathCallback, context);
525 }
526
527 // ---------------------------------------------------------------------------
528
529 }; // namespace android
530