From 597a433f9d4379a53aec65b941a4e55072eb4790 Mon Sep 17 00:00:00 2001 From: s30023221 Date: Tue, 24 Sep 2024 22:38:42 +0800 Subject: [PATCH] calc containerWindow Signed-off-by: s30023221 Change-Id: Iaf710a4bafdd6b51b8fe6b6f005b7cba9b8337d3 --- .../include/pipeline/rs_surface_render_node.h | 10 +- .../src/pipeline/rs_surface_render_node.cpp | 236 +++++------------- 2 files changed, 64 insertions(+), 182 deletions(-) diff --git a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h index 3e58b3ecf0..156999afa0 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_surface_render_node.h @@ -801,8 +801,10 @@ public: { return "[outR: " + std::to_string(containerConfig_.outR) + " inR: " + std::to_string(containerConfig_.inR) + - " bt: " + std::to_string(containerConfig_.bt) + - " bp: " + std::to_string(containerConfig_.bp) + "]"; + " x: " + std::to_string(containerConfig_.innerRect.left_) + + " y: " + std::to_string(containerConfig_.innerRect.top_) + + " w: " + std::to_string(containerConfig_.innerRect.width_) + + " h: " + std::to_string(containerConfig_.innerRect.height_) + "]"; } bool IsOpaqueRegionChanged() const @@ -1401,11 +1403,11 @@ private: bool hasContainerWindow_ = false; // set to false as default, set by arkui int outR = 32; // outer radius (int value) int inR = 28; // inner radius (int value) - int bp = 10; // border width + padding (int value) - int bt = 76; // border width + title (int value) + RectI innerRect = {}; // inner rect, value relative to outerRect }; ContainerConfig containerConfig_; + ContainerConfig GetAbsContainerConfig() const; bool startAnimationFinished_ = false; diff --git a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp index 6a02455aad..7aec1c0da9 100644 --- a/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp +++ b/rosen/modules/render_service_base/src/pipeline/rs_surface_render_node.cpp @@ -1828,8 +1828,11 @@ void RSSurfaceRenderNode::ContainerConfig::Update(bool hasContainer, RRect rrect { this->hasContainerWindow_ = hasContainer; this->inR = RoundFloor(rrect.radius_[0].x_); - this->bp = RoundFloor(rrect.rect_.left_); - this->bt = RoundFloor(rrect.rect_.top_); + this->innerRect = { + RoundFloor(rrect.rect_.left_), + RoundFloor(rrect.rect_.top_), + RoundFloor(rrect.rect_.width_), + RoundFloor(rrect.rect_.height_) }; } void RSSurfaceRenderNode::SetContainerWindow(bool hasContainerWindow, RRect rrect) @@ -1849,67 +1852,18 @@ boundingbox rect can be set opaque. Occlusion::Region RSSurfaceRenderNode::SetUnfocusedWindowOpaqueRegion(const RectI& absRect, const ScreenRotation screenRotation) const { - Occlusion::Rect opaqueRect1{ absRect.left_ + containerConfig_.outR, + RSSurfaceRenderNode::ContainerConfig config = GetAbsContainerConfig(); + Occlusion::Rect opaqueRect1{ absRect.left_ + config.outR, absRect.top_, - absRect.GetRight() - containerConfig_.outR, + absRect.GetRight() - config.outR, absRect.GetBottom()}; Occlusion::Rect opaqueRect2{ absRect.left_, - absRect.top_ + containerConfig_.outR, + absRect.top_ + config.outR, absRect.GetRight(), - absRect.GetBottom() - containerConfig_.outR}; + absRect.GetBottom() - config.outR}; Occlusion::Region r1{opaqueRect1}; Occlusion::Region r2{opaqueRect2}; Occlusion::Region opaqueRegion = r1.Or(r2); - auto bt = std::max(containerConfig_.bt, containerConfig_.outR); - auto bp = std::max(containerConfig_.bp, containerConfig_.outR); - - switch (screenRotation) { - case ScreenRotation::ROTATION_0: { - Occlusion::Rect opaqueRect3{ absRect.left_ + bp, - absRect.top_ + bt, - absRect.GetRight() - bp, - absRect.GetBottom() - bp}; - Occlusion::Region r3{opaqueRect3}; - opaqueRegion.OrSelf(r3); - break; - } - case ScreenRotation::ROTATION_90: { - Occlusion::Rect opaqueRect3{ absRect.left_ + bt, - absRect.top_ + bp, - absRect.GetRight() - bp, - absRect.GetBottom() - bp}; - Occlusion::Region r3{opaqueRect3}; - opaqueRegion.OrSelf(r3); - break; - } - case ScreenRotation::ROTATION_180: { - Occlusion::Rect opaqueRect3{ absRect.left_ + bp, - absRect.top_ + bp, - absRect.GetRight() - bp, - absRect.GetBottom() - bt}; - Occlusion::Region r3{opaqueRect3}; - opaqueRegion.OrSelf(r3); - break; - } - case ScreenRotation::ROTATION_270: { - Occlusion::Rect opaqueRect3{ absRect.left_ + bp, - absRect.top_ + bp, - absRect.GetRight() - bt, - absRect.GetBottom() - bp}; - Occlusion::Region r3{opaqueRect3}; - opaqueRegion.OrSelf(r3); - break; - } - default: { - Occlusion::Rect opaqueRect3{ absRect.left_ + bp, - absRect.top_ + bt, - absRect.GetRight() - bp, - absRect.GetBottom() - bp}; - Occlusion::Region r3{opaqueRect3}; - opaqueRegion.OrSelf(r3); - break; - } - } return opaqueRegion; } @@ -1922,89 +1876,31 @@ screen rotation state as top/left/bottom/right has changed when screen rotated. Occlusion::Region RSSurfaceRenderNode::SetFocusedWindowOpaqueRegion(const RectI& absRect, const ScreenRotation screenRotation) const { - Occlusion::Region opaqueRegion; - switch (screenRotation) { - case ScreenRotation::ROTATION_0: { - Occlusion::Rect opaqueRect1{ - absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bt + containerConfig_.inR, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp - containerConfig_.inR}; - Occlusion::Rect opaqueRect2{ - absRect.left_ + containerConfig_.bp + containerConfig_.inR, - absRect.top_ + containerConfig_.bt, - absRect.GetRight() - containerConfig_.bp - containerConfig_.inR, - absRect.GetBottom() - containerConfig_.bp}; - Occlusion::Region r1{opaqueRect1}; - Occlusion::Region r2{opaqueRect2}; - opaqueRegion = r1.Or(r2); - break; - } - case ScreenRotation::ROTATION_90: { - Occlusion::Rect opaqueRect1{ - absRect.left_ + containerConfig_.bt + containerConfig_.inR, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bp - containerConfig_.inR, - absRect.GetBottom() - containerConfig_.bp}; - Occlusion::Rect opaqueRect2{ - absRect.left_ + containerConfig_.bt, - absRect.top_ + containerConfig_.bp + containerConfig_.inR, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp - containerConfig_.inR}; - Occlusion::Region r1{opaqueRect1}; - Occlusion::Region r2{opaqueRect2}; - opaqueRegion = r1.Or(r2); - break; - } - case ScreenRotation::ROTATION_180: { - Occlusion::Rect opaqueRect1{ - absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bp + containerConfig_.inR, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bt - containerConfig_.inR}; - Occlusion::Rect opaqueRect2{ - absRect.left_ + containerConfig_.bp + containerConfig_.inR, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bp - containerConfig_.inR, - absRect.GetBottom() - containerConfig_.bt}; - Occlusion::Region r1{opaqueRect1}; - Occlusion::Region r2{opaqueRect2}; - opaqueRegion = r1.Or(r2); - break; - } - case ScreenRotation::ROTATION_270: { - Occlusion::Rect opaqueRect1{ - absRect.left_ + containerConfig_.bp + containerConfig_.inR, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bt - containerConfig_.inR, - absRect.GetBottom() - containerConfig_.bp}; - Occlusion::Rect opaqueRect2{ - absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bp + containerConfig_.inR, - absRect.GetRight() - containerConfig_.bt, - absRect.GetBottom() - containerConfig_.bp - containerConfig_.inR}; - Occlusion::Region r1{opaqueRect1}; - Occlusion::Region r2{opaqueRect2}; - opaqueRegion = r1.Or(r2); - break; - } - default: { - Occlusion::Rect opaqueRect1{ - absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bt + containerConfig_.inR, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp - containerConfig_.inR}; - Occlusion::Rect opaqueRect2{ - absRect.left_ + containerConfig_.bp + containerConfig_.inR, - absRect.top_ + containerConfig_.bt, - absRect.GetRight() - containerConfig_.bp - containerConfig_.inR, - absRect.GetBottom() - containerConfig_.bp}; - Occlusion::Region r1{opaqueRect1}; - Occlusion::Region r2{opaqueRect2}; - opaqueRegion = r1.Or(r2); - break; - } - } + RSSurfaceRenderNode::ContainerConfig config = GetAbsContainerConfig(); + Occlusion::Rect outRect1{ absRect.left_ + config.outR, + absRect.top_, + absRect.GetRight() - config.outR, + absRect.GetBottom()}; + Occlusion::Rect outRect2{ absRect.left_, + absRect.top_ + config.outR, + absRect.GetRight(), + absRect.GetBottom() - config.outR}; + Occlusion::Region outRegion1{outRect1}; + Occlusion::Region outRegion2{outRect2}; + Occlusion::Region absRegion{Occlusion::Rect{absRect}}; + Occlusion::Region outRRegion = absRegion.Sub(outRegion1).Sub(outRegion2); + RectI innerRect = config.innerRect; + Occlusion::Rect opaqueRect1{ innerRect.left_ + config.inR, + innerRect.top_, + innerRect.GetRight() - config.inR, + innerRect.GetBottom()}; + Occlusion::Rect opaqueRect2{ innerRect.left_, + innerRect.top_ + config.inR, + innerRect.GetRight(), + innerRect.GetBottom() - config.inR}; + Occlusion::Region r1{opaqueRect1}; + Occlusion::Region r2{opaqueRect2}; + Occlusion::Region opaqueRegion = r1.Or(r2).Sub(outRRegion); return opaqueRegion; } @@ -2039,48 +1935,32 @@ void RSSurfaceRenderNode::ResetSurfaceContainerRegion(const RectI& screeninfo, c return; } Occlusion::Region absRegion{Occlusion::Rect{absRect}}; - Occlusion::Rect innerRect; - switch (screenRotation) { - case ScreenRotation::ROTATION_0: { - innerRect = Occlusion::Rect{ absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bt, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp}; - break; - } - case ScreenRotation::ROTATION_90: { - innerRect = Occlusion::Rect{ absRect.left_ + containerConfig_.bt, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp}; - break; - } - case ScreenRotation::ROTATION_180: { - innerRect = Occlusion::Rect{ absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bt}; - break; - } - case ScreenRotation::ROTATION_270: { - innerRect = Occlusion::Rect{ absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bp, - absRect.GetRight() - containerConfig_.bt, - absRect.GetBottom() - containerConfig_.bp}; - break; - } - default: { - innerRect = Occlusion::Rect{ absRect.left_ + containerConfig_.bp, - absRect.top_ + containerConfig_.bt, - absRect.GetRight() - containerConfig_.bp, - absRect.GetBottom() - containerConfig_.bp}; - break; - } - } - Occlusion::Region innerRectRegion{innerRect}; + Occlusion::Region innerRectRegion = SetFocusedWindowOpaqueRegion(absRect, screenRotation); containerRegion_ = absRegion.Sub(innerRectRegion); } +RSSurfaceRenderNode::ContainerConfig RSSurfaceRenderNode::GetAbsContainerConfig() const +{ + auto& geoPtr = GetRenderProperties().GetBoundsGeometry(); + RSSurfaceRenderNode::ContainerConfig config; + if (geoPtr) { + auto& matrix = geoPtr->GetAbsMatrix(); + float scale = std::min(matrix.Get(Drawing::Matrix::SCALE_X), matrix.Get(Drawing::Matrix::SCALE_Y)); + config.inR = static_cast(std::round(containerConfig_.inR * scale)); + config.outR = static_cast(std::round(containerConfig_.inR * scale)); + RectF r = { + containerConfig_.innerRect.left_, + containerConfig_.innerRect.top_, + containerConfig_.innerRect.width_, + containerConfig_.innerRect.height_}; + auto rect = geoPtr->MapAbsRect(r); + config.innerRect = rect; + return config; + } else { + return config; + } +} + void RSSurfaceRenderNode::OnSync() { RS_OPTIONAL_TRACE_NAME_FMT("RSSurfaceRenderNode::OnSync name[%s] dirty[%s]",