diff options
| author | 2016-11-28 21:59:59 +0000 | |
|---|---|---|
| committer | 2016-11-28 22:00:00 +0000 | |
| commit | e6d6448f5a4ccf34ff3e8e8fd11b0718ff08a20c (patch) | |
| tree | 77dec938e0f3eb7f7b63ae4f52deeb066eecda7f | |
| parent | d0246c80cf07e9f3f699d74d6ebdab48da373d6d (diff) | |
| parent | b018bf0e0877b19e3c7cc2697d0b7729c711eadd (diff) | |
Merge "libui: update for IAllocator changes"
| -rw-r--r-- | include/ui/GrallocAllocator.h | 8 | ||||
| -rw-r--r-- | libs/ui/GrallocAllocator.cpp | 27 | ||||
| -rw-r--r-- | libs/ui/GraphicBufferAllocator.cpp | 2 |
3 files changed, 25 insertions, 12 deletions
diff --git a/include/ui/GrallocAllocator.h b/include/ui/GrallocAllocator.h index e3c42487c5..5645bed129 100644 --- a/include/ui/GrallocAllocator.h +++ b/include/ui/GrallocAllocator.h @@ -32,6 +32,7 @@ using hardware::graphics::allocator::V2_0::ConsumerUsage; using hardware::graphics::allocator::V2_0::BufferDescriptor; using hardware::graphics::allocator::V2_0::Buffer; using hardware::graphics::allocator::V2_0::IAllocator; +using hardware::graphics::allocator::V2_0::IAllocatorClient; using hardware::graphics::common::V1_0::PixelFormat; // Allocator is a wrapper to IAllocator, a proxy to server-side allocator. @@ -40,12 +41,12 @@ public: Allocator(); // this will be removed and Allocator will be always valid - bool valid() const { return (mService != nullptr); } + bool valid() const { return (mAllocator != nullptr); } std::string dumpDebugInfo() const; Error createBufferDescriptor( - const IAllocator::BufferDescriptorInfo& descriptorInfo, + const IAllocatorClient::BufferDescriptorInfo& descriptorInfo, BufferDescriptor& descriptor) const; void destroyBufferDescriptor(BufferDescriptor descriptor) const; @@ -56,7 +57,8 @@ public: native_handle_t*& bufferHandle) const; private: - sp<IAllocator> mService; + sp<IAllocator> mAllocator; + sp<IAllocatorClient> mClient; }; } // namespace Gralloc2 diff --git a/libs/ui/GrallocAllocator.cpp b/libs/ui/GrallocAllocator.cpp index 2eb1988cc8..021122a03b 100644 --- a/libs/ui/GrallocAllocator.cpp +++ b/libs/ui/GrallocAllocator.cpp @@ -28,14 +28,25 @@ constexpr Error kDefaultError = Error::NO_RESOURCES; Allocator::Allocator() { - mService = IAllocator::getService("gralloc"); + mAllocator = IAllocator::getService("gralloc"); + if (mAllocator != nullptr) { + mAllocator->createClient( + [&](const auto& tmpError, const auto& tmpClient) { + if (tmpError == Error::NONE) { + mClient = tmpClient; + } + }); + if (mClient == nullptr) { + mAllocator.clear(); + } + } } std::string Allocator::dumpDebugInfo() const { std::string info; - mService->dumpDebugInfo([&](const auto& tmpInfo) { + mAllocator->dumpDebugInfo([&](const auto& tmpInfo) { info = tmpInfo.c_str(); }); @@ -43,11 +54,11 @@ std::string Allocator::dumpDebugInfo() const } Error Allocator::createBufferDescriptor( - const IAllocator::BufferDescriptorInfo& descriptorInfo, + const IAllocatorClient::BufferDescriptorInfo& descriptorInfo, BufferDescriptor& descriptor) const { Error error = kDefaultError; - mService->createDescriptor(descriptorInfo, + mClient->createDescriptor(descriptorInfo, [&](const auto& tmpError, const auto& tmpDescriptor) { error = tmpError; if (error != Error::NONE) { @@ -62,7 +73,7 @@ Error Allocator::createBufferDescriptor( void Allocator::destroyBufferDescriptor(BufferDescriptor descriptor) const { - mService->destroyDescriptor(descriptor); + mClient->destroyDescriptor(descriptor); } Error Allocator::allocate(BufferDescriptor descriptor, Buffer& buffer) const @@ -71,7 +82,7 @@ Error Allocator::allocate(BufferDescriptor descriptor, Buffer& buffer) const descriptors.setToExternal(&descriptor, 1); Error error = kDefaultError; - auto status = mService->allocate(descriptors, + auto status = mClient->allocate(descriptors, [&](const auto& tmpError, const auto& tmpBuffers) { error = tmpError; if (tmpError != Error::NONE) { @@ -86,14 +97,14 @@ Error Allocator::allocate(BufferDescriptor descriptor, Buffer& buffer) const void Allocator::free(Buffer buffer) const { - mService->free(buffer); + mClient->free(buffer); } Error Allocator::exportHandle(BufferDescriptor descriptor, Buffer buffer, native_handle_t*& bufferHandle) const { Error error = kDefaultError; - auto status = mService->exportHandle(descriptor, buffer, + auto status = mClient->exportHandle(descriptor, buffer, [&](const auto& tmpError, const auto& tmpBufferHandle) { error = tmpError; if (tmpError != Error::NONE) { diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index e333bc10dd..d2585867cf 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -106,7 +106,7 @@ public: PixelFormat format, uint32_t layerCount, uint32_t usage) : mAllocator(allocator), mBufferValid(false) { - Gralloc2::IAllocator::BufferDescriptorInfo info = {}; + Gralloc2::IAllocatorClient::BufferDescriptorInfo info = {}; info.width = width; info.height = height; info.format = static_cast<Gralloc2::PixelFormat>(format); |