diff options
author | susi_su <susisu@google.com> | 2022-08-01 21:03:44 +0800 |
---|---|---|
committer | susi_su <susisu@google.com> | 2022-09-29 21:32:28 +0800 |
commit | 8ffb22466984efdd3154473e63e78aaa762ef23a (patch) | |
tree | e23b8b2b455b1098c050d95e0b0e6c12425f6574 /libhwc2.1/histogram_mediator.cpp | |
parent | 9c5b796746c5a0ffbfd71681e6df3886f6125c57 (diff) |
libhw2.1: change mIDLHistogram to shared_ptr
change mIDLHistogram to shared_ptr to avoid
memory error when destructing ExynosDisplayDrmInterfaceModule
bug: b/240292495
test: tested by a histogram client program locally
Change-Id: I4f093ac78faa49cdb34d4dd07ae6634d5d82f3f8
Diffstat (limited to 'libhwc2.1/histogram_mediator.cpp')
-rw-r--r-- | libhwc2.1/histogram_mediator.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/libhwc2.1/histogram_mediator.cpp b/libhwc2.1/histogram_mediator.cpp index c917783..991b972 100644 --- a/libhwc2.1/histogram_mediator.cpp +++ b/libhwc2.1/histogram_mediator.cpp @@ -19,8 +19,9 @@ histogram::HistogramMediator::HistogramMediator(ExynosDisplay *display) { mDisplay = display; ExynosDisplayDrmInterface *moduleDisplayInterface = static_cast<ExynosDisplayDrmInterface *>(display->mDisplayInterface.get()); + mIDLHistogram = std::make_shared<HistogramReceiver>(); - moduleDisplayInterface->registerHistogramInfo(static_cast<IDLHistogram *>(&mIDLHistogram)); + moduleDisplayInterface->registerHistogramInfo(mIDLHistogram); moduleDisplayInterface->getPanelResolution(); } uint32_t histogram::HistogramMediator::getFrameCount() { @@ -60,8 +61,8 @@ histogram::HistogramErrorCode histogram::HistogramMediator::requestHist() { return histogram::HistogramErrorCode::ENABLE_HIST_ERROR; } { - std::unique_lock<std::mutex> lk(mIDLHistogram.mDataCollectingMutex); - mIDLHistogram.mHistReq_pending = true; + std::unique_lock<std::mutex> lk(mIDLHistogram->mDataCollectingMutex); + mIDLHistogram->mHistReq_pending = true; } return histogram::HistogramErrorCode::NONE; } @@ -94,25 +95,25 @@ int histogram::HistogramMediator::calculateThreshold(const RoiRect &roi) { histogram::HistogramErrorCode histogram::HistogramMediator::setRoiWeightThreshold( const RoiRect roi, const Weight weight, const HistogramPos pos) { int threshold = calculateThreshold(roi); - mIDLHistogram.setHistogramROI((uint16_t)roi.left, (uint16_t)roi.top, - (uint16_t)(roi.right - roi.left), - (uint16_t)(roi.bottom - roi.top)); - mIDLHistogram.setHistogramWeights(weight.weightR, weight.weightG, weight.weightB); - mIDLHistogram.setHistogramThreshold(threshold); - mIDLHistogram.setHistogramPos(pos); + mIDLHistogram->setHistogramROI((uint16_t)roi.left, (uint16_t)roi.top, + (uint16_t)(roi.right - roi.left), + (uint16_t)(roi.bottom - roi.top)); + mIDLHistogram->setHistogramWeights(weight.weightR, weight.weightG, weight.weightB); + mIDLHistogram->setHistogramThreshold(threshold); + mIDLHistogram->setHistogramPos(pos); return histogram::HistogramErrorCode::NONE; } histogram::HistogramErrorCode histogram::HistogramMediator::collectRoiLuma( std::vector<char16_t> *buf) { - std::unique_lock<std::mutex> lk(mIDLHistogram.mDataCollectingMutex); + std::unique_lock<std::mutex> lk(mIDLHistogram->mDataCollectingMutex); - mIDLHistogram.mHistData_cv.wait_for(lk, std::chrono::milliseconds(50), [this]() { - return (!isDisplayPowerOff() && !mIDLHistogram.mHistReq_pending); + mIDLHistogram->mHistData_cv.wait_for(lk, std::chrono::milliseconds(50), [this]() { + return (!isDisplayPowerOff() && !mIDLHistogram->mHistReq_pending); }); - if (mIDLHistogram.mHistReq_pending == false) setSampleFrameCounter(getFrameCount()); - buf->assign(mIDLHistogram.mHistData, mIDLHistogram.mHistData + HISTOGRAM_BINS_SIZE); + if (mIDLHistogram->mHistReq_pending == false) setSampleFrameCounter(getFrameCount()); + buf->assign(mIDLHistogram->mHistData, mIDLHistogram->mHistData + HISTOGRAM_BINS_SIZE); return histogram::HistogramErrorCode::NONE; } |