检测并设置DRM标记+截图/虚拟屏适配DRM

Signed-off-by: linghao-ji <jilinghao@huawei.com>
Change-Id: Ied71d75ec9a8a71e8bee06667136158ccecfd36f
This commit is contained in:
linghao-ji 2024-04-21 12:26:07 +08:00
parent a2db0264e6
commit a11807a606
18 changed files with 233 additions and 63 deletions

View File

@ -514,11 +514,12 @@ void RSDisplayRenderNodeDrawable::ProcessVirtualScreen(RSDisplayRenderNode& disp
auto mirroredParams = static_cast<RSDisplayRenderParams*>(mirroredNode->GetRenderParams().get());
auto hasSecSurface = mirroredParams->GetDisplayHasSecSurface();
auto hasSkipSurface = mirroredParams->GetDisplayHasSkipSurface();
auto hasProtectedSurface = mirroredParams->GetDisplayHasProtectedSurface();
auto hasCaptureWindow = mirroredParams->GethasCaptureWindow();
auto mirroredProcessor = std::static_pointer_cast<RSUniRenderVirtualProcessor>(processor);
bool hasSpicalLayer = (hasSecSurface[mirroredNode->GetScreenId()] || hasSkipSurface[mirroredNode->GetScreenId()] ||
hasCaptureWindow[mirroredNode->GetScreenId()] || !params.GetScreenInfo().filteredAppSet.empty() ||
RSMainThread::Instance()->IsCurtainScreenOn());
hasProtectedSurface[mirroredNode->GetScreenId()] || hasCaptureWindow[mirroredNode->GetScreenId()] ||
!params.GetScreenInfo().filteredAppSet.empty() || RSMainThread::Instance()->IsCurtainScreenOn());
if (mirroredNode->GetSecurityDisplay() != displayNodeSp.GetSecurityDisplay() &&
mirroredProcessor && hasSpicalLayer) {
curCanvas_ = mirroredProcessor->GetCanvas();
@ -713,7 +714,8 @@ void RSDisplayRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas)
Drawing::AutoCanvasRestore acr(canvas, true);
if (params->HasSecurityLayer() || params->HasSkipLayer() || params->HasCaptureWindow()) {
if (params->HasSecurityLayer() || params->HasSkipLayer() ||
params->HasProtectedLayer() || params->HasCaptureWindow()) {
RS_LOGD("RSDisplayRenderNodeDrawable::OnCapture: params %{public}s \
process RSDisplayRenderNode(id:[%{public}" PRIu64 "]) Not using UniRender buffer.",
params->ToString().c_str(), params->GetId());

View File

@ -371,7 +371,7 @@ void RSSurfaceRenderNodeDrawable::CaptureSingleSurfaceNode(RSSurfaceRenderNode&
return;
}
if (!(surfaceParams.HasSecurityLayer() || surfaceParams.HasSkipLayer()) &&
if (!(surfaceParams.HasSecurityLayer() || surfaceParams.HasSkipLayer() || surfaceParams.HasProtectedLayer()) &&
DealWithUIFirstCache(surfaceNode, canvas, surfaceParams, *uniParams)) {
return;
}
@ -391,6 +391,23 @@ void RSSurfaceRenderNodeDrawable::CaptureSingleSurfaceNode(RSSurfaceRenderNode&
} else {
surfaceParams.ApplyAlphaAndMatrixToCanvas(canvas);
}
if (surfaceParams.GetIsProtectedLayer()) {
RS_LOGD("RSSurfaceRenderNodeDrawable::CaptureSingleSurfaceNode: \
process RSSurfaceRenderNode(id:[%{public}" PRIu64 "]) clear black since it is protected layer.",
surfaceParams.GetId());
Drawing::Brush rectBrush;
rectBrush.SetColor(Drawing::Color::COLOR_BLACK);
canvas.AttachBrush(rectBrush);
canvas.DrawRect(Drawing::Rect(0, 0, surfaceParams.GetBounds().GetWidth(),
surfaceParams.GetBounds().GetHeight()));
canvas.DetachBrush();
if (isSelfDrawingSurface && !surfaceParams.IsSpherizeValid()) {
canvas.Restore();
}
return;
}
auto parentSurfaceMatrix = RSRenderParams::parentSurfaceMatrix_;
RSRenderParams::parentSurfaceMatrix_ = canvas.GetTotalMatrix();
@ -442,7 +459,7 @@ void RSSurfaceRenderNodeDrawable::CaptureSurfaceInDisplay(RSSurfaceRenderNode& s
return;
}
if (!(surfaceParams.HasSecurityLayer() || surfaceParams.HasSkipLayer()) &&
if (!(surfaceParams.HasSecurityLayer() || surfaceParams.HasSkipLayer() || surfaceParams.HasProtectedLayer()) &&
DealWithUIFirstCache(surfaceNode, canvas, surfaceParams, *uniParams)) {
return;
}
@ -455,6 +472,23 @@ void RSSurfaceRenderNodeDrawable::CaptureSurfaceInDisplay(RSSurfaceRenderNode& s
}
surfaceParams.ApplyAlphaAndMatrixToCanvas(canvas);
if (surfaceParams.GetIsProtectedLayer()) {
RS_LOGD("RSSurfaceRenderNodeDrawable::CaptureSurfaceInDisplay: \
process RSSurfaceRenderNode(id:[%{public}" PRIu64 "]) clear black since it is protected layer.",
surfaceParams.GetId());
Drawing::Brush rectBrush;
rectBrush.SetColor(Drawing::Color::COLOR_BLACK);
canvas.AttachBrush(rectBrush);
canvas.DrawRect(Drawing::Rect(0, 0, surfaceParams.GetBounds().GetWidth(),
surfaceParams.GetBounds().GetHeight()));
canvas.DetachBrush();
if (isSelfDrawingSurface && !surfaceParams.IsSpherizeValid()) {
canvas.Restore();
}
return;
}
auto parentSurfaceMatrix = RSRenderParams::parentSurfaceMatrix_;
RSRenderParams::parentSurfaceMatrix_ = canvas.GetTotalMatrix();

View File

@ -1102,6 +1102,14 @@ void RSMainThread::ConsumeAndUpdateAllNodes()
}
}
const auto& surfaceBuffer = surfaceNode->GetBuffer();
if (deviceType_ == DeviceType::PHONE && surfaceBuffer &&
(surfaceBuffer->GetUsage() & BUFFER_USAGE_PROTECTED)) {
if (!surfaceNode->GetProtectedLayer()) {
surfaceNode->SetProtectedLayer(true);
}
}
// still have buffer(s) to consume.
if (surfaceHandler.GetAvailableBufferCount() > 0) {
needRequestNextVsync = true;

View File

@ -63,9 +63,9 @@ bool RSSurfaceCaptureTask::Run(sptr<RSISurfaceCaptureCallback> callback)
pixelmap = CreatePixelMapBySurfaceNode(surfaceNode, visitor_->IsUniRender());
visitor_->IsDisplayNode(false);
} else if (auto displayNode = node->ReinterpretCastTo<RSDisplayRenderNode>()) {
visitor_->SetHasingSecurityOrSkipLayer(FindSecurityOrSkipLayer());
visitor_->SetHasingSecurityOrSkipOrProtectedLayer(FindSecurityOrSkipOrProtectedLayer());
pixelmap = CreatePixelMapByDisplayNode(displayNode, visitor_->IsUniRender(),
visitor_->GetHasingSecurityOrSkipLayer());
visitor_->GetHasingSecurityOrSkipOrProtectedLayer());
visitor_->IsDisplayNode(true);
} else {
RS_LOGE("RSSurfaceCaptureTask::Run: Invalid RSRenderNodeType!");
@ -284,7 +284,7 @@ std::unique_ptr<Media::PixelMap> RSSurfaceCaptureTask::CreatePixelMapBySurfaceNo
}
std::unique_ptr<Media::PixelMap> RSSurfaceCaptureTask::CreatePixelMapByDisplayNode(
std::shared_ptr<RSDisplayRenderNode> node, bool isUniRender, bool hasSecurityOrSkipLayer)
std::shared_ptr<RSDisplayRenderNode> node, bool isUniRender, bool hasSecurityOrSkipOrProtectedLayer)
{
if (node == nullptr) {
RS_LOGE("RSSurfaceCaptureTask::CreatePixelMapByDisplayNode: node is nullptr");
@ -429,22 +429,22 @@ std::shared_ptr<Drawing::Surface> RSSurfaceCaptureTask::CreateSurface(const std:
return Drawing::Surface::MakeRasterDirect(info, address, pixelmap->GetRowBytes());
}
bool RSSurfaceCaptureTask::FindSecurityOrSkipLayer()
bool RSSurfaceCaptureTask::FindSecurityOrSkipOrProtectedLayer()
{
const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap();
bool hasSecurityOrSkipLayer = false;
bool hasSecurityOrSkipOrProtectedLayer = false;
nodeMap.TraverseSurfaceNodes([this,
&hasSecurityOrSkipLayer](const std::shared_ptr<RSSurfaceRenderNode>& surfaceNode)
&hasSecurityOrSkipOrProtectedLayer](const std::shared_ptr<RSSurfaceRenderNode>& surfaceNode)
mutable {
if (surfaceNode == nullptr || !surfaceNode->IsOnTheTree()) {
return;
}
if (surfaceNode->GetSecurityLayer() || surfaceNode->GetSkipLayer()) {
hasSecurityOrSkipLayer = true;
if (surfaceNode->GetSecurityLayer() || surfaceNode->GetSkipLayer() || surfaceNode->GetProtectedLayer()) {
hasSecurityOrSkipOrProtectedLayer = true;
return;
}
});
return hasSecurityOrSkipLayer;
return hasSecurityOrSkipOrProtectedLayer;
}
RSSurfaceCaptureVisitor::RSSurfaceCaptureVisitor(float scaleX, float scaleY, bool isUniRender)
@ -496,7 +496,7 @@ void RSSurfaceCaptureVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode &node
if (IsUniRender()) {
bool isCurtainScreenOn = RSMainThread::Instance()->IsCurtainScreenOn();
if (hasSecurityOrSkipLayer_ || isCurtainScreenOn) {
if (hasSecurityOrSkipOrProtectedLayer_ || isCurtainScreenOn) {
RS_LOGD("RSSurfaceCaptureVisitor::ProcessDisplayRenderNode: \
process RSDisplayRenderNode(id:[%{public}" PRIu64 "]) Not using UniRender buffer.", node.GetId());
@ -672,6 +672,20 @@ void RSSurfaceCaptureVisitor::CaptureSingleSurfaceNodeWithUni(RSSurfaceRenderNod
return;
}
if (node.GetProtectedLayer()) {
RS_LOGD("RSSurfaceCaptureVisitor::CaptureSingleSurfaceNodeWithUni: \
process RSSurfaceRenderNode(id:[%{public}" PRIu64 "]) clear black since it is protected layer.",
node.GetId());
Drawing::Brush rectBrush;
rectBrush.SetColor(Drawing::Color::COLOR_BLACK);
canvas_->AttachBrush(rectBrush);
canvas_->DrawRect(Drawing::Rect(0, 0, property.GetBoundsWidth(), property.GetBoundsHeight()));
canvas_->DetachBrush();
canvas_->Restore();
canvas_->Restore();
return;
}
if (isSelfDrawingSurface) {
RSPropertiesPainter::DrawBackground(property, *canvas_);
RSPropertiesPainter::DrawMask(property, *canvas_);
@ -695,7 +709,7 @@ void RSSurfaceCaptureVisitor::CaptureSingleSurfaceNodeWithUni(RSSurfaceRenderNod
canvas_->Restore();
}
if (!node.GetHasSecurityLayer() && !node.GetHasSkipLayer() &&
if (!node.GetHasSecurityLayer() && !node.GetHasSkipLayer() && !node.GetProtectedLayer() &&
isUIFirst_ && RSUniRenderUtil::HandleCaptureNode(node, *canvas_)) {
RS_LOGD("RSSurfaceCaptureVisitor::CaptureSingleSurfaceNodeWithUni: \
process RSSurfaceRenderNode [%{public}s, %{public}" PRIu64 "] use cache texture.",
@ -721,7 +735,7 @@ void RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithUni(RSSurfaceRenderNode
canvas_->SetMatrix(geoPtr->GetAbsMatrix());
}
if (!node.GetHasSecurityLayer() && !node.GetHasSkipLayer() &&
if (!node.GetHasSecurityLayer() && !node.GetHasSkipLayer() && !node.GetProtectedLayer() &&
isUIFirst_ && RSUniRenderUtil::HandleSubThreadNode(node, *canvas_)) {
RS_LOGD("RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithUni: \
process RSSurfaceRenderNode [%{public}s, %{public}" PRIu64 "] use cache texture.",
@ -729,6 +743,18 @@ void RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithUni(RSSurfaceRenderNode
return;
}
if (node.GetProtectedLayer()) {
RS_LOGD("RSSurfaceCaptureVisitor::CaptureSurfaceInDisplayWithUni: \
process RSSurfaceRenderNode(id:[%{public}" PRIu64 "]) clear black since it is protected layer.",
node.GetId());
Drawing::Brush rectBrush;
rectBrush.SetColor(Drawing::Color::COLOR_BLACK);
canvas_->AttachBrush(rectBrush);
canvas_->DrawRect(Drawing::Rect(0, 0, property.GetBoundsWidth(), property.GetBoundsHeight()));
canvas_->DetachBrush();
return;
}
bool isSelfDrawingSurface = node.GetSurfaceNodeType() == RSSurfaceNodeType::SELF_DRAWING_NODE;
if (isSelfDrawingSurface) {
canvas_->Save();

View File

@ -65,14 +65,14 @@ class RSSurfaceCaptureVisitor : public RSNodeVisitor {
return isUniRender_;
}
bool GetHasingSecurityOrSkipLayer() const
bool GetHasingSecurityOrSkipOrProtectedLayer() const
{
return hasSecurityOrSkipLayer_;
return hasSecurityOrSkipOrProtectedLayer_;
}
void SetHasingSecurityOrSkipLayer(const bool &hasSecurityOrSkipLayer)
void SetHasingSecurityOrSkipOrProtectedLayer(const bool &hasSecurityOrSkipOrProtectedLayer)
{
hasSecurityOrSkipLayer_ = hasSecurityOrSkipLayer;
hasSecurityOrSkipOrProtectedLayer_ = hasSecurityOrSkipOrProtectedLayer;
}
private:
@ -100,7 +100,7 @@ class RSSurfaceCaptureVisitor : public RSNodeVisitor {
float scaleX_ = 1.0f;
float scaleY_ = 1.0f;
bool isUniRender_ = false;
bool hasSecurityOrSkipLayer_ = false;
bool hasSecurityOrSkipOrProtectedLayer_ = false;
bool isUIFirst_ = false;
std::unordered_set<NodeId> curCacheFilterRects_ = {};
@ -131,9 +131,9 @@ private:
bool isUniRender = false);
std::unique_ptr<Media::PixelMap> CreatePixelMapByDisplayNode(std::shared_ptr<RSDisplayRenderNode> node,
bool isUniRender = false, bool hasSecurityOrSkipLayer = false);
bool isUniRender = false, bool hasSecurityOrSkipOrProtectedLayer = false);
bool FindSecurityOrSkipLayer();
bool FindSecurityOrSkipOrProtectedLayer();
// It is currently only used on folding screen.
int32_t ScreenCorrection(ScreenRotation screenRotation);

View File

@ -80,9 +80,9 @@ bool RSSurfaceCaptureTaskParallel::Run(sptr<RSISurfaceCaptureCallback> callback)
pixelmap = CreatePixelMapBySurfaceNode(curNode, visitor_->IsUniRender());
visitor_->IsDisplayNode(false);
} else if (auto displayNode = node->ReinterpretCastTo<RSDisplayRenderNode>()) {
visitor_->SetHasingSecurityOrSkipLayer(FindSecurityOrSkipLayer());
visitor_->SetHasingSecurityOrSkipOrProtectedLayer(FindSecurityOrSkipOrProtectedLayer());
pixelmap = CreatePixelMapByDisplayNode(displayNode, visitor_->IsUniRender(),
visitor_->GetHasingSecurityOrSkipLayer());
visitor_->GetHasingSecurityOrSkipOrProtectedLayer());
visitor_->IsDisplayNode(true);
displayNodeDrawable = std::static_pointer_cast<DrawableV2::RSRenderNodeDrawable>(
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(displayNode));
@ -381,22 +381,22 @@ std::shared_ptr<Drawing::Surface> RSSurfaceCaptureTaskParallel::CreateSurface(
return Drawing::Surface::MakeRasterDirect(info, address, pixelmap->GetRowBytes());
}
bool RSSurfaceCaptureTaskParallel::FindSecurityOrSkipLayer()
bool RSSurfaceCaptureTaskParallel::FindSecurityOrSkipOrProtectedLayer()
{
const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap();
bool hasSecurityOrSkipLayer = false;
bool hasSecurityOrSkipOrProtectedLayer = false;
nodeMap.TraverseSurfaceNodes([this,
&hasSecurityOrSkipLayer](const std::shared_ptr<RSSurfaceRenderNode>& surfaceNode)
&hasSecurityOrSkipOrProtectedLayer](const std::shared_ptr<RSSurfaceRenderNode>& surfaceNode)
mutable {
if (surfaceNode == nullptr || !surfaceNode->IsOnTheTree()) {
return;
}
if (surfaceNode->GetSecurityLayer() || surfaceNode->GetSkipLayer()) {
hasSecurityOrSkipLayer = true;
if (surfaceNode->GetSecurityLayer() || surfaceNode->GetSkipLayer() || surfaceNode->GetProtectedLayer()) {
hasSecurityOrSkipOrProtectedLayer = true;
return;
}
});
return hasSecurityOrSkipLayer;
return hasSecurityOrSkipOrProtectedLayer;
}
} // namespace Rosen

View File

@ -44,7 +44,7 @@ private:
std::unique_ptr<Media::PixelMap> CreatePixelMapByDisplayNode(std::shared_ptr<RSDisplayRenderNode> node,
bool isUniRender = false, bool hasSecurityOrSkipLayer = false);
bool FindSecurityOrSkipLayer();
bool FindSecurityOrSkipOrProtectedLayer();
// It is currently only used on folding screen.
int32_t ScreenCorrection(ScreenRotation screenRotation);

View File

@ -237,6 +237,7 @@ RSUniRenderVisitor::RSUniRenderVisitor(const RSUniRenderVisitor& visitor) : RSUn
screenInfo_ = visitor.screenInfo_;
displayHasSecSurface_ = visitor.displayHasSecSurface_;
displayHasSkipSurface_ = visitor.displayHasSkipSurface_;
displayHasProtectedSurface_ = visitor.displayHasProtectedSurface_;
hasCaptureWindow_ = visitor.hasCaptureWindow_;
parentSurfaceNodeMatrix_ = visitor.parentSurfaceNodeMatrix_;
curAlpha_ = visitor.curAlpha_;
@ -260,6 +261,7 @@ void RSUniRenderVisitor::CopyVisitorInfos(std::shared_ptr<RSUniRenderVisitor> vi
screenInfo_ = visitor->screenInfo_;
displayHasSecSurface_ = visitor->displayHasSecSurface_;
displayHasSkipSurface_ = visitor->displayHasSkipSurface_;
displayHasProtectedSurface_ = visitor->displayHasProtectedSurface_;
hasCaptureWindow_ = visitor->hasCaptureWindow_;
parentSurfaceNodeMatrix_ = visitor->parentSurfaceNodeMatrix_;
curAlpha_ = visitor->curAlpha_;
@ -767,6 +769,7 @@ void RSUniRenderVisitor::PrepareDisplayRenderNode(RSDisplayRenderNode& node)
currentVisitDisplay_ = node.GetScreenId();
displayHasSecSurface_.emplace(currentVisitDisplay_, false);
displayHasSkipSurface_.emplace(currentVisitDisplay_, false);
displayHasProtectedSurface_.emplace(currentVisitDisplay_, false);
hasCaptureWindow_.emplace(currentVisitDisplay_, false);
node.GetDirtySurfaceNodeMap().clear();
@ -1128,7 +1131,7 @@ void RSUniRenderVisitor::PrepareTypesOfSurfaceRenderNodeAfterUpdate(RSSurfaceRen
}
}
void RSUniRenderVisitor::UpdateSecurityAndSkipLayerRecord(RSSurfaceRenderNode& node)
void RSUniRenderVisitor::UpdateSecuritySkipAndProtectedLayersRecord(RSSurfaceRenderNode& node)
{
if (node.GetHasSecurityLayer()) {
displayHasSecSurface_[currentVisitDisplay_] = true;
@ -1136,6 +1139,9 @@ void RSUniRenderVisitor::UpdateSecurityAndSkipLayerRecord(RSSurfaceRenderNode& n
if (node.GetHasSkipLayer() && node.GetName().find(CAPTURE_WINDOW_NAME) == std::string::npos) {
displayHasSkipSurface_[currentVisitDisplay_] = true;
}
if (node.GetHasProtectedLayer()) {
displayHasProtectedSurface_[currentVisitDisplay_] = true;
}
}
void RSUniRenderVisitor::UpdateForegroundFilterCacheWithDirty(RSRenderNode& node,
@ -1204,7 +1210,7 @@ void RSUniRenderVisitor::QuickPrepareDisplayRenderNode(RSDisplayRenderNode& node
SurfaceOcclusionCallbackToWMS();
curDisplayNode_->UpdatePartialRenderParams();
curDisplayNode_->UpdateScreenRenderParams(screenInfo_, displayHasSecSurface_, displayHasSkipSurface_,
hasCaptureWindow_);
displayHasProtectedSurface_, hasCaptureWindow_);
HandleColorGamuts(node, screenManager_);
HandlePixelFormat(node, screenManager_);
if (UNLIKELY(!SharedTransitionParam::unpairedShareTransitions_.empty())) {
@ -1463,6 +1469,7 @@ bool RSUniRenderVisitor::InitDisplayInfo(RSDisplayRenderNode& node)
currentVisitDisplay_ = node.GetScreenId();
displayHasSecSurface_.emplace(currentVisitDisplay_, false);
displayHasSkipSurface_.emplace(currentVisitDisplay_, false);
displayHasProtectedSurface_.emplace(currentVisitDisplay_, false);
hasCaptureWindow_.emplace(currentVisitDisplay_, false);
curDisplayDirtyManager_ = node.GetDirtyManager();
curDisplayNode_ = node.shared_from_this()->ReinterpretCastTo<RSDisplayRenderNode>();
@ -1530,7 +1537,7 @@ bool RSUniRenderVisitor::BeforeUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node)
}
// only need collect first level node's security & skip layer info
if (node.GetId() == node.GetFirstLevelNodeId()) {
UpdateSecurityAndSkipLayerRecord(node);
UpdateSecuritySkipAndProtectedLayersRecord(node);
}
if (node.IsMainWindowType() || node.IsLeashWindow()) {
// UpdateCurCornerRadius must process before curSurfaceNode_ update
@ -2481,7 +2488,7 @@ void RSUniRenderVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode& node)
CheckPixelFormat(node);
// only need collect first level node's security & skip layer info
if (nodeId == node.GetFirstLevelNodeId()) {
UpdateSecurityAndSkipLayerRecord(node);
UpdateSecuritySkipAndProtectedLayersRecord(node);
}
// stop traversal if node keeps static
if (isQuickSkipPreparationEnabled_ && CheckIfSurfaceRenderNodeStatic(node)) {
@ -3582,8 +3589,9 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
auto processor = std::static_pointer_cast<RSUniRenderVirtualProcessor>(processor_);
if (mirrorNode->GetSecurityDisplay() != isSecurityDisplay_ && processor &&
(hasCaptureWindow_[mirrorNode->GetScreenId()] || displayHasSecSurface_[mirrorNode->GetScreenId()] ||
displayHasSkipSurface_[mirrorNode->GetScreenId()] || !screenInfo_.filteredAppSet.empty() ||
isCurtainScreenOn_)) {
displayHasSkipSurface_[mirrorNode->GetScreenId()] ||
displayHasProtectedSurface_[mirrorNode->GetScreenId()] ||
!screenInfo_.filteredAppSet.empty() || isCurtainScreenOn_)) {
if (isPc_&& hasCaptureWindow_[mirrorNode->GetScreenId()]) {
processor->MirrorScenePerf();
}
@ -3603,7 +3611,8 @@ void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
std::shared_ptr<Drawing::Image> cacheImageProcessed = GetCacheImageFromMirrorNode(mirrorNode);
bool canvasRotation = screenManager->GetCanvasRotation(node.GetScreenId());
if (cacheImageProcessed && !displayHasSkipSurface_[mirrorNode->GetScreenId()] &&
!displayHasSecSurface_[mirrorNode->GetScreenId()] && screenInfo_.filteredAppSet.empty()) {
!displayHasSecSurface_[mirrorNode->GetScreenId()] &&
!displayHasProtectedSurface_[mirrorNode->GetScreenId()] && screenInfo_.filteredAppSet.empty()) {
RS_LOGD("RSUniRenderVisitor::ProcessDisplayRenderNode screen recording optimization is enable");
ScaleMirrorIfNeed(node, canvasRotation);
RotateMirrorCanvasIfNeed(node, canvasRotation);
@ -4070,7 +4079,8 @@ void RSUniRenderVisitor::AssignGlobalZOrderAndCreateLayer(
iter = childHardwareEnabledNodes.erase(iter);
continue;
}
if (childNode->GetBuffer() != nullptr && !childNode->IsHardwareForcedDisabled()) {
if (childNode->GetBuffer() != nullptr &&
(!childNode->IsHardwareForcedDisabled() || childNode->GetProtectedLayer())) {
// SetGlobalZOrder here to ensure zOrder committed to composer is continuous
childNode->SetGlobalZOrder(globalZOrder_++);
RS_LOGD("createLayer: %{public}" PRIu64 "", childNode->GetId());
@ -5036,7 +5046,7 @@ bool RSUniRenderVisitor::ForceHardwareComposer(RSSurfaceRenderNode& node) const
!isUpdateCachedSurface_;
}
bool RSUniRenderVisitor::UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node)
bool RSUniRenderVisitor::UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node, bool isProtected)
{
Drawing::AutoCanvasRestore acr(*canvas_.get(), true);
@ -5055,7 +5065,7 @@ bool RSUniRenderVisitor::UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node)
hasRotation = rotation == GRAPHIC_ROTATE_90 || rotation == GRAPHIC_ROTATE_270;
}
node.UpdateSrcRect(*canvas_, dst, hasRotation);
return !node.IsHardwareDisabledBySrcRect();
return isProtected ? true : !node.IsHardwareDisabledBySrcRect();
}
void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
@ -5163,6 +5173,15 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
}
}
if (isSecurityDisplay_ && node.GetProtectedLayer()) {
Drawing::Brush rectBrush;
rectBrush.SetColor(Drawing::Color::COLOR_BLACK);
canvas_->AttachBrush(rectBrush);
canvas_->DrawRect(Drawing::Rect(0, 0, property.GetBoundsWidth(), property.GetBoundsHeight()));
canvas_->DetachBrush();
return;
}
// when surfacenode named "CapsuleWindow", cache the current canvas as SkImage for screen recording
if (!isSecurityDisplay_ && canvas_->GetSurface() != nullptr &&
node.GetName().find(CAPTURE_WINDOW_NAME) != std::string::npos) {
@ -5256,8 +5275,9 @@ void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
IsHardwareComposerEnabled(), node.IsHardwareForcedDisabled());
}
// if this window is in freeze state, disable hardware composer for its child surfaceView
if (IsHardwareComposerEnabled() && node.IsHardwareEnabledType() && (!node.IsHardwareForcedDisabled() ||
ForceHardwareComposer(node)) && UpdateSrcRectForHwcNode(node)) {
if (IsHardwareComposerEnabled() && UpdateSrcRectForHwcNode(node, node.GetProtectedLayer()) &&
(node.GetProtectedLayer() || (node.IsHardwareEnabledType() && (!node.IsHardwareForcedDisabled() ||
ForceHardwareComposer(node))))) {
if (!node.IsHardwareEnabledTopSurface()) {
canvas_->Clear(Drawing::Color::COLOR_TRANSPARENT);
}

View File

@ -367,7 +367,7 @@ private:
// mark surfaceNode's child surfaceView nodes hardware forced disabled
void MarkSubHardwareEnableNodeState(RSSurfaceRenderNode& surfaceNode);
void CollectAppNodeForHwc(std::shared_ptr<RSSurfaceRenderNode> surfaceNode);
void UpdateSecurityAndSkipLayerRecord(RSSurfaceRenderNode& node);
void UpdateSecuritySkipAndProtectedLayersRecord(RSSurfaceRenderNode& node);
void PrepareEffectNodeIfCacheReuse(const std::shared_ptr<RSRenderNode>& cacheRootNode,
std::shared_ptr<RSEffectRenderNode> effectNode);
@ -381,7 +381,7 @@ private:
bool IsFirstVisitedCacheForced() const;
bool IsRosenWebHardwareDisabled(RSSurfaceRenderNode& node, int rotation) const;
bool ForceHardwareComposer(RSSurfaceRenderNode& node) const;
bool UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node); // return if srcRect is allowed by dss restriction
bool UpdateSrcRectForHwcNode(RSSurfaceRenderNode& node, bool isProtected = false); // return if srcRect is allowed by dss restriction
std::shared_ptr<Drawing::Image> GetCacheImageFromMirrorNode(std::shared_ptr<RSDisplayRenderNode> mirrorNode);
void SwitchColorFilterDrawing(int currentSaveCount);
@ -443,6 +443,7 @@ private:
ScreenId currentVisitDisplay_ = INVALID_SCREEN_ID;
std::map<ScreenId, bool> displayHasSecSurface_;
std::map<ScreenId, bool> displayHasSkipSurface_;
std::map<ScreenId, bool> displayHasProtectedSurface_;
std::map<ScreenId, bool> hasCaptureWindow_;
std::set<ScreenId> mirroredDisplays_;
bool isSecurityDisplay_ = false;

View File

@ -78,6 +78,10 @@ public:
{
return displayHasSkipSurface_;
}
const std::map<ScreenId, bool>& GetDisplayHasProtectedSurface() const
{
return displayHasProtectedSurface_;
}
const std::map<ScreenId, bool>& GethasCaptureWindow() const
{
return hasCaptureWindow_;
@ -94,6 +98,7 @@ public:
bool GetMainAndLeashSurfaceDirty() const;
bool HasSecurityLayer();
bool HasSkipLayer();
bool HasProtectedLayer();
bool HasCaptureWindow();
void SetRotationChanged(bool changed);
@ -105,6 +110,7 @@ public:
private:
std::map<ScreenId, bool> displayHasSecSurface_;
std::map<ScreenId, bool> displayHasSkipSurface_;
std::map<ScreenId, bool> displayHasProtectedSurface_;
std::map<ScreenId, bool> hasCaptureWindow_;
std::vector<RSBaseRenderNode::SharedPtr> allMainAndLeashSurfaces_;
int32_t offsetX_ = -1;

View File

@ -110,6 +110,10 @@ public:
{
return isSkipLayer_;
}
bool GetIsProtectedLayer() const
{
return isProtectedLayer_;
}
const std::set<NodeId>& GetSecurityLayerIds() const
{
return securityLayerIds_;
@ -126,6 +130,10 @@ public:
{
return skipLayerIds_.size() != 0;
}
bool HasProtectedLayer()
{
return protectedLayerIds_.size() != 0;
}
std::string GetName() const
{
@ -259,8 +267,10 @@ private:
bool isLastFrameHardwareEnabled_ = false;
bool isSecurityLayer_ = false;
bool isSkipLayer_ = false;
bool isProtectedLayer_ = false;
std::set<NodeId> skipLayerIds_= {};
std::set<NodeId> securityLayerIds_= {};
std::set<NodeId> protectedLayerIds_= {};
std::set<int32_t> bufferCacheSet_ = {};
std::string name_= "";

View File

@ -261,7 +261,8 @@ public:
void UpdateRenderParams() override;
void UpdatePartialRenderParams();
void UpdateScreenRenderParams(ScreenInfo& screenInfo, std::map<ScreenId, bool>& displayHasSecSurface,
std::map<ScreenId, bool>& displayHasSkipSurface, std::map<ScreenId, bool>& hasCaptureWindow);
std::map<ScreenId, bool>& displayHasSkipSurface, std::map<ScreenId, bool>& displayHasProtectedSurface,
std::map<ScreenId, bool>& hasCaptureWindow);
void RecordMainAndLeashSurfaces(RSBaseRenderNode::SharedPtr surface);
std::vector<RSBaseRenderNode::SharedPtr>& GetAllMainAndLeashSurfaces() { return curMainAndLeashSurfaceNodes_;}

View File

@ -426,17 +426,21 @@ public:
void SetSecurityLayer(bool isSecurityLayer);
void SetSkipLayer(bool isSkipLayer);
void SetProtectedLayer(bool isProtectedLayer);
// get whether it is a security/skip layer itself
bool GetSecurityLayer() const;
bool GetSkipLayer() const;
bool GetProtectedLayer() const;
// get whether it and it's subtree contain security layer
bool GetHasSecurityLayer() const;
bool GetHasSkipLayer() const;
bool GetHasProtectedLayer() const;
void SyncSecurityInfoToFirstLevelNode();
void SyncSkipInfoToFirstLevelNode();
void SyncProtectedInfoToFirstLevelNode();
void SetFingerprint(bool hasFingerprint);
bool GetFingerprint() const;
@ -1088,8 +1092,10 @@ private:
bool isSecurityLayer_ = false;
bool isSkipLayer_ = false;
bool isProtectedLayer_ = false;
std::set<NodeId> skipLayerIds_= {};
std::set<NodeId> securityLayerIds_= {};
std::set<NodeId> protectedLayerIds_= {};
bool hasFingerprint_ = false;
RectI srcRect_;

View File

@ -68,6 +68,7 @@ void RSDisplayRenderParams::OnSync(const std::unique_ptr<RSRenderParams>& target
targetDisplayParams->allMainAndLeashSurfaces_ = allMainAndLeashSurfaces_;
targetDisplayParams->displayHasSecSurface_ = displayHasSecSurface_;
targetDisplayParams->displayHasSkipSurface_ = displayHasSkipSurface_;
targetDisplayParams->displayHasProtectedSurface_ = displayHasProtectedSurface_;
targetDisplayParams->hasCaptureWindow_ = hasCaptureWindow_;
targetDisplayParams->offsetX_ = offsetX_;
targetDisplayParams->offsetY_ = offsetY_;
@ -119,6 +120,16 @@ bool RSDisplayRenderParams::HasSkipLayer()
return hasSkipLayerFlag;
}
bool RSDisplayRenderParams::HasProtectedLayer()
{
bool hasProtectedLayerFlag = false;
auto iter = displayHasProtectedSurface_.find(screenId_);
if (iter != displayHasProtectedSurface_.end()) {
hasProtectedLayerFlag = iter->second;
}
return hasProtectedLayerFlag;
}
bool RSDisplayRenderParams::HasCaptureWindow()
{
bool hasCaptureWindow = false;

View File

@ -232,8 +232,10 @@ void RSSurfaceRenderParams::OnSync(const std::unique_ptr<RSRenderParams>& target
targetSurfaceParams->isOccludedByFilterCache_ = isOccludedByFilterCache_;
targetSurfaceParams->isSecurityLayer_ = isSecurityLayer_;
targetSurfaceParams->isSkipLayer_ = isSkipLayer_;
targetSurfaceParams->isProtectedLayer_ = isProtectedLayer_;
targetSurfaceParams->skipLayerIds_= skipLayerIds_;
targetSurfaceParams->securityLayerIds_= securityLayerIds_;
targetSurfaceParams->protectedLayerIds_ = protectedLayerIds_;
targetSurfaceParams->name_ = name_;
targetSurfaceParams->surfaceCacheContentStatic_ = surfaceCacheContentStatic_;
targetSurfaceParams->bufferCacheSet_ = bufferCacheSet_;

View File

@ -206,7 +206,7 @@ void RSDisplayRenderNode::UpdateRenderParams()
void RSDisplayRenderNode::UpdateScreenRenderParams(ScreenInfo& screenInfo,
std::map<ScreenId, bool>& displayHasSecSurface, std::map<ScreenId, bool>& displayHasSkipSurface,
std::map<ScreenId, bool>& hasCaptureWindow)
std::map<ScreenId, bool>& displayHasProtectedSurface, std::map<ScreenId, bool>& hasCaptureWindow)
{
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
@ -219,6 +219,7 @@ void RSDisplayRenderNode::UpdateScreenRenderParams(ScreenInfo& screenInfo,
displayParams->screenInfo_ = std::move(screenInfo);
displayParams->displayHasSecSurface_ = std::move(displayHasSecSurface);
displayParams->displayHasSkipSurface_ = std::move(displayHasSkipSurface);
displayParams->displayHasProtectedSurface_ = std::move(displayHasProtectedSurface);
displayParams->hasCaptureWindow_ = std::move(hasCaptureWindow);
}

View File

@ -209,7 +209,8 @@ bool RSSurfaceRenderNode::ShouldPrepareSubnodes()
void RSSurfaceRenderNode::StoreMustRenewedInfo()
{
mustRenewedInfo_ = RSRenderNode::HasMustRenewedInfo() || GetHasSecurityLayer() || GetHasSkipLayer();
mustRenewedInfo_ = RSRenderNode::HasMustRenewedInfo() || GetHasSecurityLayer() ||
GetHasSkipLayer() || GetHasProtectedLayer();
}
std::string RSSurfaceRenderNode::DirtyRegionDump() const
@ -393,6 +394,7 @@ void RSSurfaceRenderNode::OnTreeStateChanged()
// sync skip & security info
SyncSecurityInfoToFirstLevelNode();
SyncSkipInfoToFirstLevelNode();
SyncProtectedInfoToFirstLevelNode();
}
void RSSurfaceRenderNode::OnResetParent()
@ -670,6 +672,18 @@ void RSSurfaceRenderNode::SetSkipLayer(bool isSkipLayer)
SyncSkipInfoToFirstLevelNode();
}
void RSSurfaceRenderNode::SetProtectedLayer(bool isProtectedLayer)
{
isProtectedLayer_ = isProtectedLayer;
SetDirty();
if (isProtectedLayer) {
protectedLayerIds_.insert(GetId());
} else {
protectedLayerIds_.erase(GetId());
}
SyncProtectedInfoToFirstLevelNode();
}
bool RSSurfaceRenderNode::GetSecurityLayer() const
{
return isSecurityLayer_;
@ -681,6 +695,11 @@ bool RSSurfaceRenderNode::GetSkipLayer() const
return isSkipLayer_;
}
bool RSSurfaceRenderNode::GetProtectedLayer() const
{
return isProtectedLayer_;
}
bool RSSurfaceRenderNode::GetHasSecurityLayer() const
{
return securityLayerIds_.size() != 0;
@ -691,6 +710,10 @@ bool RSSurfaceRenderNode::GetHasSkipLayer() const
return skipLayerIds_.size() != 0;
}
bool RSSurfaceRenderNode::GetHasProtectedLayer() const
{
return protectedLayerIds_.size() != 0;
}
void RSSurfaceRenderNode::SyncSecurityInfoToFirstLevelNode()
{
@ -732,6 +755,23 @@ void RSSurfaceRenderNode::SyncSkipInfoToFirstLevelNode()
}
}
void RSSurfaceRenderNode::SyncProtectedInfoToFirstLevelNode()
{
if (isProtectedLayer_) {
auto firstLevelNode = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(GetFirstLevelNode());
// firstLevelNode is the nearest app window / leash node
if (firstLevelNode && GetFirstLevelNodeId() != GetId()) {
firstLevelNode->SetDirty();
// should always sync protectedLayerIds_ to firstLevelNode
if (isProtectedLayer_ && IsOnTheTree()) {
firstLevelNode->protectedLayerIds_.insert(GetId());
} else {
firstLevelNode->protectedLayerIds_.erase(GetId());
}
}
}
}
void RSSurfaceRenderNode::SetFingerprint(bool hasFingerprint)
{
hasFingerprint_ = hasFingerprint;
@ -2336,8 +2376,10 @@ void RSSurfaceRenderNode::UpdateRenderParams()
surfaceParams->SetAncestorDisplayNode(ancestorDisplayNode_);
surfaceParams->isSecurityLayer_ = isSecurityLayer_;
surfaceParams->isSkipLayer_ = isSkipLayer_;
surfaceParams->isProtectedLayer_ = isProtectedLayer_;
surfaceParams->skipLayerIds_= skipLayerIds_;
surfaceParams->securityLayerIds_= securityLayerIds_;
surfaceParams->protectedLayerIds_= protectedLayerIds_;
surfaceParams->name_= name_;
surfaceParams->positionZ_ = properties.GetPositionZ();
surfaceParams->SetNeedSync(true);

View File

@ -431,18 +431,18 @@ HWTEST_F(RSSurfaceCaptureTaskTest, CreateSurface002, Function | SmallTest | Leve
}
/*
* @tc.name: FindSecurityOrSkipLayer001
* @tc.name: FindSecurityOrSkipOrProtectedLayer001
* @tc.desc: Test RSSurfaceCaptureTaskTest.CreateSurface002
* @tc.type: FUNC
* @tc.require: issueI794H6
*/
HWTEST_F(RSSurfaceCaptureTaskTest, FindSecurityOrSkipLayer001, Function | SmallTest | Level2)
HWTEST_F(RSSurfaceCaptureTaskTest, FindSecurityOrSkipOrProtectedLayer001, Function | SmallTest | Level2)
{
NodeId id = 0;
float scaleX = 0.f;
float scaleY = 0.f;
RSSurfaceCaptureTask task(id, scaleX, scaleY);
EXPECT_EQ(false, task.FindSecurityOrSkipLayer());
EXPECT_EQ(false, task.FindSecurityOrSkipOrProtectedLayer());
}
/*
@ -978,13 +978,13 @@ HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode002, Function | Small
HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode003, Function | SmallTest | Level2)
{
ASSERT_NE(nullptr, visitor_);
auto hasSecurityOrSkipLayer = visitor_->hasSecurityOrSkipLayer_;
visitor_->hasSecurityOrSkipLayer_ = true;
auto hasSecurityOrSkipOrProtectedLayer = visitor_->hasSecurityOrSkipOrProtectedLayer_;
visitor_->hasSecurityOrSkipOrProtectedLayer_ = true;
NodeId id = 1;
RSDisplayNodeConfig config;
RSDisplayRenderNode node(id, config);
visitor_->ProcessDisplayRenderNode(node);
visitor_->hasSecurityOrSkipLayer_ = hasSecurityOrSkipLayer;
visitor_->hasSecurityOrSkipOrProtectedLayer_ = hasSecurityOrSkipOrProtectedLayer;
}
/*
@ -996,8 +996,8 @@ HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode003, Function | Small
HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode004, Function | SmallTest | Level2)
{
ASSERT_NE(nullptr, visitor_);
auto hasSecurityOrSkipLayer = visitor_->hasSecurityOrSkipLayer_;
visitor_->hasSecurityOrSkipLayer_ = true;
auto hasSecurityOrSkipOrProtectedLayer = visitor_->hasSecurityOrSkipOrProtectedLayer_;
visitor_->hasSecurityOrSkipOrProtectedLayer_ = true;
NodeId id = 1;
RSDisplayNodeConfig config;
RSDisplayRenderNode node(id, config);
@ -1009,7 +1009,7 @@ HWTEST_F(RSSurfaceCaptureTaskTest, ProcessDisplayRenderNode004, Function | Small
sptr<OHOS::SurfaceBuffer> buffer = new SurfaceBufferImpl(0);
node.SetBuffer(buffer, acquireFence, damage, timestamp);
visitor_->ProcessDisplayRenderNode(node);
visitor_->hasSecurityOrSkipLayer_ = hasSecurityOrSkipLayer;
visitor_->hasSecurityOrSkipOrProtectedLayer_ = hasSecurityOrSkipOrProtectedLayer;
}
/*
@ -1066,12 +1066,12 @@ HWTEST_F(RSSurfaceCaptureTaskTest, AdjustZOrderAndDrawSurfaceNode, Function | Sm
}
/*
* @tc.name: FindSecurityOrSkipLayer
* @tc.desc: Test RSSurfaceCaptureTaskTest.FindSecurityOrSkipLayer
* @tc.name: FindSecurityOrSkipOrProtectedLayer
* @tc.desc: Test RSSurfaceCaptureTaskTest.FindSecurityOrSkipOrProtectedLayer
* @tc.type: FUNC
* @tc.require: issueI7G9F0
*/
HWTEST_F(RSSurfaceCaptureTaskTest, FindSecurityOrSkipLayer, Function | SmallTest | Level2)
HWTEST_F(RSSurfaceCaptureTaskTest, FindSecurityOrSkipOrProtectedLayer, Function | SmallTest | Level2)
{
float scaleX = 0.f;
float scaleY = 0.f;
@ -1090,7 +1090,7 @@ HWTEST_F(RSSurfaceCaptureTaskTest, FindSecurityOrSkipLayer, Function | SmallTest
node3->SetIsOnTheTree(true);
node3->isSecurityLayer_ = true;
nodeMap.surfaceNodeMap_[3] = node3;
ASSERT_TRUE(task.FindSecurityOrSkipLayer());
ASSERT_TRUE(task.FindSecurityOrSkipOrProtectedLayer());
nodeMap.surfaceNodeMap_.clear();
}