diff options
author | 2017-02-02 12:13:34 -0800 | |
---|---|---|
committer | 2017-02-03 14:21:36 -0800 | |
commit | e96a325aff9da4e02abeb7b9178592583cf3b78c (patch) | |
tree | b93ba6ca1f80ef765d9579a7e69d0336a12abd62 | |
parent | bd448543439eb0f337191897bc3305eb8be0adda (diff) |
Add methods for allocating and locking GraphicBuffers via gralloc1 flags
Bug: 34050596
Test: manual
Change-Id: I9515e60fe6b67d2c6f02b1bb78651669430f12ef
-rw-r--r-- | include/gui/GraphicBufferAlloc.h | 4 | ||||
-rw-r--r-- | include/gui/IGraphicBufferAlloc.h | 23 | ||||
-rw-r--r-- | include/ui/GraphicBuffer.h | 10 | ||||
-rw-r--r-- | include/ui/GraphicBufferAllocator.h | 7 | ||||
-rw-r--r-- | include/ui/GraphicBufferMapper.h | 4 | ||||
-rw-r--r-- | libs/gui/GraphicBufferAlloc.cpp | 5 | ||||
-rw-r--r-- | libs/gui/IGraphicBufferAlloc.cpp | 12 | ||||
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 31 | ||||
-rw-r--r-- | libs/ui/GraphicBufferAllocator.cpp | 61 | ||||
-rw-r--r-- | libs/ui/GraphicBufferMapper.cpp | 14 | ||||
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 28 |
11 files changed, 132 insertions, 67 deletions
diff --git a/include/gui/GraphicBufferAlloc.h b/include/gui/GraphicBufferAlloc.h index b19a1acc5e..9e189076f2 100644 --- a/include/gui/GraphicBufferAlloc.h +++ b/include/gui/GraphicBufferAlloc.h @@ -35,8 +35,8 @@ public: virtual ~GraphicBufferAlloc(); virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, - uint32_t usage, std::string requestorName, - status_t* error) override; + uint64_t producerUsage, uint64_t consumerUsage, + std::string requestorName, status_t* error) override; }; diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h index 2a7690a881..1e578cc260 100644 --- a/include/gui/IGraphicBufferAlloc.h +++ b/include/gui/IGraphicBufferAlloc.h @@ -38,14 +38,29 @@ public: /* Create a new GraphicBuffer for the client to use. */ virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t layerCount, uint32_t usage, - std::string requestorName, status_t* error) = 0; + PixelFormat format, uint32_t layerCount, uint64_t producerUsage, + uint64_t consumerUsage, std::string requestorName, + status_t* error) = 0; sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t layerCount, uint32_t usage, status_t* error) { - return createGraphicBuffer(w, h, format, layerCount, usage, "<Unknown>", - error); + return createGraphicBuffer(w, h, format, layerCount, usage, + usage, "<Unknown>", error); + } + + sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t layerCount, uint32_t usage, + std::string requestorName, status_t* error) { + return createGraphicBuffer(w, h, format, layerCount, usage, + usage, requestorName, error); + } + + sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h, + PixelFormat format, uint32_t layerCount, uint64_t producerUsage, + uint64_t consumerUsage, status_t* error) { + return createGraphicBuffer(w, h, format, layerCount, producerUsage, + consumerUsage, "<Unknown>", error); } }; diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index 1bbcee2625..54f4cd3688 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -81,6 +81,11 @@ public: uint32_t inLayerCount, uint32_t inUsage, std::string requestorName = "<Unknown>"); + // creates w * h buffer with a layer count using gralloc1 + GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, + uint32_t inLayerCount, uint64_t inProducerUsage, + uint64_t inConsumerUsage, std::string requestorName = "<Unknown>"); + // create a buffer from an existing handle GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage, uint32_t inStride, @@ -122,6 +127,8 @@ public: status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd); status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, int fenceFd); + status_t lockAsync(uint64_t inProducerUsage, uint64_t inConsumerUsage, + const Rect& rect, void** vaddr, int fenceFd); status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr, int fenceFd); status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, @@ -166,7 +173,8 @@ private: const GraphicBuffer& operator = (const GraphicBuffer& rhs) const; status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, - uint32_t inLayerCount, uint32_t inUsage, std::string requestorName); + uint32_t inLayerCount, uint64_t inProducerUsage, + uint64_t inConsumerUsage, std::string requestorName); void free_handle(); diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h index 16967d430f..2ccc44b783 100644 --- a/include/ui/GraphicBufferAllocator.h +++ b/include/ui/GraphicBufferAllocator.h @@ -65,8 +65,8 @@ public: static inline GraphicBufferAllocator& get() { return getInstance(); } status_t allocate(uint32_t w, uint32_t h, PixelFormat format, - uint32_t layerCount, uint32_t usage, buffer_handle_t* handle, - uint32_t* stride, uint64_t graphicBufferId, + uint32_t layerCount, uint64_t producerUsage, uint64_t consumerUsage, + buffer_handle_t* handle, uint32_t* stride, uint64_t graphicBufferId, std::string requestorName); status_t free(buffer_handle_t handle); @@ -81,7 +81,8 @@ private: uint32_t stride; PixelFormat format; uint32_t layerCount; - uint32_t usage; + uint64_t producerUsage; + uint64_t consumerUsage; size_t size; std::string requestorName; }; diff --git a/include/ui/GraphicBufferMapper.h b/include/ui/GraphicBufferMapper.h index b6de1b2ed5..acba353ba3 100644 --- a/include/ui/GraphicBufferMapper.h +++ b/include/ui/GraphicBufferMapper.h @@ -55,6 +55,10 @@ public: status_t lockAsync(buffer_handle_t handle, uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); + status_t lockAsync(buffer_handle_t handle, + uint64_t producerUsage, uint64_t consumerUsage, const Rect& bounds, + void** vaddr, int fenceFd); + status_t lockAsyncYCbCr(buffer_handle_t handle, uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd); diff --git a/libs/gui/GraphicBufferAlloc.cpp b/libs/gui/GraphicBufferAlloc.cpp index 30f5e53520..f2d367711a 100644 --- a/libs/gui/GraphicBufferAlloc.cpp +++ b/libs/gui/GraphicBufferAlloc.cpp @@ -33,9 +33,10 @@ GraphicBufferAlloc::~GraphicBufferAlloc() { sp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, - uint32_t usage, std::string requestorName, status_t* error) { + uint64_t producerUsage, uint64_t consumerUsage, + std::string requestorName, status_t* error) { sp<GraphicBuffer> graphicBuffer(new GraphicBuffer( - width, height, format, layerCount, usage, + width, height, format, layerCount, producerUsage, consumerUsage, std::move(requestorName))); status_t err = graphicBuffer->initCheck(); *error = err; diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp index a3d3b74c6b..21a0dd5b3d 100644 --- a/libs/gui/IGraphicBufferAlloc.cpp +++ b/libs/gui/IGraphicBufferAlloc.cpp @@ -46,14 +46,16 @@ public: virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, - uint32_t usage, std::string requestorName, status_t* error) { + uint64_t producerUsage, uint64_t consumerUsage, + std::string requestorName, status_t* error) { Parcel data, reply; data.writeInterfaceToken(IGraphicBufferAlloc::getInterfaceDescriptor()); data.writeUint32(width); data.writeUint32(height); data.writeInt32(static_cast<int32_t>(format)); data.writeUint32(layerCount); - data.writeUint32(usage); + data.writeUint64(producerUsage); + data.writeUint64(consumerUsage); if (requestorName.empty()) { requestorName += "[PID "; requestorName += std::to_string(getpid()); @@ -108,12 +110,14 @@ status_t BnGraphicBufferAlloc::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint32_t layerCount = data.readUint32(); - uint32_t usage = data.readUint32(); + uint64_t producerUsage = data.readUint64(); + uint64_t consumerUsage = data.readUint64(); status_t error = NO_ERROR; std::string requestorName; data.readUtf8FromUtf16(&requestorName); sp<GraphicBuffer> result = createGraphicBuffer(width, height, - format, layerCount, usage, requestorName, &error); + format, layerCount, producerUsage, consumerUsage, + requestorName, &error); reply->writeInt32(error); if (result != 0) { reply->write(*result); diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 07164a4f44..d29bae177b 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -67,13 +67,13 @@ GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, layerCount = usage = 0; handle = NULL; - mInitCheck = initSize(inWidth, inHeight, inFormat, 1, inUsage, + mInitCheck = initSize(inWidth, inHeight, inFormat, 1, inUsage, inUsage, std::move(requestorName)); } GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage, - std::string requestorName) + PixelFormat inFormat, uint32_t inLayerCount, uint64_t producerUsage, + uint64_t consumerUsage, std::string requestorName) : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()), mInitCheck(NO_ERROR), mId(getUniqueId()), mGenerationNumber(0) { @@ -84,8 +84,8 @@ GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, layerCount = usage = 0; handle = NULL; - mInitCheck = initSize(inWidth, inHeight, inFormat, inLayerCount, inUsage, - std::move(requestorName)); + mInitCheck = initSize(inWidth, inHeight, inFormat, inLayerCount, + producerUsage, consumerUsage, std::move(requestorName)); } GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight, @@ -177,7 +177,7 @@ status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight, allocator.free(handle); handle = 0; } - return initSize(inWidth, inHeight, inFormat, inLayerCount, inUsage, + return initSize(inWidth, inHeight, inFormat, inLayerCount, inUsage, inUsage, "[Reallocation]"); } @@ -193,19 +193,20 @@ bool GraphicBuffer::needsReallocation(uint32_t inWidth, uint32_t inHeight, } status_t GraphicBuffer::initSize(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inLayerCount, uint32_t inUsage, - std::string requestorName) + PixelFormat inFormat, uint32_t inLayerCount, uint64_t inProducerUsage, + uint64_t inConsumerUsage, std::string requestorName) { GraphicBufferAllocator& allocator = GraphicBufferAllocator::get(); uint32_t outStride = 0; status_t err = allocator.allocate(inWidth, inHeight, inFormat, inLayerCount, - inUsage, &handle, &outStride, mId, std::move(requestorName)); + inProducerUsage, inConsumerUsage, &handle, &outStride, mId, + std::move(requestorName)); if (err == NO_ERROR) { width = static_cast<int>(inWidth); height = static_cast<int>(inHeight); format = inFormat; layerCount = inLayerCount; - usage = static_cast<int>(inUsage); + usage = static_cast<int>(inProducerUsage | inConsumerUsage); stride = static_cast<int>(outStride); } return err; @@ -268,6 +269,12 @@ status_t GraphicBuffer::lockAsync(uint32_t inUsage, void** vaddr, int fenceFd) status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, int fenceFd) { + return lockAsync(inUsage, inUsage, rect, vaddr, fenceFd); +} + +status_t GraphicBuffer::lockAsync(uint64_t inProducerUsage, + uint64_t inConsumerUsage, const Rect& rect, void** vaddr, int fenceFd) +{ if (rect.left < 0 || rect.right > width || rect.top < 0 || rect.bottom > height) { ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)", @@ -275,8 +282,8 @@ status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect, width, height); return BAD_VALUE; } - status_t res = getBufferMapper().lockAsync(handle, inUsage, rect, vaddr, - fenceFd); + status_t res = getBufferMapper().lockAsync(handle, inProducerUsage, + inConsumerUsage, rect, vaddr, fenceFd); return res; } diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index 07ad4c107f..b14110e599 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -63,15 +63,19 @@ void GraphicBufferAllocator::dump(String8& result) const for (size_t i=0 ; i<c ; i++) { const alloc_rec_t& rec(list.valueAt(i)); if (rec.size) { - snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %4u | %8X | 0x%08x | %s\n", + snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64 + ", 0x%" PRIx64 " | %s\n", list.keyAt(i), rec.size/1024.0, rec.width, rec.stride, rec.height, rec.layerCount, rec.format, - rec.usage, rec.requestorName.c_str()); + rec.producerUsage, rec.consumerUsage, + rec.requestorName.c_str()); } else { - snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %4u | %8X | 0x%08x | %s\n", + snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %4u | %8X | 0x%" PRIx64 + ", 0x%" PRIx64 " | %s\n", list.keyAt(i), rec.width, rec.stride, rec.height, rec.layerCount, rec.format, - rec.usage, rec.requestorName.c_str()); + rec.producerUsage, rec.consumerUsage, + rec.requestorName.c_str()); } result.append(buffer); total += rec.size; @@ -102,7 +106,8 @@ class HalBuffer { public: HalBuffer(const Gralloc2::Allocator* allocator, uint32_t width, uint32_t height, - PixelFormat format, uint32_t layerCount, uint32_t usage) + PixelFormat format, uint32_t layerCount, uint64_t producerUsage, + uint64_t consumerUsage) : mAllocator(allocator), mBufferValid(false) { Gralloc2::IAllocatorClient::BufferDescriptorInfo info = {}; @@ -110,14 +115,16 @@ public: info.height = height; info.format = static_cast<Gralloc2::PixelFormat>(format); info.layerCount = layerCount; - info.producerUsageMask = usage; - info.consumerUsageMask = usage; + info.producerUsageMask = producerUsage; + info.consumerUsageMask = consumerUsage; Gralloc2::BufferDescriptor descriptor; auto error = mAllocator->createBufferDescriptor(info, &descriptor); if (error != Gralloc2::Error::NONE) { - ALOGE("Failed to create desc (%u x %u) layerCount %u format %d usage %u: %d", - width, height, layerCount, format, usage, error); + ALOGE("Failed to create desc (%u x %u) layerCount %u format %d producerUsage %" PRIx64 + " consumerUsage %" PRIx64 ": %d", + width, height, layerCount, format, producerUsage, + consumerUsage, error); return; } @@ -127,8 +134,10 @@ public: } if (error != Gralloc2::Error::NONE) { - ALOGE("Failed to allocate (%u x %u) layerCount %u format %d usage %u: %d", - width, height, layerCount, format, usage, error); + ALOGE("Failed to allocate (%u x %u) layerCount %u format %d producerUsage %" PRIx64 + " consumerUsage %" PRIx64 ": %d", + width, height, layerCount, format, producerUsage, + consumerUsage, error); mAllocator->destroyBufferDescriptor(descriptor); return; } @@ -195,9 +204,9 @@ private: } // namespace status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, - PixelFormat format, uint32_t layerCount, uint32_t usage, - buffer_handle_t* handle, uint32_t* stride, uint64_t graphicBufferId, - std::string requestorName) + PixelFormat format, uint32_t layerCount, uint64_t producerUsage, + uint64_t consumerUsage, buffer_handle_t* handle, uint32_t* stride, + uint64_t graphicBufferId, std::string requestorName) { ATRACE_CALL(); @@ -210,13 +219,10 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, if (layerCount < 1) layerCount = 1; - // Filter out any usage bits that should not be passed to the gralloc module - usage &= GRALLOC_USAGE_ALLOC_MASK; - gralloc1_error_t error; if (mAllocator->valid()) { HalBuffer buffer(mAllocator.get(), width, height, format, layerCount, - usage); + producerUsage, consumerUsage); if (!buffer.exportHandle(mMapper, handle, stride)) { return NO_MEMORY; } @@ -247,22 +253,26 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, return BAD_VALUE; } error = descriptor->setProducerUsage( - static_cast<gralloc1_producer_usage_t>(usage)); + static_cast<gralloc1_producer_usage_t>(producerUsage)); if (error != GRALLOC1_ERROR_NONE) { - ALOGE("Failed to set producer usage to %u: %d", usage, error); + ALOGE("Failed to set producer usage to %" PRIx64 ": %d", + producerUsage, error); return BAD_VALUE; } error = descriptor->setConsumerUsage( - static_cast<gralloc1_consumer_usage_t>(usage)); + static_cast<gralloc1_consumer_usage_t>(consumerUsage)); if (error != GRALLOC1_ERROR_NONE) { - ALOGE("Failed to set consumer usage to %u: %d", usage, error); + ALOGE("Failed to set consumer usage to %" PRIx64 ": %d", + consumerUsage, error); return BAD_VALUE; } error = mDevice->allocate(descriptor, graphicBufferId, handle); if (error != GRALLOC1_ERROR_NONE) { - ALOGE("Failed to allocate (%u x %u) layerCount %u format %d usage %u: %d", - width, height, layerCount, format, usage, error); + ALOGE("Failed to allocate (%u x %u) layerCount %u format %d " + "producerUsage %" PRIx64 " consumerUsage %" PRIx64 ": %d", + width, height, layerCount, format, producerUsage, + consumerUsage, error); return NO_MEMORY; } @@ -282,7 +292,8 @@ status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, rec.stride = *stride; rec.format = format; rec.layerCount = layerCount; - rec.usage = usage; + rec.producerUsage = producerUsage; + rec.consumerUsage = consumerUsage; rec.size = static_cast<size_t>(height * (*stride) * bpp); rec.requestorName = std::move(requestorName); list.add(*handle, rec); diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index 1ff934bfe9..f03a30730b 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -143,6 +143,13 @@ status_t GraphicBufferMapper::unlock(buffer_handle_t handle) status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle, uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd) { + return lockAsync(handle, usage, usage, bounds, vaddr, fenceFd); +} + +status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle, + uint64_t producerUsage, uint64_t consumerUsage, const Rect& bounds, + void** vaddr, int fenceFd) +{ ATRACE_CALL(); gralloc1_rect_t accessRegion = asGralloc1Rect(bounds); @@ -151,12 +158,13 @@ status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle, const Gralloc2::IMapper::Rect& accessRect = *reinterpret_cast<Gralloc2::IMapper::Rect*>(&accessRegion); error = static_cast<gralloc1_error_t>(mMapper->lock( - handle, usage, usage, accessRect, fenceFd, vaddr)); + handle, producerUsage, consumerUsage, accessRect, + fenceFd, vaddr)); } else { sp<Fence> fence = new Fence(fenceFd); error = mDevice->lock(handle, - static_cast<gralloc1_producer_usage_t>(usage), - static_cast<gralloc1_consumer_usage_t>(usage), + static_cast<gralloc1_producer_usage_t>(producerUsage), + static_cast<gralloc1_consumer_usage_t>(consumerUsage), &accessRegion, vaddr, fence); } diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 1672397a97..2782ed7a7d 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -21,7 +21,7 @@ #include <stdlib.h> #include <string.h> -#include <hardware/gralloc.h> +#include <hardware/gralloc1.h> #include <system/window.h> #include <EGL/egl.h> @@ -1833,7 +1833,8 @@ EGLClientBuffer eglCreateNativeClientBufferANDROID(const EGLint *attrib_list) { clearError(); - int usage = 0; + uint64_t producerUsage = 0; + uint64_t consumerUsage = 0; uint32_t width = 0; uint32_t height = 0; uint32_t format = 0; @@ -1866,13 +1867,13 @@ EGLClientBuffer eglCreateNativeClientBufferANDROID(const EGLint *attrib_list) GET_NONNEGATIVE_VALUE(EGL_LAYER_COUNT_ANDROID, layer_count); case EGL_NATIVE_BUFFER_USAGE_ANDROID: if (value & EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID) { - usage |= GRALLOC_USAGE_PROTECTED; + producerUsage |= GRALLOC1_PRODUCER_USAGE_PROTECTED; } if (value & EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID) { - usage |= GRALLOC_USAGE_HW_RENDER; + producerUsage |= GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET; } if (value & EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID) { - usage |= GRALLOC_USAGE_HW_TEXTURE; + consumerUsage |= GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE; } break; default: @@ -1940,8 +1941,10 @@ EGLClientBuffer eglCreateNativeClientBufferANDROID(const EGLint *attrib_list) CHECK_ERROR_CONDITION("Unable to write format"); err = data.writeUint32(layer_count); CHECK_ERROR_CONDITION("Unable to write layer count"); - err = data.writeUint32(usage); - CHECK_ERROR_CONDITION("Unable to write usage"); + err = data.writeUint64(producerUsage); + CHECK_ERROR_CONDITION("Unable to write producer usage"); + err = data.writeUint64(consumerUsage); + CHECK_ERROR_CONDITION("Unable to write consumer usage"); err = data.writeUtf8AsUtf16( std::string("[eglCreateNativeClientBufferANDROID pid ") + std::to_string(getpid()) + ']'); @@ -1958,12 +1961,15 @@ EGLClientBuffer eglCreateNativeClientBufferANDROID(const EGLint *attrib_list) err = gBuffer->initCheck(); if (err != NO_ERROR) { ALOGE("Unable to create native buffer " - "{ w=%u, h=%u, f=%u, u=%#x, lc=%u}: %#x", width, height, format, - usage, layer_count, err); + "{ w=%u, h=%u, f=%u, pu=%" PRIx64 " cu=%" PRIx64 ", lc=%u} %#x", + width, height, format, producerUsage, consumerUsage, + layer_count, err); goto error_condition; } - ALOGV("Created new native buffer %p { w=%u, h=%u, f=%u, u=%#x, lc=%u}", - gBuffer, width, height, format, usage, layer_count); + ALOGV("Created new native buffer %p { w=%u, h=%u, f=%u, pu=%" PRIx64 + " cu=%" PRIx64 ", lc=%u}", + gBuffer, width, height, format, producerUsage, consumerUsage, + layer_count); return static_cast<EGLClientBuffer>(gBuffer->getNativeBuffer()); #undef CHECK_ERROR_CONDITION |