PC扩展屏支持硬光标特性

Signed-off-by: lili(@lili-lili-lili) <lili304@h-partners.com>

Change-Id: 1c7d67a726ee0a917498fb0df1f5135ccf26af17
This commit is contained in:
lili(@lili-lili-lili) 2024-10-21 11:14:22 +08:00
parent e84f8141e7
commit c9704994a5
22 changed files with 328 additions and 30 deletions

View File

@ -351,6 +351,28 @@ static void ClipRegion(Drawing::Canvas& canvas, Drawing::Region& region, bool cl
}
}
bool RSDisplayRenderNodeDrawable::HardCursorCreateLayer(std::shared_ptr<RSProcessor> processor)
{
bool ret = false;
auto& hardCursorDrawables = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardCursorDrawables();
RS_OPTIONAL_TRACE_NAME_FMT("HardCursorCreateLayer size:%d", static_cast<int>(hardCursorDrawables.size()));
for (const auto& drawable : hardCursorDrawables) {
if (drawable.id != GetId() || !drawable.drawablePtr) {
continue;
}
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(drawable.drawablePtr->GetRenderParams().get());
if (!surfaceParams) {
continue;
}
auto surfaceDrawable = std::static_pointer_cast<RSSurfaceRenderNodeDrawable>(drawable.drawablePtr);
if (surfaceParams->IsHardCursorEnabled()) {
processor->CreateLayerForRenderThread(*surfaceDrawable);
ret = true;
}
}
return ret;
}
bool RSDisplayRenderNodeDrawable::CheckDisplayNodeSkip(
RSDisplayRenderParams& params, std::shared_ptr<RSProcessor> processor)
{
@ -367,8 +389,9 @@ bool RSDisplayRenderNodeDrawable::CheckDisplayNodeSkip(
RSUniRenderThread::Instance().SetSkipJankAnimatorFrame(true);
#endif
auto pendingDrawables = RSUifirstManager::Instance().GetPendingPostDrawables();
auto isHardCursor = HardCursorCreateLayer(processor);
if (!RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetForceCommitLayer() &&
pendingDrawables.size() == 0) {
pendingDrawables.size() == 0 && !isHardCursor) {
RS_TRACE_NAME("DisplayNodeSkip skip commit");
return true;
}
@ -518,7 +541,14 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
}
drawable->GetRenderParams()->SetLayerCreated(false);
}
auto& hardCursorDrawables = uniParam->GetHardCursorDrawables();
for (const auto& drawable : hardCursorDrawables) {
if (drawable.id != GetId() || !drawable.drawablePtr ||
!drawable.drawablePtr->GetRenderParams()) {
continue;
}
drawable.drawablePtr->GetRenderParams()->SetLayerCreated(false);
}
// if screen power off, skip on draw, needs to draw one more frame.
if (params && RSUniRenderUtil::CheckRenderSkipIfScreenOff(true, params->GetScreenId())) {
return;
@ -805,6 +835,7 @@ void RSDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
processor->CreateLayerForRenderThread(*surfaceDrawable);
}
}
HardCursorCreateLayer(processor);
SetDirtyRects(damageRegionrects);
processor->ProcessDisplaySurfaceForRenderThread(*this);
RSUifirstManager::Instance().CreateUIFirstLayer(processor);
@ -1396,6 +1427,20 @@ void RSDisplayRenderNodeDrawable::FindHardwareEnabledNodes(RSDisplayRenderParams
params.GetHardwareEnabledDrawables().emplace_back(drawable);
}
}
auto& hardCursorDrawables = RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardCursorDrawables();
for (const auto& drawable : hardCursorDrawables) {
if (drawable.id != GetId() || !drawable.drawablePtr) {
continue;
}
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(drawable.drawablePtr->GetRenderParams().get());
if (!surfaceParams) {
continue;
}
auto surfaceDrawable = std::static_pointer_cast<RSSurfaceRenderNodeDrawable>(drawable.drawablePtr);
if (surfaceParams->IsHardCursorEnabled()) {
params.GetHardwareEnabledTopDrawables().emplace_back(drawable.drawablePtr);
}
}
}

View File

