diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index 33ef1fc89..e75415b37 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -61,13 +61,19 @@ void GraphicBufferAllocator::dump(String8& result) const const size_t c = list.size(); for (size_t i=0 ; icommon.version >= 1 && mAllocDev->dump) { mAllocDev->dump(mAllocDev, buffer, SIZE); @@ -101,13 +107,19 @@ status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat forma if (err == NO_ERROR) { Mutex::Autolock _l(sLock); KeyedVector& list(sAllocList); + int bpp = bytesPerPixel(format); + if (bpp < 0) { + // probably a HAL custom format. in any case, we don't know + // what its pixel size is. + bpp = 0; + } alloc_rec_t rec; rec.w = w; rec.h = h; rec.s = *stride; rec.format = format; rec.usage = usage; - rec.size = h * stride[0] * bytesPerPixel(format); + rec.size = h * stride[0] * bpp; list.add(*handle, rec); }