• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RENDER_SERVICE_CORE_FEATURE_RS_UNI_DIRTY_COMPUTE_UTIL_H
17 #define RENDER_SERVICE_CORE_FEATURE_RS_UNI_DIRTY_COMPUTE_UTIL_H
18 
19 #include <list>
20 #include <mutex>
21 #include <set>
22 #include <unordered_map>
23 
24 #include "common/rs_occlusion_region.h"
25 #include "common/rs_obj_abs_geometry.h"
26 #include "drawable/rs_surface_render_node_drawable.h"
27 #include "params/rs_screen_render_params.h"
28 
29 namespace OHOS {
30 namespace Rosen {
31 class RSDirtyRectsDfx;
32 class RSUniDirtyComputeUtil {
33 public:
34     static std::vector<RectI> GetCurrentFrameVisibleDirty(DrawableV2::RSScreenRenderNodeDrawable& screenDrawable,
35         ScreenInfo& screenInfo, RSScreenRenderParams& params);
36     static std::vector<RectI> ScreenIntersectDirtyRects(const Occlusion::Region &region, const ScreenInfo& screenInfo);
37     static std::vector<RectI> GetFilpDirtyRects(const std::vector<RectI>& srcRects, const ScreenInfo& screenInfo);
38     static std::vector<RectI> FilpRects(const std::vector<RectI>& srcRects, const ScreenInfo& screenInfo);
39     static GraphicIRect IntersectRect(const GraphicIRect& first, const GraphicIRect& second);
40     static void UpdateVirtualExpandScreenAccumulatedParams(
41         RSScreenRenderParams& params, DrawableV2::RSScreenRenderNodeDrawable& screenDrawable);
42     static bool CheckVirtualExpandScreenSkip(
43         RSScreenRenderParams& params, DrawableV2::RSScreenRenderNodeDrawable& screenDrawable);
44 };
45 
46 class DirtyStatusAutoUpdate {
47 public:
DirtyStatusAutoUpdate(RSRenderThreadParams & uniParams,bool isSingleLogicalDisplay)48     DirtyStatusAutoUpdate(RSRenderThreadParams& uniParams, bool isSingleLogicalDisplay) : uniParams_(uniParams)
49     {
50         isVirtualDirtyEnabled_ = uniParams_.IsVirtualDirtyEnabled();
51         uniParams_.SetVirtualDirtyEnabled(isVirtualDirtyEnabled_ && isSingleLogicalDisplay);
52     }
~DirtyStatusAutoUpdate()53     ~DirtyStatusAutoUpdate()
54     {
55         uniParams_.SetVirtualDirtyEnabled(isVirtualDirtyEnabled_);
56     }
57 private:
58     RSRenderThreadParams& uniParams_;
59     bool isVirtualDirtyEnabled_;
60 };
61 
62 class RSUniFilterDirtyComputeUtil {
63 public:
64     static FilterDirtyRegionInfo GenerateFilterDirtyRegionInfo(
65         RSRenderNode& filterNode, const std::optional<Occlusion::Region>& preDirty, bool isSurface);
66     // Entry for filter dirty region process
67     static void DealWithFilterDirtyRegion(Occlusion::Region& damageRegion, Occlusion::Region& drawRegion,
68         DrawableV2::RSScreenRenderNodeDrawable& screenDrawable, const std::optional<Drawing::Matrix>& matrix,
69         bool dirtyAlign = false);
70 private:
71     static bool DealWithFilterDirtyForScreen(Occlusion::Region& damageRegion, Occlusion::Region& drawRegion,
72         DrawableV2::RSScreenRenderNodeDrawable& screenDrawable, const std::optional<Drawing::Matrix>& matrix);
73 
74     static bool DealWithFilterDirtyForSurface(Occlusion::Region& damageRegion, Occlusion::Region& drawRegion,
75         std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& drawables,
76         const std::optional<Drawing::Matrix>& matrix);
77     // basic check point
78     static bool CheckMergeFilterDirty(Occlusion::Region& damageRegion, Occlusion::Region& drawRegion,
79         RSDirtyRegionManager& dirtyManager, const std::optional<Drawing::Matrix>& matrix,
80         const std::optional<Occlusion::Region>& visibleRegion);
81 
82     static void ResetFilterInfoStatus(DrawableV2::RSScreenRenderNodeDrawable& screenDrawable,
83         std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& surfaceDrawables);
84 
85     static Occlusion::Region GetVisibleEffectRegion(RSRenderNode& filterNode);
86     inline static bool dirtyAlignEnabled_ = false;
87 };
88 }
89 }
90 #endif // RENDER_SERVICE_CORE_FEATURE_RS_UNI_DIRTY_COMPUTE_UTIL_H