summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiwen 'Steve' Cai <jwcai@google.com> 2019-01-15 21:49:07 -0800
committer Tianyu Jiang <tianyuj@google.com> 2019-02-12 14:18:28 -0800
commitdfe0f4c69ad4f547db7109e7b4a1db42448d1233 (patch)
treeb9eecc1f4174e7735bc95573b2b56bc04af55f43
parent1603cc25a633eda3e11ffffe90c39fde7323471a (diff)
Fix BufferHubBuffer black screen
1/ BufferHubService should read back fields of HardwareBufferDescription of allocated BufferNode and send them back to the client. 2/ Update some minor naming for better readability. Bug: 122959735 Test: cts-tradefed run commandAndExit cts -m CtsNativeHardwareTestCases Change-Id: I10a176810d78c754fe0b69d4128078fc17d50035
-rw-r--r--libs/ui/BufferHubBuffer.cpp8
-rw-r--r--services/bufferhub/BufferHubService.cpp8
2 files changed, 11 insertions, 5 deletions
diff --git a/libs/ui/BufferHubBuffer.cpp b/libs/ui/BufferHubBuffer.cpp
index 405bcb62e1..604665bc91 100644
--- a/libs/ui/BufferHubBuffer.cpp
+++ b/libs/ui/BufferHubBuffer.cpp
@@ -79,10 +79,10 @@ BufferHubBuffer::BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layer
sp<IBufferClient> client;
BufferTraits bufferTraits;
IBufferHub::allocateBuffer_cb alloc_cb = [&](const auto& status, const auto& outClient,
- const auto& traits) {
+ const auto& outTraits) {
ret = status;
client = std::move(outClient);
- bufferTraits = std::move(traits);
+ bufferTraits = std::move(outTraits);
};
if (!bufferhub->allocateBuffer(desc, static_cast<uint32_t>(userMetadataSize), alloc_cb)
@@ -116,10 +116,10 @@ BufferHubBuffer::BufferHubBuffer(const sp<NativeHandle>& token) {
sp<IBufferClient> client;
BufferTraits bufferTraits;
IBufferHub::importBuffer_cb import_cb = [&](const auto& status, const auto& outClient,
- const auto& traits) {
+ const auto& outTraits) {
ret = status;
client = std::move(outClient);
- bufferTraits = std::move(traits);
+ bufferTraits = std::move(outTraits);
};
// hidl_handle(native_handle_t*) simply creates a raw pointer reference withouth ownership
diff --git a/services/bufferhub/BufferHubService.cpp b/services/bufferhub/BufferHubService.cpp
index 90ac1c2535..ade08e7d17 100644
--- a/services/bufferhub/BufferHubService.cpp
+++ b/services/bufferhub/BufferHubService.cpp
@@ -73,7 +73,13 @@ Return<void> BufferHubService::allocateBuffer(const HardwareBufferDescription& d
buildBufferInfo(bufferInfoStorage, node->id(), node->addNewActiveClientsBitToMask(),
node->userMetadataSize(), node->metadata().ashmemFd(),
node->eventFd().get());
- BufferTraits bufferTraits = {/*bufferDesc=*/description,
+ // During the gralloc allocation carried out by BufferNode, gralloc allocator will populate the
+ // fields of its HardwareBufferDescription (i.e. strides) according to the actual
+ // gralloc implementation. We need to read those fields back and send them to the client via
+ // BufferTraits.
+ HardwareBufferDescription allocatedBufferDesc;
+ memcpy(&allocatedBufferDesc, &node->bufferDesc(), sizeof(AHardwareBuffer_Desc));
+ BufferTraits bufferTraits = {/*bufferDesc=*/allocatedBufferDesc,
/*bufferHandle=*/hidl_handle(node->bufferHandle()),
/*bufferInfo=*/std::move(bufferInfo)};