Loading libs/vr/libbufferhub/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ localIncludeFiles = [ staticLibraries = [ "libdvrcommon", "libpdx_default_transport", "libgrallocusage", ] sharedLibraries = [ Loading libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h +4 −2 Original line number Diff line number Diff line Loading @@ -113,8 +113,10 @@ class BufferHubBuffer : public pdx::Client { uint32_t format() const { return slices_[0].format(); } uint32_t usage() const { return slices_[0].usage(); } uint32_t layer_count() const { return slices_[0].layer_count(); } uint64_t producer_usage() const { return slices_[0].producer_usage(); } uint64_t consumer_usage() const { return slices_[0].consumer_usage(); } // TODO(b/37881101) Clean up producer/consumer usage. uint64_t producer_usage() const { return slices_[0].usage(); } uint64_t consumer_usage() const { return slices_[0].usage(); } protected: explicit BufferHubBuffer(LocalChannelHandle channel); Loading libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h +4 −3 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ class NativeBufferHandle { width_(buffer.width()), height_(buffer.height()), format_(buffer.format()), producer_usage_(buffer.producer_usage()), consumer_usage_(buffer.consumer_usage()) { producer_usage_(buffer.usage()), consumer_usage_(buffer.usage()) { // Populate the fd and int vectors: native_handle->data[] is an array of fds // followed by an array of opaque ints. const int fd_count = buffer.handle()->numFds; Loading @@ -48,10 +48,11 @@ class NativeBufferHandle { for (const auto& fd : fds_) fd_ints.push_back(fd.Get()); // TODO(b/37881101) Get rid of producer/consumer usage. const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, stride_, format_, producer_usage_, consumer_usage_); (producer_usage_ | consumer_usage_)); if (ret < 0) return ret; Loading libs/vr/libbufferhub/include/private/dvr/ion_buffer.h +10 −35 Original line number Diff line number Diff line Loading @@ -12,20 +12,12 @@ namespace dvr { class IonBuffer { public: IonBuffer(); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint32_t usage); uint32_t stride, uint32_t format, uint64_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t format, uint64_t usage); ~IonBuffer(); IonBuffer(IonBuffer&& other); Loading @@ -39,36 +31,25 @@ class IonBuffer { // previous native handle if necessary. Returns 0 on success or a negative // errno code otherwise. If allocation fails the previous native handle is // left intact. int Alloc(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); int Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); int Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t usage); // Resets the underlying native handle and parameters, freeing the previous // native handle if necessary. void Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); void Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t stride, uint32_t format, uint64_t usage); // Like Reset but also registers the native handle, which is necessary for // native handles received over IPC. Returns 0 on success or a negative errno // code otherwise. If import fails the previous native handle is left intact. int Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); int Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t stride, uint32_t format, uint64_t usage); // Like Reset but imports a native handle from raw fd and int arrays. Returns // 0 on success or a negative errno code otherwise. If import fails the // previous native handle is left intact. int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t format, uint64_t usage); // Duplicates the native handle underlying |other| and then imports it. This // is useful for creating multiple, independent views of the same Ion/Gralloc Loading @@ -95,19 +76,13 @@ class IonBuffer { uint32_t format() const { return buffer_.get() ? buffer_->getPixelFormat() : 0; } uint64_t producer_usage() const { return producer_usage_; } uint64_t consumer_usage() const { return consumer_usage_; } uint32_t usage() const { return buffer_.get() ? buffer_->getUsage() : 0; } uint64_t usage() const { return buffer_.get() ? static_cast<uint64_t>(buffer_->getUsage()) : 0; } private: sp<GraphicBuffer> buffer_; // GraphicBuffer doesn't expose these separately. Keep these values cached for // BufferHub to check policy against. Clients that import these buffers won't // get the full picture, which is okay. uint64_t producer_usage_; uint64_t consumer_usage_; IonBuffer(const IonBuffer&) = delete; void operator=(const IonBuffer&) = delete; }; Loading libs/vr/libbufferhub/ion_buffer.cpp +27 −83 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ #include <log/log.h> #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <grallocusage/GrallocUsageConversion.h> #include <utils/Trace.h> #include <mutex> Loading @@ -19,39 +18,26 @@ namespace dvr { IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage) : IonBuffer(width, height, format, usage, usage) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) uint64_t usage) : IonBuffer() { Alloc(width, height, format, producer_usage, consumer_usage); Alloc(width, height, format, usage); } IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) uint32_t stride, uint32_t format, uint64_t usage) : IonBuffer(handle, width, height, 1, stride, 0, format, usage) {} IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint32_t usage) : IonBuffer(handle, width, height, layer_count, stride, layer_stride, format, usage, usage) {} IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) uint32_t layer_stride, uint32_t format, uint64_t usage) : buffer_(nullptr) { ALOGD_IF(TRACE, "IonBuffer::IonBuffer: handle=%p width=%u height=%u layer_count=%u " "stride=%u layer stride=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, "stride=%u layer stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, layer_stride, format, producer_usage, consumer_usage); usage); if (handle != 0) { Import(handle, width, height, stride, format, producer_usage, consumer_usage); Import(handle, width, height, stride, format, usage); } } Loading Loading @@ -82,105 +68,64 @@ void IonBuffer::FreeHandle() { if (buffer_.get()) { // GraphicBuffer unregisters and cleans up the handle if needed buffer_ = nullptr; producer_usage_ = 0; consumer_usage_ = 0; } } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint32_t usage) { return Alloc(width, height, format, usage, usage); } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { ALOGD_IF( TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, width, height, format, producer_usage, consumer_usage); uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u usage=%" PRIx64, width, height, format, usage); // TODO: forget about split producer/consumer usage sp<GraphicBuffer> buffer = new GraphicBuffer( width, height, format, kDefaultGraphicBufferLayerCount, android_convertGralloc1To0Usage(producer_usage, consumer_usage)); width, height, format, kDefaultGraphicBufferLayerCount, usage); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Aloc: Failed to allocate buffer"); return -EINVAL; } else { buffer_ = buffer; producer_usage_ = producer_usage; consumer_usage_ = consumer_usage; return 0; } } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { Reset(handle, width, height, stride, format, usage, usage); } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Reset: handle=%p width=%u height=%u stride=%u format=%u " "producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, handle, width, height, stride, format, producer_usage, consumer_usage); Import(handle, width, height, stride, format, producer_usage, consumer_usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { return Import(handle, width, height, stride, format, usage, usage); "usage=%" PRIx64, handle, width, height, stride, format, usage); Import(handle, width, height, stride, format, usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ATRACE_NAME("IonBuffer::Import1"); ALOGD_IF( TRACE, "IonBuffer::Import: handle=%p width=%u height=%u stride=%u format=%u " "producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, handle, width, height, stride, format, producer_usage, consumer_usage); "usage=%" PRIx64, handle, width, height, stride, format, usage); FreeHandle(); sp<GraphicBuffer> buffer = new GraphicBuffer(handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, static_cast<uint64_t>(android_convertGralloc1To0Usage( producer_usage, consumer_usage)), stride); sp<GraphicBuffer> buffer = new GraphicBuffer( handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, usage, stride); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Import: Failed to import buffer"); return -EINVAL; } else { buffer_ = buffer; producer_usage_ = producer_usage; consumer_usage_ = consumer_usage; return 0; } } int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { return Import(fd_array, fd_count, int_array, int_count, width, height, stride, format, usage, usage); } int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ATRACE_NAME("IonBuffer::Import2"); ALOGD_IF(TRACE, "IonBuffer::Import: fd_count=%d int_count=%d width=%u height=%u " "stride=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, fd_count, int_count, width, height, stride, format, producer_usage, consumer_usage); "stride=%u format=%u usage=%" PRIx64, fd_count, int_count, width, height, stride, format, usage); if (fd_count < 0 || int_count < 0) { ALOGE("IonBuffer::Import: invalid arguments."); Loading @@ -198,8 +143,7 @@ int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, memcpy(handle->data, fd_array, sizeof(int) * fd_count); memcpy(handle->data + fd_count, int_array, sizeof(int) * int_count); const int ret = Import(handle, width, height, stride, format, producer_usage, consumer_usage); const int ret = Import(handle, width, height, stride, format, usage); if (ret < 0) { ALOGE("IonBuffer::Import: failed to import raw native handle: %s", strerror(-ret)); Loading Loading @@ -236,7 +180,7 @@ int IonBuffer::Duplicate(const IonBuffer* other) { const int ret = Import(handle, other->width(), other->height(), other->stride(), other->format(), other->producer_usage(), other->consumer_usage()); other->format(), other->usage()); if (ret < 0) { ALOGE("IonBuffer::Duplicate: Failed to import duplicate native handle: %s", strerror(-ret)); Loading Loading
libs/vr/libbufferhub/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ localIncludeFiles = [ staticLibraries = [ "libdvrcommon", "libpdx_default_transport", "libgrallocusage", ] sharedLibraries = [ Loading
libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h +4 −2 Original line number Diff line number Diff line Loading @@ -113,8 +113,10 @@ class BufferHubBuffer : public pdx::Client { uint32_t format() const { return slices_[0].format(); } uint32_t usage() const { return slices_[0].usage(); } uint32_t layer_count() const { return slices_[0].layer_count(); } uint64_t producer_usage() const { return slices_[0].producer_usage(); } uint64_t consumer_usage() const { return slices_[0].consumer_usage(); } // TODO(b/37881101) Clean up producer/consumer usage. uint64_t producer_usage() const { return slices_[0].usage(); } uint64_t consumer_usage() const { return slices_[0].usage(); } protected: explicit BufferHubBuffer(LocalChannelHandle channel); Loading
libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h +4 −3 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ class NativeBufferHandle { width_(buffer.width()), height_(buffer.height()), format_(buffer.format()), producer_usage_(buffer.producer_usage()), consumer_usage_(buffer.consumer_usage()) { producer_usage_(buffer.usage()), consumer_usage_(buffer.usage()) { // Populate the fd and int vectors: native_handle->data[] is an array of fds // followed by an array of opaque ints. const int fd_count = buffer.handle()->numFds; Loading @@ -48,10 +48,11 @@ class NativeBufferHandle { for (const auto& fd : fds_) fd_ints.push_back(fd.Get()); // TODO(b/37881101) Get rid of producer/consumer usage. const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, stride_, format_, producer_usage_, consumer_usage_); (producer_usage_ | consumer_usage_)); if (ret < 0) return ret; Loading
libs/vr/libbufferhub/include/private/dvr/ion_buffer.h +10 −35 Original line number Diff line number Diff line Loading @@ -12,20 +12,12 @@ namespace dvr { class IonBuffer { public: IonBuffer(); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint32_t usage); uint32_t stride, uint32_t format, uint64_t usage); IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t format, uint64_t usage); ~IonBuffer(); IonBuffer(IonBuffer&& other); Loading @@ -39,36 +31,25 @@ class IonBuffer { // previous native handle if necessary. Returns 0 on success or a negative // errno code otherwise. If allocation fails the previous native handle is // left intact. int Alloc(uint32_t width, uint32_t height, uint32_t format, uint32_t usage); int Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); int Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t usage); // Resets the underlying native handle and parameters, freeing the previous // native handle if necessary. void Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); void Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t stride, uint32_t format, uint64_t usage); // Like Reset but also registers the native handle, which is necessary for // native handles received over IPC. Returns 0 on success or a negative errno // code otherwise. If import fails the previous native handle is left intact. int Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); int Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t stride, uint32_t format, uint64_t usage); // Like Reset but imports a native handle from raw fd and int arrays. Returns // 0 on success or a negative errno code otherwise. If import fails the // previous native handle is left intact. int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage); int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage); uint32_t format, uint64_t usage); // Duplicates the native handle underlying |other| and then imports it. This // is useful for creating multiple, independent views of the same Ion/Gralloc Loading @@ -95,19 +76,13 @@ class IonBuffer { uint32_t format() const { return buffer_.get() ? buffer_->getPixelFormat() : 0; } uint64_t producer_usage() const { return producer_usage_; } uint64_t consumer_usage() const { return consumer_usage_; } uint32_t usage() const { return buffer_.get() ? buffer_->getUsage() : 0; } uint64_t usage() const { return buffer_.get() ? static_cast<uint64_t>(buffer_->getUsage()) : 0; } private: sp<GraphicBuffer> buffer_; // GraphicBuffer doesn't expose these separately. Keep these values cached for // BufferHub to check policy against. Clients that import these buffers won't // get the full picture, which is okay. uint64_t producer_usage_; uint64_t consumer_usage_; IonBuffer(const IonBuffer&) = delete; void operator=(const IonBuffer&) = delete; }; Loading
libs/vr/libbufferhub/ion_buffer.cpp +27 −83 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ #include <log/log.h> #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <grallocusage/GrallocUsageConversion.h> #include <utils/Trace.h> #include <mutex> Loading @@ -19,39 +18,26 @@ namespace dvr { IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage) : IonBuffer(width, height, format, usage, usage) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) uint64_t usage) : IonBuffer() { Alloc(width, height, format, producer_usage, consumer_usage); Alloc(width, height, format, usage); } IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) uint32_t stride, uint32_t format, uint64_t usage) : IonBuffer(handle, width, height, 1, stride, 0, format, usage) {} IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint32_t usage) : IonBuffer(handle, width, height, layer_count, stride, layer_stride, format, usage, usage) {} IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, uint32_t layer_stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) uint32_t layer_stride, uint32_t format, uint64_t usage) : buffer_(nullptr) { ALOGD_IF(TRACE, "IonBuffer::IonBuffer: handle=%p width=%u height=%u layer_count=%u " "stride=%u layer stride=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, "stride=%u layer stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, layer_stride, format, producer_usage, consumer_usage); usage); if (handle != 0) { Import(handle, width, height, stride, format, producer_usage, consumer_usage); Import(handle, width, height, stride, format, usage); } } Loading Loading @@ -82,105 +68,64 @@ void IonBuffer::FreeHandle() { if (buffer_.get()) { // GraphicBuffer unregisters and cleans up the handle if needed buffer_ = nullptr; producer_usage_ = 0; consumer_usage_ = 0; } } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint32_t usage) { return Alloc(width, height, format, usage, usage); } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { ALOGD_IF( TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, width, height, format, producer_usage, consumer_usage); uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u usage=%" PRIx64, width, height, format, usage); // TODO: forget about split producer/consumer usage sp<GraphicBuffer> buffer = new GraphicBuffer( width, height, format, kDefaultGraphicBufferLayerCount, android_convertGralloc1To0Usage(producer_usage, consumer_usage)); width, height, format, kDefaultGraphicBufferLayerCount, usage); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Aloc: Failed to allocate buffer"); return -EINVAL; } else { buffer_ = buffer; producer_usage_ = producer_usage; consumer_usage_ = consumer_usage; return 0; } } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { Reset(handle, width, height, stride, format, usage, usage); } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Reset: handle=%p width=%u height=%u stride=%u format=%u " "producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, handle, width, height, stride, format, producer_usage, consumer_usage); Import(handle, width, height, stride, format, producer_usage, consumer_usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { return Import(handle, width, height, stride, format, usage, usage); "usage=%" PRIx64, handle, width, height, stride, format, usage); Import(handle, width, height, stride, format, usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ATRACE_NAME("IonBuffer::Import1"); ALOGD_IF( TRACE, "IonBuffer::Import: handle=%p width=%u height=%u stride=%u format=%u " "producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, handle, width, height, stride, format, producer_usage, consumer_usage); "usage=%" PRIx64, handle, width, height, stride, format, usage); FreeHandle(); sp<GraphicBuffer> buffer = new GraphicBuffer(handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, static_cast<uint64_t>(android_convertGralloc1To0Usage( producer_usage, consumer_usage)), stride); sp<GraphicBuffer> buffer = new GraphicBuffer( handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, usage, stride); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Import: Failed to import buffer"); return -EINVAL; } else { buffer_ = buffer; producer_usage_ = producer_usage; consumer_usage_ = consumer_usage; return 0; } } int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint32_t usage) { return Import(fd_array, fd_count, int_array, int_count, width, height, stride, format, usage, usage); } int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, int int_count, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t producer_usage, uint64_t consumer_usage) { uint32_t stride, uint32_t format, uint64_t usage) { ATRACE_NAME("IonBuffer::Import2"); ALOGD_IF(TRACE, "IonBuffer::Import: fd_count=%d int_count=%d width=%u height=%u " "stride=%u format=%u producer_usage=%" PRIx64 " consumer_usage=%" PRIx64, fd_count, int_count, width, height, stride, format, producer_usage, consumer_usage); "stride=%u format=%u usage=%" PRIx64, fd_count, int_count, width, height, stride, format, usage); if (fd_count < 0 || int_count < 0) { ALOGE("IonBuffer::Import: invalid arguments."); Loading @@ -198,8 +143,7 @@ int IonBuffer::Import(const int* fd_array, int fd_count, const int* int_array, memcpy(handle->data, fd_array, sizeof(int) * fd_count); memcpy(handle->data + fd_count, int_array, sizeof(int) * int_count); const int ret = Import(handle, width, height, stride, format, producer_usage, consumer_usage); const int ret = Import(handle, width, height, stride, format, usage); if (ret < 0) { ALOGE("IonBuffer::Import: failed to import raw native handle: %s", strerror(-ret)); Loading Loading @@ -236,7 +180,7 @@ int IonBuffer::Duplicate(const IonBuffer* other) { const int ret = Import(handle, other->width(), other->height(), other->stride(), other->format(), other->producer_usage(), other->consumer_usage()); other->format(), other->usage()); if (ret < 0) { ALOGE("IonBuffer::Duplicate: Failed to import duplicate native handle: %s", strerror(-ret)); Loading