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 #include "modifier_render_thread/rs_modifiers_draw.h"
17
18 #include "command/rs_canvas_node_command.h"
19 #include "command/rs_command.h"
20 #include "command/rs_node_command.h"
21 #include "ffrt_inner.h"
22 #include "render_context/memory_handler.h"
23
24 namespace OHOS {
25 namespace Rosen {
26 std::mutex RSModifiersDraw::surfaceEntryMutex_;
27 std::unordered_map<NodeId, RSModifiersDraw::SurfaceEntry> RSModifiersDraw::surfaceEntryMap_;
28 std::mutex RSModifiersDraw::dirtyNodeMutex_;
29 std::unordered_set<NodeId> RSModifiersDraw::dirtyNodes_;
30 std::unordered_set<NodeId> RSModifiersDraw::allOffTreeNodes_;
31 bool RSModifiersDraw::offTreeNodesChange_ = false;
32 std::unordered_map<NodeId, std::unordered_set<NodeId>> RSModifiersDraw::offTreeNodes_;
33 std::mutex RSModifiersDraw::nodeStatusMutex_;
34 std::unordered_set<NodeId> RSModifiersDraw::foregroundRootSet_;
35 std::mutex RSModifiersDraw::foregroundRootSetMutex_;
36 std::vector<DestroySemaphoreInfo*> RSModifiersDraw::semaphoreInfoVec_;
37 std::mutex RSModifiersDraw::semaphoreInfoMutex_;
38 std::unordered_set<uint32_t> RSModifiersDraw::typesToSave_;
39 std::mutex RSModifiersDraw::ffrtMutex_;
40 std::condition_variable RSModifiersDraw::cv_;
41 std::atomic<uint32_t> RSModifiersDraw::ffrtTaskNum_ = 0;
42
DmaMemAlloc(int32_t width,int32_t height,const std::unique_ptr<Media::PixelMap> & pixelMap)43 sptr<SurfaceBuffer> RSModifiersDraw::DmaMemAlloc(
44 int32_t width, int32_t height, const std::unique_ptr<Media::PixelMap>& pixelMap)
45 {
46 return nullptr;
47 }
48
PurgeContextResource()49 void RSModifiersDraw::PurgeContextResource()
50 {
51 return;
52 }
53
GetFenceAndAddDrawOp(std::vector<DrawOpInfo> & targetCmds)54 void RSModifiersDraw::GetFenceAndAddDrawOp(std::vector<DrawOpInfo>& targetCmds)
55 {
56 return;
57 }
58
CreateSurfaceBuffer(const std::unique_ptr<Media::PixelMap> & pixelMap,int32_t width,int32_t height)59 sptr<SurfaceBuffer> RSModifiersDraw::CreateSurfaceBuffer(
60 const std::unique_ptr<Media::PixelMap>& pixelMap, int32_t width, int32_t height)
61 {
62 return nullptr;
63 }
64
CreateSurfaceFromGpuContext(sptr<SurfaceBuffer> surfaceBufferTmp)65 std::shared_ptr<Drawing::Surface> RSModifiersDraw::CreateSurfaceFromGpuContext(sptr<SurfaceBuffer> surfaceBufferTmp)
66 {
67 return nullptr;
68 }
69
CreateSurfaceFromCpuContext(const std::unique_ptr<Media::PixelMap> & pixelMap)70 std::shared_ptr<Drawing::Surface> RSModifiersDraw::CreateSurfaceFromCpuContext(
71 const std::unique_ptr<Media::PixelMap>& pixelMap)
72 {
73 return nullptr;
74 }
75
ClearCanvasDrawingNodeMemory()76 void RSModifiersDraw::ClearCanvasDrawingNodeMemory()
77 {
78 return;
79 }
80
ClearDrawingContextMemory()81 void RSModifiersDraw::ClearDrawingContextMemory()
82 {
83 return;
84 }
85
CreateSurface(std::unique_ptr<Media::PixelMap> & pixelMap,int32_t width,int32_t height,sptr<SurfaceBuffer> surfaceBufferTmp)86 std::shared_ptr<Drawing::Surface> RSModifiersDraw::CreateSurface(std::unique_ptr<Media::PixelMap>& pixelMap,
87 int32_t width, int32_t height, sptr<SurfaceBuffer> surfaceBufferTmp)
88 {
89 return nullptr;
90 }
91
CreatePixelMap(int32_t width,int32_t height,bool useDMA)92 std::unique_ptr<Media::PixelMap> RSModifiersDraw::CreatePixelMap(int32_t width, int32_t height, bool useDMA)
93 {
94 return nullptr;
95 }
96
GetSurfaceEntryByNodeId(NodeId nodeId)97 RSModifiersDraw::SurfaceEntry RSModifiersDraw::GetSurfaceEntryByNodeId(NodeId nodeId)
98 {
99 return SurfaceEntry {};
100 }
101
Playback(const std::shared_ptr<Drawing::Surface> & surface,const std::shared_ptr<Drawing::DrawCmdList> & cmdList,bool isCanvasType,VkSemaphore & semaphore)102 bool RSModifiersDraw::Playback(const std::shared_ptr<Drawing::Surface>& surface,
103 const std::shared_ptr<Drawing::DrawCmdList>& cmdList, bool isCanvasType, VkSemaphore& semaphore)
104 {
105 return false;
106 }
107
FlushSurfaceWithSemaphore(const std::shared_ptr<Drawing::Surface> & surface,VkSemaphore & semaphore)108 static void FlushSurfaceWithSemaphore(const std::shared_ptr<Drawing::Surface>& surface,
109 VkSemaphore& semaphore)
110 {
111 return;
112 }
113
AddPixelMapDrawOp(const std::shared_ptr<Drawing::DrawCmdList> & cmdList,const std::shared_ptr<Media::PixelMap> & pixelMap,int32_t width,int32_t height,bool isRenderWithForegroundColor,sptr<SyncFence> fence)114 void RSModifiersDraw::AddPixelMapDrawOp(const std::shared_ptr<Drawing::DrawCmdList>& cmdList,
115 const std::shared_ptr<Media::PixelMap>& pixelMap, int32_t width, int32_t height, bool isRenderWithForegroundColor,
116 sptr<SyncFence> fence)
117 {
118 return;
119 }
120
DrawSnapshot(std::shared_ptr<Drawing::Canvas> & canvas,std::shared_ptr<Drawing::Image> & snapshot)121 void RSModifiersDraw::DrawSnapshot(std::shared_ptr<Drawing::Canvas>& canvas, std::shared_ptr<Drawing::Image>& snapshot)
122 {
123 return;
124 }
125
ConvertCmdListForCanvas(const std::shared_ptr<Drawing::DrawCmdList> & cmdList,NodeId nodeId)126 void RSModifiersDraw::ConvertCmdListForCanvas(const std::shared_ptr<Drawing::DrawCmdList>& cmdList, NodeId nodeId)
127 {
128 return;
129 }
130
CheckAndDrawSnapshot(SurfaceEntry & surfaceEntry,const std::shared_ptr<Drawing::DrawCmdList> & cmdList,NodeId nodeId)131 bool RSModifiersDraw::CheckAndDrawSnapshot(SurfaceEntry& surfaceEntry,
132 const std::shared_ptr<Drawing::DrawCmdList>& cmdList, NodeId nodeId)
133 {
134 return false;
135 }
136
UpdateSize(const std::shared_ptr<Drawing::DrawCmdList> & cmdList,int32_t & width,int32_t & height)137 void RSModifiersDraw::UpdateSize(const std::shared_ptr<Drawing::DrawCmdList>& cmdList,
138 int32_t& width, int32_t& height)
139 {
140 return;
141 }
142
ConvertCmdList(DrawOpInfo & targetCmd)143 void RSModifiersDraw::ConvertCmdList(DrawOpInfo& targetCmd)
144 {
145 return;
146 }
147
ClearOffTreeNodeMemory(NodeId nodeId)148 void RSModifiersDraw::ClearOffTreeNodeMemory(NodeId nodeId)
149 {
150 return;
151 }
152
InsertOffTreeNode(NodeId instanceId,NodeId nodeId)153 void RSModifiersDraw::InsertOffTreeNode(NodeId instanceId, NodeId nodeId)
154 {
155 return;
156 }
157
EraseOffTreeNode(NodeId instanceId,NodeId nodeId)158 void RSModifiersDraw::EraseOffTreeNode(NodeId instanceId, NodeId nodeId)
159 {
160 return;
161 }
162
MergeOffTreeNodeSet()163 void RSModifiersDraw::MergeOffTreeNodeSet()
164 {
165 return;
166 }
167
GetPixelMapByNodeId(NodeId nodeId,bool useDMA)168 std::unique_ptr<Media::PixelMap> RSModifiersDraw::GetPixelMapByNodeId(NodeId nodeId, bool useDMA)
169 {
170 return nullptr;
171 }
172
AddDrawRegions(NodeId nodeId,std::shared_ptr<RectF> rect)173 void RSModifiersDraw::AddDrawRegions(NodeId nodeId, std::shared_ptr<RectF> rect)
174 {
175 return;
176 }
177
EraseDrawRegions(NodeId nodeId)178 void RSModifiersDraw::EraseDrawRegions(NodeId nodeId)
179 {
180 return;
181 }
182
RemoveSurfaceByNodeId(NodeId nodeId,bool postTask)183 void RSModifiersDraw::RemoveSurfaceByNodeId(NodeId nodeId, bool postTask)
184 {
185 return;
186 }
187
ResetSurfaceByNodeId(int32_t width,int32_t height,NodeId nodeId,bool needResetOpItems,bool postTask)188 bool RSModifiersDraw::ResetSurfaceByNodeId(
189 int32_t width, int32_t height, NodeId nodeId, bool needResetOpItems, bool postTask)
190 {
191 return false;
192 }
193
CheckNodeIsOffTree(NodeId nodeId)194 bool RSModifiersDraw::CheckNodeIsOffTree(NodeId nodeId)
195 {
196 return false;
197 }
198
CreateNextFrameSurface()199 void RSModifiersDraw::CreateNextFrameSurface()
200 {
201 return;
202 }
203
CheckIfModifiersDrawThreadInited()204 bool RSModifiersDraw::CheckIfModifiersDrawThreadInited()
205 {
206 return false;
207 }
208
InsertForegroundRoot(NodeId nodeId)209 void RSModifiersDraw::InsertForegroundRoot(NodeId nodeId)
210 {
211 return;
212 }
213
EraseForegroundRoot(NodeId nodeId)214 void RSModifiersDraw::EraseForegroundRoot(NodeId nodeId)
215 {
216 return;
217 }
218
IsBackground()219 bool RSModifiersDraw::IsBackground()
220 {
221 return false;
222 }
223
ClearBackGroundMemory()224 void RSModifiersDraw::ClearBackGroundMemory()
225 {
226 return;
227 }
228
DestroySemaphore()229 void RSModifiersDraw::DestroySemaphore()
230 {
231 return;
232 }
233
SeperateHybridRenderCmdList(std::unique_ptr<RSTransactionData> & transactionData,std::vector<DrawOpInfo> & targetCmds,uint32_t & enableTextHybridOpCnt)234 bool RSModifiersDraw::SeperateHybridRenderCmdList(std::unique_ptr<RSTransactionData>& transactionData,
235 std::vector<DrawOpInfo>& targetCmds, uint32_t& enableTextHybridOpCnt)
236 {
237 return false;
238 }
239
TraverseDrawOpInfo(std::vector<DrawOpInfo> & targetCmds,std::atomic<size_t> & cmdIndex)240 void RSModifiersDraw::TraverseDrawOpInfo(std::vector<DrawOpInfo>& targetCmds, std::atomic<size_t>& cmdIndex)
241 {
242 return;
243 }
244
ConvertTransactionForCanvas(std::unique_ptr<RSTransactionData> & transactionData)245 void RSModifiersDraw::ConvertTransactionForCanvas(std::unique_ptr<RSTransactionData>& transactionData)
246 {
247 return;
248 }
249
ConvertTransactionWithFFRT(std::unique_ptr<RSTransactionData> & transactionData,std::shared_ptr<RSIRenderClient> & renderServiceClient,bool & isNeedCommit,std::vector<DrawOpInfo> & targetCmds)250 void RSModifiersDraw::ConvertTransactionWithFFRT(std::unique_ptr<RSTransactionData>& transactionData,
251 std::shared_ptr<RSIRenderClient>& renderServiceClient, bool& isNeedCommit, std::vector<DrawOpInfo>& targetCmds)
252 {
253 return;
254 }
255
ConvertTransactionWithoutFFRT(std::unique_ptr<RSTransactionData> & transactionData,std::vector<DrawOpInfo> & targetCmds)256 void RSModifiersDraw::ConvertTransactionWithoutFFRT(
257 std::unique_ptr<RSTransactionData>& transactionData, std::vector<DrawOpInfo>& targetCmds)
258 {
259 return;
260 }
261
IsTargetCommand(Drawing::DrawCmdList::HybridRenderType hybridRenderType,uint16_t type,uint16_t subType,bool cmdListEmpty)262 bool RSModifiersDraw::IsTargetCommand(
263 Drawing::DrawCmdList::HybridRenderType hybridRenderType, uint16_t type, uint16_t subType, bool cmdListEmpty)
264 {
265 return false;
266 }
267 } // namespace Rosen
268 } // namespace OHOS
269