Loading libs/gui/bufferqueue/1.0/H2BGraphicBufferProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1061,7 +1061,7 @@ status_t H2BGraphicBufferProducer::detachNextBuffer( status_t H2BGraphicBufferProducer::attachBuffer( int* outSlot, const sp<GraphicBuffer>& buffer) { AnwBuffer tBuffer; AnwBuffer tBuffer{}; wrapAs(&tBuffer, *buffer); status_t fnStatus; status_t transStatus = toStatusT(mBase->attachBuffer(tBuffer, Loading @@ -1076,7 +1076,7 @@ status_t H2BGraphicBufferProducer::queueBuffer( int slot, const QueueBufferInput& input, QueueBufferOutput* output) { HGraphicBufferProducer::QueueBufferInput tInput; HGraphicBufferProducer::QueueBufferInput tInput{}; native_handle_t* nh; if (!wrapAs(&tInput, &nh, input)) { ALOGE("H2BGraphicBufferProducer::queueBuffer - " Loading libs/gui/bufferqueue/2.0/B2HGraphicBufferProducer.cpp +52 −44 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ */ //#define LOG_NDEBUG 0 #define LOG_TAG "H2BGraphicBufferProducer@2.0" #define LOG_TAG "B2HGraphicBufferProducer@2.0" #include <android-base/logging.h> Loading @@ -30,13 +30,38 @@ #include <vndk/hardware_buffer.h> namespace android { namespace hardware { namespace graphics { namespace bufferqueue { namespace V2_0 { namespace utils { namespace /* unnamed */ { using BQueueBufferInput = ::android:: IGraphicBufferProducer::QueueBufferInput; using HQueueBufferInput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferInput; using BQueueBufferOutput = ::android:: IGraphicBufferProducer::QueueBufferOutput; using HQueueBufferOutput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferOutput; using ::android::hardware::graphics::bufferqueue::V2_0::utils::b2h; using ::android::hardware::graphics::bufferqueue::V2_0::utils::h2b; bool b2h(BQueueBufferOutput const& from, HQueueBufferOutput* to) { to->width = from.width; to->height = from.height; to->transformHint = static_cast<int32_t>(from.transformHint); to->numPendingBuffers = from.numPendingBuffers; to->nextFrameNumber = from.nextFrameNumber; to->bufferReplaced = from.bufferReplaced; return true; } } // unnamed namespace // B2HGraphicBufferProducer // ======================== Loading Loading @@ -161,11 +186,7 @@ Return<void> B2HGraphicBufferProducer::queueBuffer( int32_t slot, QueueBufferInput const& hInput, queueBuffer_cb _hidl_cb) { using HOutput = QueueBufferOutput; using BInput = BGraphicBufferProducer::QueueBufferInput; using BOutput = BGraphicBufferProducer::QueueBufferOutput; BInput bInput{ BQueueBufferInput bInput{ hInput.timestamp, hInput.isAutoTimestamp, static_cast<android_dataspace>(hInput.dataSpace), Loading @@ -178,35 +199,32 @@ Return<void> B2HGraphicBufferProducer::queueBuffer( // Convert crop. if (!h2b(hInput.crop, &bInput.crop)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } // Convert surfaceDamage. if (!h2b(hInput.surfaceDamage, &bInput.surfaceDamage)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } // Convert fence. if (!h2b(hInput.fence, &bInput.fence)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } BOutput bOutput{}; BQueueBufferOutput bOutput{}; HStatus hStatus{}; bool converted = b2h( QueueBufferOutput hOutput{}; bool converted = b2h( mBase->queueBuffer(static_cast<int>(slot), bInput, &bOutput), &hStatus); &hStatus) && b2h(bOutput, &hOutput); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, HOutput{bOutput.width, bOutput.height, static_cast<int32_t>(bOutput.transformHint), bOutput.numPendingBuffers, bOutput.nextFrameNumber, bOutput.bufferReplaced}); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, hOutput); return {}; } Loading Loading @@ -236,33 +254,23 @@ Return<void> B2HGraphicBufferProducer::connect( HConnectionType hConnectionType, bool producerControlledByApp, connect_cb _hidl_cb) { using BOutput = BGraphicBufferProducer::QueueBufferOutput; using HOutput = HGraphicBufferProducer::QueueBufferOutput; sp<BProducerListener> bListener = new H2BProducerListener(hListener); if (!bListener) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); int bConnectionType{}; if (!bListener || !h2b(hConnectionType, &bConnectionType)) { _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } int bConnectionType; if (!h2b(hConnectionType, &bConnectionType)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); return {}; } BOutput bOutput{}; BQueueBufferOutput bOutput{}; HStatus hStatus{}; bool converted = b2h( mBase->connect(bListener, QueueBufferOutput hOutput{}; bool converted = b2h(mBase->connect(bListener, bConnectionType, producerControlledByApp, &bOutput), &hStatus); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, HOutput{bOutput.width, bOutput.height, static_cast<int32_t>(bOutput.transformHint), bOutput.numPendingBuffers, bOutput.nextFrameNumber, bOutput.bufferReplaced}); &hStatus) && b2h(bOutput, &hOutput); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, hOutput); return {}; } Loading libs/gui/bufferqueue/2.0/H2BGraphicBufferProducer.cpp +49 −57 Original line number Diff line number Diff line Loading @@ -29,13 +29,54 @@ #include <vndk/hardware_buffer.h> namespace android { namespace hardware { namespace graphics { namespace bufferqueue { namespace V2_0 { namespace utils { namespace /* unnamed */ { using BQueueBufferInput = ::android:: IGraphicBufferProducer::QueueBufferInput; using HQueueBufferInput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferInput; using BQueueBufferOutput = ::android:: IGraphicBufferProducer::QueueBufferOutput; using HQueueBufferOutput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferOutput; using ::android::hardware::graphics::bufferqueue::V2_0::utils::b2h; using ::android::hardware::graphics::bufferqueue::V2_0::utils::h2b; bool b2h(BQueueBufferInput const& from, HQueueBufferInput* to, HFenceWrapper* hFenceWrapper) { to->timestamp = from.timestamp; to->isAutoTimestamp = static_cast<bool>(from.isAutoTimestamp); to->dataSpace = static_cast<int32_t>(from.dataSpace); to->transform = static_cast<int32_t>(from.transform); to->stickyTransform = static_cast<int32_t>(from.stickyTransform); if (!b2h(from.crop, &to->crop) || !b2h(from.surfaceDamage, &to->surfaceDamage) || !b2h(from.fence, hFenceWrapper)) { return false; } to->fence = hFenceWrapper->getHandle(); return true; } bool h2b(HQueueBufferOutput const& from, BQueueBufferOutput* to) { to->width = from.width; to->height = from.height; to->transformHint = static_cast<uint32_t>(from.transformHint); to->numPendingBuffers = from.numPendingBuffers; to->nextFrameNumber = from.nextFrameNumber; to->bufferReplaced = from.bufferReplaced; return true; } } // unnamed namespace // H2BGraphicBufferProducer // ======================== Loading Loading @@ -209,47 +250,13 @@ status_t H2BGraphicBufferProducer::queueBuffer( int slot, QueueBufferInput const& input, QueueBufferOutput* output) { HRect hCrop{}; (void)b2h(input.crop, &hCrop); using HInput = HGraphicBufferProducer::QueueBufferInput; HInput hInput{ input.timestamp, static_cast<bool>(input.isAutoTimestamp), static_cast<int32_t>(input.dataSpace), {}, // crop static_cast<int32_t>(input.transform), static_cast<int32_t>(input.stickyTransform), {}, // fence {} // surfaceDamage }; // Convert crop. if (!b2h(input.crop, &hInput.crop)) { LOG(ERROR) << "queueBuffer: corrupted input crop rectangle."; return UNKNOWN_ERROR; } // Convert surfaceDamage. size_t numRects; Rect const* rectArray = input.surfaceDamage.getArray(&numRects); hInput.surfaceDamage.resize(numRects); for (size_t i = 0; i < numRects; ++i) { if (!b2h(rectArray[i], &hInput.surfaceDamage[i])) { LOG(ERROR) << "queueBuffer: corrupted input surface damage."; return UNKNOWN_ERROR; } } // Convert fence. HQueueBufferInput hInput{}; HFenceWrapper hFenceWrapper; if (!b2h(input.fence, &hFenceWrapper)) { LOG(ERROR) << "queueBuffer: corrupted input fence."; if (!b2h(input, &hInput, &hFenceWrapper)) { LOG(ERROR) << "queueBuffer: corrupted input."; return UNKNOWN_ERROR; } hInput.fence = hFenceWrapper.getHandle(); using HOutput = HGraphicBufferProducer::QueueBufferOutput; bool converted{}; status_t bStatus{}; Return<void> transResult = mBase->queueBuffer( Loading @@ -257,15 +264,8 @@ status_t H2BGraphicBufferProducer::queueBuffer( hInput, [&converted, &bStatus, output]( HStatus hStatus, HOutput const& hOutput) { converted = h2b(hStatus, &bStatus); output->width = hOutput.width; output->height = hOutput.height; output->transformHint = static_cast<uint32_t>(hOutput.transformHint); output->numPendingBuffers = hOutput.numPendingBuffers; output->nextFrameNumber = hOutput.nextFrameNumber; output->bufferReplaced = hOutput.bufferReplaced; HQueueBufferOutput const& hOutput) { converted = h2b(hStatus, &bStatus) && h2b(hOutput, output); }); if (!transResult.isOk()) { Loading Loading @@ -332,7 +332,6 @@ status_t H2BGraphicBufferProducer::connect( } } using HOutput = HGraphicBufferProducer::QueueBufferOutput; bool converted{}; status_t bStatus{}; Return<void> transResult = mBase->connect( Loading @@ -341,15 +340,8 @@ status_t H2BGraphicBufferProducer::connect( producerControlledByApp, [&converted, &bStatus, output]( HStatus hStatus, HOutput hOutput) { converted = h2b(hStatus, &bStatus); output->width = hOutput.width; output->height = hOutput.height; output->transformHint = static_cast<uint32_t>(hOutput.transformHint); output->numPendingBuffers = hOutput.numPendingBuffers; output->nextFrameNumber = hOutput.nextFrameNumber; output->bufferReplaced = hOutput.bufferReplaced; HQueueBufferOutput const& hOutput) { converted = h2b(hStatus, &bStatus) && h2b(hOutput, output); }); if (!transResult.isOk()) { LOG(ERROR) << "connect: transaction failed."; Loading Loading
libs/gui/bufferqueue/1.0/H2BGraphicBufferProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1061,7 +1061,7 @@ status_t H2BGraphicBufferProducer::detachNextBuffer( status_t H2BGraphicBufferProducer::attachBuffer( int* outSlot, const sp<GraphicBuffer>& buffer) { AnwBuffer tBuffer; AnwBuffer tBuffer{}; wrapAs(&tBuffer, *buffer); status_t fnStatus; status_t transStatus = toStatusT(mBase->attachBuffer(tBuffer, Loading @@ -1076,7 +1076,7 @@ status_t H2BGraphicBufferProducer::queueBuffer( int slot, const QueueBufferInput& input, QueueBufferOutput* output) { HGraphicBufferProducer::QueueBufferInput tInput; HGraphicBufferProducer::QueueBufferInput tInput{}; native_handle_t* nh; if (!wrapAs(&tInput, &nh, input)) { ALOGE("H2BGraphicBufferProducer::queueBuffer - " Loading
libs/gui/bufferqueue/2.0/B2HGraphicBufferProducer.cpp +52 −44 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ */ //#define LOG_NDEBUG 0 #define LOG_TAG "H2BGraphicBufferProducer@2.0" #define LOG_TAG "B2HGraphicBufferProducer@2.0" #include <android-base/logging.h> Loading @@ -30,13 +30,38 @@ #include <vndk/hardware_buffer.h> namespace android { namespace hardware { namespace graphics { namespace bufferqueue { namespace V2_0 { namespace utils { namespace /* unnamed */ { using BQueueBufferInput = ::android:: IGraphicBufferProducer::QueueBufferInput; using HQueueBufferInput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferInput; using BQueueBufferOutput = ::android:: IGraphicBufferProducer::QueueBufferOutput; using HQueueBufferOutput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferOutput; using ::android::hardware::graphics::bufferqueue::V2_0::utils::b2h; using ::android::hardware::graphics::bufferqueue::V2_0::utils::h2b; bool b2h(BQueueBufferOutput const& from, HQueueBufferOutput* to) { to->width = from.width; to->height = from.height; to->transformHint = static_cast<int32_t>(from.transformHint); to->numPendingBuffers = from.numPendingBuffers; to->nextFrameNumber = from.nextFrameNumber; to->bufferReplaced = from.bufferReplaced; return true; } } // unnamed namespace // B2HGraphicBufferProducer // ======================== Loading Loading @@ -161,11 +186,7 @@ Return<void> B2HGraphicBufferProducer::queueBuffer( int32_t slot, QueueBufferInput const& hInput, queueBuffer_cb _hidl_cb) { using HOutput = QueueBufferOutput; using BInput = BGraphicBufferProducer::QueueBufferInput; using BOutput = BGraphicBufferProducer::QueueBufferOutput; BInput bInput{ BQueueBufferInput bInput{ hInput.timestamp, hInput.isAutoTimestamp, static_cast<android_dataspace>(hInput.dataSpace), Loading @@ -178,35 +199,32 @@ Return<void> B2HGraphicBufferProducer::queueBuffer( // Convert crop. if (!h2b(hInput.crop, &bInput.crop)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } // Convert surfaceDamage. if (!h2b(hInput.surfaceDamage, &bInput.surfaceDamage)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } // Convert fence. if (!h2b(hInput.fence, &bInput.fence)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } BOutput bOutput{}; BQueueBufferOutput bOutput{}; HStatus hStatus{}; bool converted = b2h( QueueBufferOutput hOutput{}; bool converted = b2h( mBase->queueBuffer(static_cast<int>(slot), bInput, &bOutput), &hStatus); &hStatus) && b2h(bOutput, &hOutput); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, HOutput{bOutput.width, bOutput.height, static_cast<int32_t>(bOutput.transformHint), bOutput.numPendingBuffers, bOutput.nextFrameNumber, bOutput.bufferReplaced}); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, hOutput); return {}; } Loading Loading @@ -236,33 +254,23 @@ Return<void> B2HGraphicBufferProducer::connect( HConnectionType hConnectionType, bool producerControlledByApp, connect_cb _hidl_cb) { using BOutput = BGraphicBufferProducer::QueueBufferOutput; using HOutput = HGraphicBufferProducer::QueueBufferOutput; sp<BProducerListener> bListener = new H2BProducerListener(hListener); if (!bListener) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); int bConnectionType{}; if (!bListener || !h2b(hConnectionType, &bConnectionType)) { _hidl_cb(HStatus::UNKNOWN_ERROR, QueueBufferOutput{}); return {}; } int bConnectionType; if (!h2b(hConnectionType, &bConnectionType)) { _hidl_cb(HStatus::UNKNOWN_ERROR, HOutput{}); return {}; } BOutput bOutput{}; BQueueBufferOutput bOutput{}; HStatus hStatus{}; bool converted = b2h( mBase->connect(bListener, QueueBufferOutput hOutput{}; bool converted = b2h(mBase->connect(bListener, bConnectionType, producerControlledByApp, &bOutput), &hStatus); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, HOutput{bOutput.width, bOutput.height, static_cast<int32_t>(bOutput.transformHint), bOutput.numPendingBuffers, bOutput.nextFrameNumber, bOutput.bufferReplaced}); &hStatus) && b2h(bOutput, &hOutput); _hidl_cb(converted ? hStatus : HStatus::UNKNOWN_ERROR, hOutput); return {}; } Loading
libs/gui/bufferqueue/2.0/H2BGraphicBufferProducer.cpp +49 −57 Original line number Diff line number Diff line Loading @@ -29,13 +29,54 @@ #include <vndk/hardware_buffer.h> namespace android { namespace hardware { namespace graphics { namespace bufferqueue { namespace V2_0 { namespace utils { namespace /* unnamed */ { using BQueueBufferInput = ::android:: IGraphicBufferProducer::QueueBufferInput; using HQueueBufferInput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferInput; using BQueueBufferOutput = ::android:: IGraphicBufferProducer::QueueBufferOutput; using HQueueBufferOutput = ::android::hardware::graphics::bufferqueue::V2_0:: IGraphicBufferProducer::QueueBufferOutput; using ::android::hardware::graphics::bufferqueue::V2_0::utils::b2h; using ::android::hardware::graphics::bufferqueue::V2_0::utils::h2b; bool b2h(BQueueBufferInput const& from, HQueueBufferInput* to, HFenceWrapper* hFenceWrapper) { to->timestamp = from.timestamp; to->isAutoTimestamp = static_cast<bool>(from.isAutoTimestamp); to->dataSpace = static_cast<int32_t>(from.dataSpace); to->transform = static_cast<int32_t>(from.transform); to->stickyTransform = static_cast<int32_t>(from.stickyTransform); if (!b2h(from.crop, &to->crop) || !b2h(from.surfaceDamage, &to->surfaceDamage) || !b2h(from.fence, hFenceWrapper)) { return false; } to->fence = hFenceWrapper->getHandle(); return true; } bool h2b(HQueueBufferOutput const& from, BQueueBufferOutput* to) { to->width = from.width; to->height = from.height; to->transformHint = static_cast<uint32_t>(from.transformHint); to->numPendingBuffers = from.numPendingBuffers; to->nextFrameNumber = from.nextFrameNumber; to->bufferReplaced = from.bufferReplaced; return true; } } // unnamed namespace // H2BGraphicBufferProducer // ======================== Loading Loading @@ -209,47 +250,13 @@ status_t H2BGraphicBufferProducer::queueBuffer( int slot, QueueBufferInput const& input, QueueBufferOutput* output) { HRect hCrop{}; (void)b2h(input.crop, &hCrop); using HInput = HGraphicBufferProducer::QueueBufferInput; HInput hInput{ input.timestamp, static_cast<bool>(input.isAutoTimestamp), static_cast<int32_t>(input.dataSpace), {}, // crop static_cast<int32_t>(input.transform), static_cast<int32_t>(input.stickyTransform), {}, // fence {} // surfaceDamage }; // Convert crop. if (!b2h(input.crop, &hInput.crop)) { LOG(ERROR) << "queueBuffer: corrupted input crop rectangle."; return UNKNOWN_ERROR; } // Convert surfaceDamage. size_t numRects; Rect const* rectArray = input.surfaceDamage.getArray(&numRects); hInput.surfaceDamage.resize(numRects); for (size_t i = 0; i < numRects; ++i) { if (!b2h(rectArray[i], &hInput.surfaceDamage[i])) { LOG(ERROR) << "queueBuffer: corrupted input surface damage."; return UNKNOWN_ERROR; } } // Convert fence. HQueueBufferInput hInput{}; HFenceWrapper hFenceWrapper; if (!b2h(input.fence, &hFenceWrapper)) { LOG(ERROR) << "queueBuffer: corrupted input fence."; if (!b2h(input, &hInput, &hFenceWrapper)) { LOG(ERROR) << "queueBuffer: corrupted input."; return UNKNOWN_ERROR; } hInput.fence = hFenceWrapper.getHandle(); using HOutput = HGraphicBufferProducer::QueueBufferOutput; bool converted{}; status_t bStatus{}; Return<void> transResult = mBase->queueBuffer( Loading @@ -257,15 +264,8 @@ status_t H2BGraphicBufferProducer::queueBuffer( hInput, [&converted, &bStatus, output]( HStatus hStatus, HOutput const& hOutput) { converted = h2b(hStatus, &bStatus); output->width = hOutput.width; output->height = hOutput.height; output->transformHint = static_cast<uint32_t>(hOutput.transformHint); output->numPendingBuffers = hOutput.numPendingBuffers; output->nextFrameNumber = hOutput.nextFrameNumber; output->bufferReplaced = hOutput.bufferReplaced; HQueueBufferOutput const& hOutput) { converted = h2b(hStatus, &bStatus) && h2b(hOutput, output); }); if (!transResult.isOk()) { Loading Loading @@ -332,7 +332,6 @@ status_t H2BGraphicBufferProducer::connect( } } using HOutput = HGraphicBufferProducer::QueueBufferOutput; bool converted{}; status_t bStatus{}; Return<void> transResult = mBase->connect( Loading @@ -341,15 +340,8 @@ status_t H2BGraphicBufferProducer::connect( producerControlledByApp, [&converted, &bStatus, output]( HStatus hStatus, HOutput hOutput) { converted = h2b(hStatus, &bStatus); output->width = hOutput.width; output->height = hOutput.height; output->transformHint = static_cast<uint32_t>(hOutput.transformHint); output->numPendingBuffers = hOutput.numPendingBuffers; output->nextFrameNumber = hOutput.nextFrameNumber; output->bufferReplaced = hOutput.bufferReplaced; HQueueBufferOutput const& hOutput) { converted = h2b(hStatus, &bStatus) && h2b(hOutput, output); }); if (!transResult.isOk()) { LOG(ERROR) << "connect: transaction failed."; Loading