!9471 修复consumer attachbuffer后,生产端requestbuffer时cache缺失找不到问题

Merge pull request !9471 from 马靖涛/20240316
This commit is contained in:
openharmony_ci 2024-03-19 14:41:52 +00:00 committed by Gitee
commit 3a235d7908
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 29 additions and 2 deletions

View File

@ -93,6 +93,8 @@ public:
GSError ReadBufferRequestConfig(MessageParcel &parcel) override;
const BufferRequestConfig* GetBufferRequestConfig() const override;
void SetBufferRequestConfig(const BufferRequestConfig &config) override;
void SetConsumerAttachBufferFlag(bool value) override;
bool GetConsumerAttachBufferFlag() override;
private:
void FreeBufferHandleLocked();
@ -107,6 +109,7 @@ private:
int32_t surfaceBufferHeight_ = 0;
mutable std::mutex mutex_;
BufferRequestConfig bufferRequestConfig_;
bool isConsumerAttachBufferFlag_ = false;
};
} // namespace OHOS

View File

@ -391,15 +391,17 @@ GSError BufferQueue::ReuseBuffer(const BufferRequestConfig &config, sptr<BufferE
dbs.insert(dbs.end(), deletingList_.begin(), deletingList_.end());
deletingList_.clear();
if (needRealloc || isShared_ || producerCacheClean_) {
if (needRealloc || isShared_ || producerCacheClean_ || retval.buffer->GetConsumerAttachBufferFlag()) {
BLOGND("RequestBuffer Succ realloc Buffer[%{public}d %{public}d] with new config "\
"qid: %{public}d id: %{public}" PRIu64, config.width, config.height, retval.sequence, uniqueId_);
"qid: %{public}d attachFlag: %{public}d id: %{public}" PRIu64,
config.width, config.height, retval.sequence, retval.buffer->GetConsumerAttachBufferFlag(), uniqueId_);
if (producerCacheClean_) {
producerCacheList_.push_back(retval.sequence);
if (CheckProducerCacheList()) {
SetProducerCacheCleanFlagLocked(false);
}
}
retval.buffer->SetConsumerAttachBufferFlag(false);
} else {
BLOGND("RequestBuffer Succ Buffer[%{public}d %{public}d] in seq id: %{public}d "\
"qid: %{public}" PRIu64 " releaseFence: %{public}d",

View File

@ -184,6 +184,7 @@ GSError ConsumerSurface::AttachBufferToQueue(sptr<SurfaceBuffer>& buffer)
if (buffer == nullptr || consumer_ == nullptr) {
return GSERROR_INVALID_ARGUMENTS;
}
buffer->SetConsumerAttachBufferFlag(true);
return consumer_->AttachBufferToQueue(buffer);
}
@ -192,6 +193,7 @@ GSError ConsumerSurface::DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer)
if (buffer == nullptr || consumer_ == nullptr) {
return GSERROR_INVALID_ARGUMENTS;
}
buffer->SetConsumerAttachBufferFlag(false);
return consumer_->DetachBufferFromQueue(buffer);
}

View File

@ -663,4 +663,16 @@ void SurfaceBufferImpl::SetBufferRequestConfig(const BufferRequestConfig &config
std::lock_guard<std::mutex> lock(mutex_);
bufferRequestConfig_ = config;
}
void SurfaceBufferImpl::SetConsumerAttachBufferFlag(bool value)
{
std::lock_guard<std::mutex> lock(mutex_);
isConsumerAttachBufferFlag_ = value;
}
bool SurfaceBufferImpl::GetConsumerAttachBufferFlag()
{
std::lock_guard<std::mutex> lock(mutex_);
return isConsumerAttachBufferFlag_;
}
} // namespace OHOS

View File

@ -115,6 +115,14 @@ public:
{
(void)config;
};
virtual void SetConsumerAttachBufferFlag(bool value)
{
(void)value;
};
virtual bool GetConsumerAttachBufferFlag()
{
return false;
};
protected:
SurfaceBuffer() {}