!3750 优化displayNode skip场景 不必要的 bufferRelease

Merge pull request !3750 from Klaus_q/master_hwc
This commit is contained in:
openharmony_ci 2023-02-27 06:21:17 +00:00 committed by Gitee
commit 426315f705
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 36 additions and 5 deletions

View File

@ -81,8 +81,6 @@ void RSHardwareThread::ReleaseBuffer(sptr<SurfaceBuffer> buffer, sptr<SyncFence>
RS_TRACE_NAME("RSHardwareThread::ReleaseBuffer");
auto ret = cSurface->ReleaseBuffer(buffer, releaseFence);
if (ret != OHOS::SURFACE_ERROR_OK) {
RS_LOGE("RsDebug RSHardwareThread::ReleaseBuffer failed(ret: %d)!",
buffer->GetSeqNum(), ret);
return;
}
// reset prevBuffer if we release it successfully,

View File

@ -81,6 +81,18 @@ void RSUniRenderComposerAdapter::CommitLayers(const std::vector<LayerInfoPtr>& l
RSHardwareThread::Instance().CommitAndReleaseLayers(output_, layers);
}
void RSUniRenderComposerAdapter::SetPreBufferInfo(RSSurfaceHandler& surfaceHandler, ComposeInfo& info) const
{
if (surfaceHandler.IsPreBufferReleased()) {
// reset prevBuffer if same layer has been committed successfully,
// to avoid releasing the same buffer next frame in some situations.
info.preBuffer = nullptr;
} else {
info.preBuffer = surfaceHandler.GetPreBuffer().buffer;
surfaceHandler.SetPreBufferReleased(true);
}
}
// private func, for RSDisplayRenderNode
ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDisplayRenderNode& node) const
{
@ -98,7 +110,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDisplayRenderNode& no
info.zOrder = static_cast<int32_t>(node.GetGlobalZOrder());
info.alpha.enGlobalAlpha = true;
info.alpha.gAlpha = 255;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
info.buffer = buffer;
info.fence = node.GetAcquireFence();
info.blendType = GRAPHIC_BLEND_SRCOVER;
@ -121,7 +133,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSDrivenSurfaceRenderNo
info.zOrder = static_cast<int32_t>(node.GetGlobalZOrder());
info.alpha.enGlobalAlpha = true;
info.alpha.gAlpha = 255;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
info.buffer = buffer;
info.fence = node.GetAcquireFence();
info.blendType = GRAPHIC_BLEND_SRCOVER;
@ -299,7 +311,7 @@ ComposeInfo RSUniRenderComposerAdapter::BuildComposeInfo(RSSurfaceRenderNode& no
info.blendType = node.GetBlendType();
const auto& buffer = node.GetBuffer();
info.buffer = buffer;
info.preBuffer = node.GetPreBuffer().buffer;
SetPreBufferInfo(node, info);
GetComposerInfoSrcRect(info, node);
info.needClient = GetComposerInfoNeedClient(info, node);
DealWithNodeGravity(node, info);

View File

@ -63,6 +63,7 @@ private:
static void GetComposerInfoSrcRect(ComposeInfo &info, const RSSurfaceRenderNode& node);
bool GetComposerInfoNeedClient(const ComposeInfo &info, RSRenderNode& node) const;
bool CheckStatusBeforeCreateLayer(RSSurfaceRenderNode& node) const;
void SetPreBufferInfo(RSSurfaceHandler& surfaceHandler, ComposeInfo& info) const;
std::shared_ptr<HdiOutput> output_;
ScreenInfo screenInfo_;

View File

@ -921,6 +921,14 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
if (isOpDropped_ && dirtySurfaceNodeMap_.empty() && !curDisplayDirtyManager_->IsDirty()) {
RS_LOGD("DisplayNode skip");
RS_TRACE_NAME("DisplayNode skip");
if (!IsHardwareComposerEnabled()) {
return;
}
for (auto& node: hardwareEnabledNodes_) {
if (!node->IsHardwareForcedDisabled()) {
node->MarkCurrentFrameHardwareEnabled();
}
}
return;
}
#endif

View File

@ -89,6 +89,7 @@ public:
buffer_.acquireFence = acquireFence;
buffer_.damageRect = damage;
buffer_.timestamp = timestamp;
isPreBufferReleased_ = false;
}
const sptr<SurfaceBuffer>& GetBuffer() const
@ -128,6 +129,16 @@ public:
return buffer_.timestamp;
}
bool IsPreBufferReleased() const
{
return isPreBufferReleased_;
}
void SetPreBufferReleased(bool isPreBufferReleased)
{
isPreBufferReleased_ = isPreBufferReleased;
}
void CleanCache()
{
buffer_.Reset();
@ -175,6 +186,7 @@ private:
SurfaceBufferEntry preBuffer_;
float globalZOrder_ = 0.0f;
std::atomic<int> bufferAvailableCount_ = 0;
bool isPreBufferReleased_ = false;
};
}
}