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 RSProcessor { 35 public: 36 RSProcessor() = default; 37 virtual ~RSProcessor() noexcept = default; 38 39 RSProcessor(const RSProcessor&) = delete; 40 void operator=(const RSProcessor&) = delete; 41 42 virtual bool Init(RSDisplayRenderNode& node, int32_t offsetX, int32_t offsetY, ScreenId mirroredId, 43 std::shared_ptr<RSBaseRenderEngine> renderEngine); 44 virtual void ProcessSurface(RSSurfaceRenderNode& node) = 0; 45 virtual void ProcessDisplaySurface(RSDisplayRenderNode& node) = 0; 46 virtual void ProcessDrivenSurface(RSDrivenSurfaceRenderNode& node) = 0; 47 virtual void PostProcess() = 0; 48 49 #ifndef USE_ROSEN_DRAWING GetScreenTransformMatrix()50 const SkMatrix& GetScreenTransformMatrix() const 51 #else 52 const Drawing::Matrix& GetScreenTransformMatrix() const 53 #endif 54 { 55 return screenTransformMatrix_; 56 } 57 58 protected: 59 void CalculateMirrorAdaptiveCoefficient(float curWidth, float curHeight, 60 float mirroredWidth, float mirroredHeight); 61 void CalculateScreenTransformMatrix(const RSDisplayRenderNode& node); 62 void SetMirrorScreenSwap(const RSDisplayRenderNode& node); 63 64 void MultiLayersPerf(size_t layerNum); 65 void RequestPerf(uint32_t layerLevel, bool onOffTag); 66 #ifdef FRAME_AWARE_TRACE 67 bool FrameAwareTraceBoost(size_t layerNum); 68 #endif 69 70 ScreenInfo screenInfo_; 71 int32_t offsetX_ = 0; 72 int32_t offsetY_ = 0; 73 ScreenId mirroredId_ = INVALID_SCREEN_ID; 74 float mirrorAdaptiveCoefficient_ = 1.0f; 75 std::shared_ptr<RSBaseRenderEngine> renderEngine_; 76 #ifndef USE_ROSEN_DRAWING 77 SkMatrix screenTransformMatrix_; 78 #else 79 Drawing::Matrix screenTransformMatrix_; 80 #endif 81 BufferRequestConfig renderFrameConfig_ {}; 82 }; 83 } // namespace Rosen 84 } // namespace OHOS 85 #endif // RS_CORE_PIPELINE_PROCESSOR_H 86