Loading libs/vr/libbufferhub/buffer_hub_client.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -59,10 +59,8 @@ int BufferHubBuffer::ImportBuffer() { ALOGE("BufferHubBuffer::ImportBuffer: Failed to get buffer: %s", status.GetErrorMessage().c_str()); return -status.error(); } else if (status.get().id() >= 0) { ALOGE( "BufferHubBuffer::ImportBuffer: Expected to receive a buffer handle " "but got null!"); } else if (status.get().id() < 0) { ALOGE("BufferHubBuffer::ImportBuffer: Received an invalid id!"); return -EIO; } Loading libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h +10 −7 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ class NativeBufferHandle { stride_(buffer.stride()), width_(buffer.width()), height_(buffer.height()), layer_count_(buffer.layer_count()), format_(buffer.format()), usage_(buffer.usage()) { // Populate the fd and int vectors: native_handle->data[] is an array of fds Loading @@ -47,9 +48,10 @@ class NativeBufferHandle { for (const auto& fd : fds_) fd_ints.push_back(fd.Get()); const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, stride_, format_, usage_); const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, layer_count_, stride_, format_, usage_); if (ret < 0) return ret; Loading @@ -72,6 +74,7 @@ class NativeBufferHandle { uint32_t stride_; uint32_t width_; uint32_t height_; uint32_t layer_count_; uint32_t format_; uint64_t usage_; std::vector<int> opaque_ints_; Loading @@ -83,8 +86,8 @@ class NativeBufferHandle { } PDX_SERIALIZABLE_MEMBERS(NativeBufferHandle<FileHandleType>, id_, stride_, width_, height_, format_, usage_, opaque_ints_, fds_); width_, height_, layer_count_, format_, usage_, opaque_ints_, fds_); NativeBufferHandle(const NativeBufferHandle&) = delete; void operator=(const NativeBufferHandle&) = delete; Loading Loading @@ -224,8 +227,8 @@ struct BufferHubRPC { PDX_REMOTE_METHOD(ProducerQueueAllocateBuffers, kOpProducerQueueAllocateBuffers, std::vector<std::pair<LocalChannelHandle, size_t>>( uint32_t width, uint32_t height, uint32_t format, uint64_t usage, size_t buffer_count)); uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format, uint64_t usage, size_t buffer_count)); PDX_REMOTE_METHOD(ProducerQueueDetachBuffer, kOpProducerQueueDetachBuffer, void(size_t slot)); PDX_REMOTE_METHOD(ConsumerQueueImportBuffers, kOpConsumerQueueImportBuffers, Loading libs/vr/libbufferhub/include/private/dvr/ion_buffer.h +11 −8 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ class IonBuffer { IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, 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 usage); uint32_t layer_count, uint32_t stride, uint32_t format, uint64_t usage); ~IonBuffer(); IonBuffer(IonBuffer&& other); Loading @@ -31,25 +31,29 @@ 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, uint64_t usage); int Alloc(uint32_t width, uint32_t height, uint32_t layer_count, 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, uint64_t usage); uint32_t layer_count, 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, uint64_t usage); uint32_t layer_count, 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, uint64_t usage); int int_count, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, 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 @@ -72,7 +76,6 @@ class IonBuffer { return buffer_.get() ? buffer_->getLayerCount() : 0; } uint32_t stride() const { return buffer_.get() ? buffer_->getStride() : 0; } uint32_t layer_stride() const { return 0; } uint32_t format() const { return buffer_.get() ? buffer_->getPixelFormat() : 0; } Loading libs/vr/libbufferhub/ion_buffer.cpp +40 −36 Original line number Diff line number Diff line Loading @@ -15,36 +15,36 @@ constexpr uint32_t kDefaultGraphicBufferLayerCount = 1; namespace android { namespace dvr { IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage) : IonBuffer() { Alloc(width, height, format, usage); Alloc(width, height, kDefaultGraphicBufferLayerCount, format, usage); } IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) : IonBuffer(handle, width, height, 1, stride, 0, format, usage) {} : IonBuffer(handle, width, height, kDefaultGraphicBufferLayerCount, stride, 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, uint64_t usage) uint32_t layer_count, uint32_t 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 usage=%" PRIx64, handle, width, height, layer_count, stride, layer_stride, format, usage); "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); if (handle != 0) { Import(handle, width, height, stride, format, usage); Import(handle, width, height, layer_count, stride, format, usage); } } IonBuffer::~IonBuffer() { ALOGD_IF(TRACE, "IonBuffer::~IonBuffer: handle=%p width=%u height=%u stride=%u " "format=%u usage=%x", "format=%u usage=%" PRIx64, handle(), width(), height(), stride(), format(), usage()); FreeHandle(); } Loading @@ -71,14 +71,14 @@ void IonBuffer::FreeHandle() { } } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t usage) { int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u usage=%" PRIx64, width, height, format, usage); "IonBuffer::Alloc: width=%u height=%u layer_count=%u format=%u " "usage=%" PRIx64, width, height, layer_count, format, usage); sp<GraphicBuffer> buffer = new GraphicBuffer( width, height, format, kDefaultGraphicBufferLayerCount, usage); sp<GraphicBuffer> buffer = new GraphicBuffer(width, height, format, layer_count, usage); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Aloc: Failed to allocate buffer"); return -EINVAL; Loading @@ -89,26 +89,27 @@ int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) { uint32_t layer_count, uint32_t stride, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Reset: handle=%p width=%u height=%u stride=%u format=%u " "usage=%" PRIx64, handle, width, height, stride, format, usage); Import(handle, width, height, stride, format, usage); "IonBuffer::Reset: handle=%p width=%u height=%u layer_count=%u " "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); Import(handle, width, height, layer_count, stride, format, usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) { uint32_t layer_count, 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 " "usage=%" PRIx64, handle, width, height, stride, format, usage); ALOGD_IF(TRACE, "IonBuffer::Import: handle=%p width=%u height=%u layer_count=%u " "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); FreeHandle(); sp<GraphicBuffer> buffer = new GraphicBuffer( handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, usage, stride); sp<GraphicBuffer> buffer = new GraphicBuffer(handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, layer_count, usage, stride); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Import: Failed to import buffer"); return -EINVAL; Loading @@ -120,12 +121,14 @@ int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, 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 usage) { uint32_t layer_count, 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 usage=%" PRIx64, fd_count, int_count, width, height, stride, format, usage); "layer_count=%u stride=%u format=%u usage=%" PRIx64, fd_count, int_count, width, height, layer_count, stride, format, usage); if (fd_count < 0 || int_count < 0) { ALOGE("IonBuffer::Import: invalid arguments."); Loading @@ -143,7 +146,8 @@ 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, usage); const int ret = Import(handle, width, height, layer_count, stride, format, usage); if (ret < 0) { ALOGE("IonBuffer::Import: failed to import raw native handle: %s", strerror(-ret)); Loading Loading @@ -179,8 +183,8 @@ int IonBuffer::Duplicate(const IonBuffer* other) { sizeof(int) * int_count); const int ret = Import(handle, other->width(), other->height(), other->stride(), other->format(), other->usage()); Import(handle, other->width(), other->height(), other->layer_count(), other->stride(), other->format(), other->usage()); if (ret < 0) { ALOGE("IonBuffer::Duplicate: Failed to import duplicate native handle: %s", strerror(-ret)); Loading libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h +12 −12 Original line number Diff line number Diff line Loading @@ -17,10 +17,11 @@ class IonBufferMock { IonBufferMock() {} MOCK_METHOD0(GetGrallocModuleImpl, gralloc_module_t const*()); MOCK_METHOD6(Import, int(buffer_handle_t handle, int width, int height, int layer_count, int stride, int format, int usage)); MOCK_METHOD9(Import, int(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int layer_count, int stride, int format, int usage)); MOCK_METHOD9(Import, int(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int stride, int format, int usage)); MOCK_METHOD6(Lock, int(int usage, int x, int y, int width, int height, void** address)); MOCK_METHOD0(Unlock, int()); Loading @@ -29,7 +30,6 @@ class IonBufferMock { MOCK_CONST_METHOD0(height, int()); MOCK_CONST_METHOD0(layer_count, int()); MOCK_CONST_METHOD0(stride, int()); MOCK_CONST_METHOD0(layer_stride, int()); MOCK_CONST_METHOD0(format, int()); MOCK_CONST_METHOD0(usage, int()); }; Loading @@ -46,15 +46,16 @@ class IonBuffer { static gralloc_module_t const* GetGrallocModule() { return staticObject->GetGrallocModuleImpl(); } int Import(buffer_handle_t handle, int width, int height, int stride, int format, int usage) { return mock_->Import(handle, width, height, stride, format, usage); int Import(buffer_handle_t handle, int width, int height, int layer_count, int stride, int format, int usage) { return mock_->Import(handle, width, height, layer_count, stride, format, usage); } int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int stride, int format, int usage) { int int_count, int width, int height, int layer_count, int stride, int format, int usage) { return mock_->Import(fd_array, fd_count, int_array, int_count, width, height, stride, format, usage); height, layer_count, stride, format, usage); } int Lock(int usage, int x, int y, int width, int height, void** address) { return mock_->Lock(usage, x, y, width, height, address); Loading @@ -65,7 +66,6 @@ class IonBuffer { int height() const { return mock_->height(); } int layer_count() const { return mock_->layer_count(); } int stride() const { return mock_->stride(); } int layer_stride() const { return mock_->layer_stride(); } int format() const { return mock_->format(); } int usage() const { return mock_->usage(); } std::unique_ptr<IonBufferMock> mock_; Loading Loading
libs/vr/libbufferhub/buffer_hub_client.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -59,10 +59,8 @@ int BufferHubBuffer::ImportBuffer() { ALOGE("BufferHubBuffer::ImportBuffer: Failed to get buffer: %s", status.GetErrorMessage().c_str()); return -status.error(); } else if (status.get().id() >= 0) { ALOGE( "BufferHubBuffer::ImportBuffer: Expected to receive a buffer handle " "but got null!"); } else if (status.get().id() < 0) { ALOGE("BufferHubBuffer::ImportBuffer: Received an invalid id!"); return -EIO; } Loading
libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h +10 −7 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ class NativeBufferHandle { stride_(buffer.stride()), width_(buffer.width()), height_(buffer.height()), layer_count_(buffer.layer_count()), format_(buffer.format()), usage_(buffer.usage()) { // Populate the fd and int vectors: native_handle->data[] is an array of fds Loading @@ -47,9 +48,10 @@ class NativeBufferHandle { for (const auto& fd : fds_) fd_ints.push_back(fd.Get()); const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, stride_, format_, usage_); const int ret = buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(), opaque_ints_.size(), width_, height_, layer_count_, stride_, format_, usage_); if (ret < 0) return ret; Loading @@ -72,6 +74,7 @@ class NativeBufferHandle { uint32_t stride_; uint32_t width_; uint32_t height_; uint32_t layer_count_; uint32_t format_; uint64_t usage_; std::vector<int> opaque_ints_; Loading @@ -83,8 +86,8 @@ class NativeBufferHandle { } PDX_SERIALIZABLE_MEMBERS(NativeBufferHandle<FileHandleType>, id_, stride_, width_, height_, format_, usage_, opaque_ints_, fds_); width_, height_, layer_count_, format_, usage_, opaque_ints_, fds_); NativeBufferHandle(const NativeBufferHandle&) = delete; void operator=(const NativeBufferHandle&) = delete; Loading Loading @@ -224,8 +227,8 @@ struct BufferHubRPC { PDX_REMOTE_METHOD(ProducerQueueAllocateBuffers, kOpProducerQueueAllocateBuffers, std::vector<std::pair<LocalChannelHandle, size_t>>( uint32_t width, uint32_t height, uint32_t format, uint64_t usage, size_t buffer_count)); uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format, uint64_t usage, size_t buffer_count)); PDX_REMOTE_METHOD(ProducerQueueDetachBuffer, kOpProducerQueueDetachBuffer, void(size_t slot)); PDX_REMOTE_METHOD(ConsumerQueueImportBuffers, kOpConsumerQueueImportBuffers, Loading
libs/vr/libbufferhub/include/private/dvr/ion_buffer.h +11 −8 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ class IonBuffer { IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, 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 usage); uint32_t layer_count, uint32_t stride, uint32_t format, uint64_t usage); ~IonBuffer(); IonBuffer(IonBuffer&& other); Loading @@ -31,25 +31,29 @@ 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, uint64_t usage); int Alloc(uint32_t width, uint32_t height, uint32_t layer_count, 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, uint64_t usage); uint32_t layer_count, 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, uint64_t usage); uint32_t layer_count, 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, uint64_t usage); int int_count, uint32_t width, uint32_t height, uint32_t layer_count, uint32_t stride, 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 @@ -72,7 +76,6 @@ class IonBuffer { return buffer_.get() ? buffer_->getLayerCount() : 0; } uint32_t stride() const { return buffer_.get() ? buffer_->getStride() : 0; } uint32_t layer_stride() const { return 0; } uint32_t format() const { return buffer_.get() ? buffer_->getPixelFormat() : 0; } Loading
libs/vr/libbufferhub/ion_buffer.cpp +40 −36 Original line number Diff line number Diff line Loading @@ -15,36 +15,36 @@ constexpr uint32_t kDefaultGraphicBufferLayerCount = 1; namespace android { namespace dvr { IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer() : IonBuffer(nullptr, 0, 0, 0, 0, 0, 0) {} IonBuffer::IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage) : IonBuffer() { Alloc(width, height, format, usage); Alloc(width, height, kDefaultGraphicBufferLayerCount, format, usage); } IonBuffer::IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) : IonBuffer(handle, width, height, 1, stride, 0, format, usage) {} : IonBuffer(handle, width, height, kDefaultGraphicBufferLayerCount, stride, 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, uint64_t usage) uint32_t layer_count, uint32_t 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 usage=%" PRIx64, handle, width, height, layer_count, stride, layer_stride, format, usage); "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); if (handle != 0) { Import(handle, width, height, stride, format, usage); Import(handle, width, height, layer_count, stride, format, usage); } } IonBuffer::~IonBuffer() { ALOGD_IF(TRACE, "IonBuffer::~IonBuffer: handle=%p width=%u height=%u stride=%u " "format=%u usage=%x", "format=%u usage=%" PRIx64, handle(), width(), height(), stride(), format(), usage()); FreeHandle(); } Loading @@ -71,14 +71,14 @@ void IonBuffer::FreeHandle() { } } int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t usage) { int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Alloc: width=%u height=%u format=%u usage=%" PRIx64, width, height, format, usage); "IonBuffer::Alloc: width=%u height=%u layer_count=%u format=%u " "usage=%" PRIx64, width, height, layer_count, format, usage); sp<GraphicBuffer> buffer = new GraphicBuffer( width, height, format, kDefaultGraphicBufferLayerCount, usage); sp<GraphicBuffer> buffer = new GraphicBuffer(width, height, format, layer_count, usage); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Aloc: Failed to allocate buffer"); return -EINVAL; Loading @@ -89,26 +89,27 @@ int IonBuffer::Alloc(uint32_t width, uint32_t height, uint32_t format, } void IonBuffer::Reset(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) { uint32_t layer_count, uint32_t stride, uint32_t format, uint64_t usage) { ALOGD_IF(TRACE, "IonBuffer::Reset: handle=%p width=%u height=%u stride=%u format=%u " "usage=%" PRIx64, handle, width, height, stride, format, usage); Import(handle, width, height, stride, format, usage); "IonBuffer::Reset: handle=%p width=%u height=%u layer_count=%u " "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); Import(handle, width, height, layer_count, stride, format, usage); } int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, uint32_t stride, uint32_t format, uint64_t usage) { uint32_t layer_count, 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 " "usage=%" PRIx64, handle, width, height, stride, format, usage); ALOGD_IF(TRACE, "IonBuffer::Import: handle=%p width=%u height=%u layer_count=%u " "stride=%u format=%u usage=%" PRIx64, handle, width, height, layer_count, stride, format, usage); FreeHandle(); sp<GraphicBuffer> buffer = new GraphicBuffer( handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, kDefaultGraphicBufferLayerCount, usage, stride); sp<GraphicBuffer> buffer = new GraphicBuffer(handle, GraphicBuffer::TAKE_UNREGISTERED_HANDLE, width, height, format, layer_count, usage, stride); if (buffer->initCheck() != OK) { ALOGE("IonBuffer::Import: Failed to import buffer"); return -EINVAL; Loading @@ -120,12 +121,14 @@ int IonBuffer::Import(buffer_handle_t handle, uint32_t width, uint32_t height, 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 usage) { uint32_t layer_count, 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 usage=%" PRIx64, fd_count, int_count, width, height, stride, format, usage); "layer_count=%u stride=%u format=%u usage=%" PRIx64, fd_count, int_count, width, height, layer_count, stride, format, usage); if (fd_count < 0 || int_count < 0) { ALOGE("IonBuffer::Import: invalid arguments."); Loading @@ -143,7 +146,8 @@ 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, usage); const int ret = Import(handle, width, height, layer_count, stride, format, usage); if (ret < 0) { ALOGE("IonBuffer::Import: failed to import raw native handle: %s", strerror(-ret)); Loading Loading @@ -179,8 +183,8 @@ int IonBuffer::Duplicate(const IonBuffer* other) { sizeof(int) * int_count); const int ret = Import(handle, other->width(), other->height(), other->stride(), other->format(), other->usage()); Import(handle, other->width(), other->height(), other->layer_count(), other->stride(), other->format(), other->usage()); if (ret < 0) { ALOGE("IonBuffer::Duplicate: Failed to import duplicate native handle: %s", strerror(-ret)); Loading
libs/vr/libbufferhub/mocks/ion_buffer/private/dvr/ion_buffer.h +12 −12 Original line number Diff line number Diff line Loading @@ -17,10 +17,11 @@ class IonBufferMock { IonBufferMock() {} MOCK_METHOD0(GetGrallocModuleImpl, gralloc_module_t const*()); MOCK_METHOD6(Import, int(buffer_handle_t handle, int width, int height, int layer_count, int stride, int format, int usage)); MOCK_METHOD9(Import, int(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int layer_count, int stride, int format, int usage)); MOCK_METHOD9(Import, int(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int stride, int format, int usage)); MOCK_METHOD6(Lock, int(int usage, int x, int y, int width, int height, void** address)); MOCK_METHOD0(Unlock, int()); Loading @@ -29,7 +30,6 @@ class IonBufferMock { MOCK_CONST_METHOD0(height, int()); MOCK_CONST_METHOD0(layer_count, int()); MOCK_CONST_METHOD0(stride, int()); MOCK_CONST_METHOD0(layer_stride, int()); MOCK_CONST_METHOD0(format, int()); MOCK_CONST_METHOD0(usage, int()); }; Loading @@ -46,15 +46,16 @@ class IonBuffer { static gralloc_module_t const* GetGrallocModule() { return staticObject->GetGrallocModuleImpl(); } int Import(buffer_handle_t handle, int width, int height, int stride, int format, int usage) { return mock_->Import(handle, width, height, stride, format, usage); int Import(buffer_handle_t handle, int width, int height, int layer_count, int stride, int format, int usage) { return mock_->Import(handle, width, height, layer_count, stride, format, usage); } int Import(const int* fd_array, int fd_count, const int* int_array, int int_count, int width, int height, int stride, int format, int usage) { int int_count, int width, int height, int layer_count, int stride, int format, int usage) { return mock_->Import(fd_array, fd_count, int_array, int_count, width, height, stride, format, usage); height, layer_count, stride, format, usage); } int Lock(int usage, int x, int y, int width, int height, void** address) { return mock_->Lock(usage, x, y, width, height, address); Loading @@ -65,7 +66,6 @@ class IonBuffer { int height() const { return mock_->height(); } int layer_count() const { return mock_->layer_count(); } int stride() const { return mock_->stride(); } int layer_stride() const { return mock_->layer_stride(); } int format() const { return mock_->format(); } int usage() const { return mock_->usage(); } std::unique_ptr<IonBufferMock> mock_; Loading