• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_TASK_MANAGER_H
17 #define RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_TASK_MANAGER_H
18 
19 #include "rs_render_task.h"
20 #include <cstdint>
21 #include <map>
22 #include <vector>
23 #include <memory>
24 
25 namespace OHOS {
26 namespace Rosen {
27 class RSParallelTaskManager {
28 public:
29     RSParallelTaskManager();
30     ~RSParallelTaskManager();
31     void Initialize(uint32_t threadNum);
32     void PushRenderTask(std::unique_ptr<RSRenderTask> renderTask);
33     void PushCompositionTask(std::unique_ptr<RSCompositionTask> compositionTask);
34     void LBCalcAndSubmitSuperTask(std::shared_ptr<RSBaseRenderNode> displayNode);
35     void LBCalcAndSubmitCompositionTask(std::shared_ptr<RSBaseRenderNode> baseNode);
36     uint32_t GetTaskNum() const;
37     void Reset();
38     void SetSubThreadRenderTaskLoad(uint32_t threadIdx, uint64_t loadId, float cost);
39     void UpdateNodeCost(RSDisplayRenderNode& node, std::vector<uint32_t>& parallelPolicy) const;
40     void LoadParallelPolicy(std::vector<uint32_t>& parallelPolicy);
41     void GetCostFactor(std::map<std::string, int32_t>& costFactor, std::map<int64_t, int32_t>& imageFactor) const;
GetParallelRenderExtEnable()42     bool GetParallelRenderExtEnable() const
43     {
44         return isParallelRenderExtEnabled_;
45     }
46 
47 private:
48     void SubmitSuperTask();
49     std::vector<uint32_t> LoadBalancing();
50     std::vector<std::unique_ptr<RSRenderTask>> renderTaskList_;
51     std::unique_ptr<RSSuperRenderTask> cachedSuperRenderTask_;
52     std::vector<std::unique_ptr<RSSuperRenderTask>> superRenderTaskList_;
53     std::vector<std::unique_ptr<RSCompositionTask>> compositionTaskList_;
54     std::map<int, float> evalTaskCost_;
55     uint32_t threadNum_;
56     uint32_t taskNum_;
57     bool isParallelRenderExtEnabled_;
58     int* loadBalance_;
59     std::vector<uint32_t> parallelPolicy_;
60 };
61 } // namespace Rosen
62 } // namespace OHOS
63 #endif // RENDER_SERVICE_CORE_PIPELINE_PARALLEL_RENDER_RS_PARALLEL_TASK_MANAGER_H