• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 RS_CORE_PIPELINE_PROCESSOR_H
17 #define RS_CORE_PIPELINE_PROCESSOR_H
18 
19 #include <memory>
20 
21 #ifndef USE_ROSEN_DRAWING
22 #include "include/core/SkMatrix.h"
23 #else
24 #include "utils/matrix.h"
25 #endif
26 
27 #include "rs_base_render_engine.h"
28 #include "pipeline/rs_display_render_node.h"
29 #include "pipeline/rs_surface_render_node.h"
30 
31 namespace OHOS {
32 namespace Rosen {
33 class RSDrivenSurfaceRenderNode;
34 class RSRcdSurfaceRenderNode;
35 class RSProcessor {
36 public:
37     RSProcessor() = default;
38     virtual ~RSProcessor() noexcept = default;
39 
40     RSProcessor(const RSProcessor&) = delete;
41     void operator=(const RSProcessor&) = delete;
42 
43     virtual bool Init(RSDisplayRenderNode& node, int32_t offsetX, int32_t offsetY, ScreenId mirroredId,
44                       std::shared_ptr<RSBaseRenderEngine> renderEngine);
45     virtual void ProcessSurface(RSSurfaceRenderNode& node) = 0;
46     virtual void ProcessDisplaySurface(RSDisplayRenderNode& node) = 0;
47     virtual void ProcessDrivenSurface(RSDrivenSurfaceRenderNode& node) = 0;
48     virtual void PostProcess(RSDisplayRenderNode* node = nullptr) = 0;
49     virtual void ProcessRcdSurface(RSRcdSurfaceRenderNode& node) = 0;
50     void SetSecurityDisplay(bool isSecurityDisplay);
51     void SetDisplayHasSecSurface(bool displayHasSecSurface);
52     void MirrorScenePerf();
53 
54 #ifndef USE_ROSEN_DRAWING
GetScreenTransformMatrix()55     const SkMatrix& GetScreenTransformMatrix() const
56 #else
57     const Drawing::Matrix& GetScreenTransformMatrix() const
58 #endif
59     {
60         return screenTransformMatrix_;
61     }
62 
63 protected:
64     void CalculateMirrorAdaptiveCoefficient(float curWidth, float curHeight,
65         float mirroredWidth, float mirroredHeight);
66     void CalculateScreenTransformMatrix(const RSDisplayRenderNode& node);
67     void SetMirrorScreenSwap(const RSDisplayRenderNode& node);
68 
69     void MultiLayersPerf(size_t layerNum);
70     void RequestPerf(uint32_t layerLevel, bool onOffTag);
71 #ifdef FRAME_AWARE_TRACE
72     bool FrameAwareTraceBoost(size_t layerNum);
73 #endif
74 
75     ScreenInfo screenInfo_;
76     int32_t offsetX_ = 0;
77     int32_t offsetY_ = 0;
78     ScreenId mirroredId_ = INVALID_SCREEN_ID;
79     float mirrorAdaptiveCoefficient_ = 1.0f;
80     std::shared_ptr<RSBaseRenderEngine> renderEngine_;
81 #ifndef USE_ROSEN_DRAWING
82     SkMatrix screenTransformMatrix_;
83 #else
84     Drawing::Matrix screenTransformMatrix_;
85 #endif
86     BufferRequestConfig renderFrameConfig_ {};
87     bool isSecurityDisplay_ = false;
88     bool displayHasSecSurface_ = false;
89     static bool needDisableMultiLayersPerf_;
90 };
91 } // namespace Rosen
92 } // namespace OHOS
93 #endif // RS_CORE_PIPELINE_PROCESSOR_H
94