@ -159,6 +159,7 @@ private:
void UpdateDisplayDirtyManager(int32_t bufferage, bool useAlignedDirtyRegion = false);
static void CheckFilterCacheFullyCovered(RSSurfaceRenderParams& surfaceParams, RectI screenRect);
static void CheckAndUpdateFilterCacheOcclusion(RSDisplayRenderParams& params, ScreenInfo& screenInfo);
bool HardCursorCreateLayer(std::shared_ptr<RSProcessor> processor);
// For P3-scRGB Control
bool EnablescRGBForP3AndUiFirst(const GraphicColorGamut& currentGamut);

View File

@ -294,6 +294,12 @@ bool RSSurfaceRenderNodeDrawable::IsHardwareEnabled()
return false;
}
bool RSSurfaceRenderNodeDrawable::IsHardwareEnabledTopSurface() const
{
return surfaceNodeType_ == RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE &&
GetName() == "pointer window" && RSSystemProperties::GetHardCursorEnabled();
}
void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
{
if (!ShouldPaint()) {
@ -349,6 +355,10 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
if (hasSkipCacheLayer_ && curDrawingCacheRoot_) {
curDrawingCacheRoot_->SetSkipCacheLayer(true);
}
if (surfaceParams->IsHardCursorEnabled()) {
RS_TRACE_NAME_FMT("RSSurfaceRenderNodeDrawable::OnDraw hardcursor skip SurfaceName:%s", name_.c_str());
return;
}
Drawing::Region curSurfaceDrawRegion = CalculateVisibleRegion(*uniParam, *surfaceParams, *this, isUiFirstNode);
@ -741,7 +751,8 @@ GraphicColorGamut RSSurfaceRenderNodeDrawable::GetAncestorDisplayColorGamut(cons
void RSSurfaceRenderNodeDrawable::DealWithSelfDrawingNodeBuffer(
RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams)
{
if (surfaceParams.GetHardwareEnabled() && !RSUniRenderThread::IsInCaptureProcess()) {
if ((surfaceParams.GetHardwareEnabled() || surfaceParams.IsHardCursorEnabled()) &&
!RSUniRenderThread::IsInCaptureProcess()) {
if (!IsHardwareEnabledTopSurface() && !surfaceParams.IsLayerTop()) {
ClipHoleForSelfDrawingNode(canvas, surfaceParams);
}

View File

@ -234,10 +234,8 @@ public:
}
void RegisterDeleteBufferListenerOnSync(sptr<IConsumerSurface> consumer) override;
#endif
bool IsHardwareEnabledTopSurface() const
{
return surfaceNodeType_ == RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE && GetName() == "pointer window";
}
bool IsHardwareEnabledTopSurface() const;
inline bool CheckCacheSurface()
{

View File

@ -1558,6 +1558,15 @@ void RSMainThread::CollectInfoForHardwareComposer()
});
}
void RSMainThread::CollectInfoForHardCursor(NodeId id,
DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr cursorDrawable)
{
if (!isUniRender_) {
return;
}
hardCursorDrawables_.push_back({ id, cursorDrawable });
}
bool RSMainThread::IsLastFrameUIFirstEnabled(NodeId appNodeId) const
{
for (auto& node : subThreadNodes_) {
@ -1995,6 +2004,7 @@ void RSMainThread::UniRender(std::shared_ptr<RSBaseRenderNode> rootNode)
WaitUntilUploadTextureTaskFinishedForGL();
renderThreadParams_->selfDrawables_ = std::move(selfDrawables_);
renderThreadParams_->hardwareEnabledTypeDrawables_ = std::move(hardwareEnabledDrwawables_);
renderThreadParams_->hardCursorDrawables_ = std::move(hardCursorDrawables_);
return;
}
}
@ -2015,6 +2025,7 @@ void RSMainThread::UniRender(std::shared_ptr<RSBaseRenderNode> rootNode)
uniVisitor->SurfaceOcclusionCallbackToWMS();
rsVsyncRateReduceManager_.SetUniVsync();
renderThreadParams_->selfDrawables_ = std::move(selfDrawables_);
renderThreadParams_->hardCursorDrawables_ = std::move(hardCursorDrawables_);
renderThreadParams_->hardwareEnabledTypeDrawables_ = std::move(hardwareEnabledDrwawables_);
renderThreadParams_->isOverDrawEnabled_ = isOverDrawEnabledOfCurFrame_;
renderThreadParams_->isDrawingCacheDfxEnabled_ = isDrawingCacheDfxEnabledOfCurFrame_;
@ -3837,6 +3848,7 @@ void RSMainThread::ResetHardwareEnabledState(bool isUniRender)
hardwareEnabledDrwawables_.clear();
selfDrawingNodes_.clear();
selfDrawables_.clear();
hardCursorDrawables_.clear();
}
}

View File

@ -362,6 +362,8 @@ public:
bool IsHardwareEnabledNodesNeedSync();
bool IsOcclusionNodesNeedSync(NodeId id, bool useCurWindow);
void CollectInfoForHardCursor(NodeId id,
DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr cursorDrawable);
void CallbackDrawContextStatusToWMS(bool isUniRender = false);
void SetHardwareTaskNum(uint32_t num);
@ -628,6 +630,7 @@ private:
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> selfDrawables_;
bool isHardwareForcedDisabled_ = false; // if app node has shadow or filter, disable hardware composer for all
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledDrwawables_;
std::vector<HardCursorInfo> hardCursorDrawables_;
// for client node tree dump
struct NodeTreeDumpTask {

View File

@ -802,6 +802,9 @@ void RSUniRenderVisitor::QuickPrepareSurfaceRenderNode(RSSurfaceRenderNode& node
CheckIsGpuOverDrawBufferOptimizeNode(node);
}
PostPrepare(node, !isSubTreeNeedPrepare);
if (node.IsHardwareEnabledTopSurface() && node.shared_from_this()) {
UpdateHwcNodeProperty(node.shared_from_this()->ReinterpretCastTo<RSSurfaceRenderNode>());
}
CheckMergeFilterDirtyByIntersectWithDirty(curSurfaceNoBelowDirtyFilter_, false);
curAlpha_ = prevAlpha;
prepareClipRect_ = prepareClipRect;
@ -1255,6 +1258,10 @@ bool RSUniRenderVisitor::BeforeUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node)
if (node.GetRSSurfaceHandler() && node.GetRSSurfaceHandler()->GetBuffer()) {
node.SetBufferRelMatrix(RSUniRenderUtil::GetMatrixOfBufferToRelRect(node));
}
if (node.IsHardwareEnabledTopSurface()) {
RSMainThread::Instance()->CollectInfoForHardCursor(curDisplayNode_->GetId(),
node.GetRenderDrawable());
}
node.setQosCal((RSMainThread::Instance()->GetDeviceType() == DeviceType::PC) &&
RSSystemParameters::GetVSyncControlEnabled());
return true;
@ -1292,6 +1299,9 @@ bool RSUniRenderVisitor::AfterUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node)
}
// 3. Update HwcNode Info for appNode
UpdateHwcNodeInfoForAppNode(node);
if (node.IsHardwareEnabledTopSurface()) {
UpdateSrcRect(node, geoPtr->GetAbsMatrix(), geoPtr->GetAbsRect());
}
return true;
}
@ -1378,12 +1388,14 @@ void RSUniRenderVisitor::UpdateSrcRect(RSSurfaceRenderNode& node,
void RSUniRenderVisitor::UpdateDstRect(RSSurfaceRenderNode& node, const RectI& absRect, const RectI& clipRect)
{
auto dstRect = absRect;
// If the screen is expanded, intersect the destination rectangle with the screen rectangle
dstRect = dstRect.IntersectRect(RectI(curDisplayNode_->GetDisplayOffsetX(), curDisplayNode_->GetDisplayOffsetY(),
screenInfo_.width, screenInfo_.height));
// Remove the offset of the screen
dstRect.left_ = dstRect.left_ - curDisplayNode_->GetDisplayOffsetX();
dstRect.top_ = dstRect.top_ - curDisplayNode_->GetDisplayOffsetY();
if (!node.IsHardwareEnabledTopSurface()) {
// If the screen is expanded, intersect the destination rectangle with the screen rectangle
dstRect = dstRect.IntersectRect(RectI(curDisplayNode_->GetDisplayOffsetX(),
curDisplayNode_->GetDisplayOffsetY(), screenInfo_.width, screenInfo_.height));
// Remove the offset of the screen
dstRect.left_ = dstRect.left_ - curDisplayNode_->GetDisplayOffsetX();
dstRect.top_ = dstRect.top_ - curDisplayNode_->GetDisplayOffsetY();
}
// If the node is a hardware-enabled type, intersect its destination rectangle with the prepare clip rectangle
if (node.IsHardwareEnabledType()) {
dstRect = dstRect.IntersectRect(clipRect);
@ -1763,7 +1775,6 @@ void RSUniRenderVisitor::UpdateHwcNodeDirtyRegionAndCreateLayer(std::shared_ptr<
if (hwcNodes.empty()) {
return;
}
std::shared_ptr<RSSurfaceRenderNode> pointWindow;
std::vector<std::shared_ptr<RSSurfaceRenderNode>> topLayers;
for (auto hwcNode : hwcNodes) {
auto hwcNodePtr = hwcNode.lock();
@ -1775,10 +1786,6 @@ void RSUniRenderVisitor::UpdateHwcNodeDirtyRegionAndCreateLayer(std::shared_ptr<
topLayers.emplace_back(hwcNodePtr);
continue;
}
if (node->IsHardwareEnabledTopSurface()) {
pointWindow = hwcNodePtr;
continue;
}
if (hasUniRenderHdrSurface_) {
hwcNodePtr->SetHardwareForcedDisabledState(true);
}
@ -1794,9 +1801,85 @@ void RSUniRenderVisitor::UpdateHwcNodeDirtyRegionAndCreateLayer(std::shared_ptr<
if (!topLayers.empty()) {
UpdateTopLayersDirtyStatus(topLayers);
}
if (pointWindow) {
UpdatePointWindowDirtyStatus(pointWindow);
}
bool RSUniRenderVisitor::HasMirrorDisplay() const
{
const std::shared_ptr<RSBaseRenderNode> rootNode =
RSMainThread::Instance()->GetContext().GetGlobalRootRenderNode();
if (rootNode == nullptr || rootNode->GetChildrenCount() <= 1) {
return false;
}
for (auto& child : *rootNode->GetSortedChildren()) {
if (!child || !child->IsInstanceOf<RSDisplayRenderNode>()) {
continue;
}
auto displayNode = child->ReinterpretCastTo<RSDisplayRenderNode>();
if (!displayNode) {
continue;
}
if (displayNode->IsMirrorDisplay()) {
return true;
}
}
return false;
}
bool RSUniRenderVisitor::HasVirtualDisplay() const
{
const std::shared_ptr<RSBaseRenderNode> rootNode =
RSMainThread::Instance()->GetContext().GetGlobalRootRenderNode();
if (rootNode == nullptr || rootNode->GetChildrenCount() <= 1) {
return false;
}
bool hasVirtualDisplay = false;
for (auto& child : *rootNode->GetSortedChildren()) {
if (!child || !child->IsInstanceOf<RSDisplayRenderNode>()) {
continue;
}
auto displayNode = child->ReinterpretCastTo<RSDisplayRenderNode>();
if (!displayNode) {
continue;
}
auto screenManager = CreateOrGetScreenManager();
if (!screenManager) {
return false;
}
RSScreenType screenType;
screenManager->GetScreenType(displayNode->GetScreenId(), screenType);
if (screenType == RSScreenType::VIRTUAL_TYPE_SCREEN) {
hasVirtualDisplay = true;
}
}
return hasVirtualDisplay;
}
bool RSUniRenderVisitor::CheckIfHardCursorEnable() const
{
if (RSMainThread::Instance()->GetDeviceType() != DeviceType::PC) {
return false;
}
std::shared_ptr<RSBaseRenderNode> rootNode =
RSMainThread::Instance()->GetContext().GetGlobalRootRenderNode();
if (rootNode == nullptr) {
RS_LOGE("CheckIfHardCursorEnable rootNode is nullptr");
return false;
}
auto childCount = rootNode->GetChildrenCount();
if (childCount == 1) {
return true;
} else if (childCount < 1) {
return false;
}
bool hasMirrorDisplay = HasMirrorDisplay();
bool hasVirtualDisplay = HasVirtualDisplay();
RS_LOGD("CheckIfHardCursorEnable childCount:%{public}d, hasMirrorDisplay:%{public}d, hasVirtualDisplay:%{public}d",
childCount, hasMirrorDisplay, hasVirtualDisplay);
// For expand physical screen.
if (!hasMirrorDisplay || (hasMirrorDisplay && hasVirtualDisplay)) {
return true;
}
return false;
}
void RSUniRenderVisitor::UpdatePointWindowDirtyStatus(std::shared_ptr<RSSurfaceRenderNode>& pointWindow)
@ -1805,9 +1888,10 @@ void RSUniRenderVisitor::UpdatePointWindowDirtyStatus(std::shared_ptr<RSSurfaceR
if (pointSurfaceHandler) {
// globalZOrder_ + 2 is displayNode layer, point window must be at the top.
pointSurfaceHandler->SetGlobalZOrder(globalZOrder_ + 2);
pointWindow->SetHardwareForcedDisabledState(!IsHardwareComposerEnabled() || !pointWindow->ShouldPaint());
auto checkHardCursorEnable = CheckIfHardCursorEnable();
pointWindow->SetHardwareForcedDisabledState(true);
auto transform = RSUniRenderUtil::GetLayerTransform(*pointWindow, screenInfo_);
pointWindow->UpdateHwcNodeLayerInfo(transform);
pointWindow->UpdateHwcNodeLayerInfo(transform, checkHardCursorEnable);
if (RSMainThread::Instance()->GetDeviceType() == DeviceType::PC) {
pointerWindowManager_.UpdatePointerDirtyToGlobalDirty(pointWindow, curDisplayNode_);
}
@ -1869,6 +1953,9 @@ void RSUniRenderVisitor::UpdateSurfaceDirtyAndGlobalDirty()
RSMainThread::Instance()->GetContext().AddPendingSyncNode(nodePtr);
// 0. update hwc node dirty region and create layer
UpdateHwcNodeDirtyRegionAndCreateLayer(surfaceNode);
if (surfaceNode->IsHardwareEnabledTopSurface()) {
UpdatePointWindowDirtyStatus(surfaceNode);
}
// 1. calculate abs dirtyrect and update partialRenderParams
// currently only sync visible region info
surfaceNode->UpdatePartialRenderParams();

View File

@ -134,6 +134,10 @@ public:
screenInfo_ = screenInfo;
}
bool CheckIfHardCursorEnable() const;
bool HasMirrorDisplay() const;
bool HasVirtualDisplay() const;
// Use in updating hwcnode hardware state with background alpha
void UpdateHardwareStateByHwcNodeBackgroundAlpha(const std::vector<std::weak_ptr<RSSurfaceRenderNode>>& hwcNodes);

View File

@ -268,6 +268,7 @@ public:
virtual bool IsLeashWindow() const { return true; }
virtual bool IsAppWindow() const { return false; }
virtual bool GetHardwareEnabled() const { return false; }
virtual bool IsHardCursorEnabled() const { return false; }
virtual bool GetLayerCreated() const { return false; }
virtual bool GetLastFrameHardwareEnabled() const { return false; }
virtual void SetLayerCreated(bool layerCreated) {}

View File

@ -44,6 +44,10 @@ struct CaptureParam {
isFirstNode_(isFirstNode),
isSystemCalling_(isSystemCalling) {}
};
struct HardCursorInfo {
NodeId id = INVALID_NODEID;
DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr drawablePtr = nullptr;
};
class RSB_EXPORT RSRenderThreadParams {
public:
RSRenderThreadParams() = default;
@ -124,7 +128,11 @@ public:
return hardwareEnabledTypeDrawables_;
}
const std::vector<HardCursorInfo>& GetHardCursorDrawables() const
{
return hardCursorDrawables_;
}
void SetPendingScreenRefreshRate(uint32_t rate)
{
pendingScreenRefreshRate_ = rate;
@ -373,6 +381,7 @@ private:
DirtyRegionDebugType dirtyRegionDebugType_ = DirtyRegionDebugType::DISABLED;
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> selfDrawables_;
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledTypeDrawables_;
std::vector<HardCursorInfo> hardCursorDrawables_;
bool isForceCommitLayer_ = false;
bool hasMirrorDisplay_ = false;
// accumulatedDirtyRegion to decide whether to skip tranasparent nodes.

View File

@ -327,6 +327,8 @@ public:
const RSLayerInfo& GetLayerInfo() const override;
void SetHardwareEnabled(bool enabled);
bool GetHardwareEnabled() const override;
void SetHardCursorEnabled(bool enabled);
bool IsHardCursorEnabled() const override;
void SetLastFrameHardwareEnabled(bool enabled);
bool GetLastFrameHardwareEnabled() const override;
void SetFixRotationByUser(bool flag);
@ -538,6 +540,7 @@ private:
Rect damageRect_ = {0, 0, 0, 0};
#endif
bool isHardwareEnabled_ = false;
bool isHardCursorEnabled_ = false;
bool isLastFrameHardwareEnabled_ = false;
bool isFixRotationByUser_ = false;
bool isInFixedRotation_ = false;

View File

@ -113,10 +113,7 @@ public:
return isNodeDirty_;
}
bool IsHardwareEnabledTopSurface() const
{
return nodeType_ == RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE && GetName() == "pointer window";
}
bool IsHardwareEnabledTopSurface() const;
void SetLayerTop(bool isTop);
@ -132,7 +129,7 @@ public:
return false;
}
return (nodeType_ == RSSurfaceNodeType::SELF_DRAWING_NODE && isHardwareEnabledNode_) ||
IsHardwareEnabledTopSurface() || IsLayerTop();
IsLayerTop();
}
void SetHardwareEnabled(bool isEnabled, SelfDrawingNodeType selfDrawingType = SelfDrawingNodeType::DEFAULT)
@ -416,7 +413,7 @@ public:
void ProcessAnimatePropertyAfterChildren(RSPaintFilterCanvas& canvas) override;
void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override;
bool IsSCBNode() const;
void UpdateHwcNodeLayerInfo(GraphicTransformType transform);
void UpdateHwcNodeLayerInfo(GraphicTransformType transform, bool isHardCursorEnable = false);
void UpdateHardwareDisabledState(bool disabled);
void SetHwcChildrenDisabledStateByUifirst();

View File

@ -180,6 +180,7 @@ public:
static HgmRefreshRates GetHgmRefreshRatesEnabled();
static void SetHgmRefreshRateModesEnabled(std::string param);
static HgmRefreshRateModes GetHgmRefreshRateModesEnabled();
static bool GetHardCursorEnabled();
static float GetAnimationScale();
static bool GetProxyNodeDebugEnabled();

View File

@ -167,6 +167,20 @@ bool RSSurfaceRenderParams::GetHardwareEnabled() const
return isHardwareEnabled_;
}
void RSSurfaceRenderParams::SetHardCursorEnabled(bool enabled)
{
if (isHardCursorEnabled_ == enabled) {
return;
}
isHardCursorEnabled_ = enabled;
needSync_ = true;
}
bool RSSurfaceRenderParams::IsHardCursorEnabled() const
{
return isHardCursorEnabled_;
}
void RSSurfaceRenderParams::SetLastFrameHardwareEnabled(bool enabled)
{
if (isLastFrameHardwareEnabled_ == enabled) {
@ -452,6 +466,7 @@ void RSSurfaceRenderParams::OnSync(const std::unique_ptr<RSRenderParams>& target
targetSurfaceParams->oldDirtyInSurface_ = oldDirtyInSurface_;
targetSurfaceParams->transparentRegion_ = transparentRegion_;
targetSurfaceParams->isHardwareEnabled_ = isHardwareEnabled_;
targetSurfaceParams->isHardCursorEnabled_ = isHardCursorEnabled_;
targetSurfaceParams->isLastFrameHardwareEnabled_ = isLastFrameHardwareEnabled_;
targetSurfaceParams->isFixRotationByUser_ = isFixRotationByUser_;
targetSurfaceParams->isInFixedRotation_ = isInFixedRotation_;

View File

@ -1143,6 +1143,12 @@ void RSSurfaceRenderNode::SetLayerTop(bool isTop)
AddToPendingSyncList();
}
bool RSSurfaceRenderNode::IsHardwareEnabledTopSurface() const
{
return ShouldPaint() && nodeType_ == RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE &&
GetName() == "pointer window" && RSSystemProperties::GetHardCursorEnabled();
}
void RSSurfaceRenderNode::SetColorSpace(GraphicColorGamut colorSpace)
{
colorSpace_ = colorSpace;
@ -1550,7 +1556,7 @@ bool RSSurfaceRenderNode::IsSCBNode() const
return surfaceWindowType_ != SurfaceWindowType::SYSTEM_SCB_WINDOW;
}
void RSSurfaceRenderNode::UpdateHwcNodeLayerInfo(GraphicTransformType transform)
void RSSurfaceRenderNode::UpdateHwcNodeLayerInfo(GraphicTransformType transform, bool isHardCursorEnable)
{
#ifndef ROSEN_CROSS_PLATFORM
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
@ -1596,6 +1602,7 @@ void RSSurfaceRenderNode::UpdateHwcNodeLayerInfo(GraphicTransformType transform)
#endif
surfaceParams->SetLayerInfo(layer);
surfaceParams->SetHardwareEnabled(!IsHardwareForcedDisabled());
surfaceParams->SetHardCursorEnabled(IsHardwareEnabledTopSurface() && isHardCursorEnable);
surfaceParams->SetLastFrameHardwareEnabled(isLastFrameHwcEnabled_);
surfaceParams->SetInFixedRotation(isInFixedRotation_);
// 1 means need source tuning

View File

@ -221,6 +221,11 @@ HgmRefreshRateModes RSSystemProperties::GetHgmRefreshRateModesEnabled()
return {};
}
bool RSSystemProperties::GetHardCursorEnabled()
{
return false;
}
bool RSSystemProperties::GetSkipForAlphaZeroEnabled()
{
return {};

View File

@ -511,6 +511,14 @@ HgmRefreshRateModes RSSystemProperties::GetHgmRefreshRateModesEnabled()
return static_cast<HgmRefreshRateModes>(ConvertToInt(enable, 0));
}
bool RSSystemProperties::GetHardCursorEnabled()
{
static CachedHandle g_Handle = CachedParameterCreate("rosen.hardCursor.enabled", "1");
int changed = 0;
const char *enable = CachedParameterGetChanged(g_Handle, &changed);
return ConvertToInt(enable, 1) != 0;
}
bool RSSystemProperties::GetSkipForAlphaZeroEnabled()
{
static CachedHandle g_Handle = CachedParameterCreate("persist.skipForAlphaZero.enabled", "1");

View File

@ -221,6 +221,11 @@ HgmRefreshRateModes RSSystemProperties::GetHgmRefreshRateModesEnabled()
return {};
}
bool RSSystemProperties::GetHardCursorEnabled()
{
return false;
}
bool RSSystemProperties::GetSkipForAlphaZeroEnabled()
{
return {};

View File

@ -412,6 +412,27 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, CalculateVirtualDirtyForWiredScreen006
ASSERT_EQ(damageRects.size(), 0);
}
/**
* @tc.name: HardCursorCreateLayer
* @tc.desc: Test HardCursorCreateLayer
* @tc.type: FUNC
* @tc.require: #IAX2SN
*/
HWTEST_F(RSDisplayRenderNodeDrawableTest, HardCursorCreateLayerTest, TestSize.Level1)
{
ASSERT_NE(renderNode_, nullptr);
ASSERT_NE(displayDrawable_, nullptr);
ASSERT_NE(displayDrawable_->renderParams_, nullptr);
auto params = static_cast<RSDisplayRenderParams*>(displayDrawable_->GetRenderParams().get());
ASSERT_NE(params, nullptr);
auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType());
ASSERT_NE(processor, nullptr);
auto result = displayDrawable_->HardCursorCreateLayer(processor);
ASSERT_EQ(result, false);
}
/**
* @tc.name: CheckDisplayNodeSkip
* @tc.desc: Test CheckDisplayNodeSkip

View File

@ -1167,6 +1167,11 @@ HWTEST_F(RSSurfaceRenderNodeDrawableTest, DealWithSelfDrawingNodeBufferTest001,
surfaceDrawable_->DealWithSelfDrawingNodeBuffer(canvas, *surfaceParams);
ASSERT_TRUE(surfaceParams->GetHardwareEnabled());
surfaceParams->isHardCursorEnabled_ = true;
surfaceDrawable_->DealWithSelfDrawingNodeBuffer(canvas, *surfaceParams);
ASSERT_TRUE(surfaceParams->IsHardCursorEnabled());
ASSERT_FALSE(surfaceDrawable_->IsHardwareEnabledTopSurface());
surfaceParams->isLayerTop_ = true;
surfaceDrawable_->DealWithSelfDrawingNodeBuffer(canvas, *surfaceParams);
ASSERT_TRUE(surfaceParams->IsLayerTop());

View File

@ -4499,4 +4499,46 @@ HWTEST_F(RSUniRenderVisitorTest, IsFirstFrameOfOverdrawSwitch, TestSize.Level1)
ASSERT_NE(rsUniRenderVisitor, nullptr);
ASSERT_EQ(rsUniRenderVisitor->IsFirstFrameOfOverdrawSwitch(), false);
}
/**
* @tc.name: HasMirrorDisplay
* @tc.desc: Test HasMirrorDisplay
* @tc.type: FUNC
* @tc.require: issueIAX2SN
*/
HWTEST_F(RSUniRenderVisitorTest, HasMirrorDisplayTest, TestSize.Level1)
{
auto mainThread = RSMainThread::Instance();
ASSERT_NE(mainThread, nullptr);
auto result = mainThread->HasMirrorDisplay();
ASSERT_EQ(result, false);
}
/**
* @tc.name: HasVirtualDisplay
* @tc.desc: Test HasVirtualDisplay
* @tc.type: FUNC
* @tc.require: issueIAX2SN
*/
HWTEST_F(RSUniRenderVisitorTest, HasVirtualDisplayTest, TestSize.Level1)
{
auto rsUniRenderVisitor = std::make_shared<RSUniRenderVisitor>();
ASSERT_NE(rsUniRenderVisitor, nullptr);
auto result = rsUniRenderVisitor->HasVirtualDisplay();
ASSERT_EQ(result, false);
}
/**
* @tc.name: CheckIfHardCursorEnable
* @tc.desc: Test CheckIfHardCursorEnable
* @tc.type: FUNC
* @tc.require: issueIAX2SN
*/
HWTEST_F(RSUniRenderVisitorTest, CheckIfHardCursorEnableTest, TestSize.Level1)
{
auto rsUniRenderVisitor = std::make_shared<RSUniRenderVisitor>();
ASSERT_NE(rsUniRenderVisitor, nullptr);
auto result = rsUniRenderVisitor->CheckIfHardCursorEnable();
ASSERT_EQ(result, false);
}
} // OHOS::Rosen

View File

@ -290,4 +290,22 @@ HWTEST_F(RSSurfaceRenderParamsTest, SetNeedCacheSurface, TestSize.Level1)
EXPECT_EQ(params.GetNeedCacheSurface(), false);
EXPECT_EQ(params.needSync_, true);
}
/**
* @tc.name: SetHardCursorEnabled
* @tc.desc: SetHardCursorEnabled and IsHardCursorEnabled test
* @tc.type:FUNC
* @tc.require: issueIAX2SN
*/
HWTEST_F(RSSurfaceRenderParamsTest, SetHardCursorEnabledTest, TestSize.Level1)
{
RSSurfaceRenderParams params(114);
params.SetHardCursorEnabled(false);
EXPECT_EQ(params.needSync_, false);
EXPECT_EQ(params.IsHardCursorEnabled(), false);
params.SetHardCursorEnabled(true);
EXPECT_EQ(params.needSync_, true);
EXPECT_EQ(params.IsHardCursorEnabled(), true);
}
}