diff --git a/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp b/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp index 3f3385716eab26183c982d1cc1600ec1d54ceb1c..1b92b3934f9f78f235b20c71bb359ed3588462e0 100644 --- a/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp +++ b/rosen/modules/render_service/core/drawable/dfx/rs_dirty_rects_dfx.cpp @@ -284,7 +284,7 @@ void RSDirtyRectsDfx::DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas, if (!screenParams_) { return; } - // hsc todo:dfx迁移到display, 使用displayParams + auto params = static_cast(screenParams_.get()); if (surfaceParams.IsFirstLevelCrossNode() && !params->IsFirstVisitCrossNodeDisplay()) { return; diff --git a/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.cpp b/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.cpp index 6926cfdbf434d31bbabc6d329f843993f694345d..a604abb5cc1c209935ec053bbcbd457ea72a405e 100644 --- a/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.cpp +++ b/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.cpp @@ -43,7 +43,7 @@ void RSRefreshRateDfx::OnDraw(RSPaintFilterCanvas& canvas) } uint32_t currentRefreshRate = OHOS::Rosen::HgmCore::Instance().GetScreenCurrentRefreshRate(screenId); uint32_t realtimeRefreshRate = RSRealtimeRefreshRateManager::Instance().GetRealtimeRefreshRate(screenId); - static bool showRealtimeRefreshRate = system::GetParameter("const.logsystem.versiontype", "") == "beta"; + static bool showRealtimeRefreshRate = RSSystemProperties::GetVersionType() == "beta"; std::string info = std::to_string(currentRefreshRate); if (showRealtimeRefreshRate || RSSystemParameters::GetShowRefreshRateEnabled()) { info += " " + std::to_string(realtimeRefreshRate); @@ -58,11 +58,9 @@ void RSRefreshRateDfx::OnDraw(RSPaintFilterCanvas& canvas) brush.SetColor(currentRefreshRate <= 60 ? SK_ColorRED : SK_ColorGREEN); // low refresh rate 60 brush.SetAntiAlias(true); RSAutoCanvasRestore acr(&canvas); - canvas.ResetMatrix(); canvas.AttachBrush(brush); if (!RefreshRateRotationProcess(canvas, params->GetScreenRotation(), - static_cast(params->GetBounds().GetWidth()), - static_cast(params->GetBounds().GetHeight()))) { + params->GetBounds().GetWidth(), params->GetBounds().GetHeight())) { return; } // 100.f:Scalar x of drawing TextBlob; 200.f:Scalar y of drawing TextBlob @@ -71,7 +69,7 @@ void RSRefreshRateDfx::OnDraw(RSPaintFilterCanvas& canvas) } bool RSRefreshRateDfx::RefreshRateRotationProcess(RSPaintFilterCanvas& canvas, - ScreenRotation rotation, uint32_t translateWidth, uint32_t translateHeight) + ScreenRotation rotation, float translateWidth, float translateHeight) { auto params = static_cast(logicalDisplayParams_.get()); auto screenManager = CreateOrGetScreenManager(); @@ -79,9 +77,10 @@ bool RSRefreshRateDfx::RefreshRateRotationProcess(RSPaintFilterCanvas& canvas, return false; } Drawing::Matrix invertMatrix; - if (params->GetNeedOffscreen() && params->GetMatrix().Invert(invertMatrix)) { + if (params->GetMatrix().Invert(invertMatrix)) { canvas.ConcatMatrix(invertMatrix); } + auto screenId = params->GetScreenId(); auto screenCorrection = screenManager->GetScreenCorrection(screenId); if (screenCorrection != ScreenRotation::INVALID_SCREEN_ROTATION && @@ -91,17 +90,22 @@ bool RSRefreshRateDfx::RefreshRateRotationProcess(RSPaintFilterCanvas& canvas, - static_cast(screenCorrection)) % SCREEN_ROTATION_NUM); } + // 2: if ret is odd, width and height should be swapped + if ((static_cast(rotation) - static_cast(params->GetNodeRotation())) % 2) { + std::swap(translateWidth, translateHeight); + } + + canvas.Translate(params->GetOffsetX(), params->GetOffsetY()); if (rotation != ScreenRotation::ROTATION_0) { if (rotation == ScreenRotation::ROTATION_90) { canvas.Rotate(-90, 0, 0); // 90 degree for text draw - canvas.Translate(-(static_cast(translateWidth)), 0); + canvas.Translate(-translateWidth, 0); } else if (rotation == ScreenRotation::ROTATION_180) { - // 180 degree for text draw - canvas.Rotate(-180, static_cast(translateWidth) / 2, // 2 half of screen width - static_cast(translateHeight) / 2); // 2 half of screen height + // 180: degree for text draw, 2: half + canvas.Rotate(-180, translateWidth / 2, translateHeight / 2); } else if (rotation == ScreenRotation::ROTATION_270) { canvas.Rotate(-270, 0, 0); // 270 degree for text draw - canvas.Translate(0, -(static_cast(translateHeight))); + canvas.Translate(0, -translateHeight); } else { return false; } diff --git a/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.h b/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.h index 0a9534c441ce28b37794535f1d2ae0284bee1af4..f2a58ea33afbba20ddac9f2ba9bf240252a4b9bf 100644 --- a/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.h +++ b/rosen/modules/render_service/core/drawable/dfx/rs_refresh_rate_dfx.h @@ -34,7 +34,7 @@ public: private: bool RefreshRateRotationProcess(RSPaintFilterCanvas& canvas, - ScreenRotation rotation, uint32_t translateWidth, uint32_t translateHeight); + ScreenRotation rotation, float translateWidth, float translateHeight); const DrawableV2::RSLogicalDisplayRenderNodeDrawable& logicalDisplayDrawable_; const std::unique_ptr& logicalDisplayParams_; diff --git a/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.cpp index 594aec34a53e1a47a74d73e5aee6f7cde6c5c05b..3cf92eeb2b1b59f92f620048695e8bb2f12cc4e9 100644 --- a/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.cpp @@ -17,6 +17,7 @@ #include "rs_trace.h" #include "graphic_feature_param_manager.h" +#include "feature/dirty/rs_uni_dirty_compute_util.h" #include "feature/drm/rs_drm_util.h" #include "feature/hdr/rs_hdr_util.h" #include "feature/uifirst/rs_uifirst_manager.h" @@ -180,6 +181,7 @@ void RSLogicalDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (params->GetNeedOffscreen()) { uniParam->SetOpDropped(false); + curCanvas_->Clear(Drawing::Color::COLOR_BLACK); } if (needOffscreen) { @@ -190,7 +192,7 @@ void RSLogicalDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (screenInfo.isSamplingOn && scaleManager_ != nullptr) { screenParams->SetSlrMatrix(scaleManager_->GetScaleMatrix()); } - PrepareOffscreenRender(*this, !screenInfo.isSamplingOn); + PrepareOffscreenRender(*this, !screenInfo.isSamplingOn, !screenInfo.isSamplingOn); #ifdef RS_PROFILER_ENABLED if (auto canvas = RSCaptureRecorder::GetInstance().TryInstantCapture(static_cast(curCanvas_->GetWidth()), @@ -198,7 +200,7 @@ void RSLogicalDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) curCanvas_->AddCanvas(canvas); } #endif - if (!params->GetNeedOffscreen() && !screenInfo.isSamplingOn && (isHdrOn || isScRGBEnable)) { + if (!params->GetNeedOffscreen() && !screenInfo.isSamplingOn) { curCanvas_->ClipRect(rect); } else { curCanvas_->Clear(Drawing::Color::COLOR_TRANSPARENT); @@ -223,7 +225,9 @@ void RSLogicalDisplayRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) if (needOffscreen && canvasBackup_) { Drawing::AutoCanvasRestore acr(*canvasBackup_, true); - params->ApplyAlphaAndMatrixToCanvas(*curCanvas_); + if (params->GetNeedOffscreen()) { + params->ApplyAlphaAndMatrixToCanvas(*curCanvas_); + } ClearTransparentBeforeSaveLayer(); #ifdef RS_PROFILER_ENABLED RSCaptureRecorder::GetInstance().EndInstantCapture(SkpCaptureType::EXTENDED); @@ -269,17 +273,16 @@ void RSLogicalDisplayRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas) } bool noBuffer = RSUniRenderThread::GetCaptureParam().isSnapshot_ && screenDrawable->GetRSSurfaceHandlerOnDraw()->GetBuffer() == nullptr; - // temporary: copy not support when until display node on mirrored screen node - bool forceRedraw = screenParam->GetChildDisplayCount() > 1; if (noBuffer) { RS_LOGW("RSLogicalDisplayRenderNodeDrawable::OnCapture: buffer is null!"); } + auto specialLayerType = GetSpecialLayerType(*params); // Screenshot blackList, exclude surfaceNode in blackList while capturing displayNode auto currentBlackList = RSUniRenderThread::Instance().GetBlackList(); if (specialLayerType != NO_SPECIAL_LAYER || UNLIKELY(noBuffer) || screenParam->GetScreenInfo().isSamplingOn || UNLIKELY(RSUniRenderThread::GetCaptureParam().isMirror_) || screenDrawable->IsRenderSkipIfScreenOff() || - !currentBlackList.empty() || forceRedraw) { + !currentBlackList.empty()) { RS_LOGD("RSLogicalDisplayRenderNodeDrawable::OnCapture: \ process RSLogicalDisplayRenderNode(id:[%{public}" PRIu64 "]) Not using UniRender buffer.", params->GetId()); @@ -288,6 +291,7 @@ void RSLogicalDisplayRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas) "isSamplingOn: %d, isRenderSkipIfScreenOff: %d, blackList: %lu", __func__, params->GetScreenId(), specialLayerType != NO_SPECIAL_LAYER, noBuffer, screenParam->GetScreenInfo().isSamplingOn, screenDrawable->IsRenderSkipIfScreenOff(), currentBlackList.size()); + if (!UNLIKELY(RSUniRenderThread::GetCaptureParam().isMirror_)) { params->ApplyAlphaAndMatrixToCanvas(*paintFilterCanvas); } @@ -315,7 +319,7 @@ void RSLogicalDisplayRenderNodeDrawable::DrawHardwareEnabledNodes( std::vector hwcNodes; std::vector hwcTopNodes; RSUniRenderUtil::CollectHardwareEnabledNodesByDisplayNodeId(hwcNodes, hwcTopNodes, params.GetId()); - + RS_LOGI("RSLogicalDisplayRenderNodeDrawable::DrawHardwareEnabledNodes: \ process RSScreenRenderNode(id:[%{public}" PRIu64 "]) \ Using UniRender buffer with hwcNodes(%{public}zu), hwcTopNodes(%{public}zu).", @@ -323,7 +327,7 @@ void RSLogicalDisplayRenderNodeDrawable::DrawHardwareEnabledNodes( RS_TRACE_NAME_FMT("Process ScreenRenderNodeDrawable[%{public}" PRIu64 "] \ using UniRender buffer with hwcNodes(%{public}zu), hwcTopNodes(%{public}zu).", params.GetScreenId(), hwcNodes.size(), hwcTopNodes.size()); - + RSUniRenderUtil::AdjustZOrderAndDrawSurfaceNode(hwcNodes, canvas, *screenParams); auto renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); @@ -346,7 +350,7 @@ void RSLogicalDisplayRenderNodeDrawable::DrawExpandDisplay(RSLogicalDisplayRende RS_LOGD("%{public}s HDRCast isHDREnabledVirtualScreen true", __func__); curCanvas_->SetHDREnabledVirtualScreen(true); curCanvas_->SetHdrOn(true); - PrepareOffscreenRender(*this, false); + PrepareOffscreenRender(*this, false, false); RSRenderNodeDrawable::OnDraw(*curCanvas_); FinishOffscreenRender(Drawing::SamplingOptions(Drawing::FilterMode::NEAREST, Drawing::MipmapMode::NONE), screenInfo.isSamplingOn); @@ -437,28 +441,28 @@ std::vector RSLogicalDisplayRenderNodeDrawable::CalculateVirtualDirty( RSLogicalDisplayRenderParams& params, Drawing::Matrix canvasMatrix) { // uniParam/drawable/mirroredParams not null in caller - std::vector mappedDamageRegionRects; + Occlusion::Region mappedDamageRegion; auto& uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams(); auto curScreenParams = static_cast(curScreenDrawable.GetRenderParams().get()); auto drawable = curScreenParams->GetMirrorSourceDrawable().lock(); if (!drawable) { RS_LOGE("%{public}s mirroredDrawable nullptr", __func__); - virtualProcesser->SetRoiRegionToCodec(mappedDamageRegionRects); - return mappedDamageRegionRects; + virtualProcesser->SetRoiRegionToCodec(mappedDamageRegion.GetRegionRectIs()); + return mappedDamageRegion.GetRegionRectIs(); } auto mirroredDrawable = std::static_pointer_cast(drawable); auto mirrorParams = static_cast(mirroredDrawable->GetRenderParams().get()); sptr screenManager = CreateOrGetScreenManager(); if (!screenManager) { RS_LOGE("RSLogicalDisplayRenderNodeDrawable::CalculateVirtualDirty ScreenManager is nullptr"); - virtualProcesser->SetRoiRegionToCodec(mappedDamageRegionRects); - return mappedDamageRegionRects; + virtualProcesser->SetRoiRegionToCodec(mappedDamageRegion.GetRegionRectIs()); + return mappedDamageRegion.GetRegionRectIs(); } const auto& curScreenInfo = curScreenParams->GetScreenInfo(); if (!curScreenInfo.isEqualVsyncPeriod) { RS_LOGD("RSLogicalDisplayRenderNodeDrawable::CalculateVirtualDirty frame rate is irregular"); - virtualProcesser->SetRoiRegionToCodec(mappedDamageRegionRects); - return mappedDamageRegionRects; + virtualProcesser->SetRoiRegionToCodec(mappedDamageRegion.GetRegionRectIs()); + return mappedDamageRegion.GetRegionRectIs(); } const auto& mainScreenInfo = mirrorParams->GetScreenInfo(); int32_t bufferAge = virtualProcesser->GetBufferAge(); @@ -467,7 +471,7 @@ std::vector RSLogicalDisplayRenderNodeDrawable::CalculateVirtualDirty( std::shared_ptr tmpGeo = std::make_shared(); for (auto& rect : damageRegionRects) { RectI mappedRect = tmpGeo->MapRect(rect.ConvertTo(), canvasMatrix); - mappedDamageRegionRects.emplace_back(mappedRect); + mappedDamageRegion.OrSelf(Occlusion::Region(Occlusion::Rect(mappedRect))); } bool needRefresh = !(lastCanvasMatrix_ == canvasMatrix) || !(lastMirrorMatrix_ == mirrorParams->GetMatrix()) || @@ -497,9 +501,13 @@ std::vector RSLogicalDisplayRenderNodeDrawable::CalculateVirtualDirty( } UpdateDisplayDirtyManager(curScreenDrawable.GetSyncDirtyManager(), bufferAge, false); auto extraDirty = curScreenDrawable.GetSyncDirtyManager()->GetDirtyRegion(); - if (!extraDirty.IsEmpty()) { - mappedDamageRegionRects.emplace_back(extraDirty); + mappedDamageRegion.OrSelf(Occlusion::Region(Occlusion::Rect(extraDirty))); + + if (!virtualProcesser->GetDrawVirtualMirrorCopy()) { + RSUniFilterDirtyComputeUtil::DealWithFilterDirtyRegion( + mappedDamageRegion, mappedDamageRegion, *mirroredDrawable, canvasMatrix, false); } + auto mappedDamageRegionRects = mappedDamageRegion.GetRegionRectIs(); if (!uniParam->IsVirtualDirtyDfxEnabled()) { virtualProcesser->SetDirtyInfo(mappedDamageRegionRects); RS_TRACE_NAME_FMT("SetDamageRegion damageRegionrects num: %zu, info: %s", @@ -595,12 +603,10 @@ void RSLogicalDisplayRenderNodeDrawable::WiredScreenProjection( RS_LOGE("RSLogicalDisplayRenderNodeDrawable::WiredScreenProjection mirror source is null"); return; } - // temporary: copy not support when multi display node on mirrored screen node - bool forceRedraw = mirroredScreenParams->GetChildDisplayCount() > 1; bool isProcessSecLayer = !MultiScreenParam::IsExternalScreenSecure() && mirroredParams->GetSpecialLayerMgr().Find(SpecialLayerType::HAS_SECURITY); - auto isRedraw = RSSystemParameters::GetDebugMirrorOndrawEnabled() || forceRedraw || + auto isRedraw = RSSystemParameters::GetDebugMirrorOndrawEnabled() || (RSSystemParameters::GetWiredScreenOndrawEnabled() && !enableVisibleRect_ && (mirroredScreenParams->GetHDRPresent() || isProcessSecLayer || !currentBlackList_.empty() || mirroredParams->GetSpecialLayerMgr().Find(SpecialLayerType::HAS_PROTECTED))); @@ -622,8 +628,9 @@ void RSLogicalDisplayRenderNodeDrawable::WiredScreenProjection( DrawWiredMirrorOnDraw(*mirroredDrawable, params); } else { MirrorRedrawDFX(false, params.GetScreenId()); - std::vector damageRegionRects = CalculateVirtualDirtyForWiredScreen(*curScreenDrawable, - isMirrorSLRCopy_ ? scaleManager_->GetScaleMatrix() : curCanvas_->GetTotalMatrix()); + auto matrix = isMirrorSLRCopy_ ? scaleManager_->GetScaleMatrix() : curCanvas_->GetTotalMatrix(); + matrix.PreTranslate(-mirroredParams->GetOffsetX(), -mirroredParams->GetOffsetY()); + std::vector damageRegionRects = CalculateVirtualDirtyForWiredScreen(*curScreenDrawable, matrix); rsDirtyRectsDfx.SetVirtualDirtyRects(damageRegionRects, curScreenParams->GetScreenInfo()); DrawWiredMirrorCopy(*mirroredDrawable); } @@ -649,6 +656,12 @@ void RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorCopy(RSLogicalDisplayRen RS_LOGE("RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorCopy mirroredScreenDrawable is null"); return; } + auto width = mirroredParams->GetBounds().GetWidth(); + auto height = mirroredParams->GetBounds().GetHeight(); + if (mirroredParams->GetNodeRotation() == ScreenRotation::ROTATION_90 || + mirroredParams->GetNodeRotation() == ScreenRotation::ROTATION_270) { + std::swap(width, height); + } auto cacheImage = mirroredScreenDrawable->GetCacheImgForCapture(); if (cacheImage && RSSystemProperties::GetDrawMirrorCacheImageEnabled()) { RS_TRACE_NAME("DrawWiredMirrorCopy with cacheImage"); @@ -657,7 +670,10 @@ void RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorCopy(RSLogicalDisplayRen scaleManager_->ProcessCacheImage(*curCanvas_, *cacheImage); } else if (!enableVisibleRect_) { RS_TRACE_NAME("DrawWiredMirrorCopy with SkiaScale"); - RSUniRenderUtil::ProcessCacheImage(*curCanvas_, *cacheImage); + Drawing::RectI srcRect = { mirroredParams->GetOffsetX(), mirroredParams->GetOffsetY(), + mirroredParams->GetOffsetX() + width, mirroredParams->GetOffsetY() + height }; + RSUniRenderUtil::ProcessCacheImageRect(*curCanvas_, *cacheImage, srcRect, + Drawing::Rect(0, 0, width, height)); } else { RS_TRACE_NAME_FMT("DrawWiredMirrorCopy with VisibleRect[%d, %d, %d, %d]", curVisibleRect_.GetLeft(), curVisibleRect_.GetTop(), @@ -673,6 +689,10 @@ void RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorCopy(RSLogicalDisplayRen if (enableVisibleRect_) { drawParams.srcRect = curVisibleRect_; drawParams.dstRect = Drawing::Rect(0, 0, curVisibleRect_.GetWidth(), curVisibleRect_.GetHeight()); + } else { + drawParams.srcRect = { mirroredParams->GetOffsetX(), mirroredParams->GetOffsetY(), + mirroredParams->GetOffsetX() + width, mirroredParams->GetOffsetY() + height }; + drawParams.dstRect = Drawing::Rect(0, 0, width, height); } drawParams.isMirror = true; renderEngine->DrawScreenNodeWithParams(*curCanvas_, @@ -743,17 +763,23 @@ void RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorOnDraw( RS_LOGE("RSLogicalDisplayRenderNodeDrawable::DrawWiredMirrorOnDraw mirroredScreenParams is null"); return; } - auto screenInfo = mirroredScreenParams->GetScreenInfo(); uniParam->SetScreenInfo(screenInfo); - Drawing::Rect rect(0, 0, screenInfo.width, screenInfo.height); + auto width = mirroredParams->GetBounds().GetWidth(); + auto height = mirroredParams->GetBounds().GetHeight(); + if (mirroredParams->GetNodeRotation() == ScreenRotation::ROTATION_90 || + mirroredParams->GetNodeRotation() == ScreenRotation::ROTATION_270) { + std::swap(width, height); + } + Drawing::Rect rect(0, 0, width, height); curCanvas_->ClipRect(rect, Drawing::ClipOp::INTERSECT, false); + curCanvas_->Translate(-mirroredParams->GetOffsetX(), -mirroredParams->GetOffsetY()); curCanvas_->ConcatMatrix(mirroredParams->GetMatrix()); RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix()); mirroredDrawable.RSRenderNodeDrawable::OnDraw(*curCanvas_); auto [__, screenParam] = GetScreenParams(params); bool displayP3Enable = screenParam ? screenParam->GetNewColorSpace() == GRAPHIC_COLOR_GAMUT_DISPLAY_P3 : false; - // 1.f: wired screen not use hdr, use default value 1.f + // 1.f: wired screen not use hdr, use default value 1.f RSUniRenderUtil::SwitchColorFilter(*curCanvas_, 1.f, displayP3Enable); uniParam->SetOpDropped(isOpDropped); @@ -782,22 +808,21 @@ void RSLogicalDisplayRenderNodeDrawable::DrawMirrorScreen( virtualProcesser->CanvasInit(*this); auto cacheImage = mirroredScreenDrawable ? mirroredScreenDrawable->GetCacheImgForCapture() : nullptr; + const auto screenInfo = uniParam->GetScreenInfo(); // record screenInfo auto [__, screenParams] = GetScreenParams(params); if (!screenParams) { RS_LOGE("RSLogicalDisplayRenderNodeDrawable::DrawMirrorScreen screenParams is null"); return; } - // temporary: copy not support when until display node on mirrored screen node - bool forceRedraw = mirroredScreenParams->GetChildDisplayCount() > 1; uniParam->SetScreenInfo(screenParams->GetScreenInfo()); // if specialLayer is visible and no CacheImg if ((mirroredParams->IsSecurityDisplay() != params.IsSecurityDisplay() && specialLayerType == HAS_SPECIAL_LAYER) - || !cacheImage || params.GetVirtualScreenMuteStatus() || forceRedraw) { + || !cacheImage || params.GetVirtualScreenMuteStatus()) { MirrorRedrawDFX(true, params.GetScreenId()); virtualProcesser->SetDrawVirtualMirrorCopy(false); - DrawMirror(params, virtualProcesser, &RSLogicalDisplayRenderNodeDrawable::OnCapture, *uniParam); + DrawMirror(params, virtualProcesser, *uniParam); } else { MirrorRedrawDFX(false, params.GetScreenId()); virtualProcesser->SetDrawVirtualMirrorCopy(true); @@ -948,7 +973,7 @@ void RSLogicalDisplayRenderNodeDrawable::SetCanvasBlack(RSProcessor& processor) } void RSLogicalDisplayRenderNodeDrawable::DrawMirror(RSLogicalDisplayRenderParams& params, - std::shared_ptr virtualProcesser, DrawFuncPtr drawFunc, RSRenderThreadParams& uniParam) + std::shared_ptr virtualProcesser, RSRenderThreadParams& uniParam) { RS_TRACE_FUNC(); @@ -1029,7 +1054,7 @@ void RSLogicalDisplayRenderNodeDrawable::DrawMirror(RSLogicalDisplayRenderParams curCanvas_->Clear(Drawing::Color::COLOR_TRANSPARENT); virtualProcesser->CanvasClipRegionForUniscaleMode(visibleClipRectMatrix_, mirroredScreenInfo); curCanvas_->ConcatMatrix(mirroredParams->GetMatrix()); - PrepareOffscreenRender(*mirroredDrawable, false); + PrepareOffscreenRender(*mirroredDrawable, false, false); #ifdef RS_PROFILER_ENABLED if (auto canvas = RSCaptureRecorder::GetInstance().TryInstantCapture(static_cast(curCanvas_->GetWidth()), static_cast(curCanvas_->GetHeight()), SkpCaptureType::ON_CAPTURE)) { @@ -1045,7 +1070,7 @@ void RSLogicalDisplayRenderNodeDrawable::DrawMirror(RSLogicalDisplayRenderParams RSRenderParams::SetParentSurfaceMatrix(curCanvas_->GetTotalMatrix()); bool isOpDropped = uniParam.IsOpDropped(); uniParam.SetOpDropped(false); // disable partial render - (mirroredDrawable->*drawFunc)(*curCanvas_); + mirroredDrawable->OnCapture(*curCanvas_); uniParam.SetOpDropped(isOpDropped); RSUniRenderThread::ResetCaptureParam(); #ifdef RS_PROFILER_ENABLED @@ -1066,7 +1091,7 @@ void RSLogicalDisplayRenderNodeDrawable::UpdateSlrScale(ScreenInfo& screenInfo, { if (screenInfo.isSamplingOn && RSSystemProperties::GetSLRScaleEnabled()) { if (scaleManager_== nullptr) { - scaleManager_ = std::make_unique( + scaleManager_ = std::make_shared( screenInfo.phyWidth, screenInfo.phyHeight, screenInfo.width, screenInfo.height); } else { scaleManager_->CheckOrRefreshScreen( @@ -1103,33 +1128,35 @@ void RSLogicalDisplayRenderNodeDrawable::ScaleCanvasIfNeeded(const ScreenInfo& s void RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen( RSLogicalDisplayRenderNodeDrawable& mirroredDrawable) { - auto& mirroredParams = mirroredDrawable.GetRenderParams(); + auto mirroredParams = static_cast(mirroredDrawable.GetRenderParams().get()); if (!mirroredParams) { RS_LOGE("RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen mirroredParams is null"); return; } auto [_, mirroredScreenParams] = GetScreenParams(*mirroredParams); - auto& nodeParams = GetRenderParams(); - if (!nodeParams || !mirroredScreenParams) { + auto params = static_cast(GetRenderParams().get()); + auto [__, screenParam] = GetScreenParams(*params); + if (!params || !mirroredScreenParams || !screenParam) { RS_LOGE("RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen nodeParams is null"); return; } - auto [__, screenParam] = GetScreenParams(*nodeParams); - if (!screenParam) { - RS_LOGE("RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen screenParam is null"); - return; + + auto mainWidth = enableVisibleRect_ ? curVisibleRect_.GetWidth() : mirroredParams->GetBounds().GetWidth(); + auto mainHeight = enableVisibleRect_ ? curVisibleRect_.GetHeight() : mirroredParams->GetBounds().GetHeight(); + auto mirrorWidth = screenParam->GetBounds().GetWidth(); + auto mirrorHeight = screenParam->GetBounds().GetHeight(); + + auto nodeRotation = mirroredParams->GetNodeRotation(); + bool needRotate = (nodeRotation == ScreenRotation::ROTATION_90 || nodeRotation == ScreenRotation::ROTATION_270) && + !enableVisibleRect_; + if (needRotate) { + std::swap(mainWidth, mainHeight); } - auto mainScreenInfo = mirroredScreenParams->GetScreenInfo(); - auto mainWidth = enableVisibleRect_ ? curVisibleRect_.GetWidth() : static_cast(mainScreenInfo.width); - auto mainHeight = enableVisibleRect_ ? curVisibleRect_.GetHeight() : static_cast(mainScreenInfo.height); - auto mirrorScreenInfo = screenParam->GetScreenInfo(); - auto mirrorWidth = static_cast(mirrorScreenInfo.width); - auto mirrorHeight = static_cast(mirrorScreenInfo.height); auto rotation = mirroredParams->GetScreenRotation(); auto screenManager = CreateOrGetScreenManager(); RS_TRACE_NAME_FMT("ScaleAndRotateMirrorForWiredScreen[%" PRIu64 "](%f, %f), [%" PRIu64 "](%f, %f), rotation: %d", - mirroredScreenParams->GetScreenId(), mainWidth, mainHeight, mirrorScreenInfo.id, + mirroredParams->GetScreenId(), mainWidth, mainHeight, params->GetScreenId(), mirrorWidth, mirrorHeight, rotation); if (screenManager) { auto screenCorrection = screenManager->GetScreenCorrection(mirroredScreenParams->GetScreenId()); @@ -1142,8 +1169,6 @@ void RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen( } // Rotate RotateMirrorCanvas(rotation, mirrorWidth, mirrorHeight); - // not support rotation for MirrorScreen enableVisibleRect - rotation = enableVisibleRect_ ? ScreenRotation::ROTATION_0 : rotation; if (rotation == ScreenRotation::ROTATION_90 || rotation == ScreenRotation::ROTATION_270) { std::swap(mirrorWidth, mirrorHeight); } @@ -1164,11 +1189,6 @@ void RSLogicalDisplayRenderNodeDrawable::ScaleAndRotateMirrorForWiredScreen( scaleManager_->CanvasScale(*curCanvas_); } else { auto scaleNum = std::min(mirrorWidth / mainWidth, mirrorHeight / mainHeight); - int angle = RSUniRenderUtil::GetRotationFromMatrix(curCanvas_->GetTotalMatrix()); - if (RSSystemProperties::IsSuperFoldDisplay() && RSBaseRenderUtil::PortraitAngle(angle)) { - scaleNum = mirrorHeight / mainWidth; - std::swap(mirrorWidth, mirrorHeight); - } curCanvas_->Translate((mirrorWidth - scaleNum * mainWidth) * 0.5f, (mirrorHeight - scaleNum * mainHeight) * 0.5f); curCanvas_->Scale(scaleNum, scaleNum); @@ -1263,7 +1283,7 @@ void RSLogicalDisplayRenderNodeDrawable::ClearTransparentBeforeSaveLayer() } void RSLogicalDisplayRenderNodeDrawable::PrepareOffscreenRender( - const RSLogicalDisplayRenderNodeDrawable& displayDrawable, bool useFixedSize) + const RSLogicalDisplayRenderNodeDrawable& displayDrawable, bool useFixedSize, bool useCanvasSize) { const auto& params = static_cast(displayDrawable.GetRenderParams().get()); if (UNLIKELY(!params)) { @@ -1272,6 +1292,7 @@ void RSLogicalDisplayRenderNodeDrawable::PrepareOffscreenRender( } canvasBackup_ = nullptr; useFixedOffscreenSurfaceSize_ = false; + auto frameSize = params->GetFrameRect(); auto offscreenWidth = static_cast(frameSize.GetWidth()); auto offscreenHeight = static_cast(frameSize.GetHeight()); @@ -1287,8 +1308,7 @@ void RSLogicalDisplayRenderNodeDrawable::PrepareOffscreenRender( offscreenTranslateX_ = std::round((maxRenderLength - offscreenWidth) * 0.5f); offscreenTranslateY_ = std::round((maxRenderLength - offscreenHeight) * 0.5f); } else { - maxRenderLength = - static_cast(std::max(offscreenWidth, offscreenHeight)); + maxRenderLength = static_cast(std::max(offscreenWidth, offscreenHeight)); if (offscreenSurface_ != nullptr && maxRenderLength != std::max(offscreenSurface_->Width(), offscreenSurface_->Height())) { RS_TRACE_NAME("offscreen surface's max size has changed"); @@ -1324,13 +1344,18 @@ void RSLogicalDisplayRenderNodeDrawable::PrepareOffscreenRender( RS_LOGE("RSLogicalDisplayRenderNodeDrawable::%{public}s screenParams is nullptr", __func__); return; } - if (!params->GetNeedOffscreen() || !useFixedOffscreenSurfaceSize_ || !offscreenSurface_ || + bool createOffscreenSurface = !params->GetNeedOffscreen() || !useFixedOffscreenSurfaceSize_ || !offscreenSurface_ || (screenParams->GetHDRPresent() && - offscreenSurface_->GetImageInfo().GetColorType() != Drawing::ColorType::COLORTYPE_RGBA_F16)) { + offscreenSurface_->GetImageInfo().GetColorType() != Drawing::ColorType::COLORTYPE_RGBA_F16); + if (createOffscreenSurface) { RS_TRACE_NAME_FMT("make offscreen surface with fixed size: [%d, %d]", offscreenWidth, offscreenHeight); - bool isScRGBEnable = EnablescRGBForP3AndUiFirst(screenParams->GetNewColorSpace()); - if (screenParams->GetHDRPresent() || isScRGBEnable) { + bool hdrOrScRGB = screenParams->GetHDRPresent() || EnablescRGBForP3AndUiFirst(screenParams->GetNewColorSpace()); + if (hdrOrScRGB) { RS_LOGD("HDR PrepareHdrDraw"); + if (!params->GetNeedOffscreen() && useCanvasSize) { + offscreenWidth = curCanvas_->GetWidth(); + offscreenHeight = curCanvas_->GetHeight(); + } Drawing::ImageInfo info = { offscreenWidth, offscreenHeight, Drawing::COLORTYPE_RGBA_F16, Drawing::ALPHATYPE_PREMUL, Drawing::ColorSpace::CreateSRGB() }; offscreenSurface_ = curCanvas_->GetSurface()->MakeSurface(info); @@ -1344,6 +1369,7 @@ void RSLogicalDisplayRenderNodeDrawable::PrepareOffscreenRender( curCanvas_->ClipRect(Drawing::Rect(0, 0, offscreenWidth, offscreenHeight), Drawing::ClipOp::INTERSECT, false); return; } + offscreenCanvas_ = std::make_shared(offscreenSurface_.get()); if (RSSystemProperties::GetCacheOptimizeRotateEnable()) { @@ -1502,7 +1528,7 @@ RSLogicalDisplayRenderNodeDrawable::AncestorParams RSLogicalDisplayRenderNodeDra return { nullptr, nullptr }; } auto screenParams = static_cast(screenDrawable->GetRenderParams().get()); - return {screenDrawable.get(), screenParams}; + return {screenDrawable, screenParams}; } RSLogicalDisplayRenderNodeDrawable::MirrorSourceParams RSLogicalDisplayRenderNodeDrawable::GetMirrorSourceParams( @@ -1519,9 +1545,9 @@ RSLogicalDisplayRenderNodeDrawable::MirrorSourceParams RSLogicalDisplayRenderNod } auto mirroredParams = static_cast(mirroredDrawable->GetRenderParams().get()); if (!mirroredParams) { - return { mirroredDrawable.get(), nullptr, nullptr, nullptr }; + return { mirroredDrawable, nullptr, nullptr, nullptr }; } - return std::tuple_cat(std::tuple{mirroredDrawable.get(), mirroredParams}, GetScreenParams(*mirroredParams)); + return std::tuple_cat(std::tuple{mirroredDrawable, mirroredParams}, GetScreenParams(*mirroredParams)); } } // namespace OHOS::ROSEN::DrawableV2 \ No newline at end of file diff --git a/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.h index c2790ba3d86227d5e58f6b1cc2f84d9b389b9cbd..bba164d80b8b5a78cd0de3b4d1f53605c03b1611 100644 --- a/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_logical_display_render_node_drawable.h @@ -68,7 +68,7 @@ private: void WiredScreenProjection(RSLogicalDisplayRenderParams& params, std::shared_ptr processor); using DrawFuncPtr = void(RSLogicalDisplayRenderNodeDrawable::*)(Drawing::Canvas&); void DrawMirror(RSLogicalDisplayRenderParams& params, std::shared_ptr virtualProcesser, - DrawFuncPtr drawFunc, RSRenderThreadParams& uniParam); + RSRenderThreadParams& uniParam); void DrawMirrorCopy(RSLogicalDisplayRenderParams& params, std::shared_ptr virtualProcesser, RSRenderThreadParams& uniParam); void DrawWiredMirrorCopy(RSLogicalDisplayRenderNodeDrawable& mirroredDrawable); @@ -76,7 +76,8 @@ private: RSLogicalDisplayRenderNodeDrawable& mirroredDrawable, RSLogicalDisplayRenderParams& params); void DrawMirrorScreen(RSLogicalDisplayRenderParams& params, std::shared_ptr processor); void DrawExpandDisplay(RSLogicalDisplayRenderParams& params); - void PrepareOffscreenRender(const RSLogicalDisplayRenderNodeDrawable& displayDrawable, bool useFixedSize = false); + void PrepareOffscreenRender(const RSLogicalDisplayRenderNodeDrawable& displayDrawable, bool useFixedSize = false, + bool useCanvasSize = true); void FinishOffscreenRender(const Drawing::SamplingOptions& sampling, bool isSamplingOn = false, float hdrBrightnessRatio = 1.0f); void UpdateSlrScale(ScreenInfo& screenInfo, RSScreenRenderParams* params = nullptr); @@ -100,10 +101,10 @@ private: void SetScreenRotationForPointLight(RSLogicalDisplayRenderParams& params); - using AncestorParams = std::pair; + using AncestorParams = std::pair, RSScreenRenderParams*>; AncestorParams GetScreenParams(RSRenderParams& params); - using MirrorSourceParams = std::tuple; + using MirrorSourceParams = std::tuple, + RSLogicalDisplayRenderParams*, std::shared_ptr, RSScreenRenderParams*>; MirrorSourceParams GetMirrorSourceParams(RSRenderParams& params); ScreenRotation originScreenRotation_ = ScreenRotation::INVALID_SCREEN_ROTATION; diff --git a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp index ce978bea5fbbac65e965ab566c898d00d4c7c222..8b67285f5334516515605d02eb6231adac4513b3 100755 --- a/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_render_node_drawable.cpp @@ -579,10 +579,6 @@ void RSRenderNodeDrawable::DrawDfxForCacheInfo( RSPaintFilterCanvas& canvas, const std::unique_ptr& params) { if (isDrawingCacheEnabled_ && isDrawingCacheDfxEnabled_) { - auto screenParams = static_cast(params.get()); - if (screenParams && screenParams->GetNeedOffscreen()) { - canvas.ConcatMatrix(screenParams->GetMatrix()); - } std::lock_guard lock(drawingCacheInfoMutex_); for (const auto& [id, cacheInfo] : drawingCacheInfos_) { std::string extraInfo = ", updateTimes:" + std::to_string(cacheInfo.second); diff --git a/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.cpp index 6afda4faf9a58f3b0ede5526f9ea65819d4c15c4..80a9466603c9766fa700c8fbf5e87fc41722e493 100644 --- a/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.cpp @@ -308,9 +308,7 @@ void RSScreenRenderNodeDrawable::RenderOverDraw() auto paintCanvas = std::make_shared(overdrawCanvas.get()); // traverse all drawable to detect overdraw auto params = static_cast(renderParams_.get()); - if (!params->GetNeedOffscreen()) { - paintCanvas->ConcatMatrix(params->GetMatrix()); - } + paintCanvas->ConcatMatrix(params->GetMatrix()); RS_TRACE_NAME_FMT("RSScreenRenderNodeDrawable::RenderOverDraw"); RSRenderNodeDrawable::OnDraw(*paintCanvas); // show overdraw result in main display @@ -708,8 +706,6 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) auto curVisibleRect = Drawing::RectI(rect.x, rect.y, rect.x + rect.w, rect.y + rect.h); RSUniRenderThread::Instance().SetVisibleRect(curVisibleRect); } - currentBlackList_ = screenManager->GetVirtualScreenBlackList(paramScreenId); - RSUniRenderThread::Instance().SetBlackList(currentBlackList_); if (params->GetCompositeType() == CompositeType::UNI_RENDER_COMPOSITE) { SetDrawSkipType(DrawSkipType::WIRED_SCREEN_PROJECTION); RSUniRenderThread::Instance().WaitUntilScreenNodeBufferReleased(*this); @@ -730,8 +726,6 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) processor->ProcessScreenSurfaceForRenderThread(*this); HardCursorCreateLayer(processor); processor->PostProcess(); - lastVisibleRect_ = curVisibleRect_; - RSUniRenderThread::Instance().SetVisibleRect(Drawing::RectI()); expandRenderFrame_ = nullptr; return; } @@ -848,13 +842,7 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) return; } - uniParam->SetSLRScaleManager(nullptr); - if (screenInfo.isSamplingOn) { - auto scaleManager = std::make_shared( - screenInfo.phyWidth, screenInfo.phyHeight, screenInfo.width, screenInfo.height); - screenInfo.samplingDistance = scaleManager->GetKernelSize(); - uniParam->SetSLRScaleManager(scaleManager); - } + UpdateSlrScale(screenInfo); RSDirtyRectsDfx rsDirtyRectsDfx(*this); std::vector damageRegionrects; std::vector curFrameVisibleRegionRects; @@ -937,6 +925,7 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) DrawCurtainScreen(); bool displayP3Enable = (params->GetNewColorSpace() == GRAPHIC_COLOR_GAMUT_DISPLAY_P3); RSUniRenderUtil::SwitchColorFilter(*curCanvas_, hdrBrightnessRatio, displayP3Enable); + #ifdef RS_ENABLE_OVERLAY_DISPLAY // add post filter for TV overlay display conversion RSOverlayDisplayManager::Instance().PostProcFilter(*curCanvas_); @@ -957,7 +946,7 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) } } - if (RSSystemProperties::GetDrawMirrorCacheImageEnabled() && uniParam->HasMirrorDisplay() && + if (RSSystemProperties::GetDrawMirrorCacheImageEnabled() && params->HasMirrorScreen() && curCanvas_->GetSurface() != nullptr) { cacheImgForMultiScreenView_ = curCanvas_->GetSurface()->GetImageSnapshot(); } else { @@ -1039,6 +1028,18 @@ void RSScreenRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) #endif } +void RSScreenRenderNodeDrawable::UpdateSlrScale(ScreenInfo& screenInfo) +{ + auto& uniParam = RSUniRenderThread::Instance().GetRSRenderThreadParams(); + uniParam->SetSLRScaleManager(nullptr); + if (screenInfo.isSamplingOn && RSSystemProperties::GetSLRScaleEnabled()) { + auto scaleManager = std::make_shared( + screenInfo.phyWidth, screenInfo.phyHeight, screenInfo.width, screenInfo.height); + screenInfo.samplingDistance = scaleManager->GetKernelSize(); + uniParam->SetSLRScaleManager(scaleManager); + } +} + void RSScreenRenderNodeDrawable::ClearCanvasStencil(RSPaintFilterCanvas& canvas, RSScreenRenderParams& params, RSRenderThreadParams& uniParam) { diff --git a/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.h b/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.h index ae76fad196878f003aeaa8c82a6655426fb273fb..931f934ef3742f3fd027bfe61aa9e80b5d026f56 100644 --- a/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.h +++ b/rosen/modules/render_service/core/drawable/rs_screen_render_node_drawable.h @@ -134,8 +134,6 @@ private: void DrawCurtainScreen() const; void RemoveClearMemoryTask() const; void PostClearMemoryTask() const; - void SetDisplayNodeSkipFlag(RSRenderThreadParams& uniParam, bool flag); - void UpdateDisplayDirtyManager(int32_t bufferage, bool useAlignedDirtyRegion = false); void SetScreenNodeSkipFlag(RSRenderThreadParams& uniParam, bool flag); static void CheckFilterCacheFullyCovered(RSSurfaceRenderParams& surfaceParams, RectI screenRect); static void CheckAndUpdateFilterCacheOcclusion(RSScreenRenderParams& params, const ScreenInfo& screenInfo); @@ -147,7 +145,7 @@ private: void UpdateSurfaceDrawRegion(std::shared_ptr& mainCanvas, RSScreenRenderParams* params); - void MirrorRedrawDFX(bool mirrorRedraw, ScreenId screenId); + static void UpdateSlrScale(ScreenInfo& screenInfo); void CheckHpaeBlurRun(bool isHdrOn); @@ -163,23 +161,11 @@ private: std::unique_ptr expandRenderFrame_ = nullptr; std::shared_ptr offscreenSurface_ = nullptr; // temporarily holds offscreen surface std::shared_ptr canvasBackup_ = nullptr; // backup current canvas before offscreen render - std::unordered_set currentBlackList_ = {}; - std::unordered_set currentTypeBlackList_ = {}; - std::unordered_set lastBlackList_ = {}; - std::unordered_set lastTypeBlackList_ = {}; - bool curSecExemption_ = false; - bool lastSecExemption_ = false; std::shared_ptr cacheImgForMultiScreenView_ = nullptr; - int32_t specialLayerType_ = 0; - bool castScreenEnableSkipWindow_ = false; bool isScreenNodeSkip_ = false; bool isScreenNodeSkipStatusChanged_ = false; - Drawing::Matrix lastMatrix_; - Drawing::Matrix lastMirrorMatrix_; bool useFixedOffscreenSurfaceSize_ = false; - std::shared_ptr mirrorSourceDrawable_ = nullptr; uint64_t virtualSurfaceUniqueId_ = 0; - bool resetRotate_ = false; // dirty manager std::shared_ptr syncDirtyManager_ = nullptr; std::vector dirtyRects_; diff --git a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp index 4d0a4cc03a9944442ab690cf95ece0a4edd0cece..981ce9164b39c7aea300e35a03f58adf52234ded 100755 --- a/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp +++ b/rosen/modules/render_service/core/drawable/rs_surface_render_node_drawable.cpp @@ -711,8 +711,8 @@ void RSSurfaceRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas) surfaceParams->GetFirstLevelNodeId(), surfaceParams->GetUifirstRootNodeId(), nodeId_); // Regional screen recording does not enable uifirst. - bool enableVisiableRect = RSUniRenderThread::Instance().GetEnableVisibleRect(); - if (!enableVisiableRect) { + bool enableVisibleRect = RSUniRenderThread::Instance().GetEnableVisibleRect(); + if (!enableVisibleRect) { if (subThreadCache_.DealWithUIFirstCache(this, *rscanvas, *surfaceParams, *uniParam)) { if (GetDrawSkipType() == DrawSkipType::NONE) { SetDrawSkipType(DrawSkipType::UI_FIRST_CACHE_SKIP); @@ -1185,9 +1185,9 @@ void RSSurfaceRenderNodeDrawable::CaptureSurface(RSPaintFilterCanvas& canvas, RS bool hasHidePrivacyContent = surfaceParams.HasPrivacyContentLayer() && RSUniRenderThread::GetCaptureParam().isSingleSurface_ && !RSUniRenderThread::GetCaptureParam().isSystemCalling_; - bool enableVisiableRect = RSUniRenderThread::Instance().GetEnableVisibleRect(); + bool enableVisibleRect = RSUniRenderThread::Instance().GetEnableVisibleRect(); if (!(specialLayerManager.Find(HAS_GENERAL_SPECIAL) || surfaceParams.GetHDRPresent() || hasHidePrivacyContent || - enableVisiableRect || !IsVisibleRegionEqualOnPhysicalAndVirtual(surfaceParams))) { + enableVisibleRect || !IsVisibleRegionEqualOnPhysicalAndVirtual(surfaceParams))) { // if its sub tree has a blacklist, skip drawing in UIFirst scenario if (RSUniRenderThread::GetCaptureParam().isMirror_ && surfaceParams.HasBlackListByScreenId(RSUniRenderThread::GetCaptureParam().virtualScreenId_) && diff --git a/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.cpp b/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.cpp index a7421d113efce171b2fa258cd11db2549a8c6db5..2cd4e787d6cb79042cf142af8cf818467b3d77a9 100644 --- a/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.cpp +++ b/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.cpp @@ -218,7 +218,7 @@ bool RSSurfaceCaptureTaskParallel::CreateResources() displayNodeDrawable_ = std::static_pointer_cast( DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(displayNode)); pixelMap_ = CreatePixelMapByDisplayNode(displayNode); - auto screenNode = std::static_pointer_cast(displayNode->GetAncestorScreenNode().lock()); + auto screenNode = std::static_pointer_cast(displayNode->GetParent().lock()); // When the app calls HDR screenshot and the screen contains HDR content, two pixelmaps need to be captured. if (captureConfig_.isHdrCapture && screenNode && (screenNode->GetDisplayHdrStatus() != HdrStatus::NO_HDR)) { pixelMapHDR_ = CreatePixelMapByDisplayNode(displayNode, true); @@ -254,8 +254,9 @@ bool RSSurfaceCaptureTaskParallel::Run( const Drawing::Rect& rect = captureConfig_.mainScreenRect; if (rect.GetWidth() > 0 && rect.GetHeight() > 0) { canvas.ClipRect({0, 0, rect.GetWidth(), rect.GetHeight()}); - canvas.Translate(0 - rect.GetLeft(), 0 - rect.GetTop()); + canvas.Translate(-rect.GetLeft(), -rect.GetTop()); } + canvas.Translate(-boundsX_, -boundsY_); canvas.SetDisableFilterCache(true); RSSurfaceRenderParams* curNodeParams = nullptr; if (surfaceNodeDrawable_) { @@ -487,12 +488,20 @@ std::unique_ptr RSSurfaceCaptureTaskParallel::CreatePixelMapByD RS_LOGE("RSSurfaceCaptureTaskParallel::CreatePixelMapByDisplayNode: screenManager is nullptr!"); return nullptr; } - auto screenInfo = screenManager->QueryScreenInfo(screenId); + screenCorrection_ = screenManager->GetScreenCorrection(screenId); screenRotation_ = node->GetScreenRotation(); finalRotationAngle_ = CalPixelMapRotation(); - uint32_t pixmapWidth = screenInfo.width; - uint32_t pixmapHeight = screenInfo.height; + auto bounds = node->GetRenderProperties().GetBoundsGeometry(); + uint32_t pixmapWidth = static_cast(bounds->GetWidth()); + uint32_t pixmapHeight = static_cast(bounds->GetHeight()); + boundsX_ = bounds->GetX(); + boundsY_ = bounds->GetY(); + auto rotation = node->GetRotation(); + if (rotation == ScreenRotation::ROTATION_90 || rotation == ScreenRotation::ROTATION_270) { + std::swap(pixmapWidth, pixmapHeight); + } + const Drawing::Rect& rect = captureConfig_.mainScreenRect; float rectWidth = rect.GetWidth(); float rectHeight = rect.GetHeight(); @@ -514,7 +523,7 @@ std::unique_ptr RSSurfaceCaptureTaskParallel::CreatePixelMapByD rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), captureConfig_.useDma, screenRotation_, screenCorrection_, captureConfig_.blackList.size(), isHDRCapture); std::unique_ptr pixelMap = Media::PixelMap::Create(opts); - auto screenNode = std::static_pointer_cast(node->GetAncestorScreenNode().lock()); + auto screenNode = std::static_pointer_cast(node->GetParent().lock()); if (pixelMap && screenNode) { GraphicColorGamut windowColorGamut = isHDRCapture ? GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB : screenNode->GetColorSpace(); diff --git a/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.h b/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.h index 05c75a417775eebb6c8af53096a7271b9655021b..562e6114c22f086b375ba325f21746331bb85ba1 100644 --- a/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.h +++ b/rosen/modules/render_service/core/feature/capture/rs_surface_capture_task_parallel.h @@ -108,6 +108,8 @@ private: RSSurfaceCaptureConfig captureConfig_; ScreenRotation screenCorrection_ = ScreenRotation::ROTATION_0; ScreenRotation screenRotation_ = ScreenRotation::ROTATION_0; + float boundsX_ = 0; + float boundsY_ = 0; int32_t finalRotationAngle_ = RS_ROTATION_0; // only used for RSUniRenderThread std::shared_ptr gpuContext_ = nullptr; diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_main_thread.cpp b/rosen/modules/render_service/core/pipeline/main_thread/rs_main_thread.cpp index ac3d8062872ec98dbf86962dabd69172c8081ee3..9065adffb5903462da6d0ecada6cf6fd09582261 100644 --- a/rosen/modules/render_service/core/pipeline/main_thread/rs_main_thread.cpp +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_main_thread.cpp @@ -2517,14 +2517,6 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr rootNod return false; } - // children->size() is 1, the extended screen is not supported - // there is no visible hwc node or visible hwc nodes don't need update - if (children->size() == 1 && (!screenNode->HwcDisplayRecorder().HasVisibleHwcNodes() || - !ExistBufferIsVisibleAndUpdate())) { - RS_TRACE_NAME_FMT("%s: no hwcNode in visibleRegion", __func__); - return true; - } - #ifdef RS_ENABLE_GPU auto processor = RSProcessorFactory::CreateProcessor(screenNode->GetCompositeType()); auto renderEngine = GetRenderEngine(); @@ -4889,13 +4881,13 @@ bool RSMainThread::IsSingleDisplay() return rootNode->GetChildrenCount() == 1; } -// hsc todo bool RSMainThread::HasMirrorDisplay() const { bool hasWiredMirrorDisplay = false; bool hasVirtualMirrorDisplay = false; const std::shared_ptr rootNode = context_->GetGlobalRootRenderNode(); - if (rootNode == nullptr || rootNode->GetChildrenCount() <= 1) { + bool isSingleNodeOrEmpty = rootNode == nullptr || rootNode->GetChildrenCount() <= 1; + if (isSingleNodeOrEmpty) { hasWiredMirrorDisplay_.store(false); hasVirtualMirrorDisplay_.store(false); LppVideoHandler::Instance().SetHasVirtualMirrorDisplay(false); @@ -4903,7 +4895,8 @@ bool RSMainThread::HasMirrorDisplay() const } for (auto& child : *rootNode->GetSortedChildren()) { - if (!child || !child->IsInstanceOf()) { + bool isScreenNodeChild = child && child->IsInstanceOf(); + if (!isScreenNodeChild) { continue; } auto screenNode = child->ReinterpretCastTo(); diff --git a/rosen/modules/render_service/core/pipeline/main_thread/rs_uni_render_visitor.cpp b/rosen/modules/render_service/core/pipeline/main_thread/rs_uni_render_visitor.cpp index 073de1374ae5d08523255855631c74cafd9acff9..b0dc3b0a5cc1ed8f7a502882118c004bb8e64183 100644 --- a/rosen/modules/render_service/core/pipeline/main_thread/rs_uni_render_visitor.cpp +++ b/rosen/modules/render_service/core/pipeline/main_thread/rs_uni_render_visitor.cpp @@ -302,7 +302,7 @@ void RSUniRenderVisitor::CheckColorSpaceWithSelfDrawingNode(RSSurfaceRenderNode& return; } if (curScreenNode_ == nullptr) { - RS_LOGD("CheckColorSpaceWithSelfDrawingNode curDisplayNode_ is nullptr"); + RS_LOGD("CheckColorSpaceWithSelfDrawingNode curScreenNode_ is nullptr"); return; } // currently, P3 is the only supported wide color gamut, this may be modified later. @@ -360,10 +360,6 @@ bool IsScreenSupportedWideColorGamut(ScreenId id, const sptr& s void RSUniRenderVisitor::HandleColorGamuts(RSScreenRenderNode& node) { - if (screenManager_ == nullptr) { - RS_LOGD("HandleColorGamuts screenManager is nullptr."); - return; - } RSScreenType screenType = BUILT_IN_TYPE_SCREEN; if (screenManager_->GetScreenType(node.GetScreenId(), screenType) != SUCCESS) { RS_LOGD("HandleColorGamuts get screen type failed."); @@ -916,13 +912,12 @@ bool RSUniRenderVisitor::InitLogicalDisplayInfo(RSLogicalDisplayRenderNode& node curLogicalDisplayNode_->GetMultableSpecialLayerMgr().Set(HAS_GENERAL_SPECIAL, false); curLogicalDisplayNode_->SetCompositeType(curScreenNode_->GetCompositeType()); curLogicalDisplayNode_->SetHasCaptureWindow(false); - curLogicalDisplayNode_->SetAncestorScreenNode(curScreenNode_); auto mirrorSourceNode = curLogicalDisplayNode_->GetMirrorSource().lock(); - if (mirrorSourceNode) { - auto mirroredScreen = std::static_pointer_cast( - mirrorSourceNode->GetAncestorScreenNode().lock()); + auto mirrorSourceScreenNode = mirrorSourceNode ? + std::static_pointer_cast(mirrorSourceNode->GetParent().lock()) : nullptr; + if (mirrorSourceScreenNode) { curScreenNode_->SetIsMirrorScreen(true); - curScreenNode_->SetMirrorSource(mirroredScreen); + curScreenNode_->SetMirrorSource(mirrorSourceScreenNode); } else { curScreenNode_->SetIsMirrorScreen(false); curScreenNode_->ResetMirrorSource(); @@ -1895,6 +1890,7 @@ bool RSUniRenderVisitor::InitScreenInfo(RSScreenRenderNode& node) allBlackList_ = screenManager_->GetAllBlackList(); allWhiteList_ = screenManager_->GetAllWhiteList(); screenWhiteList_ = screenManager_->GetScreenWhiteList(); + node.GetLogicalDisplayNodeDrawables().clear(); // 3 init Occlusion info needRecalculateOcclusion_ = false; @@ -2471,12 +2467,12 @@ void RSUniRenderVisitor::UpdateHwcNodesIfVisibleForApp(std::shared_ptrGetVisibleRegion(); visibleRegion.MakeBound(); auto visibleRectI = visibleRegion.GetBound().ToRectI(); - auto screenInfo = curScreenNode_->GetScreenInfo(); - visibleRectI.left_ = static_cast(std::round(visibleRectI.left_ * screenInfo.GetRogWidthRatio())); - visibleRectI.top_ = static_cast(std::round(visibleRectI.top_ * screenInfo.GetRogHeightRatio())); - visibleRectI.width_ = static_cast(std::round(visibleRectI.width_ * screenInfo.GetRogWidthRatio())); - visibleRectI.height_ = - static_cast(std::round(visibleRectI.height_ * screenInfo.GetRogHeightRatio())); + auto widthRatio = curScreenNode_->GetScreenInfo().GetRogWidthRatio(); + auto heightRatio = curScreenNode_->GetScreenInfo().GetRogHeightRatio(); + visibleRectI.left_ = static_cast(std::round(visibleRectI.left_ * widthRatio)); + visibleRectI.top_ = static_cast(std::round(visibleRectI.top_ * heightRatio)); + visibleRectI.width_ = static_cast(std::round(visibleRectI.width_ * widthRatio)); + visibleRectI.height_ = static_cast(std::round(visibleRectI.height_ * heightRatio)); auto newRegionRect = Occlusion::Rect(visibleRectI, true); newRegionRect.Expand(EXPAND_ONE_PIX, EXPAND_ONE_PIX, EXPAND_ONE_PIX, EXPAND_ONE_PIX); Occlusion::Rect dstRect(hwcNodePtr->GetDstRect()); @@ -3400,43 +3396,59 @@ void RSUniRenderVisitor::ProcessUnpairedSharedTransitionNode() void RSUniRenderVisitor::CheckMergeDebugRectforRefreshRate(std::vector& surfaces) { // Debug dirtyregion of show current refreshRation - if (RSRealtimeRefreshRateManager::Instance().GetShowRefreshRateEnabled()) { - if (curScreenNode_ == nullptr) { - RS_LOGE("RSUniRenderVisitor::CheckMergeDebugRectforRefreshRate curScreenNode is nullptr"); - return; + if (!RSRealtimeRefreshRateManager::Instance().GetShowRefreshRateEnabled()) { + return; + } + if (curScreenNode_ == nullptr) { + RS_LOGE("RSUniRenderVisitor::CheckMergeDebugRectforRefreshRate curScreenNode is nullptr"); + return; + } + static const RectI refreshDirtyRect = {100, 100, 500, 200}; // setDirtyRegion for RealtimeRefreshRate + bool surfaceNodeSet = false; + for (auto surface : surfaces) { + auto surfaceNode = RSBaseRenderNode::ReinterpretCast(surface); + if (surfaceNode == nullptr) { + RS_LOGE("RSUniRenderVisitor::CheckMergeDebugRectforRefreshRate surfaceNode is nullptr"); + continue; } - RectI tempRect = {100, 100, 500, 200}; // setDirtyRegion for RealtimeRefreshRate - bool surfaceNodeSet = false; - bool needMapAbsRect = false; - for (auto surface : surfaces) { - auto surfaceNode = RSBaseRenderNode::ReinterpretCast(surface); - if (surfaceNode == nullptr) { - RS_LOGE("RSUniRenderVisitor::CheckMergeDebugRectforRefreshRate surfaceNode is nullptr"); + if (surfaceNode->GetSurfaceWindowType() == SurfaceWindowType::SCB_GESTURE_BACK) { + // refresh rate rect for mainwindow + auto& surfaceGeoPtr = surfaceNode->GetRenderProperties().GetBoundsGeometry(); + if (!surfaceGeoPtr) { continue; } - if (surfaceNode->GetSurfaceWindowType() == SurfaceWindowType::SCB_GESTURE_BACK) { - // refresh rate rect for mainwindow - auto& geoPtr = surfaceNode->GetRenderProperties().GetBoundsGeometry(); - if (!geoPtr) { - break; - } - if (needMapAbsRect) { - tempRect = geoPtr->MapAbsRect(tempRect.ConvertTo()); - } - curScreenNode_->GetDirtyManager()->MergeDirtyRect(tempRect, true); - surfaceNodeSet = true; - break; + auto displayNodeId = surfaceNode->GetLogicalDisplayNodeId(); + const auto& nodeMap = RSMainThread::Instance()->GetContext().GetNodeMap(); + auto displayNode = nodeMap.GetRenderNode(displayNodeId); + if (!displayNode) { + continue; } + auto& displayGeoPtr = displayNode->GetRenderProperties().GetBoundsGeometry(); + if (!displayGeoPtr) { + continue; + } + auto tmpRect = refreshDirtyRect; + auto windowContainer = displayNode->GetWindowContainer(); + if (windowContainer && + (!ROSEN_EQ(windowContainer->GetRenderProperties().GetScaleX(), 1.0f, EPSILON_SCALE) || + !ROSEN_EQ(windowContainer->GetRenderProperties().GetScaleY(), 1.0f, EPSILON_SCALE))) { + tmpRect = displayGeoPtr->MapAbsRect(tmpRect.ConvertTo()); + } else { + tmpRect = surfaceGeoPtr->MapAbsRect(tmpRect.ConvertTo()); + } + curScreenNode_->GetDirtyManager()->MergeDirtyRect(tmpRect, true); + surfaceNodeSet = true; } - if (!surfaceNodeSet) { - auto &geoPtr = curScreenNode_->GetRenderProperties().GetBoundsGeometry(); + } + if (!surfaceNodeSet) { + for (auto& displayNode : *curScreenNode_->GetChildren()) { + auto& geoPtr = curScreenNode_->GetRenderProperties().GetBoundsGeometry(); if (!geoPtr) { - return; - } - if (needMapAbsRect) { - tempRect = geoPtr->MapAbsRect(tempRect.ConvertTo()); + continue; } - curScreenNode_->GetDirtyManager()->MergeDirtyRect(tempRect, true); + auto tmpRect = refreshDirtyRect; + tmpRect = geoPtr->MapAbsRect(tmpRect.ConvertTo()); + curScreenNode_->GetDirtyManager()->MergeDirtyRect(tmpRect, true); } } } diff --git a/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.cpp b/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.cpp index 71fb406910719585a36c444d92ff8fb02bbc4a02..a08293e9dfd30830e84e58b7a59e79ab7a364448 100644 --- a/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.cpp +++ b/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.cpp @@ -1940,10 +1940,5 @@ pid_t RSBaseRenderUtil::GetLastSendingPid() { return lastSendingPid_; } - -bool RSBaseRenderUtil::PortraitAngle(int angle) -{ - return angle == RS_ROTATION_90 || angle == RS_ROTATION_270; -} } // namespace Rosen } // namespace OHOS diff --git a/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.h b/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.h index bcf51214ebf02fb5d03fc4072ceeac769f15465b..5f239c8b22766da8c526631bf082a7f24cf30dbb 100644 --- a/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.h +++ b/rosen/modules/render_service/core/pipeline/render_thread/rs_base_render_util.h @@ -202,7 +202,6 @@ public: static void IncAcquiredBufferCount(); static void DecAcquiredBufferCount(); static pid_t GetLastSendingPid(); - static bool PortraitAngle(int angle); private: static bool CreateYuvToRGBABitMap(sptr buffer, std::vector& newBuffer, diff --git a/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.cpp b/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.cpp index 3ad169e3c426e7c0c8ba42ff64ce691d034edc12..c0bb485fba5bcaafd7fe60771deb1649ba51f0df 100644 --- a/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.cpp +++ b/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.cpp @@ -49,6 +49,7 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSScreenRender if (!params) { return false; } + virtualScreenId_ = params->GetScreenId(); VirtualScreenStatus screenStatus = screenManager->GetVirtualScreenStatus(virtualScreenId_); if (screenStatus == VIRTUAL_SCREEN_PAUSE) { @@ -57,9 +58,10 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSScreenRender } scaleMode_ = screenManager->GetScaleMode(virtualScreenId_); - + const auto& virtualScreenInfo = params->GetScreenInfo(); + enableVisibleRect_ = virtualScreenInfo.enableVisibleRect; canvasRotation_ = screenManager->GetCanvasRotation(virtualScreenId_); - if (EnableVisibleRect()) { + if (enableVisibleRect_) { const auto& rect = screenManager->GetMirrorScreenVisibleRect(virtualScreenId_); visibleRect_ = Drawing::RectI(rect.x, rect.y, rect.x + rect.w, rect.y + rect.h); // not support rotation for MirrorScreen visibleRect @@ -67,21 +69,26 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSScreenRender } bool mirrorScreenHDR = false; bool expandScreenHDR = false; - renderFrameConfig_.colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; - auto mirroredDisplayDrawable = std::static_pointer_cast( - params->GetMirrorSourceDrawable().lock()); - auto mirroredParams = mirroredDisplayDrawable ? - static_cast(mirroredDisplayDrawable->GetRenderParams().get()) : nullptr; - if (mirroredParams) { - screenRotation_ = mirroredParams->GetScreenRotation(); - screenCorrection_ = screenManager->GetScreenCorrection(mirroredParams->GetScreenId()); - auto mainScreenInfo = screenManager->QueryScreenInfo(mirroredParams->GetScreenId()); - mirroredScreenWidth_ = mainScreenInfo.isSamplingOn ? static_cast(mainScreenInfo.phyWidth) : - static_cast(mainScreenInfo.width); - mirroredScreenHeight_ = mainScreenInfo.isSamplingOn ? static_cast(mainScreenInfo.phyHeight) : - static_cast(mainScreenInfo.height); - if (params->GetNewColorSpace() != GRAPHIC_COLOR_GAMUT_SRGB) { + auto mirroredScreenDrawable = + std::static_pointer_cast(params->GetMirrorSourceDrawable().lock()); + if (mirroredScreenDrawable) { + auto childDrawables = params->GetDisplayDrawables(); + if (childDrawables.empty() || childDrawables.front() == nullptr) { + RS_LOGE("RSUniRenderVirtualProcessor::InitForRenderThread: no child display in mirror screen"); + return false; + } + auto displayDrawable = childDrawables.front(); + auto displayParams = static_cast(displayDrawable->GetRenderParams().get()); + auto mirroredDisplayDrawable = std::static_pointer_cast( + displayParams->GetMirrorSourceDrawable().lock()); + auto mirroredDisplayParams = static_cast( + mirroredDisplayDrawable->GetRenderParams().get()); + auto mirroredScreenParams = static_cast(mirroredScreenDrawable->GetRenderParams().get()); + screenRotation_ = mirroredDisplayParams->GetScreenRotation(); + screenCorrection_ = screenManager->GetScreenCorrection(mirroredDisplayParams->GetScreenId()); + if (params->GetNewColorSpace() != GRAPHIC_COLOR_GAMUT_SRGB && + mirroredScreenParams->GetNewColorSpace() != GRAPHIC_COLOR_GAMUT_SRGB) { renderFrameConfig_.colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_DISPLAY_P3; RS_LOGD("RSUniRenderVirtualProcessor::Init Set virtual screen buffer colorGamut to P3."); } @@ -162,7 +169,10 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSScreenRender bool RSUniRenderVirtualProcessor::UpdateMirrorInfo(DrawableV2::RSLogicalDisplayRenderNodeDrawable& displayDrawable) { - auto& params = displayDrawable.GetRenderParams(); + if (!RSProcessor::UpdateMirrorInfo(displayDrawable)) { + return false; + } + auto params = static_cast(displayDrawable.GetRenderParams().get()); if (!params) { return false; } @@ -175,63 +185,28 @@ bool RSUniRenderVirtualProcessor::UpdateMirrorInfo(DrawableV2::RSLogicalDisplayR if (mirroredDisplayDrawable) { auto& mirroredParams = mirroredDisplayDrawable->GetRenderParams(); if (mirroredParams) { - auto mirriredDisplayParams = static_cast(mirroredParams.get()); - screenRotation_ = mirriredDisplayParams->GetScreenRotation(); - screenCorrection_ = screenManager->GetScreenCorrection(mirriredDisplayParams->GetScreenId()); - auto mainScreenInfo = screenManager->QueryScreenInfo(mirriredDisplayParams->GetScreenId()); - // 宽高改成node bounds - mirroredScreenWidth_ = mainScreenInfo.isSamplingOn ? static_cast(mainScreenInfo.phyWidth) : - static_cast(mainScreenInfo.width); - mirroredScreenHeight_ = mainScreenInfo.isSamplingOn ? static_cast(mainScreenInfo.phyHeight) : - static_cast(mainScreenInfo.height); - } - } - return true; -} - -bool RSUniRenderVirtualProcessor::RequestVirtualFrame(DrawableV2::RSScreenRenderNodeDrawable& screenDrawable) -{ - auto renderEngine = RSUniRenderThread::Instance().GetRenderEngine(); - if (renderEngine == nullptr) { - RS_LOGE("RSUniRenderVirtualProcessor::RequestVirtualFrame RenderEngine is null!"); - return false; - } - if (producerSurface_ == nullptr) { - RS_LOGE("RSUniRenderVirtualProcessor::RequestVirtualFrame for virtualScreen(id %{public}" PRIu64 "):" - "ProducerSurface is null!", virtualScreenId_); - return false; - } -#ifdef RS_ENABLE_GL - if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) { - renderFrame_ = renderEngine->RequestFrame(producerSurface_, renderFrameConfig_, forceCPU_, false); - } -#endif - if (renderFrame_ == nullptr) { - uint64_t pSurfaceUniqueId = producerSurface_->GetUniqueId(); - auto rsSurface = screenDrawable.GetVirtualSurface(pSurfaceUniqueId); - if (rsSurface == nullptr || updateFlag_) { - RS_LOGD("RSUniRenderVirtualProcessor::RequestVirtualFrame," - "Make rssurface from producer virtualScreen(id %{public}" PRIu64 ")", virtualScreenId_); - RS_TRACE_NAME_FMT("RSUniRenderVirtualProcessor::RequestVirtualFrame," - "Make rssurface from producer virtualScreen(id %" PRIu64 ")", virtualScreenId_); - rsSurface = renderEngine->MakeRSSurface(producerSurface_, forceCPU_); - screenDrawable.SetVirtualSurface(rsSurface, pSurfaceUniqueId); + auto mirroredDisplayParams = static_cast(mirroredParams.get()); + auto mainScreenInfo = screenManager->QueryScreenInfo(mirroredDisplayParams->GetScreenId()); + mirroredScreenWidth_ = mirroredDisplayParams->GetBounds().GetWidth(); + mirroredScreenHeight_ = mirroredDisplayParams->GetBounds().GetHeight(); + if (mirroredDisplayParams->GetNodeRotation() == ScreenRotation::ROTATION_90 || + mirroredDisplayParams->GetNodeRotation() == ScreenRotation::ROTATION_270) { + std::swap(mirroredScreenWidth_, mirroredScreenHeight_); + } + if (mainScreenInfo.isSamplingOn) { + mirroredScreenWidth_ *= mainScreenInfo.samplingScale; + mirroredScreenHeight_ *= mainScreenInfo.samplingScale; + } + mirroredTranslateX_ = mirroredDisplayParams->GetOffsetX(); + mirroredTranslateY_ = mirroredDisplayParams->GetOffsetY(); + isMirroredDisplayRotating_ = mirroredDisplayParams->IsRotationChanged(); } - renderFrame_ = renderEngine->RequestFrame( - std::static_pointer_cast(rsSurface), renderFrameConfig_, forceCPU_, false); - } - if (renderFrame_ == nullptr) { - RS_LOGE("RSUniRenderVirtualProcessor::RequestVirtualFrame RenderFrame is null!"); - return false; } return true; } void RSUniRenderVirtualProcessor::CanvasInit(DrawableV2::RSLogicalDisplayRenderNodeDrawable& displayDrawable) { - auto params = static_cast(displayDrawable.GetRenderParams().get()); - // displayDrawable.GetRenderParams() not null in caller - // Save the initial canvas state canvas_->Save(); if (displayDrawable.IsFirstTimeToProcessor() || canvasRotation_ || autoBufferRotation_) { @@ -245,8 +220,8 @@ void RSUniRenderVirtualProcessor::CanvasInit(DrawableV2::RSLogicalDisplayRenderN } displayDrawable.SetOriginScreenRotation(screenRotation_); } - auto rotationDiff = static_cast(displayDrawable.GetOriginScreenRotation()) - - static_cast(screenCorrection_); + auto rotationDiff = + static_cast(displayDrawable.GetOriginScreenRotation()) - static_cast(screenCorrection_); auto rotationAngle = static_cast((rotationDiff + SCREEN_ROTATION_NUM) % SCREEN_ROTATION_NUM); OriginScreenRotation(rotationAngle, renderFrameConfig_.width, renderFrameConfig_.height); @@ -382,6 +357,18 @@ void RSUniRenderVirtualProcessor::OriginScreenRotation(ScreenRotation screenRota } } +void RSUniRenderVirtualProcessor::CalculateTransform(ScreenRotation rotation) +{ + if (canvas_ == nullptr) { + RS_LOGE("RSUniRenderVirtualProcessor::CalculateTransform: Canvas is null!"); + return; + } + + canvas_->Save(); + ScaleMirrorIfNeed(rotation, *canvas_); + canvasMatrix_ = canvas_->GetTotalMatrix(); +} + void RSUniRenderVirtualProcessor::ScaleMirrorIfNeed(const ScreenRotation angle, RSPaintFilterCanvas& canvas) { if (screenCorrection_ == ScreenRotation::ROTATION_90 || @@ -396,7 +383,7 @@ void RSUniRenderVirtualProcessor::ScaleMirrorIfNeed(const ScreenRotation angle, float mirroredScreenWidth = mirroredScreenWidth_; float mirroredScreenHeight = mirroredScreenHeight_; - if (EnableVisibleRect()) { + if (enableVisibleRect_) { mirroredScreenWidth = visibleRect_.GetWidth(); mirroredScreenHeight = visibleRect_.GetHeight(); if (mirroredScreenWidth < EPSILON || mirroredScreenHeight < EPSILON) { @@ -410,15 +397,22 @@ void RSUniRenderVirtualProcessor::ScaleMirrorIfNeed(const ScreenRotation angle, mirroredScreenWidth, mirroredScreenHeight, virtualScreenWidth_, virtualScreenHeight_, static_cast(screenCorrection_), static_cast(angle), static_cast(scaleMode_)); - if (!EnableVisibleRect() && - ROSEN_EQ(mirroredScreenWidth, virtualScreenWidth_) && ROSEN_EQ(mirroredScreenHeight, virtualScreenHeight_)) { - return; + bool needScale = ROSEN_NE(mirroredScreenWidth, virtualScreenWidth_) || + ROSEN_NE(mirroredScreenHeight, virtualScreenHeight_); + if (needScale) { + if (scaleMode_ == ScreenScaleMode::FILL_MODE) { + Fill(canvas, mirroredScreenWidth, mirroredScreenHeight, virtualScreenWidth_, virtualScreenHeight_); + } else if (scaleMode_ == ScreenScaleMode::UNISCALE_MODE) { + UniScale(canvas, mirroredScreenWidth, mirroredScreenHeight, virtualScreenWidth_, virtualScreenHeight_); + } } - if (scaleMode_ == ScreenScaleMode::FILL_MODE) { - Fill(canvas, mirroredScreenWidth, mirroredScreenHeight, virtualScreenWidth_, virtualScreenHeight_); - } else if (scaleMode_ == ScreenScaleMode::UNISCALE_MODE) { - UniScale(canvas, mirroredScreenWidth, mirroredScreenHeight, virtualScreenWidth_, virtualScreenHeight_); + if (enableVisibleRect_ && !drawMirrorCopy_) { + canvas.Translate(-visibleRect_.GetLeft(), -visibleRect_.GetTop()); + RS_LOGD("RSUniRenderVirtualProcessor::ScaleMirrorIfNeed: Scale With VisibleRect, " + "mirrorScaleX_: %{public}f, mirrorScaleY_: %{public}f", mirrorScaleX_, mirrorScaleY_); + } else { + canvas.Translate(-mirroredTranslateX_, -mirroredTranslateY_); } } @@ -441,18 +435,6 @@ void RSUniRenderVirtualProcessor::ProcessSurface(RSSurfaceRenderNode& node) RS_LOGI("RSUniRenderVirtualProcessor::ProcessSurface() is not supported."); } -void RSUniRenderVirtualProcessor::CalculateTransform(ScreenRotation rotation) -{ - if (canvas_ == nullptr) { - RS_LOGE("RSUniRenderVirtualProcessor::CalculateTransform: Canvas is null!"); - return; - } - - canvas_->Save(); - ScaleMirrorIfNeed(rotation, *canvas_); - canvasMatrix_ = canvas_->GetTotalMatrix(); -} - void RSUniRenderVirtualProcessor::ProcessScreenSurfaceForRenderThread( DrawableV2::RSScreenRenderNodeDrawable& screenDrawable) { @@ -465,8 +447,11 @@ void RSUniRenderVirtualProcessor::ProcessScreenSurfaceForRenderThread( return; } auto params = RSUniRenderUtil::CreateBufferDrawParam(*surfaceHandler, forceCPU_); + if (renderEngine_ == nullptr) { + return; + } params.isMirror = true; - if (EnableVisibleRect()) { + if (enableVisibleRect_) { params.srcRect = visibleRect_; params.dstRect = Drawing::Rect(0, 0, visibleRect_.GetWidth(), visibleRect_.GetHeight()); } @@ -481,9 +466,6 @@ void RSUniRenderVirtualProcessor::Fill(RSPaintFilterCanvas& canvas, mirrorScaleX_ = mirrorWidth / mainWidth; mirrorScaleY_ = mirrorHeight / mainHeight; canvas.Scale(mirrorScaleX_, mirrorScaleY_); - if (EnableVisibleRect() && !drawMirrorCopy_) { - canvas.Translate(-visibleRect_.GetLeft(), -visibleRect_.GetTop()); - } } } @@ -505,7 +487,7 @@ void RSUniRenderVirtualProcessor::UniScale(RSPaintFilterCanvas& canvas, startY = (mirrorHeight / mirrorScaleY_ - mainHeight) / 2; // 2 for calc Y } - if (EnableSlrScale()) { + if (EnableSlrScale() && !isMirroredDisplayRotating_) { if (slrManager_ == nullptr) { slrManager_ = std::make_shared(virtualScreenWidth_, virtualScreenHeight_, mirroredScreenWidth_, mirroredScreenHeight_); @@ -521,12 +503,6 @@ void RSUniRenderVirtualProcessor::UniScale(RSPaintFilterCanvas& canvas, } canvas.Scale(mirrorScaleX_, mirrorScaleY_); - if (EnableVisibleRect() && !drawMirrorCopy_) { - canvas.Translate(-visibleRect_.GetLeft(), -visibleRect_.GetTop()); - RS_LOGD("RSUniRenderVirtualProcessor::UniScale: Scale With VisibleRect, " - "mirrorScaleX_: %{public}f, mirrorScaleY_: %{public}f, startX: %{public}f, startY: %{public}f", - mirrorScaleX_, mirrorScaleY_, startX, startY); - } canvas.Translate(startX, startY); } @@ -534,7 +510,7 @@ bool RSUniRenderVirtualProcessor::EnableSlrScale() { float slrScale = std::min(mirrorScaleX_, mirrorScaleY_); if (MultiScreenParam::IsSlrScaleEnabled() && RSSystemProperties::GetSLRScaleEnabled() && - (slrScale < SLR_SCALE_THR_HIGH) && !EnableVisibleRect() && drawMirrorCopy_) { + (slrScale < SLR_SCALE_THR_HIGH) && !enableVisibleRect_ && drawMirrorCopy_) { return true; } return false; @@ -546,12 +522,7 @@ void RSUniRenderVirtualProcessor::ProcessCacheImage(Drawing::Image& cacheImage) RS_LOGE("RSUniRenderVirtualProcessor::ProcessCacheImage: Canvas is null!"); return; } - if (EnableSlrScale()) { - if (slrManager_ == nullptr) { - RS_LOGW("RSUniRenderVirtualProcessor::ProcessCacheImage: SlrManager is null!"); - RSUniRenderUtil::ProcessCacheImage(*canvas_, cacheImage); - return; - } + if (EnableSlrScale() && slrManager_) { slrManager_->ProcessCacheImage(*canvas_, cacheImage); RS_LOGD("RSUniRenderVirtualProcessor::ProcessCacheImage: Darw With SLR."); return; @@ -569,10 +540,11 @@ void RSUniRenderVirtualProcessor::CanvasClipRegionForUniscaleMode(const Drawing: if (scaleMode_ != ScreenScaleMode::UNISCALE_MODE) { return; } - Drawing::Rect rect(0, 0, mirroredScreenWidth_, mirroredScreenHeight_); + Drawing::Rect rect(mirroredTranslateX_, mirroredTranslateY_, + mirroredTranslateX_ + mirroredScreenWidth_, mirroredTranslateY_ + mirroredScreenHeight_); // SLR scaling does not scale canvas, get scale matrix from slrManager_ if SLR scaling is enabled. auto matrix = EnableSlrScale() && slrManager_ ? slrManager_->GetScaleMatrix() : canvas_->GetTotalMatrix(); - if (EnableVisibleRect()) { + if (enableVisibleRect_) { if (drawMirrorCopy_) { rect = Drawing::Rect(0, 0, visibleRect_.GetWidth(), visibleRect_.GetHeight()); } else { @@ -597,15 +569,6 @@ void RSUniRenderVirtualProcessor::ProcessRcdSurface(RSRcdSurfaceRenderNode& node RS_LOGI("RSUniRenderVirtualProcessor::ProcessRcdSurface() is not supported."); } -bool RSUniRenderVirtualProcessor::EnableVisibleRect() -{ - auto screenManager = CreateOrGetScreenManager(); - if (screenManager == nullptr) { - return false; - } - return screenManager->QueryScreenInfo(virtualScreenId_).enableVisibleRect; -} - bool RSUniRenderVirtualProcessor::CheckIfBufferSizeNeedChange( ScreenRotation firstBufferRotation, ScreenRotation curBufferRotation) { @@ -633,6 +596,8 @@ void RSUniRenderVirtualProcessor::SetVirtualScreenSize( std::swap(virtualScreenInfo.width, virtualScreenInfo.height); RS_LOGI("RSUniRenderVirtualProcessor::%{public}s, swap buffer width and height, width: %{public}" PRIu32 ", height: %{public}" PRIu32, __func__, renderFrameConfig_.width, renderFrameConfig_.height); + RS_TRACE_NAME_FMT("RSUniRenderVirtualProcessor::%s: swap buffer width and height, " + "width: %" PRIu32 "height: %" PRIu32, __func__, renderFrameConfig_.width, renderFrameConfig_.height); } } diff --git a/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.h b/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.h index 824289536b8d85a46363894d99bd7eb79697ba4b..89c6a56a068501730c9faa20a1ed6749b08a014d 100644 --- a/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.h +++ b/rosen/modules/render_service/core/pipeline/render_thread/rs_uni_render_virtual_processor.h @@ -79,14 +79,10 @@ public: { return canvasMatrix_; } -#ifdef USE_VIDEO_PROCESSING_ENGINE - GSError SetMetadata(const Media::VideoProcessingEngine::CM_ColorSpaceInfo& colorspaceInfo); -#endif void SetDirtyInfo(const std::vector& damageRegion); int32_t GetBufferAge() const; // when virtual screen partial refresh closed, use this function to reset RoiRegion in buffer GSError SetRoiRegionToCodec(const std::vector& damageRegion); - bool RequestVirtualFrame(DrawableV2::RSScreenRenderNodeDrawable& screenDrawable); void CalculateTransform(ScreenRotation rotation); void ScaleMirrorIfNeed(const ScreenRotation angle, RSPaintFilterCanvas& canvas); void CanvasClipRegionForUniscaleMode(const Drawing::Matrix& visibleClipRectMatrix = Drawing::Matrix(), @@ -96,18 +92,16 @@ public: { drawMirrorCopy_ = drawMirrorCopy; } - void CanvasInit(DrawableV2::RSLogicalDisplayRenderNodeDrawable& screenDrawable); - bool GetDrawVirtualMirrorCopy() const { return drawMirrorCopy_; } + void CanvasInit(DrawableV2::RSLogicalDisplayRenderNodeDrawable& displayDrawable); private: void SetVirtualScreenSize(DrawableV2::RSScreenRenderNodeDrawable& screenNodeDrawble, const sptr& screenManager); bool CheckIfBufferSizeNeedChange(ScreenRotation firstBufferRotation, ScreenRotation curBufferRotation); void OriginScreenRotation(ScreenRotation screenRotation, float width, float height); - bool EnableVisibleRect(); bool EnableSlrScale(); GSError SetColorSpaceForMetadata(GraphicColorGamut colorSpace); @@ -120,25 +114,24 @@ private: std::unique_ptr renderFrame_; std::shared_ptr canvas_; bool forceCPU_ = false; - float mirrorWidth_ = 0.f; - float mirrorHeight_ = 0.f; - float mainWidth_ = 0.f; - float mainHeight_ = 0.f; float originalVirtualScreenWidth_ = 0.f; // used for recording the original virtual screen width float originalVirtualScreenHeight_ = 0.f; // used for recording the original virtual screen height float virtualScreenWidth_ = 0.f; float virtualScreenHeight_ = 0.f; float mirroredScreenWidth_ = 0.f; float mirroredScreenHeight_ = 0.f; - bool updateFlag_ = false; bool canvasRotation_ = false; bool autoBufferRotation_ = false; // whether buffer rotation is automatically adjusted based on the screen rotation + bool isMirroredDisplayRotating_ = false; ScreenScaleMode scaleMode_ = ScreenScaleMode::INVALID_MODE; ScreenRotation screenRotation_ = ScreenRotation::ROTATION_0; ScreenRotation screenCorrection_ = ScreenRotation::ROTATION_0; float mirrorScaleX_ = 1.0f; float mirrorScaleY_ = 1.0f; + float mirroredTranslateX_ = 0.f; + float mirroredTranslateY_ = 0.f; Drawing::Matrix canvasMatrix_; + bool enableVisibleRect_ = false; Drawing::Rect visibleRect_; sptr screenManager_ = nullptr; ScreenId virtualScreenId_ = INVALID_SCREEN_ID; diff --git a/rosen/modules/render_service_base/include/params/rs_logical_display_render_params.h b/rosen/modules/render_service_base/include/params/rs_logical_display_render_params.h index 066cf6793673f41022cbb90e9db5c2b69ef6d4ed..ccd5f2bc08d96556db5ac1d8d9f2b477b1fdf76d 100644 --- a/rosen/modules/render_service_base/include/params/rs_logical_display_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_logical_display_render_params.h @@ -93,6 +93,16 @@ public: return ancestorScreenDrawable_; } + float GetOffsetX() const + { + return offsetX_; + } + + float GetOffsetY() const + { + return offsetY_; + } + private: DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr ancestorScreenDrawable_; bool hasSecLayerInVisibleRect_ = false; @@ -114,6 +124,8 @@ private: bool displaySpecialSurfaceChanged_ = false; bool hasSecLayerInVisibleRectChanged_ = false; + float offsetX_ = 0.f; + float offsetY_ = 0.f; friend class RSLogicalDisplayRenderNode; }; diff --git a/rosen/modules/render_service_base/include/params/rs_render_params.h b/rosen/modules/render_service_base/include/params/rs_render_params.h index 8b8be674d1bb41aab09882204f5734b0aa948c24..2ff421ef853d9d133cc68bd20b9225cc9813956d 100644 --- a/rosen/modules/render_service_base/include/params/rs_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_render_params.h @@ -327,7 +327,6 @@ public: return {}; } - // hsc toDo: no need to use virtual func virtual void SetRotationChanged(bool changed) {} virtual bool IsRotationChanged() const { diff --git a/rosen/modules/render_service_base/include/params/rs_screen_render_params.h b/rosen/modules/render_service_base/include/params/rs_screen_render_params.h index 9a5304e90ff9c0548dd5ad5e57b53e1cec16921a..c18ba656132f0a4307cbdd8bfe207533c382fc37 100644 --- a/rosen/modules/render_service_base/include/params/rs_screen_render_params.h +++ b/rosen/modules/render_service_base/include/params/rs_screen_render_params.h @@ -105,9 +105,6 @@ public: float GetGlobalZOrder() const; void SetMainAndLeashSurfaceDirty(bool isDirty); bool GetMainAndLeashSurfaceDirty() const; - // hsc todo: to delete - void SetNeedOffscreen(bool needOffscreen); - bool GetNeedOffscreen() const; void SetFingerprint(bool hasFingerprint) override; bool GetFingerprint() override; @@ -215,7 +212,6 @@ private: bool hasChildCrossNode_ = false; bool isMainAndLeashSurfaceDirty_ = false; bool needForceUpdateHwcNodes_ = false; - bool needOffscreen_ = false; bool hasFingerprint_ = false; bool hasHdrPresent_ = false; bool isHDRStatusChanged_ = false; @@ -226,6 +222,7 @@ private: float hdrBrightnessRatio_ = 1.0f; float zOrder_ = 0.0f; bool isZoomed_ = false; + uint32_t mirrorDstCount_ = 0; bool hasMirrorScreen_ = false; Drawing::Matrix slrMatrix_; // vector of rcd drawable, should be removed in OH 6.0 rcd refactoring diff --git a/rosen/modules/render_service_base/include/pipeline/rs_logical_display_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_logical_display_render_node.h index 6f9012affa752303b50b24b14fb8bad258339193..a79c0ad5cb52479cdf59039ace543b04cc9755ae 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_logical_display_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_logical_display_render_node.h @@ -86,7 +86,7 @@ public: screenRotation_ = screenRotation; } - ScreenRotation GetScreenRotation() + ScreenRotation GetScreenRotation() const { return screenRotation_; } @@ -151,16 +151,6 @@ public: hasCaptureWindow_ = hasCaptureWindow; } - void SetAncestorScreenNode(const RSBaseRenderNode::WeakPtr& ancestorScreenNode) - { - ancestorScreenNode_ = ancestorScreenNode; - } - - RSBaseRenderNode::WeakPtr GetAncestorScreenNode() - { - return ancestorScreenNode_; - } - void NotifySetOnTreeFlag() { waitToSetOnTree_ = true; @@ -220,7 +210,6 @@ private: // Use in mirror screen visible rect projection std::vector securityVisibleLayerList_; // surface node id - RSBaseRenderNode::WeakPtr ancestorScreenNode_; // window Container std::shared_ptr windowContainer_; diff --git a/rosen/modules/render_service_base/include/pipeline/rs_screen_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_screen_render_node.h index 869eddf870330b49e5b1f7754f065ee118ee1d05..5fc9648ce6173c01aa97f123b752a46b735aeecc 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_screen_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_screen_render_node.h @@ -72,8 +72,8 @@ public: isGeometryInitialized_ = true; properties.SetBounds({0, 0, info.width, info.height}); properties.SetFrame({0, 0, info.width, info.height}); - screenInfo_ = std::move(info); } + screenInfo_ = std::move(info); } const ScreenInfo& GetScreenInfo() const diff --git a/rosen/modules/render_service_base/src/command/rs_display_node_command.cpp b/rosen/modules/render_service_base/src/command/rs_display_node_command.cpp index f7d2ef8f5dbe7ad622f938390a58e169ee65b312..a350ffb3278e0a4f5867d99a54615c7044b4f00d 100644 --- a/rosen/modules/render_service_base/src/command/rs_display_node_command.cpp +++ b/rosen/modules/render_service_base/src/command/rs_display_node_command.cpp @@ -51,10 +51,8 @@ void DisplayNodeCommandHelper::Create(RSContext& context, NodeId id, const RSDis config, context.weak_from_this()), RSRenderNodeGC::NodeDestructor); auto& nodeMap = context.GetMutableNodeMap(); nodeMap.RegisterRenderNode(node); - if (config.screenId == INVALID_SCREEN_ID) { - return; - } - auto lambda = [&node](const std::shared_ptr& screenRenderNode) { + + auto lambda = [&node](auto& screenRenderNode) { screenRenderNode->AddChild(node); }; if (!TrySetScreenNodeByScreenId(context, config.screenId, lambda)) { @@ -78,9 +76,9 @@ void DisplayNodeCommandHelper::AddDisplayNodeToTree(RSContext& context, NodeId i auto& nodeMap = context.GetMutableNodeMap(); auto logicalDisplayNode = nodeMap.GetRenderNode(id); if (logicalDisplayNode == nullptr) { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, id); return; } - auto screenId = logicalDisplayNode->GetScreenId(); if (screenId == INVALID_SCREEN_ID) { RS_LOGE("%{public}s failed, screenId must be set before display node add to true", __func__); @@ -103,6 +101,7 @@ void DisplayNodeCommandHelper::RemoveDisplayNodeFromTree(RSContext& context, Nod auto& nodeMap = context.GetMutableNodeMap(); auto logicalDisplayNode = nodeMap.GetRenderNode(id); if (logicalDisplayNode == nullptr) { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, id); return; } @@ -126,9 +125,16 @@ void DisplayNodeCommandHelper::SetScreenId(RSContext& context, NodeId id, uint64 "], screenId:[%{public}" PRIu64 "]", __func__, id, screenId); return; } + logicalDisplayNode->SetScreenId(screenId); logicalDisplayNode->NotifyScreenNotSwitching(); - AddDisplayNodeToTree(context, id); + auto lambda = [&logicalDisplayNode](auto& screenRenderNode) { + screenRenderNode->AddChild(logicalDisplayNode); + }; + if (!TrySetScreenNodeByScreenId(context, screenId, lambda)) { + RS_LOGE("%{public}s Invalid ScreenId NodeId: %{public}" PRIu64 + ", curNodeId: %{public}" PRIu64, __func__, screenId, id); + } } void DisplayNodeCommandHelper::SetForceCloseHdr(RSContext& context, NodeId id, bool isForceCloseHdr) @@ -149,9 +155,10 @@ void DisplayNodeCommandHelper::SetForceCloseHdr(RSContext& context, NodeId id, b void DisplayNodeCommandHelper::SetScreenRotation(RSContext& context, NodeId id, const ScreenRotation& screenRotation) { - RS_LOGE("SetScreenRotation %{public}d", (int)screenRotation); if (auto node = context.GetNodeMap().GetRenderNode(id)) { node->SetScreenRotation(screenRotation); + } else { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, id); } } @@ -159,6 +166,8 @@ void DisplayNodeCommandHelper::SetSecurityDisplay(RSContext& context, NodeId id, { if (auto node = context.GetNodeMap().GetRenderNode(id)) { node->SetSecurityDisplay(isSecurityDisplay); + } else { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, id); } } @@ -166,6 +175,7 @@ void DisplayNodeCommandHelper::SetDisplayMode(RSContext& context, NodeId id, con { auto node = context.GetNodeMap().GetRenderNode(id); if (node == nullptr) { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, id); return; } @@ -190,6 +200,8 @@ void DisplayNodeCommandHelper::SetBootAnimation(RSContext& context, NodeId nodeI { if (auto node = context.GetNodeMap().GetRenderNode(nodeId)) { node->SetBootAnimation(isBootAnimation); + } else { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, nodeId); } } @@ -197,8 +209,10 @@ void DisplayNodeCommandHelper::SetScbNodePid(RSContext& context, NodeId nodeId, const std::vector& oldScbPids, int32_t currentScbPid) { if (auto node = context.GetNodeMap().GetRenderNode(nodeId)) { - ROSEN_LOGI("SetScbNodePid NodeId:[%{public}" PRIu64 "] currentPid:[%{public}d]", nodeId, currentScbPid); + RS_LOGI("SetScbNodePid NodeId:[%{public}" PRIu64 "] currentPid:[%{public}d]", nodeId, currentScbPid); node->SetScbNodePid(oldScbPids, currentScbPid); + } else { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, nodeId); } } @@ -206,10 +220,12 @@ void DisplayNodeCommandHelper::SetVirtualScreenMuteStatus(RSContext& context, No bool virtualScreenMuteStatus) { if (auto node = context.GetNodeMap().GetRenderNode(nodeId)) { - ROSEN_LOGI("SetVirtualScreenMuteStatus NodeId:[%{public}" PRIu64 "]" + RS_LOGI("SetVirtualScreenMuteStatus NodeId:[%{public}" PRIu64 "]" " screenId: %{public}" PRIu64 " virtualScreenMuteStatus: %{public}d", nodeId, node->GetScreenId(), virtualScreenMuteStatus); node->SetVirtualScreenMuteStatus(virtualScreenMuteStatus); + } else { + RS_LOGE("%{public}s Invalid NodeId curNodeId: %{public}" PRIu64, __func__, nodeId); } } diff --git a/rosen/modules/render_service_base/src/params/rs_logical_display_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_logical_display_render_params.cpp index b6af0f666648ae61014dee64a1217f455b0963fe..66480f934e68f3b2ec8e9a044a12e133fd3beb5d 100644 --- a/rosen/modules/render_service_base/src/params/rs_logical_display_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_logical_display_render_params.cpp @@ -46,6 +46,8 @@ void RSLogicalDisplayRenderParams::OnSync(const std::unique_ptr& targetLogicalDisplayRenderParam->hasSecLayerInVisibleRectChanged_ = hasSecLayerInVisibleRectChanged_; targetLogicalDisplayRenderParam->ancestorScreenDrawable_ = ancestorScreenDrawable_; targetLogicalDisplayRenderParam->hasCaptureWindow_ = hasCaptureWindow_; + targetLogicalDisplayRenderParam->offsetX_ = offsetX_; + targetLogicalDisplayRenderParam->offsetY_ = offsetY_; RSRenderParams::OnSync(target); } diff --git a/rosen/modules/render_service_base/src/params/rs_screen_render_params.cpp b/rosen/modules/render_service_base/src/params/rs_screen_render_params.cpp index 7ded442c3a62a0ce94d56494f93b0e178d3a95f7..ec46c852b981e07681e4a199d807fa7f430e8282 100644 --- a/rosen/modules/render_service_base/src/params/rs_screen_render_params.cpp +++ b/rosen/modules/render_service_base/src/params/rs_screen_render_params.cpp @@ -186,7 +186,13 @@ bool RSScreenRenderParams::GetZoomed() const void RSScreenRenderParams::SetHasMirrorScreen(bool hasMirrorScreen) { - if (hasMirrorScreen_ == hasMirrorScreen) { + if (hasMirrorScreen) { + mirrorDstCount_++; + } else { + mirrorDstCount_--; + } + bool ret = (mirrorDstCount_ != 0); + if (hasMirrorScreen_ == ret) { return; } needSync_ = true; @@ -273,20 +279,6 @@ DrawableV2::RSRenderNodeDrawableAdapter::WeakPtr RSScreenRenderParams::GetMirror return mirrorSourceDrawable_; } -void RSScreenRenderParams::SetNeedOffscreen(bool needOffscreen) -{ - if (needOffscreen_ == needOffscreen) { - return; - } - needOffscreen_ = needOffscreen; - needSync_ = true; -} - -bool RSScreenRenderParams::GetNeedOffscreen() const -{ - return needOffscreen_; -} - void RSScreenRenderParams::SetDrawnRegion(const Occlusion::Region& region) { drawnRegion_ = region; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_logical_display_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_logical_display_render_node.cpp index 003c3c36dde9623e11100517670f12d46753dbc4..dfd5b7e1f9ede284b8c0959bc089c2e985880a3b 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_logical_display_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_logical_display_render_node.cpp @@ -20,7 +20,6 @@ #include "visitor/rs_node_visitor.h" namespace OHOS::Rosen { - RSLogicalDisplayRenderNode::RSLogicalDisplayRenderNode(NodeId id, const RSDisplayNodeConfig& config, const std::weak_ptr& context, bool isTextureExportNode) : RSRenderNode(id, context, isTextureExportNode), screenId_(config.screenId) {} @@ -98,15 +97,19 @@ void RSLogicalDisplayRenderNode::UpdateRenderParams() logicalDisplayRenderParam->compositeType_ = compositeType_; logicalDisplayRenderParam->hasSecLayerInVisibleRectChanged_ = hasSecLayerInVisibleRectChanged_; logicalDisplayRenderParam->hasCaptureWindow_ = hasCaptureWindow_; - auto screenNode = ancestorScreenNode_.lock(); + auto screenNode = GetParent().lock(); auto screenDrawable = screenNode ? screenNode->GetRenderDrawable() : nullptr; logicalDisplayRenderParam->SetAncestorScreenDrawable(screenDrawable); + auto& boundGeo = GetRenderProperties().GetBoundsGeometry(); + if (boundGeo) { + logicalDisplayRenderParam->offsetX_ = boundGeo->GetX(); + logicalDisplayRenderParam->offsetY_ = boundGeo->GetY(); + } RSRenderNode::UpdateRenderParams(); } RSRenderNode::ChildrenListSharedPtr RSLogicalDisplayRenderNode::GetSortedChildren() const { - return RSRenderNode::GetSortedChildren(); int32_t currentScbPid = GetCurrentScbPid(); ChildrenListSharedPtr fullChildrenList = RSRenderNode::GetSortedChildren(); if (currentScbPid < 0) { diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_proxy.h b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_proxy.h index 8edbe9aecaaa7b1c9fa19cc3299e76cd46432bdb..c9f60fd743212be736105c4b24625a57f8828cef 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_proxy.h +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_proxy.h @@ -28,7 +28,8 @@ public: explicit RSRenderServiceProxy(const sptr& impl); virtual ~RSRenderServiceProxy() noexcept = default; - sptr CreateConnection(const sptr& token) override; + std::pair, sptr> CreateConnection( + const sptr& token) override; private: static inline BrokerDelegator delegator_; diff --git a/rosen/test/render/render/unittest/pipeline/rs_main_thread_unit_test.cpp b/rosen/test/render/render/unittest/pipeline/rs_main_thread_unit_test.cpp index 2097de6c7169ed3a58047b661f8baf85eb81a027..2c808ae537c87a156c3446e9b02000c04cf0a21d 100644 --- a/rosen/test/render/render/unittest/pipeline/rs_main_thread_unit_test.cpp +++ b/rosen/test/render/render/unittest/pipeline/rs_main_thread_unit_test.cpp @@ -3343,29 +3343,6 @@ HWTEST_F(RSMainThreadUnitTest, CheckAndUpdateInstanceContentStaticStatus003, Tes mainThread->CheckAndUpdateInstanceContentStaticStatus(nullptr); } -/** - * @tc.name: UpdateRogSizeIfNeeded - * @tc.desc: UpdateRogSizeIfNeeded Test - * @tc.type: FUNC - * @tc.require: issueI7HDVG - */ -HWTEST_F(RSMainThreadUnitTest, UpdateRogSizeIfNeeded, TestSize.Level1) -{ - auto mainThread = RSMainThread::Instance(); - ASSERT_NE(mainThread, nullptr); - // prepare context - auto contextInit = mainThread->context_; - auto context = std::make_shared(); - auto rootNode = context->GetGlobalRootRenderNode(); - NodeId id = 1; - RSDisplayNodeConfig config; - auto childDisplayNode = std::make_shared(id, config); - rootNode->AddChild(childDisplayNode); - mainThread->context_ = context; - mainThread->UpdateRogSizeIfNeeded(); - mainThread->context_ = contextInit; -} - /** * @tc.name: ReleaseSurface * @tc.desc: ReleaseSurface Test diff --git a/rosen/test/render_service/render_service/unittest/drawable/rs_screen_render_node_drawable_test.cpp b/rosen/test/render_service/render_service/unittest/drawable/rs_screen_render_node_drawable_test.cpp index 19a1eae9c2799039bacbf3db7b40dd411e6de151..212cf3ad4d45e73cccb63ed6da75f79968b29207 100644 --- a/rosen/test/render_service/render_service/unittest/drawable/rs_screen_render_node_drawable_test.cpp +++ b/rosen/test/render_service/render_service/unittest/drawable/rs_screen_render_node_drawable_test.cpp @@ -188,10 +188,11 @@ HWTEST_F(RSScreenRenderNodeDrawableTest, DrawCurtainScreen, TestSize.Level1) auto params = std::make_unique(); params->isCurtainScreenOn_ = true; RSUniRenderThread::Instance().Sync(std::move(params)); - RSUniRenderThread::Instance().GetRSRenderThreadParams()->isCurtainScreenOn_ = true; screenDrawable_->DrawCurtainScreen(); EXPECT_TRUE(RSUniRenderThread::Instance().IsCurtainScreenOn()); - RSUniRenderThread::Instance().GetRSRenderThreadParams()->isCurtainScreenOn_ = false; + params = std::make_unique(); + params->isCurtainScreenOn_ = false; + RSUniRenderThread::Instance().Sync(std::move(params)); } /** @@ -240,7 +241,9 @@ HWTEST_F(RSScreenRenderNodeDrawableTest, RenderOverDraw, TestSize.Level1) if (drawingCanvas_) { screenDrawable_->curCanvas_ = std::make_shared(drawingCanvas_.get()); } - RSUniRenderThread::Instance().GetRSRenderThreadParams()->isOverDrawEnabled_ = true; + auto params = std::make_unique(); + params->isOverDrawEnabled_ = true; + RSUniRenderThread::Instance().Sync(std::move(params)); screenDrawable_->RenderOverDraw(); } @@ -268,7 +271,9 @@ HWTEST_F(RSScreenRenderNodeDrawableTest, HardCursorCreateLayerTest, TestSize.Lev auto renderNode = std::make_shared(nodeId); auto drawablePtr = RSRenderNodeDrawableAdapter::OnGenerate(renderNode); EXPECT_NE(drawablePtr, nullptr); - RSUniRenderThread::Instance().GetRSRenderThreadParams()->hardCursorDrawableVec_ = { { nodeId, 0, drawablePtr } }; + auto renderParams = std::make_unique(); + renderParams->hardCursorDrawableVec_ = { { nodeId, 0, drawablePtr } }; + RSUniRenderThread::Instance().Sync(move(renderParams)); result = screenDrawable_->HardCursorCreateLayer(processor); ASSERT_EQ(result, false); @@ -298,7 +303,9 @@ HWTEST_F(RSScreenRenderNodeDrawableTest, CheckScreenNodeSkipTest, TestSize.Level ASSERT_EQ(result, true); RSUniRenderThread::Instance().uniRenderEngine_ = std::make_shared(); - RSUniRenderThread::Instance().GetRSRenderThreadParams()->forceCommitReason_ = 1; + auto renderParams = std::make_unique(); + renderParams->forceCommitReason_ = 1; + RSUniRenderThread::Instance().Sync(move(renderParams)); result = screenDrawable_->CheckScreenNodeSkip(*params, processor); ASSERT_EQ(result, true); @@ -320,8 +327,9 @@ HWTEST_F(RSScreenRenderNodeDrawableTest, CheckScreenNodeSkipTest, TestSize.Level screenDrawable_->syncDirtyManager_->debugRect_ = { 1, 1, 1, 1 }; result = screenDrawable_->CheckScreenNodeSkip(*params, processor); ASSERT_EQ(result, false); - RSUniRenderThread::Instance().uniRenderEngine_ = nullptr; - RSUniRenderThread::Instance().GetRSRenderThreadParams()->forceCommitReason_ = 0; + renderParams = std::make_unique(); + renderParams->forceCommitReason_ = 0; + RSUniRenderThread::Instance().Sync(move(renderParams)); RSMainThread::Instance()->isDirty_ = false; RSUifirstManager::Instance().hasForceUpdateNode_ = false; diff --git a/rosen/test/render_service/render_service/unittest/feature/capture/rs_surface_capture_task_parallel_test.cpp b/rosen/test/render_service/render_service/unittest/feature/capture/rs_surface_capture_task_parallel_test.cpp index 720582712c45c6fa89ac799d07db50af16df8f8d..f67e706c6d012a6b1ff7becc8b4af78f5cf69043 100644 --- a/rosen/test/render_service/render_service/unittest/feature/capture/rs_surface_capture_task_parallel_test.cpp +++ b/rosen/test/render_service/render_service/unittest/feature/capture/rs_surface_capture_task_parallel_test.cpp @@ -254,29 +254,6 @@ HWTEST_F(RSSurfaceCaptureTaskParallelTest, CreatePixelMapByDisplayNode002, TestS ASSERT_EQ(nullptr, task.CreatePixelMapByDisplayNode(node)); } -/* - * @tc.name: CreatePixelMapByDisplayNode004 - * @tc.desc: Test RSSurfaceCaptureTaskParallel.CreatePixelMapByDisplayNode with not nullptr - * @tc.type: FUNC - * @tc.require: issueIAHND9 -*/ -HWTEST_F(RSSurfaceCaptureTaskParallelTest, CreatePixelMapByDisplayNode004, TestSize.Level2) -{ - RSSurfaceCaptureConfig captureConfig; - RSSurfaceCaptureTaskParallel task(0, captureConfig); - RSDisplayNodeConfig config; - std::shared_ptr node = std::make_shared(0, config); - ASSERT_EQ(nullptr, task.CreatePixelMapByDisplayNode(node)); - - NodeId id = 0; - ScreenId screenId = 0; - std::shared_ptr context = std::make_shared(); - auto screenNode = std::make_shared(id, screenId, context); - ASSERT_NE(screenNode, nullptr); - node->SetAncestorScreenNode(screenNode); - ASSERT_EQ(nullptr, task.CreatePixelMapByDisplayNode(node)); -} - /* * @tc.name: CreatePixelMapByDisplayNode003 * @tc.desc: Test RSSurfaceCaptureTaskParallel.CreatePixelMapByDisplayNode003 with pixelmap is nullptr @@ -295,7 +272,7 @@ HWTEST_F(RSSurfaceCaptureTaskParallelTest, CreatePixelMapByDisplayNode003, TestS std::shared_ptr context = std::make_shared(); auto screenNode = std::make_shared(id, screenId, context); ASSERT_EQ(screenNode, nullptr); - node->SetAncestorScreenNode(screenNode); + screenNode->AddChild(node); ASSERT_EQ(nullptr, task.CreatePixelMapByDisplayNode(node)); } diff --git a/rosen/test/render_service/render_service_base/unittest/command/rs_display_node_command_test.cpp b/rosen/test/render_service/render_service_base/unittest/command/rs_display_node_command_test.cpp index a4dd4955e974f96716c8ca70cae44aad9c04ee04..be1d416d8c6bb01ab9ab723d8f0828b17a40ec43 100644 --- a/rosen/test/render_service/render_service_base/unittest/command/rs_display_node_command_test.cpp +++ b/rosen/test/render_service/render_service_base/unittest/command/rs_display_node_command_test.cpp @@ -164,23 +164,6 @@ HWTEST_F(RSDisplayNodeCommandTest, SetBootAnimation001, TestSize.Level1) EXPECT_NE(context.GetNodeMap().GetRenderNode(id), nullptr); } -/** - * @tc.name: SetRogSize001 - * @tc.desc: SetScreenId test. - * @tc.type: FUNC - */ -HWTEST_F(RSDisplayNodeCommandTest, SetRogSize001, TestSize.Level1) -{ - RSContext context; - NodeId id = static_cast(1); - DisplayNodeCommandHelper::SetScreenId(context, id, 1); - - RSDisplayNodeConfig config { 0, false, 0 }; - DisplayNodeCommandHelper::Create(context, id, config); - DisplayNodeCommandHelper::SetScreenId(context, id, 1); - EXPECT_NE(context.GetNodeMap().GetRenderNode(id), nullptr); -} - /** * @tc.name: SetForceCloseHdrTest * @tc.desc: SetForceCloseHdr test.