mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
!3750 优化displayNode skip场景 不必要的 bufferRelease
Merge pull request !3750 from Klaus_q/master_hwc
This commit is contained in:
commit
426315f705
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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_;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user